1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "analogue_clock_mode.h"
#include "config.h"
#include "time.h"
AnalogueClockMode::AnalogueClockMode()
:
MinorMode( 1 )
{
}
void AnalogueClockMode::draw( int segment )
{
Time &time = Time::get_instance();
int second = segment / NUM_SECOND_SEGMENTS;
int second_segment = segment % NUM_SECOND_SEGMENTS;
// what needs to be drawn?
bool draw_tick = ( !second_segment && second % 5 == 0 && second ) ||
( second == 0 && second_segment == 1 ) ||
( second == 59 && second_segment == NUM_SECOND_SEGMENTS - 1 );
bool draw_second = !second_segment && second == time.get_seconds();
bool draw_minute = !second_segment && second == time.get_minutes();
bool draw_hour = segment == time.get_hours() * 5 * NUM_SECOND_SEGMENTS +
( 5 * NUM_SECOND_SEGMENTS * time.get_minutes() / 60 );
// set the LEDs
led_on( 9, true );
led_on( 8, draw_tick || draw_second );
for( int a = 6; a <= 7; a++ )
led_on( a, draw_minute || draw_second );
for( int a = 0; a <= 5; a++ )
led_on( a, draw_minute || draw_second || draw_hour );
}
|