@@ -34,14 +34,6 @@ const char * const iconBmpName[] = {
34
34
// add new icons in icon_list.inc only
35
35
};
36
36
37
- // This List is Auto-Generated. Please add new icons in small_icon_list.inc only
38
- const char * const smallIconBmpName [] = {
39
- #define X_SMALLICON (NAME ) #NAME ,
40
- #include "small_icon_list.inc"
41
- #undef X_SMALLICON
42
- // add new icons in small_icon_list.inc only
43
- };
44
-
45
37
BMPUPDATE_STAT bmpDecode (char * bmp , uint32_t addr )
46
38
{
47
39
FIL bmpFile ;
@@ -133,6 +125,37 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
133
125
return BMP_SUCCESS ;
134
126
}
135
127
128
+ void dispIconFail (uint8_t * lbl , BMPUPDATE_STAT bmpState )
129
+ {
130
+ char * stat_txt ;
131
+ char error_txt [30 ];
132
+
133
+ GUI_SetColor (infoSettings .reminder_color );
134
+ GUI_ClearPrect (& labelFailedRect );
135
+ GUI_DispString (labelFailedRect .x0 , labelFailedRect .y0 , lbl );
136
+
137
+ switch (bmpState )
138
+ {
139
+ case BMP_INVALIDFILE :
140
+ stat_txt = "BMP file not valid " ;
141
+ break ;
142
+
143
+ case BMP_NOT24BIT :
144
+ stat_txt = "Format is not 24Bit" ;
145
+ break ;
146
+
147
+ case BMP_NOTFOUND :
148
+ default :
149
+ stat_txt = "BMP file not found " ;
150
+ break ;
151
+ }
152
+
153
+ sprintf (error_txt , "Error: %s" , stat_txt );
154
+ GUI_DispString (labelFailedRect .x0 , labelFailedRect .y0 + BYTE_HEIGHT + 2 , (uint8_t * )error_txt );
155
+ GUI_RestoreColorDefault ();
156
+ Delay_ms (1000 ); // give some time to the user to read failed icon name.
157
+ }
158
+
136
159
static inline bool updateIcon (char * rootDir )
137
160
{
138
161
uint16_t found = 0 ;
@@ -165,24 +188,25 @@ static inline bool updateIcon(char * rootDir)
165
188
for (int i = 0 ; i < COUNT (iconBmpName ); i ++ )
166
189
{
167
190
GUI_POINT last_size = bmp_size ;
168
- sprintf (curBmpPath , "%s" BMP_UPDATE_DIR "/%s.bmp" , rootDir , iconBmpName [i ]);
169
- GUI_ClearPrect (& labelUpdateRect );
170
- GUI_DispString (labelUpdateRect .x0 , labelUpdateRect .y0 , (uint8_t * )curBmpPath );
171
191
192
+ sprintf (curBmpPath , "%s%s/%s.bmp" , rootDir , BMP_UPDATE_DIR , iconBmpName [i ]);
172
193
bmpState = bmpDecode (curBmpPath , ICON_ADDR (i ));
173
194
195
+ GUI_ClearPrect (& labelUpdateRect );
196
+ GUI_DispString (labelUpdateRect .x0 , labelUpdateRect .y0 , (uint8_t * )curBmpPath );
197
+ GUI_ClearRect (iconUpdateRect .x0 , iconUpdateRect .y0 , iconUpdateRect .x0 + last_size .x , iconUpdateRect .y0 + last_size .y );
198
+
174
199
if (bmpState == BMP_SUCCESS )
175
200
{ // display bmp update success
176
201
found ++ ;
177
- GUI_ClearRect (iconUpdateRect .x0 , iconUpdateRect .y0 , iconUpdateRect .x0 + last_size .x , iconUpdateRect .y0 + last_size .y );
178
202
IMAGE_ReadDisplay (iconUpdateRect .x0 , iconUpdateRect .y0 , ICON_ADDR (i ));
179
203
}
180
204
else
181
205
{ // display bmp update fail
182
206
notfound ++ ;
183
- GUI_ClearRect (iconUpdateRect .x0 , iconUpdateRect .y0 , iconUpdateRect .x0 + last_size .x , iconUpdateRect .y0 + last_size .y );
184
207
dispIconFail ((uint8_t * )curBmpPath , bmpState );
185
208
}
209
+
186
210
// Display icon update progress
187
211
sprintf (tempstr , "Updated: %d | Not Updated: %d" , found , notfound );
188
212
GUI_DispString (statUpdateRect .x0 , statUpdateRect .y0 , (uint8_t * )tempstr );
@@ -202,47 +226,14 @@ static inline bool updateIcon(char * rootDir)
202
226
dispIconFail ((uint8_t * )(curBmpPath ), bmpState );
203
227
}
204
228
205
- if (notfound == 0 )
206
- return true;
207
- else
208
- return false;
209
- }
210
-
211
- void dispIconFail (uint8_t * lbl , BMPUPDATE_STAT bmpState )
212
- {
213
- char * stat_txt ;
214
- char error_txt [30 ];
215
-
216
- GUI_SetColor (infoSettings .reminder_color );
217
- GUI_ClearPrect (& labelFailedRect );
218
- GUI_DispString (labelFailedRect .x0 , labelFailedRect .y0 , lbl );
219
-
220
- switch (bmpState )
221
- {
222
- case BMP_INVALIDFILE :
223
- stat_txt = "BMP file not valid " ;
224
- break ;
225
- case BMP_NOT24BIT :
226
- stat_txt = "Format is not 24Bit" ;
227
- break ;
228
- case BMP_NOTFOUND :
229
- default :
230
- stat_txt = "BMP file not found " ;
231
- break ;
232
- }
233
-
234
- sprintf (error_txt , "Error: %s" , stat_txt );
235
- GUI_DispString (labelFailedRect .x0 , labelFailedRect .y0 + BYTE_HEIGHT + 2 , (uint8_t * )error_txt );
236
- GUI_RestoreColorDefault ();
237
- Delay_ms (1000 ); // give some time to the user to read failed icon name.
229
+ return !notfound ;
238
230
}
239
231
240
- bool updateFont (char * font , uint32_t addr )
232
+ static bool updateFont (char * font , uint32_t addr )
241
233
{
242
234
uint8_t progress = 0 ;
243
235
UINT rnum = 0 ;
244
236
uint32_t offset = 0 ;
245
- char buffer [128 ];
246
237
FIL myfp ;
247
238
uint8_t * tempbuf = NULL ;
248
239
@@ -255,9 +246,11 @@ bool updateFont(char * font, uint32_t addr)
255
246
return false;
256
247
257
248
GUI_Clear (infoSettings .bg_color );
258
- sprintf ((void * )buffer , "%s Size: %dKB" , font , (uint32_t )f_size (& myfp ) >> 10 );
259
- GUI_DispString (0 , 100 , (uint8_t * )buffer );
260
- GUI_DispString (0 , 140 , (uint8_t * )"Updating: %" );
249
+ GUI_DispString (5 , PADDING , (uint8_t * )"Updating Fonts" );
250
+ GUI_DispString (0 , BYTE_HEIGHT * 3 + PADDING , (uint8_t * )font );
251
+ GUI_DispString (0 , BYTE_HEIGHT * 4 + PADDING , (uint8_t * )"Size: KB" );
252
+ GUI_DispDec (0 + BYTE_WIDTH * 5 , BYTE_HEIGHT * 4 + PADDING , (uint32_t )f_size (& myfp ) >> 10 , 4 , RIGHT );
253
+ GUI_DispString (0 , BYTE_HEIGHT * 5 + PADDING , (uint8_t * )"Updating: %" );
261
254
262
255
while (!f_eof (& myfp ))
263
256
{
@@ -270,10 +263,10 @@ bool updateFont(char * font, uint32_t addr)
270
263
if (progress != (offset * 100 ) / f_size (& myfp ))
271
264
{
272
265
progress = (offset * 100 ) / f_size (& myfp );
273
- GUI_DispDec (0 + BYTE_WIDTH * 9 , 140 , progress , 3 , RIGHT );
266
+ GUI_DispDec (0 + BYTE_WIDTH * 9 , BYTE_HEIGHT * 5 + PADDING , progress , 3 , RIGHT );
274
267
}
275
268
276
- if (rnum != W25QXX_SECTOR_SIZE ) break ;
269
+ if (rnum != W25QXX_SECTOR_SIZE ) break ;
277
270
}
278
271
279
272
f_close (& myfp );
@@ -371,89 +364,76 @@ void scanUpdates(void)
371
364
{
372
365
char * rootDir = NULL ;
373
366
374
- #ifdef USB_FLASH_DRIVE_SUPPORT
375
- bool checkUSBDisk = true;
376
- #endif
377
-
378
367
if (mountSDCard ())
379
368
rootDir = SD_ROOT_DIR ;
369
+ #ifdef USB_FLASH_DRIVE_SUPPORT
370
+ // check USB flash drive for update file
371
+ else if (mountUSBDisk ())
372
+ rootDir = USB_ROOT_DIR ;
373
+ #endif
374
+ else
375
+ return ;
380
376
381
- #ifdef USB_FLASH_DRIVE_SUPPORT
382
- checkupdate :
383
- #endif
384
- if (rootDir != NULL )
385
- {
386
- char curfilePath [100 ];
387
- bool flash_sign_updated = false;
388
- uint32_t saved_flash_sign [sign_count ];
377
+ char curfilePath [100 ];
378
+ bool flash_sign_updated = false;
379
+ uint32_t saved_flash_sign [sign_count ];
389
380
390
- W25Qxx_ReadBuffer ((uint8_t * )& saved_flash_sign , FLASH_SIGN_ADDR , sizeof (saved_flash_sign ));
381
+ W25Qxx_ReadBuffer ((uint8_t * )& saved_flash_sign , FLASH_SIGN_ADDR , sizeof (saved_flash_sign ));
391
382
392
- // check for font update
393
- GET_FULL_PATH (curfilePath , rootDir , FONT_UPDATE_DIR );
394
- if (f_dir_exists (curfilePath ))
395
- {
396
- bool updateOk = true;
397
- for (uint8_t i = 0 ; i < COUNT (fontAddrList ); i ++ )
398
- {
399
- GET_FULL_PATH (curfilePath , rootDir , fontPathList [i ]);
400
- if (!updateFont (curfilePath , fontAddrList [i ]))
401
- updateOk = false; // set update to false if any font fails to update
402
- }
403
-
404
- if (updateOk && saved_flash_sign [font_sign ] != FONT_CHECK_SIGN )
405
- {
406
- saved_flash_sign [font_sign ] = FONT_CHECK_SIGN ;
407
- flash_sign_updated = true;
408
- }
409
- }
410
-
411
- // check for icon/bmp update
412
- GET_FULL_PATH (curfilePath , rootDir , BMP_UPDATE_DIR );
413
- if (f_dir_exists (BMP_UPDATE_DIR ))
383
+ // check for font update
384
+ GET_FULL_PATH (curfilePath , rootDir , FONT_UPDATE_DIR );
385
+ if (f_dir_exists (curfilePath ))
386
+ {
387
+ bool updateOK = true;
388
+ for (uint8_t i = 0 ; i < COUNT (fontAddrList ); i ++ )
414
389
{
415
- if (updateIcon (rootDir ) && (saved_flash_sign [icon_sign ] != ICON_CHECK_SIGN ))
416
- {
417
- saved_flash_sign [icon_sign ] = ICON_CHECK_SIGN ;
418
- flash_sign_updated = true;
419
- }
390
+ GET_FULL_PATH (curfilePath , rootDir , fontPathList [i ]);
391
+ if (!updateFont (curfilePath , fontAddrList [i ]))
392
+ updateOK = false; // set update to false if any font fails to update
420
393
}
421
394
422
- // check for config update
423
- GET_FULL_PATH (curfilePath , rootDir , CONFIG_FILE_PATH );
424
- if (getConfigFromFile (curfilePath ) && (saved_flash_sign [config_sign ] != CONFIG_CHECK_SIGN ))
395
+ if (updateOK && saved_flash_sign [font_sign ] != FONT_CHECK_SIGN )
425
396
{
426
- saved_flash_sign [config_sign ] = CONFIG_CHECK_SIGN ;
397
+ saved_flash_sign [font_sign ] = FONT_CHECK_SIGN ;
427
398
flash_sign_updated = true;
428
399
}
400
+ }
429
401
430
- // check for language update
431
- if (getLangFromFile (rootDir ) && (saved_flash_sign [lang_sign ] != LANGUAGE_CHECK_SIGN ))
402
+ // check for icon/bmp update
403
+ GET_FULL_PATH (curfilePath , rootDir , BMP_UPDATE_DIR );
404
+ if (f_dir_exists (curfilePath ))
405
+ {
406
+ if (updateIcon (rootDir ) && (saved_flash_sign [icon_sign ] != ICON_CHECK_SIGN ))
432
407
{
433
- saved_flash_sign [lang_sign ] = LANGUAGE_CHECK_SIGN ;
408
+ saved_flash_sign [icon_sign ] = ICON_CHECK_SIGN ;
434
409
flash_sign_updated = true;
435
410
}
411
+ }
436
412
437
- // rename files
438
- scanRenameUpdate (rootDir );
439
-
440
- // check for reset file
441
- scanResetDir (rootDir );
413
+ // check for config update
414
+ GET_FULL_PATH (curfilePath , rootDir , CONFIG_FILE_PATH );
415
+ if (getConfigFromFile (curfilePath ) && (saved_flash_sign [config_sign ] != CONFIG_CHECK_SIGN ))
416
+ {
417
+ saved_flash_sign [config_sign ] = CONFIG_CHECK_SIGN ;
418
+ flash_sign_updated = true;
419
+ }
442
420
443
- // update flash sign
444
- if ( flash_sign_updated )
445
- {
446
- saveflashSign (( uint8_t * ) saved_flash_sign , sizeof ( saved_flash_sign )) ;
447
- }
421
+ // check for language update
422
+ if ( getLangFromFile ( rootDir ) && ( saved_flash_sign [ lang_sign ] != LANGUAGE_CHECK_SIGN ) )
423
+ {
424
+ saved_flash_sign [ lang_sign ] = LANGUAGE_CHECK_SIGN ;
425
+ flash_sign_updated = true;
448
426
}
449
427
450
- #ifdef USB_FLASH_DRIVE_SUPPORT
451
- // check USB flash drive for update file
452
- else if (checkUSBDisk && mountUSBDisk ())
453
- {
454
- rootDir = USB_ROOT_DIR ;
455
- checkUSBDisk = false;
456
- goto checkupdate ;
457
- }
458
- #endif
428
+ // rename files
429
+ scanRenameUpdate (rootDir );
430
+
431
+ // check for reset file
432
+ scanResetDir (rootDir );
433
+
434
+ // update flash sign
435
+ if (flash_sign_updated )
436
+ {
437
+ saveflashSign ((uint8_t * )saved_flash_sign , sizeof (saved_flash_sign ));
438
+ }
459
439
}
0 commit comments