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

Revision:
7:dc29f6647486
Parent:
5:13c70bcde7f6
Child:
8:51e0f01d5c74
--- a/main.cpp	Tue Nov 10 22:39:50 2015 +0000
+++ b/main.cpp	Thu Nov 12 21:21:48 2015 +0000
@@ -1,5 +1,68 @@
 #include "WakeupLight.h"
 
+int                             lastCheckedMinute=-1;
+
+void checkForAlarmSpecified(struct tm *tmStruct,CONFIG_TYPE_ENUM typeTime,CONFIG_TYPE_ENUM typeFlags)
+{
+    uint32_t                    value;
+    bool                        checkTime;
+
+    value=Config_Get(typeFlags);
+    if (value!=0)
+    {
+        checkTime=false;
+
+        DPrintf("checkForAlarmSpecified: %u.\r\n",tmStruct->tm_wday);
+
+        if (((value & CONFIG_ALARM_MASK_MONDAY)!=0) && (tmStruct->tm_wday==1))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_TUESDAY)!=0) && (tmStruct->tm_wday==2))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_WEDNESDAY)!=0) && (tmStruct->tm_wday==3))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_THURSDAY)!=0) && (tmStruct->tm_wday==4))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_FRIDAY)!=0) && (tmStruct->tm_wday==5))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_SATURDAY)!=0) && (tmStruct->tm_wday==6))
+            checkTime=true;
+        if (((value & CONFIG_ALARM_MASK_SUNDAY)!=0) && (tmStruct->tm_wday==0))
+            checkTime=true;
+            
+        if (checkTime==true)
+        {
+            value=Config_Get(typeTime);
+            if (value==((tmStruct->tm_hour << 8) | (tmStruct->tm_min)))
+            {
+                DPrintf("checkForAlarmSpecified: Alarm detecetd.\r\n");
+                LED_StartAnimation(LAE_WAKEUP);
+            }
+        }
+    }
+}
+    
+void checkForAlarm(void)
+{
+    struct tm                   *tmStruct;
+    time_t                      timeValue;
+
+    timeValue=time(NULL);
+    tmStruct=localtime(&timeValue);
+    
+    if (tmStruct->tm_min!=lastCheckedMinute)
+    {
+        lastCheckedMinute=tmStruct->tm_min;
+        
+        // check all alarm against current time
+        checkForAlarmSpecified(tmStruct,CT_ALARM_1_TIME,CT_ALARM_1_MASK);
+        checkForAlarmSpecified(tmStruct,CT_ALARM_2_TIME,CT_ALARM_2_MASK);
+        checkForAlarmSpecified(tmStruct,CT_ALARM_3_TIME,CT_ALARM_3_MASK);
+        checkForAlarmSpecified(tmStruct,CT_ALARM_4_TIME,CT_ALARM_4_MASK);
+        checkForAlarmSpecified(tmStruct,CT_ALARM_5_TIME,CT_ALARM_5_MASK);
+        checkForAlarmSpecified(tmStruct,CT_ALARM_6_TIME,CT_ALARM_6_MASK);
+    }
+}
+
 int main()
 {
     debug_Init();
@@ -12,6 +75,9 @@
 
     UI_Init();
 
+    Config_Init();
+
+//BSP_AUDIO_OUT_Play(NULL,28); 
 /*
 #include "SDFileSystem.h"
 SDFileSystem sd(PD_2, PC_8, PC_12, PC_11, "sd"); // MOSI, MISO, SCLK, SSEL
@@ -24,6 +90,8 @@
 
     for (;;)
     {
+        checkForAlarm();
+
         UI_Poll();
     }
 }