comparison Discovery/Src/tMenuEditSystem.c @ 1017:5924a2d1d3ba GasConsumption

Prepare custom block update function: In the flash area of the font lib some sectors may be used for custom data or a boot updater image. With this change a flash option is added to the maintainance menu. IMPORTANT: The fimwareEraseProgram.c is needed for compiling the firmware now => Add it e.g. by adding a link from the OtherSources location to your source folder.
author Ideenmodellierer
date Thu, 29 May 2025 22:04:46 +0200
parents fa1af49319e5
children 158100a84ebd
comparison
equal deleted inserted replaced
1014:8c0134a287da 1017:5924a2d1d3ba
56 void openEdit_Reset(void); 56 void openEdit_Reset(void);
57 void openEdit_Maintenance(void); 57 void openEdit_Maintenance(void);
58 //void openEdit_ShowDebugInfo(void); 58 //void openEdit_ShowDebugInfo(void);
59 //void openEdit_Salinity(void); 59 //void openEdit_Salinity(void);
60 60
61 static uint32_t swapBytes(uint32_t source)
62 {
63 uint32_t ret = 0;
64
65 ret = ((source & 0x000000FF) << 24)
66 | ((source & 0x0000FF00) << 8)
67 | ((source & 0x00FF0000) >> 8)
68 | ((source & 0xFF000000) >> 24);
69
70 return ret;
71 }
72
73
61 /* Announced function prototypes -----------------------------------------------*/ 74 /* Announced function prototypes -----------------------------------------------*/
62 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 75 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
63 uint8_t OnAction_Time (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 76 uint8_t OnAction_Time (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
64 uint8_t OnAction_12HR (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 77 uint8_t OnAction_12HR (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 uint8_t OnAction_Format (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 78 uint8_t OnAction_Format (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
99 uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 112 uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
100 #endif 113 #endif
101 #ifdef SCREENTEST 114 #ifdef SCREENTEST
102 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 115 uint8_t OnAction_ScreenTest (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
103 #endif 116 #endif
104 uint8_t OnAction_Information (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 117 uint8_t OnAction_Information (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
118 uint8_t OnAction_FlashBootloader (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
119
105 /* 120 /*
106 uint8_t OnAction_Salinity (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 121 uint8_t OnAction_Salinity (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
107 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 122 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
108 */ 123 */
109 124
1381 } 1396 }
1382 1397
1383 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 1398 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
1384 } 1399 }
1385 1400
1401 customBlockInfo_t blockInfo;
1402
1386 void openEdit_Maintenance(void) 1403 void openEdit_Maintenance(void)
1387 { 1404 {
1388 char text[32]; 1405 char text[32];
1389 unsigned char index = 0; 1406 unsigned char index = 0;
1390 SSettings *pSettings = settingsGetPointer(); 1407 SSettings *pSettings = settingsGetPointer();
1391 SSensorDataDiveO2* pDiveO2Data = NULL; 1408 SSensorDataDiveO2* pDiveO2Data = NULL;
1409
1410 customBlockInfo_t* pCustumBlockInfo = (customBlockInfo_t *) CUSTOM_BLOCK_INFO_ADDR;
1411
1412 blockInfo.Type = swapBytes(pCustumBlockInfo->Type);
1413 blockInfo.fletcher = swapBytes(pCustumBlockInfo->fletcher);
1414 blockInfo.length = swapBytes(pCustumBlockInfo->length);
1392 1415
1393 resetMenuEdit(CLUT_MenuPageSystem); 1416 resetMenuEdit(CLUT_MenuPageSystem);
1394 1417
1395 text[0] = '\001'; 1418 text[0] = '\001';
1396 text[1] = TXT_2BYTE; 1419 text[1] = TXT_2BYTE;
1430 break; 1453 break;
1431 } 1454 }
1432 } 1455 }
1433 } 1456 }
1434 1457
1458 if((blockInfo.Type & 0x0000FF00)== 0x0100)
1459 {
1460 snprintf(text,32,"Flash Bootloader");
1461 write_field_button(StMSYS5_FlashBoot, 30, 800, ME_Y_LINE4, &FontT48, text);
1462 }
1463
1435 #ifdef ENABLE_ANALYSE_SAMPLES 1464 #ifdef ENABLE_ANALYSE_SAMPLES
1436 text[0] = TXT_2BYTE; 1465 text[0] = TXT_2BYTE;
1437 text[1] = TXT2BYTE_SetSampleIndex; 1466 text[1] = TXT2BYTE_SetSampleIndex;
1438 text[2] = 0; 1467 text[2] = 0;
1439 write_field_button(StMSYS5_SetSampleIndx, 30, 800, ME_Y_LINE4, &FontT48, text); 1468 write_field_button(StMSYS5_SetSampleIndx, 30, 800, ME_Y_LINE4, &FontT48, text);
1452 } 1481 }
1453 } 1482 }
1454 #ifdef ENABLE_ANALYSE_SAMPLES 1483 #ifdef ENABLE_ANALYSE_SAMPLES
1455 setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx); 1484 setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
1456 #endif 1485 #endif
1486
1487 if((blockInfo.Type & 0x0000FF00)== 0x0100)
1488 {
1489 setEvent(StMSYS5_FlashBoot, (uint32_t)OnAction_FlashBootloader);
1490 }
1491
1457 1492
1458 1493
1459 text[0] = TXT_2BYTE; 1494 text[0] = TXT_2BYTE;
1460 text[1] = TXT2BYTE_WarnBatteryLow; 1495 text[1] = TXT2BYTE_WarnBatteryLow;
1461 text[2] = 0; 1496 text[2] = 0;
1668 Gfx_write_label_var(&tTestScreen, 10,100,10,&FontT48,CLUT_Font027,text); 1703 Gfx_write_label_var(&tTestScreen, 10,100,10,&FontT48,CLUT_Font027,text);
1669 GFX_SetFramesTopBottom(tTestScreen.FBStartAdress, NULL,480); 1704 GFX_SetFramesTopBottom(tTestScreen.FBStartAdress, NULL,480);
1670 FrameCount++; 1705 FrameCount++;
1671 } 1706 }
1672 #endif 1707 #endif
1708
1709 uint8_t OnAction_FlashBootloader (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
1710 {
1711 SHardwareData HwInfo;
1712 customBlockInfo_t* pCustumBlockInfo = (customBlockInfo_t *) CUSTOM_BLOCK_INFO_ADDR;
1713 customBlockInfo_t blockInfo;
1714 uint32_t checksum;
1715 uint8_t* pSource = (uint8_t *) 0x08100000;
1716
1717 checksum = CalcFletcher32(0x08100000,0x0811FFEF); /* last nibble contains block info => exclude */
1718
1719 blockInfo.Type = swapBytes(pCustumBlockInfo->Type);
1720 blockInfo.fletcher = swapBytes(pCustumBlockInfo->fletcher);
1721 blockInfo.length = swapBytes(pCustumBlockInfo->length);
1722
1723 if(checksum == blockInfo.fletcher)
1724 {
1725 memcpy (&HwInfo, hardwareDataGetPointer(), sizeof(SHardwareData)); /* create backup copy because data will be overwritten during flash erase */
1726
1727 bootloader_eraseFlashMemory();
1728 bootloader_programFlashMemory(pSource, blockInfo.length, &HwInfo);
1729 }
1730 return UNSPECIFIC_RETURN;
1731 }
1732
1673 /* 1733 /*
1674 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 1734 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
1675 { 1735 {
1676 write_label_var( 430, 740, 350, &FontT42, "Wait"); 1736 write_label_var( 430, 740, 350, &FontT42, "Wait");
1677 1737