show time and date on 8-digit displays

This commit is contained in:
King Kévin 2017-04-01 17:19:15 +02:00
parent d14860aab5
commit bc72ac3e30
1 changed files with 14 additions and 7 deletions

21
main.c
View File

@ -236,7 +236,10 @@ void main(void)
if (!led_tm1637_on()) { // switch on TM1637 display
printf("could not switch on TM1637\n");
}
led_max7219_test(true); // test MAX7219 display
led_max7219_intensity(15,8,0); // set brightness max and enable all digits on 1st display
led_max7219_intensity(15,8,1); // set brightness max and enable all digits on 1st display
led_max7219_test(true,0); // test 1st MAX7219 display
led_max7219_test(true,1); // test 2nd MAX7219 display
for (uint32_t i=0; i<5000000; i++) { // wait a bit to have the user check the display
__asm__("nop");
}
@ -246,13 +249,17 @@ void main(void)
if (!led_tm1637_off()) { // switch off display
printf("could not switch off TM1637\n");
}
led_max7219_test(false); // go back in normal operation
led_max7219_off(); // switch display off
led_max7219_test(false,0); // go back in normal operation
led_max7219_test(false,1); // go back in normal operation
led_max7219_off(0); // switch 1st display off
led_max7219_off(1); // switch 2nd display off
printf("OK\n");
led_max7219_number(20000000+rtc_ds1307_time[6]*10000+rtc_ds1307_time[5]*100+rtc_ds1307_time[4]+2, 0x14); // display date on 7-segments display
led_max7219_on(); // switch display on
led_max7219_number(rtc_ds1307_time[2]*1000000+rtc_ds1307_time[1]*10000+rtc_ds1307_time[0]*100, 0x54, 0); // display time on 1nd display
led_max7219_number(20000000+rtc_ds1307_time[6]*10000+rtc_ds1307_time[5]*100+rtc_ds1307_time[4], 0x14, 1); // display date on 2nd display
led_max7219_on(0); // switch 1st display on
led_max7219_on(1); // switch 2nd display on
// main loop
printf("command input: ready\n");
bool action = false; // if an action has been performed don't go to sleep
@ -301,7 +308,7 @@ void main(void)
}
while (rtc_internal_tick_flag) { // the internal RTC ticked
rtc_internal_tick_flag = false; // reset flag
//led_toggle(); // toggle LED (good to indicate if main function is stuck)
led_toggle(); // toggle LED (good to indicate if main function is stuck)
ticks_time = rtc_get_counter_val(); // copy time from internal RTC for processing
action = true; // action has been performed
if ((ticks_time%(60))==0) { // one minute passed