Display the date and time using RTC.
Dependencies: BSP_DISCO_F429ZI LCD_DISCO_F429ZI mbed
main.cpp@2:72d0921572b1, 2018-10-19 (annotated)
- Committer:
- PH_TIMC
- Date:
- Fri Oct 19 22:08:58 2018 +0000
- Revision:
- 2:72d0921572b1
- Parent:
- 0:bad75bd13618
Discovery F429ZI displays time on the LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:bad75bd13618 | 1 | #include "mbed.h" |
PH_TIMC | 2:72d0921572b1 | 2 | #include "LCD_DISCO_F429ZI.h" |
bcostm | 0:bad75bd13618 | 3 | |
PH_TIMC | 2:72d0921572b1 | 4 | LCD_DISCO_F429ZI lcd; |
bcostm | 0:bad75bd13618 | 5 | DigitalOut myled(LED1); |
bcostm | 0:bad75bd13618 | 6 | |
bcostm | 0:bad75bd13618 | 7 | int main() { |
bcostm | 0:bad75bd13618 | 8 | |
bcostm | 0:bad75bd13618 | 9 | printf("RTC example\n"); |
PH_TIMC | 2:72d0921572b1 | 10 | set_time(1539982753); // Set RTC time to Friday, October 19, 2018 1:59:13 PM GMT-07:00 DST |
bcostm | 0:bad75bd13618 | 11 | printf("Date and time are set.\n"); |
PH_TIMC | 2:72d0921572b1 | 12 | BSP_LCD_SetFont(&Font12); |
bcostm | 0:bad75bd13618 | 13 | |
bcostm | 0:bad75bd13618 | 14 | while(1) { |
bcostm | 0:bad75bd13618 | 15 | |
PH_TIMC | 2:72d0921572b1 | 16 | wait(2.0); |
PH_TIMC | 2:72d0921572b1 | 17 | lcd.Clear(LCD_COLOR_BLUE); |
PH_TIMC | 2:72d0921572b1 | 18 | lcd.SetBackColor(LCD_COLOR_BLUE); |
PH_TIMC | 2:72d0921572b1 | 19 | lcd.SetTextColor(LCD_COLOR_WHITE); |
PH_TIMC | 2:72d0921572b1 | 20 | wait(0.3); |
PH_TIMC | 2:72d0921572b1 | 21 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"DISCOVERY", CENTER_MODE); |
PH_TIMC | 2:72d0921572b1 | 22 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"STM32F429ZI", CENTER_MODE); |
PH_TIMC | 2:72d0921572b1 | 23 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"Test Nucleo", CENTER_MODE); |
PH_TIMC | 2:72d0921572b1 | 24 | lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"RTC Function", CENTER_MODE); |
PH_TIMC | 2:72d0921572b1 | 25 | wait(1); |
PH_TIMC | 2:72d0921572b1 | 26 | |
bcostm | 0:bad75bd13618 | 27 | time_t seconds = time(NULL); |
bcostm | 0:bad75bd13618 | 28 | |
PH_TIMC | 2:72d0921572b1 | 29 | lcd.DisplayStringAt(0, LINE(9), (uint8_t *)ctime(&seconds), CENTER_MODE); |
bcostm | 0:bad75bd13618 | 30 | |
bcostm | 0:bad75bd13618 | 31 | myled = !myled; |
bcostm | 0:bad75bd13618 | 32 | wait(1); |
bcostm | 0:bad75bd13618 | 33 | } |
bcostm | 0:bad75bd13618 | 34 | } |