Mercurial > public > ostc4
changeset 718:b9f699d2e3d0
Updated menu structure to support new sensor information page:
The sensor information page has been added to the sensor submenu of the hardware menu. It will be shown dynamically in case a smart sensor is detected. In order to have this dynamic visualization some new functions had to be added to the general menu file. The information page returns to the sensor menu, for this behavior also a new function had to be added.
author | Ideenmodellierer |
---|---|
date | Sun, 20 Nov 2022 20:49:41 +0100 (2022-11-20) |
parents | 88f73b05d45c |
children | 5ff9ea732cbb |
files | Discovery/Inc/tInfo.h Discovery/Inc/tMenuEdit.h Discovery/Inc/tStructure.h Discovery/Src/base.c Discovery/Src/tInfo.c Discovery/Src/tMenuEdit.c Discovery/Src/tMenuEditHardware.c |
diffstat | 7 files changed, 235 insertions(+), 132 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Inc/tInfo.h Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Inc/tInfo.h Sun Nov 20 20:49:41 2022 +0100 @@ -63,5 +63,6 @@ void tInfo_set_on_off(uint32_t editID, uint8_t int1); void exitInfo(void); +void exitInfoToBack(void); #endif /* TINFO_H */
--- a/Discovery/Inc/tMenuEdit.h Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Inc/tMenuEdit.h Sun Nov 20 20:49:41 2022 +0100 @@ -32,22 +32,23 @@ #include "tMenu.h" #define ME_Y_LINE1 (70) -#define ME_Y_LINE_STEP (65) -#define ME_Y_LINE_BASE (ME_Y_LINE1 - ME_Y_LINE_STEP) +#define ME_Y_LINE_STEP (65) +#define ME_Y_LINE_BASE (ME_Y_LINE1 - ME_Y_LINE_STEP) #define ME_Y_LINE2 (ME_Y_LINE1 + (1 * ME_Y_LINE_STEP)) #define ME_Y_LINE3 (ME_Y_LINE1 + (2 * ME_Y_LINE_STEP)) #define ME_Y_LINE4 (ME_Y_LINE1 + (3 * ME_Y_LINE_STEP)) #define ME_Y_LINE5 (ME_Y_LINE1 + (4 * ME_Y_LINE_STEP)) #define ME_Y_LINE6 (ME_Y_LINE1 + (5 * ME_Y_LINE_STEP)) +#define EXIT_TO_INFO_SENSOR (247) #define EXIT_TO_INFO_COMPASS (248) -#define EXIT_TO_MENU_WITH_LOGO (249) -#define EXIT_TO_HOME (250) -#define EXIT_TO_MENU (251) +#define EXIT_TO_MENU_WITH_LOGO (249) +#define EXIT_TO_HOME (250) +#define EXIT_TO_MENU (251) #define UPDATE_DIVESETTINGS (252) -#define UPDATE_AND_EXIT_TO_HOME (253) -#define UPDATE_AND_EXIT_TO_MENU (255) -#define UNSPECIFIC_RETURN (254) +#define UPDATE_AND_EXIT_TO_HOME (253) +#define UPDATE_AND_EXIT_TO_MENU (255) +#define UNSPECIFIC_RETURN (254) void sendActionToMenuEdit(uint8_t sendAction);
--- a/Discovery/Inc/tStructure.h Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Inc/tStructure.h Sun Nov 20 20:49:41 2022 +0100 @@ -58,20 +58,22 @@ #define PageDive 2 #define MaskLineFieldDigit _MB(7,15,0,0,0) -#define MaskFieldDigit _MB(7,15,255,0,0) -#define MaskAllButLine _MB(0,0,255,0,0) -#define MaskLineDigit _MB(7,15,0,255,0) +#define MaskFieldDigit _MB(7,15,255,0,0) +#define MaskAllButLine _MB(0,0,255,0,0) +#define MaskLineDigit _MB(7,15,0,255,0) #define InfoPageLogList 2 #define InfoPageLogShow 3 #define InfoPageCompass 6 +#define InfoPageSensor 8 -#define StI _MB(0,1,0,0,0) -#define StILOGLIST _MB(0,2,0,0,0) -#define StILOGSHOW _MB(0,3,0,0,0) +#define StI _MB(0,1,0,0,0) +#define StILOGLIST _MB(0,2,0,0,0) +#define StILOGSHOW _MB(0,3,0,0,0) #define StIDIVE _MB(0,4,0,0,0) #define StISIM _MB(0,5,0,0,0) -#define StICOMPASS _MB(0,6,0,0,0) +#define StICOMPASS _MB(0,6,0,0,0) #define StIDEBUG _MB(0,7,0,0,0) +#define StISENINFO _MB(0,8,0,0,0) #define StI_GoToLogbook _MB(0,1,1,0,0) #define StI_GoToPlanner _MB(0,1,2,0,0) @@ -264,11 +266,14 @@ //#define StMHARD2_Exit _MB(2,7,2,2,0) +#define StMHARD3_Sensors _MB(2,7,3,0,0) #define StMHARD3_O2_Sensor1 _MB(2,7,3,1,0) #define StMHARD3_O2_Sensor2 _MB(2,7,3,2,0) #define StMHARD3_O2_Sensor3 _MB(2,7,3,3,0) #define StMHARD3_O2_Calibrate _MB(2,7,3,4,0) #define StMHARD3_O2_Source _MB(2,7,3,5,0) +#define StMHARD3_Sensor_Info _MB(2,7,3,6,0) + #define StMHARD4_BrightnessEco _MB(2,7,4,1,0) #define StMHARD4_BrightnessStd _MB(2,7,4,2,0)
--- a/Discovery/Src/base.c Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Src/base.c Sun Nov 20 20:49:41 2022 +0100 @@ -212,6 +212,7 @@ #include "tHome.h" #include "tInfo.h" #include "tInfoLog.h" +#include "tInfoSensor.h" #include "tMenu.h" #include "tMenuEdit.h" #include "tMenuEditGasOC.h" @@ -699,9 +700,9 @@ tMenuEdit_refresh_live_content(); break; case BaseInfo: - tInfo_refresh(); ///< only compass at the moment 23.Feb.2015 hw + tInfo_refresh(); break; - case BaseComm: /* refresh already done in tim callback */ + case BaseComm: /* refresh already done in time callback */ break; default: if(get_globalState() == StStop) @@ -816,13 +817,17 @@ sendActionToMenuEdit(action); break; - case BaseInfo: - if (status.page == InfoPageLogList) - sendActionToInfoLogList(action); - else if (status.page == InfoPageLogShow) - sendActionToInfoLogShow(action); - else - sendActionToInfo(action); + case BaseInfo: switch(status.page) + { + case InfoPageLogList: sendActionToInfoLogList(action); + break; + case InfoPageLogShow: sendActionToInfoLogShow(action); + break; + case InfoPageSensor: sendActionToInfoSensor(action); + break; + default: sendActionToInfo(action); + break; + } break; default: @@ -1790,23 +1795,21 @@ case BaseInfo: if((timeout_in_seconds >= settingsGetPointer()->timeoutInfo) || RequestModeChange) { - if(status.page == InfoPageLogList) - { - exitLog(); - timeout_in_seconds = 0; - } - else - if(status.page == InfoPageLogShow) + timeout_in_seconds = 0; + + switch(status.page) { - show_logbook_exit(); - exitLog(); - timeout_in_seconds = 0; - } - else - if(status.page != InfoPageCompass) - { - exitInfo(); - timeout_in_seconds = 0; + case InfoPageLogList: exitLog(); + break; + case InfoPageLogShow: show_logbook_exit(); + exitLog(); + break; + case InfoPageCompass: /* compass has individual timeout */ + break; + case InfoPageSensor: exitInfoToBack(); + break; + default: exitInfo(); + break; } } break;
--- a/Discovery/Src/tInfo.c Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Src/tInfo.c Sun Nov 20 20:49:41 2022 +0100 @@ -36,7 +36,9 @@ //#include "tInfoDive.h" //#include "tInfoSurface.h" #include "tInfoCompass.h" +#include "tInfoSensor.h" #include "tMenu.h" +#include "tMenuEdit.h" #include <string.h> @@ -198,25 +200,40 @@ void tInfo_refresh(void) { - if(!inDebugMode() && (get_globalState() != StICOMPASS)) - return; - uint32_t oldIscreen; - + uint32_t globalState = get_globalState(); oldIscreen = tIscreen.FBStartAdress; - tIscreen.FBStartAdress = getFrame(14); - infoColor = CLUT_InfoCompass; - + if(inDebugMode()) - tDebug_refresh(); + { + tIscreen.FBStartAdress = getFrame(14); + infoColor = CLUT_InfoCompass; + tDebug_refresh(); + } else - refreshInfo_Compass(tIscreen); - - if(inDebugMode() || (get_globalState() == StICOMPASS)) /* could be timeout and exitInfo */ - GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); - - if(oldIscreen) - releaseFrame(14,oldIscreen); + { + switch(globalState) + { + case StICOMPASS: tIscreen.FBStartAdress = getFrame(14); + infoColor = CLUT_InfoCompass; + refreshInfo_Compass(tIscreen); + break; + case StISENINFO: tIscreen.FBStartAdress = getFrame(14); + infoColor = CLUT_MenuPageHardware; + refreshInfo_Sensor(tIscreen); + break; + default: + break; + } + } + if(oldIscreen != tIscreen.FBStartAdress) + { + GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); + if(oldIscreen) + { + releaseFrame(14,oldIscreen); + } + } } @@ -227,6 +244,12 @@ exitDebugMode(); } +void exitInfoToBack(void) +{ + releaseFrame(14,tIscreen.FBStartAdress); + exitMenuEdit_to_BackMenu(); +} + void sendActionToInfo(uint8_t sendAction) {
--- a/Discovery/Src/tMenuEdit.c Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Src/tMenuEdit.c Sun Nov 20 20:49:41 2022 +0100 @@ -33,6 +33,7 @@ #include "gfx_fonts.h" #include "tHome.h" #include "tInfoCompass.h" +#include "tInfoSensor.h" #include "tMenuEditHardware.h" #include "tMenuEditPlanner.h" #include "tMenuEditSystem.h" @@ -205,9 +206,10 @@ switch(globState) { + case (StMHARD3_O2_Sensor1): case (StMHARD3_O2_Sensor1 & MaskFieldDigit): case (StMHARD3_O2_Calibrate): - case (StMHARD3_O2_Source): refreshFct = refresh_O2Sensors; + case (StMHARD3_O2_Source): refreshFct = refresh_O2Sensors; break; case (StMHARD2_Compass_SetCourse & MaskFieldDigit): refreshFct = refresh_CompassEdit; break; @@ -342,6 +344,12 @@ openInfo_Compass(); } +void exitMenuEdit_to_InfoSensor(void) +{ + exitMenuEdit(1); + openInfo_Sensor(); +} + void exitMenuEdit_to_Home(void) { @@ -598,6 +606,11 @@ return; } + if(newContent == EXIT_TO_INFO_SENSOR) + { + exitMenuEdit_to_InfoSensor(); + return; + } switch(ident[id].maintype) {
--- a/Discovery/Src/tMenuEditHardware.c Sun Nov 20 20:46:10 2022 +0100 +++ b/Discovery/Src/tMenuEditHardware.c Sun Nov 20 20:49:41 2022 +0100 @@ -37,6 +37,7 @@ #include "tHome.h" #include "tInfo.h" #include "tInfoLog.h" +#include "tInfoSensor.h" #include "tComm.h" #include "data_exchange_main.h" @@ -62,6 +63,7 @@ uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_Sensor_Info (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -73,6 +75,7 @@ #define O2_CALIB_FRACTION_O2 (0.98F) static uint8_t O2_calib_gas = 21; +static uint8_t haveSensorInfo = 0; void openEdit_Hardware(uint8_t line) { @@ -89,7 +92,6 @@ openEdit_Compass(); break; case 3: - resetMenuEdit(CLUT_MenuPageHardware); openEdit_O2Sensors(); break; case 4: @@ -290,89 +292,123 @@ const SDiveState *pStateReal = stateRealGetPointer(); - text[0] = '\001'; - text[1] = TXT_o2Sensors; - text[2] = 0; - write_topline(text); - text[0] = TXT_2BYTE; - text[1] = TXT2BYTE_Sensor; - text[2] = ' '; - text[3] = '1'; - text[4] = 0; - write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); - text[3] = '2'; - write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); - text[3] = '3'; - write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); + if((pStateReal->lifeData.extIf_sensor_Id != 0) && (haveSensorInfo == 0)) /* the sensor is detected after the interface has been selected => add button if info become available */ + { + if(get_globalState() == StMHARD3_O2_Source) + { + y_line = 5; + } + haveSensorInfo = 1; + openEdit_O2Sensors(); + if(y_line == 5) + { + tMenuEdit_select(StMHARD3_O2_Source); + } + } + else + { + if(pStateReal->lifeData.extIf_sensor_Id == 0) + { + haveSensorInfo = 0; + } - if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) - { + text[0] = '\001'; + text[1] = TXT_o2Sensors; + text[2] = 0; + write_topline(text); + + text[0] = TXT_2BYTE; - text[1] = TXT2BYTE_HUDbattery; - text[2] = 0; - write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); + text[1] = TXT2BYTE_Sensor; + text[2] = ' '; + text[3] = '1'; + text[4] = 0; + write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); + text[3] = '2'; + write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); + text[3] = '3'; + write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); + + if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) + { + text[0] = TXT_2BYTE; + text[1] = TXT2BYTE_HUDbattery; + text[2] = 0; + write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); - snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); - write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); - } - else - { - text[0] = TXT_2BYTE; - text[1] = TXT2BYTE_O2Calib; - text[2] = 0; - write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); - snprintf(text, 20,"%d%%", O2_calib_gas); - write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); - } - - for(int i=0;i<3;i++) - { - snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); - y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); - write_label_var( 400, 800, y_line, &FontT48, text); - } + snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); + write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); + } + else + { + if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) + { + text[0] = TXT_2BYTE; + text[1] = TXT2BYTE_O2Calib; + text[2] = 0; + write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); + snprintf(text, 20,"%d%%", O2_calib_gas); + write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); + } + } - if(DataEX_external_ADC_Present()) - { - text[0] = TXT_2BYTE; - text[1] = TXT2BYTE_O2Interface; - text[2] = 0; - write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text); - text[0] = TXT_2BYTE; - switch(settingsGetPointer()->ppo2sensors_source) + for(int i=0;i<3;i++) { - default: - case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic; - text[2] = 0; - break; - case O2_SENSOR_SOURCE_ANALOG: text[1] = TXT2BYTE_O2IFAnalog; - text[2] = 0; - break; - case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital; - text[2] = 0; - break; - case O2_SENSOR_SOURCE_ANADIG: text[1] = TXT2BYTE_O2IFAnalog; - text[2] = ' '; - text[3] = '+'; - text[4] = ' '; - text[5] = TXT_2BYTE; - text[6] = TXT2BYTE_O2IFDigital; - text[7] = 0; - break; -#ifdef ENABLE_SENTINEL_MODE - case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); - break; -#endif + snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); + y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); + write_label_var( 400, 800, y_line, &FontT48, text); } - write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text); - } - tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); - tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); - tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); + if(DataEX_external_ADC_Present()) + { + text[0] = TXT_2BYTE; + text[1] = TXT2BYTE_O2Interface; + text[2] = 0; + write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text); + text[0] = TXT_2BYTE; + switch(settingsGetPointer()->ppo2sensors_source) + { + default: + case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic; + text[2] = 0; + break; + case O2_SENSOR_SOURCE_ANALOG: text[1] = TXT2BYTE_O2IFAnalog; + text[2] = 0; + break; + case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital; + text[2] = 0; + break; + case O2_SENSOR_SOURCE_ANADIG: text[1] = TXT2BYTE_O2IFAnalog; + text[2] = ' '; + text[3] = '+'; + text[4] = ' '; + text[5] = TXT_2BYTE; + text[6] = TXT2BYTE_O2IFDigital; + text[7] = 0; + break; + #ifdef ENABLE_SENTINEL_MODE + case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); + break; + #endif + } + write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text); + + if(haveSensorInfo == 1) + { + text[0] = TXT_Sensor; + text[1] = ' '; + text[2] = TXT_Information; + text[3] = 0; + write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text); + } + } + tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); + tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); + tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); + } if(get_globalState() == StMHARD3_O2_Calibrate) { @@ -389,6 +425,9 @@ { uint8_t sensorActive[3]; + set_globalState(StMHARD3_Sensors); + resetMenuEdit(CLUT_MenuPageHardware); + sensorActive[0] = 1; sensorActive[1] = 1; sensorActive[2] = 1; @@ -403,6 +442,11 @@ write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); + if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) + { + haveSensorInfo = 0; /* as long as we do not move the HUD battery into the information page... */ + } + if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) #ifdef ENABLE_SENTINEL_MODE || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) @@ -418,6 +462,10 @@ if(DataEX_external_ADC_Present()) { write_field_button(StMHARD3_O2_Source, 30, 800, ME_Y_LINE5, &FontT48, ""); + if(haveSensorInfo != 0) + { + write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE6, &FontT48, ""); + } } setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); @@ -435,6 +483,10 @@ if(DataEX_external_ADC_Present()) { setEvent(StMHARD3_O2_Source, (uint32_t)OnAction_O2_Source); + if(haveSensorInfo != 0) + { + setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info); + } } write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); @@ -560,12 +612,17 @@ settingsGetPointer()->ppo2sensors_source = source; - resetMenuEdit(CLUT_MenuPageHardware); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ - openEdit_O2Sensors(); + openEdit_O2Sensors(); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ tMenuEdit_select(StMHARD3_O2_Source); return UPDATE_DIVESETTINGS; } +uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + return EXIT_TO_INFO_SENSOR; +} + + void openEdit_Brightness(void) { uint8_t actualBrightness;