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@7:dc29f6647486, 2015-11-12 (annotated)
- Committer:
- the_sz
- Date:
- Thu Nov 12 21:21:48 2015 +0000
- Revision:
- 7:dc29f6647486
- Parent:
- 5:13c70bcde7f6
- Child:
- 8:51e0f01d5c74
f746 patch used
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 | time_t timeValue; |
the_sz | 7:dc29f6647486 | 48 | |
the_sz | 7:dc29f6647486 | 49 | timeValue=time(NULL); |
the_sz | 7:dc29f6647486 | 50 | tmStruct=localtime(&timeValue); |
the_sz | 7:dc29f6647486 | 51 | |
the_sz | 7:dc29f6647486 | 52 | if (tmStruct->tm_min!=lastCheckedMinute) |
the_sz | 7:dc29f6647486 | 53 | { |
the_sz | 7:dc29f6647486 | 54 | lastCheckedMinute=tmStruct->tm_min; |
the_sz | 7:dc29f6647486 | 55 | |
the_sz | 7:dc29f6647486 | 56 | // check all alarm against current time |
the_sz | 7:dc29f6647486 | 57 | checkForAlarmSpecified(tmStruct,CT_ALARM_1_TIME,CT_ALARM_1_MASK); |
the_sz | 7:dc29f6647486 | 58 | checkForAlarmSpecified(tmStruct,CT_ALARM_2_TIME,CT_ALARM_2_MASK); |
the_sz | 7:dc29f6647486 | 59 | checkForAlarmSpecified(tmStruct,CT_ALARM_3_TIME,CT_ALARM_3_MASK); |
the_sz | 7:dc29f6647486 | 60 | checkForAlarmSpecified(tmStruct,CT_ALARM_4_TIME,CT_ALARM_4_MASK); |
the_sz | 7:dc29f6647486 | 61 | checkForAlarmSpecified(tmStruct,CT_ALARM_5_TIME,CT_ALARM_5_MASK); |
the_sz | 7:dc29f6647486 | 62 | checkForAlarmSpecified(tmStruct,CT_ALARM_6_TIME,CT_ALARM_6_MASK); |
the_sz | 7:dc29f6647486 | 63 | } |
the_sz | 7:dc29f6647486 | 64 | } |
the_sz | 7:dc29f6647486 | 65 | |
the_sz | 0:995ae8b9afc8 | 66 | int main() |
the_sz | 0:995ae8b9afc8 | 67 | { |
the_sz | 1:35e2ad5cd1fe | 68 | debug_Init(); |
the_sz | 1:35e2ad5cd1fe | 69 | |
the_sz | 2:80026d18fcf3 | 70 | DPrintf("WakeupLight - Hardware v%08X.\r\n",BSP_GetVersion()); |
the_sz | 1:35e2ad5cd1fe | 71 | |
the_sz | 1:35e2ad5cd1fe | 72 | OnBoardLED_Init(); |
the_sz | 0:995ae8b9afc8 | 73 | |
the_sz | 1:35e2ad5cd1fe | 74 | LED_Init(); |
the_sz | 1:35e2ad5cd1fe | 75 | |
the_sz | 2:80026d18fcf3 | 76 | UI_Init(); |
the_sz | 1:35e2ad5cd1fe | 77 | |
the_sz | 7:dc29f6647486 | 78 | Config_Init(); |
the_sz | 7:dc29f6647486 | 79 | |
the_sz | 7:dc29f6647486 | 80 | //BSP_AUDIO_OUT_Play(NULL,28); |
the_sz | 5:13c70bcde7f6 | 81 | /* |
the_sz | 5:13c70bcde7f6 | 82 | #include "SDFileSystem.h" |
the_sz | 5:13c70bcde7f6 | 83 | SDFileSystem sd(PD_2, PC_8, PC_12, PC_11, "sd"); // MOSI, MISO, SCLK, SSEL |
the_sz | 5:13c70bcde7f6 | 84 | DigitalOut sdsd(PC_9); |
the_sz | 5:13c70bcde7f6 | 85 | mkdir("/sd/foo",0777); |
the_sz | 5:13c70bcde7f6 | 86 | FILE *fp = fopen("/sd/mbed.txt", "w"); |
the_sz | 5:13c70bcde7f6 | 87 | fprintf(fp, "Hello World!\n"); |
the_sz | 5:13c70bcde7f6 | 88 | fclose(fp); |
the_sz | 5:13c70bcde7f6 | 89 | */ |
the_sz | 4:2fe89414d4df | 90 | |
the_sz | 2:80026d18fcf3 | 91 | for (;;) |
the_sz | 2:80026d18fcf3 | 92 | { |
the_sz | 7:dc29f6647486 | 93 | checkForAlarm(); |
the_sz | 7:dc29f6647486 | 94 | |
the_sz | 2:80026d18fcf3 | 95 | UI_Poll(); |
the_sz | 0:995ae8b9afc8 | 96 | } |
the_sz | 0:995ae8b9afc8 | 97 | } |