Wakeup Light with touch user interface, anti-aliased Font, SD card access and RTC usage on STM32F746NG-DISCO board
Dependencies: BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src
main.cpp@12:a89096944f20, 2016-01-31 (annotated)
- Committer:
- the_sz
- Date:
- Sun Jan 31 01:02:36 2016 +0000
- Revision:
- 12:a89096944f20
- Parent:
- 9:fe2c9b3a312b
date adjust added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
the_sz | 1:35e2ad5cd1fe | 1 | #include "WakeupLight.h" |
the_sz | 0:995ae8b9afc8 | 2 | |
the_sz | 7:dc29f6647486 | 3 | int lastCheckedMinute=-1; |
the_sz | 7:dc29f6647486 | 4 | |
the_sz | 7:dc29f6647486 | 5 | void checkForAlarmSpecified(struct tm *tmStruct,CONFIG_TYPE_ENUM typeTime,CONFIG_TYPE_ENUM typeFlags) |
the_sz | 7:dc29f6647486 | 6 | { |
the_sz | 7:dc29f6647486 | 7 | uint32_t value; |
the_sz | 7:dc29f6647486 | 8 | bool checkTime; |
the_sz | 7:dc29f6647486 | 9 | |
the_sz | 7:dc29f6647486 | 10 | value=Config_Get(typeFlags); |
the_sz | 7:dc29f6647486 | 11 | if (value!=0) |
the_sz | 7:dc29f6647486 | 12 | { |
the_sz | 7:dc29f6647486 | 13 | checkTime=false; |
the_sz | 7:dc29f6647486 | 14 | |
the_sz | 7:dc29f6647486 | 15 | DPrintf("checkForAlarmSpecified: %u.\r\n",tmStruct->tm_wday); |
the_sz | 7:dc29f6647486 | 16 | |
the_sz | 7:dc29f6647486 | 17 | if (((value & CONFIG_ALARM_MASK_MONDAY)!=0) && (tmStruct->tm_wday==1)) |
the_sz | 7:dc29f6647486 | 18 | checkTime=true; |
the_sz | 7:dc29f6647486 | 19 | if (((value & CONFIG_ALARM_MASK_TUESDAY)!=0) && (tmStruct->tm_wday==2)) |
the_sz | 7:dc29f6647486 | 20 | checkTime=true; |
the_sz | 7:dc29f6647486 | 21 | if (((value & CONFIG_ALARM_MASK_WEDNESDAY)!=0) && (tmStruct->tm_wday==3)) |
the_sz | 7:dc29f6647486 | 22 | checkTime=true; |
the_sz | 7:dc29f6647486 | 23 | if (((value & CONFIG_ALARM_MASK_THURSDAY)!=0) && (tmStruct->tm_wday==4)) |
the_sz | 7:dc29f6647486 | 24 | checkTime=true; |
the_sz | 7:dc29f6647486 | 25 | if (((value & CONFIG_ALARM_MASK_FRIDAY)!=0) && (tmStruct->tm_wday==5)) |
the_sz | 7:dc29f6647486 | 26 | checkTime=true; |
the_sz | 7:dc29f6647486 | 27 | if (((value & CONFIG_ALARM_MASK_SATURDAY)!=0) && (tmStruct->tm_wday==6)) |
the_sz | 7:dc29f6647486 | 28 | checkTime=true; |
the_sz | 7:dc29f6647486 | 29 | if (((value & CONFIG_ALARM_MASK_SUNDAY)!=0) && (tmStruct->tm_wday==0)) |
the_sz | 7:dc29f6647486 | 30 | checkTime=true; |
the_sz | 7:dc29f6647486 | 31 | |
the_sz | 7:dc29f6647486 | 32 | if (checkTime==true) |
the_sz | 7:dc29f6647486 | 33 | { |
the_sz | 7:dc29f6647486 | 34 | value=Config_Get(typeTime); |
the_sz | 7:dc29f6647486 | 35 | if (value==((tmStruct->tm_hour << 8) | (tmStruct->tm_min))) |
the_sz | 7:dc29f6647486 | 36 | { |
the_sz | 7:dc29f6647486 | 37 | DPrintf("checkForAlarmSpecified: Alarm detecetd.\r\n"); |
the_sz | 7:dc29f6647486 | 38 | LED_StartAnimation(LAE_WAKEUP); |
the_sz | 7:dc29f6647486 | 39 | } |
the_sz | 7:dc29f6647486 | 40 | } |
the_sz | 7:dc29f6647486 | 41 | } |
the_sz | 7:dc29f6647486 | 42 | } |
the_sz | 7:dc29f6647486 | 43 | |
the_sz | 7:dc29f6647486 | 44 | void checkForAlarm(void) |
the_sz | 7:dc29f6647486 | 45 | { |
the_sz | 7:dc29f6647486 | 46 | struct tm *tmStruct; |
the_sz | 7:dc29f6647486 | 47 | |
the_sz | 12:a89096944f20 | 48 | RTC_Get(&tmStruct); |
the_sz | 7:dc29f6647486 | 49 | |
the_sz | 7:dc29f6647486 | 50 | if (tmStruct->tm_min!=lastCheckedMinute) |
the_sz | 7:dc29f6647486 | 51 | { |
the_sz | 7:dc29f6647486 | 52 | lastCheckedMinute=tmStruct->tm_min; |
the_sz | 7:dc29f6647486 | 53 | |
the_sz | 7:dc29f6647486 | 54 | // check all alarm against current time |
the_sz | 7:dc29f6647486 | 55 | checkForAlarmSpecified(tmStruct,CT_ALARM_1_TIME,CT_ALARM_1_MASK); |
the_sz | 7:dc29f6647486 | 56 | checkForAlarmSpecified(tmStruct,CT_ALARM_2_TIME,CT_ALARM_2_MASK); |
the_sz | 7:dc29f6647486 | 57 | checkForAlarmSpecified(tmStruct,CT_ALARM_3_TIME,CT_ALARM_3_MASK); |
the_sz | 7:dc29f6647486 | 58 | checkForAlarmSpecified(tmStruct,CT_ALARM_4_TIME,CT_ALARM_4_MASK); |
the_sz | 7:dc29f6647486 | 59 | checkForAlarmSpecified(tmStruct,CT_ALARM_5_TIME,CT_ALARM_5_MASK); |
the_sz | 7:dc29f6647486 | 60 | checkForAlarmSpecified(tmStruct,CT_ALARM_6_TIME,CT_ALARM_6_MASK); |
the_sz | 7:dc29f6647486 | 61 | } |
the_sz | 7:dc29f6647486 | 62 | } |
the_sz | 7:dc29f6647486 | 63 | |
the_sz | 0:995ae8b9afc8 | 64 | int main() |
the_sz | 0:995ae8b9afc8 | 65 | { |
the_sz | 1:35e2ad5cd1fe | 66 | debug_Init(); |
the_sz | 1:35e2ad5cd1fe | 67 | |
the_sz | 12:a89096944f20 | 68 | RTC_Init(); |
the_sz | 12:a89096944f20 | 69 | |
the_sz | 12:a89096944f20 | 70 | DPrintf("WakeupLight - Hardware v%08X @ %u MHz.\r\n",BSP_GetVersion(),(HAL_RCC_GetSysClockFreq()/1000/1000)); |
the_sz | 1:35e2ad5cd1fe | 71 | |
the_sz | 1:35e2ad5cd1fe | 72 | OnBoardLED_Init(); |
the_sz | 0:995ae8b9afc8 | 73 | |
the_sz | 12:a89096944f20 | 74 | TM_RNG_Init(); |
the_sz | 12:a89096944f20 | 75 | |
the_sz | 1:35e2ad5cd1fe | 76 | LED_Init(); |
the_sz | 1:35e2ad5cd1fe | 77 | |
the_sz | 12:a89096944f20 | 78 | Sound_Init(); |
the_sz | 12:a89096944f20 | 79 | |
the_sz | 9:fe2c9b3a312b | 80 | SD_Init(); |
the_sz | 9:fe2c9b3a312b | 81 | |
the_sz | 2:80026d18fcf3 | 82 | UI_Init(); |
the_sz | 1:35e2ad5cd1fe | 83 | |
the_sz | 7:dc29f6647486 | 84 | Config_Init(); |
the_sz | 7:dc29f6647486 | 85 | |
the_sz | 2:80026d18fcf3 | 86 | for (;;) |
the_sz | 2:80026d18fcf3 | 87 | { |
the_sz | 7:dc29f6647486 | 88 | checkForAlarm(); |
the_sz | 7:dc29f6647486 | 89 | |
the_sz | 2:80026d18fcf3 | 90 | UI_Poll(); |
the_sz | 0:995ae8b9afc8 | 91 | } |
the_sz | 0:995ae8b9afc8 | 92 | } |