Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditHardware.c @ 1082:1aa45000f92c Icon_Integration tip
Added configuration menu for HUD functions:
The V1 HUD has 4 functions (holes) which may be realized by one or two LEDs. The functions (like ppo2 monitoring or ascent speed) may be configurated by the diver using the HUD menu. The functions which may be selected depend on the HW configuration (e.g. the connected sensors) and the number of LEDs which are needed to realize the function. The previous HUD test implementation may still be activate usind the compile switch ENABLE_HUD_TESTING
| author | Ideenmodellierer |
|---|---|
| date | Sun, 15 Mar 2026 21:40:35 +0100 |
| parents | 082825daccb5 |
| children |
comparison
equal
deleted
inserted
replaced
| 1081:1b38d7b8da35 | 1082:1aa45000f92c |
|---|---|
| 40 #include "tInfoLog.h" | 40 #include "tInfoLog.h" |
| 41 #include "tInfoSensor.h" | 41 #include "tInfoSensor.h" |
| 42 #include "tComm.h" | 42 #include "tComm.h" |
| 43 #include "data_exchange_main.h" | 43 #include "data_exchange_main.h" |
| 44 #include "tMenuCvOptionText.h" | 44 #include "tMenuCvOptionText.h" |
| 45 #include "hud.h" | |
| 45 | 46 |
| 46 | 47 |
| 47 //extern void tM_build_pages(void); | 48 //extern void tM_build_pages(void); |
| 48 | 49 |
| 49 /* Private function prototypes -----------------------------------------------*/ | 50 /* Private function prototypes -----------------------------------------------*/ |
| 66 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 67 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 67 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 68 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 68 uint8_t OnAction_ButtonLock (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 69 uint8_t OnAction_ButtonLock (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 69 uint8_t OnAction_LedSequence (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 70 uint8_t OnAction_LedSequence (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 70 uint8_t OnAction_LedBrightness (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 71 uint8_t OnAction_LedBrightness (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 72 #ifdef TOBEUSEDIFMORETHAN4FUNCTIONS | |
| 73 uint8_t OnAction_LedNumber (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 74 #endif | |
| 75 uint8_t OnAction_LedFunction (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 76 | |
| 71 /* Exported functions --------------------------------------------------------*/ | 77 /* Exported functions --------------------------------------------------------*/ |
| 72 | 78 |
| 73 | 79 |
| 74 #define O2_CALIB_FRACTION_AIR (0.209F) | 80 #define O2_CALIB_FRACTION_AIR (0.209F) |
| 75 #define O2_CALIB_FRACTION_O2 (0.98F) | 81 #define O2_CALIB_FRACTION_O2 (0.98F) |
| 76 | 82 |
| 77 static uint8_t O2_calib_gas = 21; | 83 static uint8_t O2_calib_gas = 21; |
| 78 | 84 |
| 79 static externalInterfaceSensorType sensorFilter = SENSOR_NONE; /* used to have only a specific type of sensor in the sensor list view */ | 85 static externalInterfaceSensorType sensorFilter = SENSOR_NONE; /* used to have only a specific type of sensor in the sensor list view */ |
| 80 static externalInterfaceSensorType localSensorMap[3]; /* reduce the complete external sensor map to the three entries which are displayed by the menu */ | 86 static externalInterfaceSensorType localSensorMap[3]; /* reduce the complete external sensor map to the three entries which are displayed by the menu */ |
| 87 | |
| 88 #ifdef TOBEUSEDIFMORETHAN4FUNCTIONS | |
| 89 static uint8_t hudFunctionIndex = 0; /* used for selection of the LED to function mapping */ | |
| 90 #endif | |
| 81 | 91 |
| 82 void openEdit_Hardware(uint8_t line) | 92 void openEdit_Hardware(uint8_t line) |
| 83 { | 93 { |
| 84 set_globalState_Menu_Line(line); | 94 set_globalState_Menu_Line(line); |
| 85 | 95 |
| 148 | 158 |
| 149 char strSensorId[20]; | 159 char strSensorId[20]; |
| 150 char strSensorValue[30]; | 160 char strSensorValue[30]; |
| 151 uint16_t y_line; | 161 uint16_t y_line; |
| 152 uint8_t index = 0; | 162 uint8_t index = 0; |
| 163 uint8_t index2 = 0; | |
| 153 uint8_t uartSensorCnt = 0; | 164 uint8_t uartSensorCnt = 0; |
| 154 | 165 #ifndef ENABLE_HUD_TESTING |
| 166 uint8_t line; | |
| 167 #endif | |
| 155 const SDiveState *pStateReal = stateRealGetPointer(); | 168 const SDiveState *pStateReal = stateRealGetPointer(); |
| 156 SSettings *pSettings = settingsGetPointer(); | 169 SSettings *pSettings = settingsGetPointer(); |
| 157 | 170 |
| 158 if((memcmp(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, EXT_INTERFACE_SENSOR_CNT) != 0) && (sensorFilter == SENSOR_NONE)) | 171 if((memcmp(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, EXT_INTERFACE_SENSOR_CNT) != 0) && (sensorFilter == SENSOR_NONE)) |
| 159 { | 172 { |
| 186 } | 199 } |
| 187 break; | 200 break; |
| 188 case SENSOR_CO2: | 201 case SENSOR_CO2: |
| 189 case SENSOR_CO2M: pSettings->co2_sensor_active = 1; | 202 case SENSOR_CO2M: pSettings->co2_sensor_active = 1; |
| 190 break; | 203 break; |
| 204 #ifdef ENABLE_HUD_SUPPORT | |
| 205 case SENSOR_HUD: hud_Init(); | |
| 206 break; | |
| 207 #endif | |
| 191 #ifdef ENABLE_SENTINEL_MODE | 208 #ifdef ENABLE_SENTINEL_MODE |
| 192 case SENSOR_SENTINEL: | 209 case SENSOR_SENTINEL: |
| 193 case SENSOR_SENTINELM: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL; | 210 case SENSOR_SENTINELM: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL; |
| 194 break; | 211 break; |
| 195 #endif | 212 #endif |
| 258 strSensorId[4] = 'N'; | 275 strSensorId[4] = 'N'; |
| 259 break; | 276 break; |
| 260 case SENSOR_HUD: strSensorId[3] = 'H'; | 277 case SENSOR_HUD: strSensorId[3] = 'H'; |
| 261 strSensorId[4] = 'U'; | 278 strSensorId[4] = 'U'; |
| 262 strSensorId[5] = 'D'; | 279 strSensorId[5] = 'D'; |
| 280 #ifdef ENABLE_HUD_TESTING | |
| 281 strSensorId[4] = 'X'; | |
| 282 #endif | |
| 263 break; | 283 break; |
| 264 default: | 284 default: |
| 265 strSensorId[5] = 0; | 285 strSensorId[5] = 0; |
| 266 break; | 286 break; |
| 267 } | 287 } |
| 278 { | 298 { |
| 279 snprintf(strSensorValue, 20,"%ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm); | 299 snprintf(strSensorValue, 20,"%ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm); |
| 280 } | 300 } |
| 281 else if(localSensorMap[index] == SENSOR_HUD) | 301 else if(localSensorMap[index] == SENSOR_HUD) |
| 282 { | 302 { |
| 283 write_label_var( 30, 340, ME_Y_LINE2, &FontT48, "LED Sequence:"); | 303 snprintf(strSensorValue, 30,"LED Brightness: %d",pStateReal->lifeData.HUD_led_brightness); |
| 284 tMenuEdit_newInput(StMHARD3_O2_Sensor2, pStateReal->lifeData.HUD_led_sequence[0] - pStateReal->lifeData.HUD_led_sequence[1], | 304 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorValue); |
| 305 | |
| 306 for(index2 = 0; index2 < NUM_OF_HUD_FCT; index2++) | |
| 307 { | |
| 308 hud_GetString(pSettings->hudFunction[index2], (uint8_t*)strSensorId); | |
| 309 snprintf(strSensorValue, 30,"%c%c: %s",TXT_2BYTE, TXT2BYTE_FUNCTION, strSensorId); | |
| 310 write_label_var( 30, 340, ME_Y_LINE2 + (index2 * ME_Y_LINE_STEP), &FontT48, strSensorValue); | |
| 311 } | |
| 312 | |
| 313 #ifdef TOBEUSEDIFMORETHAN4FUNCTIONS | |
| 314 snprintf(strSensorValue, 30,"LED #: %d", hudFunctionIndex); | |
| 315 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorValue); | |
| 316 | |
| 317 hud_GetString(pSettings->hudFunction[hudFunctionIndex], (uint8_t*)strSensorId); | |
| 318 snprintf(strSensorValue, 30,"LED %c%c: %s",TXT_2BYTE, TXT2BYTE_FUNCTION, strSensorId); | |
| 319 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorValue); | |
| 320 #endif | |
| 321 | |
| 322 #ifdef ENABLE_HUD_TESTING /* overwrite first line with test field */ | |
| 323 | |
| 324 write_label_var( 30, 340, ME_Y_LINE1, &FontT48, "LED Sequence:"); | |
| 325 #if 0 | |
| 326 tMenuEdit_newInput(StMHARD3_O2_Sensor1, pStateReal->lifeData.HUD_led_sequence[0] - pStateReal->lifeData.HUD_led_sequence[1], | |
| 285 pStateReal->lifeData.HUD_led_sequence[2] - pStateReal->lifeData.HUD_led_sequence[3], | 327 pStateReal->lifeData.HUD_led_sequence[2] - pStateReal->lifeData.HUD_led_sequence[3], |
| 286 pStateReal->lifeData.HUD_led_sequence[4] - pStateReal->lifeData.HUD_led_sequence[5], | 328 pStateReal->lifeData.HUD_led_sequence[4] - pStateReal->lifeData.HUD_led_sequence[5], |
| 287 pStateReal->lifeData.HUD_led_sequence[6]); | 329 pStateReal->lifeData.HUD_led_sequence[6]); |
| 288 snprintf(strSensorValue, 30,"LED Brightness: %d",pStateReal->lifeData.HUD_led_brightness); | 330 #endif |
| 289 write_label_var( 30, 340, ME_Y_LINE3, &FontT48, strSensorValue); | 331 strSensorValue[0] = 0; |
| 290 snprintf(strSensorValue, 20,"o o o \023o"); | 332 |
| 333 #else | |
| 334 line = tMenuEdit_getActualId(); | |
| 335 switch(line) | |
| 336 { | |
| 337 case 3: snprintf(strSensorValue, 20,"\ao\a o o \023o"); | |
| 338 break; | |
| 339 case 2: snprintf(strSensorValue, 20,"o \ao\a o \023o"); | |
| 340 break; | |
| 341 case 1: snprintf(strSensorValue, 20,"o o \ao\a \023o"); | |
| 342 break; | |
| 343 case 4: snprintf(strSensorValue, 20,"o o o \023\ao\a"); | |
| 344 break; | |
| 345 default: snprintf(strSensorValue, 20,"o o o \023o"); | |
| 346 break; | |
| 347 } | |
| 348 #endif | |
| 291 } | 349 } |
| 292 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); | 350 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); |
| 293 if(strSensorValue[0] != 0) | 351 if(strSensorValue[0] != 0) |
| 294 { | 352 { |
| 295 write_label_var( 480, 800, y_line, &FontT48, strSensorValue); | 353 write_label_var( 480, 800, y_line, &FontT48, strSensorValue); |
| 332 } | 390 } |
| 333 if(sensorFilter == SENSOR_NONE) | 391 if(sensorFilter == SENSOR_NONE) |
| 334 { | 392 { |
| 335 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT; index++) | 393 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT; index++) |
| 336 { | 394 { |
| 337 if(pSettings->ext_sensor_map[index] != SENSOR_NONE) | 395 if((pSettings->ext_sensor_map[index] != SENSOR_NONE) && (pSettings->ext_sensor_map[index] != SENSOR_SEARCH)) |
| 338 { | 396 { |
| 339 uartSensorCnt++; | 397 uartSensorCnt++; |
| 340 } | 398 } |
| 341 } | 399 } |
| 342 if(uartSensorCnt != 0) | 400 if(uartSensorCnt != 0) |
| 398 | 456 |
| 399 void openEdit_Sensors(uint8_t filter) | 457 void openEdit_Sensors(uint8_t filter) |
| 400 { | 458 { |
| 401 static externalInterfaceSensorType lastFilter; | 459 static externalInterfaceSensorType lastFilter; |
| 402 SSettings *pSettings = settingsGetPointer(); | 460 SSettings *pSettings = settingsGetPointer(); |
| 461 #ifdef ENABLE_HUD_TESTING | |
| 403 const SDiveState* pRealState = stateRealGetPointer(); | 462 const SDiveState* pRealState = stateRealGetPointer(); |
| 463 #endif | |
| 404 uint8_t sensorActive[3]; | 464 uint8_t sensorActive[3]; |
| 405 uint8_t index = 0; | 465 uint8_t index = 0; |
| 406 char text[3]; | 466 char text[3]; |
| 407 uint32_t firstSensorId = 0; | 467 uint32_t firstSensorId = 0; |
| 408 | 468 |
| 494 else /* single, none O2 sensors */ | 554 else /* single, none O2 sensors */ |
| 495 { | 555 { |
| 496 switch(sensorFilter) | 556 switch(sensorFilter) |
| 497 { | 557 { |
| 498 case SENSOR_CO2: write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", pSettings->co2_sensor_active); /* only one CO2 supporterd => show at first line */ | 558 case SENSOR_CO2: write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", pSettings->co2_sensor_active); /* only one CO2 supporterd => show at first line */ |
| 559 break; | |
| 560 case SENSOR_HUD: | |
| 561 #ifndef ENABLE_HUD_TESTING | |
| 562 write_field_button(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, ""); | |
| 563 #endif | |
| 499 break; | 564 break; |
| 500 default: write_field_button(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, ""); | 565 default: write_field_button(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, ""); |
| 501 break; | 566 break; |
| 502 } | 567 } |
| 503 firstSensorId = StMHARD3_O2_Sensor1; | 568 firstSensorId = StMHARD3_O2_Sensor1; |
| 576 } | 641 } |
| 577 break; | 642 break; |
| 578 case SENSOR_CO2: setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | 643 case SENSOR_CO2: setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); |
| 579 localSensorMap[0] = SENSOR_CO2M; | 644 localSensorMap[0] = SENSOR_CO2M; |
| 580 break; | 645 break; |
| 581 case SENSOR_HUD: write_label_var( 30, 340, ME_Y_LINE2, &FontT48, "LED Sequence:"); | 646 case SENSOR_HUD: |
| 582 write_field_sdigit(StMHARD3_O2_Sensor2, 400, 800, ME_Y_LINE2, &FontT48, "### ### ### ###", | 647 #ifdef ENABLE_HUD_TESTING |
| 648 write_label_var( 30, 340, ME_Y_LINE1, &FontT48, "LED Sequence:"); | |
| 649 write_field_sdigit(StMHARD3_O2_Sensor1, 400, 800, ME_Y_LINE1, &FontT48, "### ### ### ###", | |
| 583 pRealState->lifeData.HUD_led_sequence[0] - pRealState->lifeData.HUD_led_sequence[1], | 650 pRealState->lifeData.HUD_led_sequence[0] - pRealState->lifeData.HUD_led_sequence[1], |
| 584 pRealState->lifeData.HUD_led_sequence[2] - pRealState->lifeData.HUD_led_sequence[3], | 651 pRealState->lifeData.HUD_led_sequence[2] - pRealState->lifeData.HUD_led_sequence[3], |
| 585 pRealState->lifeData.HUD_led_sequence[4] - pRealState->lifeData.HUD_led_sequence[5], | 652 pRealState->lifeData.HUD_led_sequence[4] - pRealState->lifeData.HUD_led_sequence[5], |
| 586 pRealState->lifeData.HUD_led_sequence[6]); | 653 pRealState->lifeData.HUD_led_sequence[6]); |
| 587 | 654 #endif |
| 588 write_field_button(StMHARD3_O2_Sensor3, 400, 800, ME_Y_LINE3, &FontT48, ""); | 655 write_field_button(StMHARD3_O2_Sensor2, 400, 800, ME_Y_LINE2, &FontT48, ""); /* LED #0 */ |
| 589 | 656 write_field_button(StMHARD3_O2_Sensor3, 400, 800, ME_Y_LINE3, &FontT48, ""); /* LED #1 */ |
| 657 write_field_button(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, ""); /* LED #2 */ | |
| 658 write_field_button(StMHARD3_Sensor_Info, 400, 800, ME_Y_LINE5, &FontT48, ""); /* LED #3 */ | |
| 659 write_field_button(StMHARD3_Sensor_Detect, 400, 800, ME_Y_LINE6, &FontT48, ""); /* LED brightness */ | |
| 660 | |
| 661 | |
| 662 #ifndef ENABLE_HUD_TESTING | |
| 590 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | 663 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); |
| 591 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_LedSequence); | 664 #else |
| 592 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_LedBrightness); | 665 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_LedSequence); |
| 593 | 666 #endif |
| 667 | |
| 668 #ifdef TOBEUSEDIFMORETHAN4FUNCTIONS | |
| 669 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_LedNumber); | |
| 670 #endif | |
| 671 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_LedFunction); | |
| 672 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_LedFunction); | |
| 673 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_LedFunction); | |
| 674 setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_LedFunction); | |
| 675 setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_LedBrightness); | |
| 594 localSensorMap[0] = SENSOR_HUD; | 676 localSensorMap[0] = SENSOR_HUD; |
| 595 break; | 677 break; |
| 596 } | 678 } |
| 597 | 679 |
| 598 if (sensorFilter == SENSOR_CO2) | 680 if (sensorFilter == SENSOR_CO2) |
| 1141 return digitContentNew; | 1223 return digitContentNew; |
| 1142 } | 1224 } |
| 1143 return UNSPECIFIC_RETURN; | 1225 return UNSPECIFIC_RETURN; |
| 1144 } | 1226 } |
| 1145 | 1227 |
| 1228 #ifdef TOBEUSEDIFMORETHAN4FUNCTIONS | |
| 1229 uint8_t OnAction_LedNumber(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 1230 { | |
| 1231 hudFunctionIndex++; | |
| 1232 if(hudFunctionIndex == NUM_OF_HUD_FCT) | |
| 1233 { | |
| 1234 hudFunctionIndex = 0; | |
| 1235 } | |
| 1236 | |
| 1237 return UNSPECIFIC_RETURN; | |
| 1238 } | |
| 1239 #endif | |
| 1240 | |
| 1241 uint8_t OnAction_LedFunction(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 1242 { | |
| 1243 SSettings *pSettings = settingsGetPointer(); | |
| 1244 uint8_t hudFunctionIndex = 0; | |
| 1245 | |
| 1246 switch (editId) | |
| 1247 { | |
| 1248 case StMHARD3_O2_Sensor2: hudFunctionIndex = 0; | |
| 1249 break; | |
| 1250 case StMHARD3_O2_Sensor3: hudFunctionIndex = 1; | |
| 1251 break; | |
| 1252 case StMHARD3_O2_Calibrate: hudFunctionIndex = 2; | |
| 1253 break; | |
| 1254 case StMHARD3_Sensor_Info: hudFunctionIndex = 3; | |
| 1255 break; | |
| 1256 default: | |
| 1257 break; | |
| 1258 } | |
| 1259 | |
| 1260 pSettings->hudFunction[hudFunctionIndex] = hud_NextFct(pSettings->hudFunction[hudFunctionIndex], hudFunctionIndex); | |
| 1261 | |
| 1262 return UNSPECIFIC_RETURN; | |
| 1263 } | |
| 1264 | |
| 1265 |
