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:
Sun Feb 21 04:26:17 2016 +0000
Revision:
14:2044ad5cd3fe
Parent:
12:a89096944f20
all fonts are working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_sz 12:a89096944f20 1 #include "WakeupLight.h"
the_sz 12:a89096944f20 2
the_sz 12:a89096944f20 3 #include "Images/ic_date_range_white_48dp_1x.h"
the_sz 12:a89096944f20 4 extern BYTE ic_query_builder_white_48dp_1x[];
the_sz 12:a89096944f20 5
the_sz 12:a89096944f20 6 UI_STRUCT uiTimeAdjust;
the_sz 12:a89096944f20 7 bool isDateAdjust;
the_sz 12:a89096944f20 8 UI_BOX_LIST_ITEM_STRUCT uiTimeItems[]=
the_sz 12:a89096944f20 9 {
the_sz 12:a89096944f20 10 { "Date", ic_date_range_white_48dp_1x }, { "Time", ic_query_builder_white_48dp_1x }
the_sz 12:a89096944f20 11 };
the_sz 12:a89096944f20 12
the_sz 12:a89096944f20 13 void UI_TimeAdjustHandler(UI_REASON_ENUM reason,int32_t index,UI_STRUCT *ui)
the_sz 12:a89096944f20 14 {
the_sz 12:a89096944f20 15 struct tm *tmStruct;
the_sz 12:a89096944f20 16
the_sz 12:a89096944f20 17 switch (reason)
the_sz 12:a89096944f20 18 {
the_sz 12:a89096944f20 19 case UR_CLICK:
the_sz 12:a89096944f20 20 DPrintf_("UI_WakeupAdjustHandler: %u.\r\n",index);
the_sz 12:a89096944f20 21 if (index==-1)
the_sz 12:a89096944f20 22 {
the_sz 12:a89096944f20 23 if (isDateAdjust==true)
the_sz 12:a89096944f20 24 {
the_sz 12:a89096944f20 25 RTC_Get(&tmStruct);
the_sz 12:a89096944f20 26
the_sz 12:a89096944f20 27 tmStruct->tm_mday=uiTimeAdjust.data.valueAdjust.values[0];
the_sz 12:a89096944f20 28 tmStruct->tm_mon=uiTimeAdjust.data.valueAdjust.values[1]-1;
the_sz 12:a89096944f20 29 tmStruct->tm_year=uiTimeAdjust.data.valueAdjust.values[2]+2000-1900;
the_sz 12:a89096944f20 30
the_sz 12:a89096944f20 31 RTC_Set(tmStruct);
the_sz 12:a89096944f20 32 }
the_sz 12:a89096944f20 33 else
the_sz 12:a89096944f20 34 {
the_sz 12:a89096944f20 35 RTC_Get(&tmStruct);
the_sz 12:a89096944f20 36
the_sz 12:a89096944f20 37 tmStruct->tm_hour=uiTimeAdjust.data.valueAdjust.values[0];
the_sz 12:a89096944f20 38 tmStruct->tm_min=(uiTimeAdjust.data.valueAdjust.values[1]*10) + (uiTimeAdjust.data.valueAdjust.values[2]);
the_sz 12:a89096944f20 39
the_sz 12:a89096944f20 40 RTC_Set(tmStruct);
the_sz 12:a89096944f20 41 }
the_sz 12:a89096944f20 42
the_sz 12:a89096944f20 43 UI_TimeShow();
the_sz 12:a89096944f20 44 break;
the_sz 12:a89096944f20 45 }
the_sz 12:a89096944f20 46 else if (index==0)
the_sz 12:a89096944f20 47 {
the_sz 12:a89096944f20 48 uiTimeAdjust.data.valueAdjust.values[0]++;
the_sz 12:a89096944f20 49 if (isDateAdjust==true)
the_sz 12:a89096944f20 50 {
the_sz 12:a89096944f20 51 if (uiTimeAdjust.data.valueAdjust.values[0]>=32)
the_sz 12:a89096944f20 52 uiTimeAdjust.data.valueAdjust.values[0]=1;
the_sz 12:a89096944f20 53 }
the_sz 12:a89096944f20 54 else
the_sz 12:a89096944f20 55 {
the_sz 12:a89096944f20 56 if (uiTimeAdjust.data.valueAdjust.values[0]>=23)
the_sz 12:a89096944f20 57 uiTimeAdjust.data.valueAdjust.values[0]=0;
the_sz 12:a89096944f20 58 }
the_sz 12:a89096944f20 59 }
the_sz 12:a89096944f20 60 else if (index==1)
the_sz 12:a89096944f20 61 {
the_sz 12:a89096944f20 62 uiTimeAdjust.data.valueAdjust.values[1]++;
the_sz 12:a89096944f20 63 if (isDateAdjust==true)
the_sz 12:a89096944f20 64 {
the_sz 12:a89096944f20 65 if (uiTimeAdjust.data.valueAdjust.values[1]>=13)
the_sz 12:a89096944f20 66 uiTimeAdjust.data.valueAdjust.values[1]=1;
the_sz 12:a89096944f20 67 }
the_sz 12:a89096944f20 68 else
the_sz 12:a89096944f20 69 {
the_sz 12:a89096944f20 70 if (uiTimeAdjust.data.valueAdjust.values[1]>=6)
the_sz 12:a89096944f20 71 uiTimeAdjust.data.valueAdjust.values[1]=0;
the_sz 12:a89096944f20 72 }
the_sz 12:a89096944f20 73 }
the_sz 12:a89096944f20 74 else if (index==2)
the_sz 12:a89096944f20 75 {
the_sz 12:a89096944f20 76 uiTimeAdjust.data.valueAdjust.values[2]++;
the_sz 12:a89096944f20 77 if (isDateAdjust==true)
the_sz 12:a89096944f20 78 {
the_sz 14:2044ad5cd3fe 79 if (uiTimeAdjust.data.valueAdjust.values[2]>=31)
the_sz 12:a89096944f20 80 uiTimeAdjust.data.valueAdjust.values[2]=16;
the_sz 12:a89096944f20 81 }
the_sz 12:a89096944f20 82 else
the_sz 12:a89096944f20 83 {
the_sz 12:a89096944f20 84 if (uiTimeAdjust.data.valueAdjust.values[2]>=10)
the_sz 12:a89096944f20 85 uiTimeAdjust.data.valueAdjust.values[2]=0;
the_sz 12:a89096944f20 86 }
the_sz 12:a89096944f20 87 }
the_sz 12:a89096944f20 88 else if (index==3)
the_sz 12:a89096944f20 89 {
the_sz 12:a89096944f20 90 uiTimeAdjust.data.valueAdjust.values[0]--;
the_sz 12:a89096944f20 91 if (isDateAdjust==true)
the_sz 12:a89096944f20 92 {
the_sz 12:a89096944f20 93 if (uiTimeAdjust.data.valueAdjust.values[0]<1)
the_sz 12:a89096944f20 94 uiTimeAdjust.data.valueAdjust.values[0]=31;
the_sz 12:a89096944f20 95 }
the_sz 12:a89096944f20 96 else
the_sz 12:a89096944f20 97 {
the_sz 12:a89096944f20 98 if (uiTimeAdjust.data.valueAdjust.values[0]<0)
the_sz 12:a89096944f20 99 uiTimeAdjust.data.valueAdjust.values[0]=23;
the_sz 12:a89096944f20 100 }
the_sz 12:a89096944f20 101 }
the_sz 12:a89096944f20 102 else if (index==4)
the_sz 12:a89096944f20 103 {
the_sz 12:a89096944f20 104 uiTimeAdjust.data.valueAdjust.values[1]--;
the_sz 12:a89096944f20 105 if (isDateAdjust==true)
the_sz 12:a89096944f20 106 {
the_sz 12:a89096944f20 107 if (uiTimeAdjust.data.valueAdjust.values[1]<1)
the_sz 12:a89096944f20 108 uiTimeAdjust.data.valueAdjust.values[1]=12;
the_sz 12:a89096944f20 109 }
the_sz 12:a89096944f20 110 else
the_sz 12:a89096944f20 111 {
the_sz 12:a89096944f20 112 if (uiTimeAdjust.data.valueAdjust.values[1]<0)
the_sz 12:a89096944f20 113 uiTimeAdjust.data.valueAdjust.values[1]=5;
the_sz 12:a89096944f20 114 }
the_sz 12:a89096944f20 115 }
the_sz 12:a89096944f20 116 else if (index==5)
the_sz 12:a89096944f20 117 {
the_sz 12:a89096944f20 118 uiTimeAdjust.data.valueAdjust.values[2]--;
the_sz 12:a89096944f20 119 if (isDateAdjust==true)
the_sz 12:a89096944f20 120 {
the_sz 12:a89096944f20 121 if (uiTimeAdjust.data.valueAdjust.values[2]<16)
the_sz 12:a89096944f20 122 uiTimeAdjust.data.valueAdjust.values[2]=30;
the_sz 12:a89096944f20 123 }
the_sz 12:a89096944f20 124 else
the_sz 12:a89096944f20 125 {
the_sz 12:a89096944f20 126 if (uiTimeAdjust.data.valueAdjust.values[2]<0)
the_sz 12:a89096944f20 127 uiTimeAdjust.data.valueAdjust.values[2]=9;
the_sz 12:a89096944f20 128 }
the_sz 12:a89096944f20 129 }
the_sz 12:a89096944f20 130 break;
the_sz 12:a89096944f20 131
the_sz 12:a89096944f20 132 case UR_SHOW:
the_sz 12:a89096944f20 133 break;
the_sz 12:a89096944f20 134 }
the_sz 12:a89096944f20 135 }
the_sz 12:a89096944f20 136
the_sz 12:a89096944f20 137 void UI_TimeHandler(UI_REASON_ENUM reason,int32_t index,UI_STRUCT *ui)
the_sz 12:a89096944f20 138 {
the_sz 12:a89096944f20 139 struct tm *tmStruct;
the_sz 12:a89096944f20 140
the_sz 12:a89096944f20 141 switch (reason)
the_sz 12:a89096944f20 142 {
the_sz 12:a89096944f20 143 case UR_CLICK:
the_sz 12:a89096944f20 144 if (index==-1)
the_sz 12:a89096944f20 145 {
the_sz 12:a89096944f20 146 // back button
the_sz 12:a89096944f20 147 UI_Show(&uiMain);
the_sz 12:a89096944f20 148 }
the_sz 12:a89096944f20 149 else if (index==0)
the_sz 12:a89096944f20 150 {
the_sz 12:a89096944f20 151 // date
the_sz 12:a89096944f20 152 isDateAdjust=true;
the_sz 12:a89096944f20 153
the_sz 12:a89096944f20 154 memset(&uiTimeAdjust,0,sizeof(uiTimeAdjust));
the_sz 12:a89096944f20 155 uiTimeAdjust.flags=UI_FLAG_TYPE_VALUE_ADJUST;
the_sz 12:a89096944f20 156 uiTimeAdjust.handler=UI_TimeAdjustHandler;
the_sz 12:a89096944f20 157 uiTimeAdjust.data.valueAdjust.count=3;
the_sz 12:a89096944f20 158
the_sz 12:a89096944f20 159 RTC_Get(&tmStruct);
the_sz 12:a89096944f20 160 uiTimeAdjust.data.valueAdjust.values[0]=tmStruct->tm_mday;
the_sz 12:a89096944f20 161 uiTimeAdjust.data.valueAdjust.values[1]=tmStruct->tm_mon+1;
the_sz 12:a89096944f20 162 uiTimeAdjust.data.valueAdjust.values[2]=tmStruct->tm_year+1900-2000;
the_sz 12:a89096944f20 163
the_sz 12:a89096944f20 164 UI_Show(&uiTimeAdjust);
the_sz 12:a89096944f20 165 }
the_sz 12:a89096944f20 166 else if (index==1)
the_sz 12:a89096944f20 167 {
the_sz 12:a89096944f20 168 // time
the_sz 12:a89096944f20 169 isDateAdjust=false;
the_sz 12:a89096944f20 170
the_sz 12:a89096944f20 171 memset(&uiTimeAdjust,0,sizeof(uiTimeAdjust));
the_sz 12:a89096944f20 172 uiTimeAdjust.flags=UI_FLAG_TYPE_VALUE_ADJUST;
the_sz 12:a89096944f20 173 uiTimeAdjust.handler=UI_TimeAdjustHandler;
the_sz 12:a89096944f20 174 uiTimeAdjust.data.valueAdjust.count=3;
the_sz 12:a89096944f20 175 uiTimeAdjust.data.valueAdjust.isTime=true;
the_sz 12:a89096944f20 176
the_sz 12:a89096944f20 177 RTC_Get(&tmStruct);
the_sz 12:a89096944f20 178 uiTimeAdjust.data.valueAdjust.values[0]=tmStruct->tm_hour;
the_sz 12:a89096944f20 179 uiTimeAdjust.data.valueAdjust.values[1]=tmStruct->tm_min / 10;
the_sz 12:a89096944f20 180 uiTimeAdjust.data.valueAdjust.values[2]=tmStruct->tm_min % 10;
the_sz 12:a89096944f20 181
the_sz 12:a89096944f20 182 UI_Show(&uiTimeAdjust);
the_sz 12:a89096944f20 183 }
the_sz 12:a89096944f20 184 break;
the_sz 12:a89096944f20 185
the_sz 12:a89096944f20 186 case UR_TIMER:
the_sz 12:a89096944f20 187 break;
the_sz 12:a89096944f20 188 }
the_sz 12:a89096944f20 189 }
the_sz 12:a89096944f20 190
the_sz 12:a89096944f20 191 void UI_TimeShow(void)
the_sz 12:a89096944f20 192 {
the_sz 12:a89096944f20 193 uiWakeup.flags=UI_FLAG_TYPE_BOX_LIST | UI_FLAG_HAS_BACK_BUTTON;
the_sz 12:a89096944f20 194 uiWakeup.handler=UI_TimeHandler;
the_sz 12:a89096944f20 195 uiWakeup.data.boxList.items=uiTimeItems;
the_sz 12:a89096944f20 196 uiWakeup.data.boxList.count=2;
the_sz 12:a89096944f20 197
the_sz 12:a89096944f20 198 UI_Show(&uiWakeup);
the_sz 12:a89096944f20 199 }