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

Committer:
the_sz
Date:
Thu Nov 12 22:01:17 2015 +0000
Revision:
8:51e0f01d5c74
Parent:
7:dc29f6647486
Child:
9:fe2c9b3a312b
sound test

Who changed what in which revision?

UserRevisionLine numberNew 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 8:51e0f01d5c74 66 #include "stm32746g_discovery_audio.h"
the_sz 8:51e0f01d5c74 67
the_sz 8:51e0f01d5c74 68 uint16_t buffer[2000];
the_sz 8:51e0f01d5c74 69 void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
the_sz 8:51e0f01d5c74 70 {
the_sz 8:51e0f01d5c74 71 DPrintf("***1");
the_sz 8:51e0f01d5c74 72 BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
the_sz 8:51e0f01d5c74 73 }
the_sz 8:51e0f01d5c74 74 void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
the_sz 8:51e0f01d5c74 75 {
the_sz 8:51e0f01d5c74 76 DPrintf("***2");
the_sz 8:51e0f01d5c74 77 BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
the_sz 8:51e0f01d5c74 78 }
the_sz 8:51e0f01d5c74 79 void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
the_sz 8:51e0f01d5c74 80 {
the_sz 8:51e0f01d5c74 81 DPrintf("***3");
the_sz 8:51e0f01d5c74 82 }
the_sz 8:51e0f01d5c74 83
the_sz 0:995ae8b9afc8 84 int main()
the_sz 0:995ae8b9afc8 85 {
the_sz 1:35e2ad5cd1fe 86 debug_Init();
the_sz 1:35e2ad5cd1fe 87
the_sz 2:80026d18fcf3 88 DPrintf("WakeupLight - Hardware v%08X.\r\n",BSP_GetVersion());
the_sz 1:35e2ad5cd1fe 89
the_sz 1:35e2ad5cd1fe 90 OnBoardLED_Init();
the_sz 0:995ae8b9afc8 91
the_sz 1:35e2ad5cd1fe 92 LED_Init();
the_sz 1:35e2ad5cd1fe 93
the_sz 2:80026d18fcf3 94 UI_Init();
the_sz 1:35e2ad5cd1fe 95
the_sz 7:dc29f6647486 96 Config_Init();
the_sz 7:dc29f6647486 97
the_sz 8:51e0f01d5c74 98
the_sz 8:51e0f01d5c74 99 // OUTPUT_DEVICE_SPEAKER OUTPUT_DEVICE_BOTH
the_sz 8:51e0f01d5c74 100 BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE,100,8000);
the_sz 8:51e0f01d5c74 101 uint32_t index;
the_sz 8:51e0f01d5c74 102 for (index=0;index<100;index++)
the_sz 8:51e0f01d5c74 103 {
the_sz 8:51e0f01d5c74 104 if ((index % 2)==0)
the_sz 8:51e0f01d5c74 105 buffer[index]=0x0000;
the_sz 8:51e0f01d5c74 106 else
the_sz 8:51e0f01d5c74 107 buffer[index]=0x7000;
the_sz 8:51e0f01d5c74 108 }
the_sz 8:51e0f01d5c74 109
the_sz 8:51e0f01d5c74 110 BSP_AUDIO_OUT_Play(buffer, sizeof(buffer)*sizeof(uint16_t));
the_sz 5:13c70bcde7f6 111 /*
the_sz 5:13c70bcde7f6 112 #include "SDFileSystem.h"
the_sz 5:13c70bcde7f6 113 SDFileSystem sd(PD_2, PC_8, PC_12, PC_11, "sd"); // MOSI, MISO, SCLK, SSEL
the_sz 5:13c70bcde7f6 114 DigitalOut sdsd(PC_9);
the_sz 5:13c70bcde7f6 115 mkdir("/sd/foo",0777);
the_sz 5:13c70bcde7f6 116 FILE *fp = fopen("/sd/mbed.txt", "w");
the_sz 5:13c70bcde7f6 117 fprintf(fp, "Hello World!\n");
the_sz 5:13c70bcde7f6 118 fclose(fp);
the_sz 5:13c70bcde7f6 119 */
the_sz 4:2fe89414d4df 120
the_sz 2:80026d18fcf3 121 for (;;)
the_sz 2:80026d18fcf3 122 {
the_sz 7:dc29f6647486 123 checkForAlarm();
the_sz 7:dc29f6647486 124
the_sz 2:80026d18fcf3 125 UI_Poll();
the_sz 0:995ae8b9afc8 126 }
the_sz 0:995ae8b9afc8 127 }