1
#include "analogue_clock_mode.h"
6
AnalogueClockMode::AnalogueClockMode()
13
void AnalogueClockMode::draw( int segment )
15
Time &time = Time::get_instance();
17
int second = segment / NUM_SECOND_SEGMENTS;
18
int second_segment = segment % NUM_SECOND_SEGMENTS;
20
// what needs to be drawn?
21
bool draw_tick = ( !second_segment && second % 5 == 0 && second ) ||
22
( second == 0 && second_segment == 1 ) ||
23
( second == 59 && second_segment == NUM_SECOND_SEGMENTS - 1 );
24
bool draw_second = !second_segment && second == time.get_seconds();
25
bool draw_minute = !second_segment && second == time.get_minutes();
26
bool draw_hour = segment == time.get_hours() * 5 * NUM_SECOND_SEGMENTS +
27
( 5 * NUM_SECOND_SEGMENTS * time.get_minutes() / 60 );
31
led_on( 8, draw_tick || draw_second );
32
for( int a = 6; a <= 7; a++ )
33
led_on( a, draw_minute || draw_second );
34
for( int a = 0; a <= 5; a++ )
35
led_on( a, draw_minute || draw_second || draw_hour );