Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src
main.cpp
00001 #include "WakeupLight.h" 00002 00003 int lastCheckedMinute=-1; 00004 00005 void checkForAlarmSpecified(struct tm *tmStruct,CONFIG_TYPE_ENUM typeTime,CONFIG_TYPE_ENUM typeFlags) 00006 { 00007 uint32_t value; 00008 bool checkTime; 00009 00010 value=Config_Get(typeFlags); 00011 if (value!=0) 00012 { 00013 checkTime=false; 00014 00015 DPrintf("checkForAlarmSpecified: %u.\r\n",tmStruct->tm_wday); 00016 00017 if (((value & CONFIG_ALARM_MASK_MONDAY)!=0) && (tmStruct->tm_wday==1)) 00018 checkTime=true; 00019 if (((value & CONFIG_ALARM_MASK_TUESDAY)!=0) && (tmStruct->tm_wday==2)) 00020 checkTime=true; 00021 if (((value & CONFIG_ALARM_MASK_WEDNESDAY)!=0) && (tmStruct->tm_wday==3)) 00022 checkTime=true; 00023 if (((value & CONFIG_ALARM_MASK_THURSDAY)!=0) && (tmStruct->tm_wday==4)) 00024 checkTime=true; 00025 if (((value & CONFIG_ALARM_MASK_FRIDAY)!=0) && (tmStruct->tm_wday==5)) 00026 checkTime=true; 00027 if (((value & CONFIG_ALARM_MASK_SATURDAY)!=0) && (tmStruct->tm_wday==6)) 00028 checkTime=true; 00029 if (((value & CONFIG_ALARM_MASK_SUNDAY)!=0) && (tmStruct->tm_wday==0)) 00030 checkTime=true; 00031 00032 if (checkTime==true) 00033 { 00034 value=Config_Get(typeTime); 00035 if (value==((tmStruct->tm_hour << 8) | (tmStruct->tm_min))) 00036 { 00037 DPrintf("checkForAlarmSpecified: Alarm detecetd.\r\n"); 00038 LED_StartAnimation(LAE_WAKEUP); 00039 } 00040 } 00041 } 00042 } 00043 00044 void checkForAlarm(void) 00045 { 00046 struct tm *tmStruct; 00047 00048 RTC_Get(&tmStruct); 00049 00050 if (tmStruct->tm_min!=lastCheckedMinute) 00051 { 00052 lastCheckedMinute=tmStruct->tm_min; 00053 00054 // check all alarm against current time 00055 checkForAlarmSpecified(tmStruct,CT_ALARM_1_TIME,CT_ALARM_1_MASK); 00056 checkForAlarmSpecified(tmStruct,CT_ALARM_2_TIME,CT_ALARM_2_MASK); 00057 checkForAlarmSpecified(tmStruct,CT_ALARM_3_TIME,CT_ALARM_3_MASK); 00058 checkForAlarmSpecified(tmStruct,CT_ALARM_4_TIME,CT_ALARM_4_MASK); 00059 checkForAlarmSpecified(tmStruct,CT_ALARM_5_TIME,CT_ALARM_5_MASK); 00060 checkForAlarmSpecified(tmStruct,CT_ALARM_6_TIME,CT_ALARM_6_MASK); 00061 } 00062 } 00063 00064 int main() 00065 { 00066 debug_Init(); 00067 00068 RTC_Init(); 00069 00070 DPrintf("WakeupLight - Hardware v%08X @ %u MHz.\r\n",BSP_GetVersion(),(HAL_RCC_GetSysClockFreq()/1000/1000)); 00071 00072 OnBoardLED_Init(); 00073 00074 TM_RNG_Init(); 00075 00076 LED_Init(); 00077 00078 Sound_Init(); 00079 00080 SD_Init(); 00081 00082 UI_Init(); 00083 00084 Config_Init(); 00085 00086 for (;;) 00087 { 00088 checkForAlarm(); 00089 00090 UI_Poll(); 00091 } 00092 }
Generated on Tue Jul 12 2022 21:40:04 by
1.7.2