Mercurial > public > ostc4
changeset 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 | 1b38d7b8da35 |
| children | |
| files | Common/Inc/configuration.h Common/Inc/settings.h Discovery/Inc/hud.h Discovery/Inc/tMenuEdit.h Discovery/Inc/text_multilanguage.h Discovery/Src/base.c Discovery/Src/data_exchange_main.c Discovery/Src/hud.c Discovery/Src/settings.c Discovery/Src/tInfoSensor.c Discovery/Src/tMenuEdit.c Discovery/Src/tMenuEditHardware.c Discovery/Src/text_multilanguage.c |
| diffstat | 13 files changed, 561 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/configuration.h Sun Mar 15 21:28:53 2026 +0100 +++ b/Common/Inc/configuration.h Sun Mar 15 21:40:35 2026 +0100 @@ -115,5 +115,8 @@ /* #define ENABLE_ADVANCED_GAS */ /* Enable to have protocol support for external HUD */ /* #define ENABLE_HUD_SUPPORT */ +/* Enable to have an item available in the HUD menu which allows the manual setting of the HUD sequence */ +/* #define ENABLE_HUD_TESTING */ + #endif
--- a/Common/Inc/settings.h Sun Mar 15 21:28:53 2026 +0100 +++ b/Common/Inc/settings.h Sun Mar 15 21:40:35 2026 +0100 @@ -97,6 +97,8 @@ #define NUMBER_OF_PROFILES (4u) +#define MAX_NUMBER_OF_HUD_FCTS (6u) /* number of functions which may be selected at once (is not equal to LEDs involved) */ + typedef enum { O2_SENSOR_SOURCE_OPTIC = 0, @@ -334,6 +336,8 @@ /* new in 0xFFFF002d */ uint8_t profileName[NUMBER_OF_PROFILES][9]; uint8_t activeProfile; + /* new in 0xFFFF002F */ + uint8_t hudFunction[MAX_NUMBER_OF_HUD_FCTS]; } SSettings; uint8_t writeData(uint8_t *);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Discovery/Inc/hud.h Sun Mar 15 21:40:35 2026 +0100 @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +/// -*- coding: UTF-8 -*- +/// +/// \file Discovery/Inc/hud.h +/// \brief +/// \author Heinrichs Weikamp +/// \date 2026 +/// +/// $Id$ +/////////////////////////////////////////////////////////////////////////////// +/// \par Copyright (c) 2014-2026 Heinrichs Weikamp gmbh +/// +/// This program is free software: you can redistribute it and/or modify +/// it under the terms of the GNU General Public License as published by +/// the Free Software Foundation, either version 3 of the License, or +/// (at your option) any later version. +/// +/// This program is distributed in the hope that it will be useful, +/// but WITHOUT ANY WARRANTY; without even the implied warranty of +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/// GNU General Public License for more details. +/// +/// You should have received a copy of the GNU General Public License +/// along with this program. If not, see <http://www.gnu.org/licenses/>. +////////////////////////////////////////////////////////////////////////////// + +#ifndef HUD_H +#define HUD_H + +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "text_multilanguage.h" + +#define NUM_OF_HUD_FCT (4u) /* number of different functions which may be displayed at HUD at once */ +#define HUD_INFO_DATA_LENGTH (24u) /* expected number of received info data */ +#define HUD_INFO_INFOSTR_LENGTH (16u) + + +#define HUD_INFO_INFOSTR_OFFSET (3u) /* offset of info string */ +#define HUD_INFO_VERSION_OFFSET (19u) /* offset of version byte */ + +enum hudFct +{ + HUD_FCT_NONE = 0, /* Slot will not be used */ + HUD_FCT_WARNING, /* Show common warning indicator */ + HUD_FCT_PPO2SUM, /* Show combined PPO2 status */ + HUD_FCT_PPO2_0, /* Show individual PPO2 status (sensor 0) */ + HUD_FCT_PPO2_1, /* Show individual PPO2 status (sensor 1) */ + HUD_FCT_PPO2_2, /* Show individual PPO2 status (sensor 2) */ + HUD_FCT_ASCENT_SPEED, /* Show indicator for ascent speed */ + HUD_FCT_DECO, /* Show deco / depth indicator */ + HUD_FCT_END +}; + +void hud_Init(void); +void hud_GetString(uint8_t id, uint8_t* pText); +uint8_t hud_NextFct(uint8_t curFct, uint8_t fctId); +void hud_UpdateStatus(void); +uint8_t hud_IsActive(void); +uint8_t hud_GetAddress(void); + +#endif /* HUD_H */ +
--- a/Discovery/Inc/tMenuEdit.h Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Inc/tMenuEdit.h Sun Mar 15 21:40:35 2026 +0100 @@ -112,6 +112,7 @@ void exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(void); void exitMenuEditField(void); void tMenuEdit_writeSettingsToFlash(void); +uint8_t tMenuEdit_getActualId(); GFX_DrawCfgScreen* getMenuEditScreen(void); #endif /* TMENU_EDIT_H */
--- a/Discovery/Inc/text_multilanguage.h Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Inc/text_multilanguage.h Sun Mar 15 21:40:35 2026 +0100 @@ -400,7 +400,12 @@ TXT2BYTE_Pulse, TXT2BYTE_Logger, + TXT2BYTE_FUNCTION, + TXT2BYTE_AscentSpeed, + TXT2BYTE_END, + + /* TODO: we are close to the end of TXT2BYTE_END => define function for additional entries... TXT3BYTE ? */ }; #endif /* TEXT_MULTILINGUAGE_H */
--- a/Discovery/Src/base.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/base.c Sun Mar 15 21:40:35 2026 +0100 @@ -239,6 +239,7 @@ #include "tMenuEditSetpoint.h" #include "cv_heartbeat.h" #include "tInfoLogger.h" +#include "hud.h" #ifdef DEMOMODE #include "demo.h" @@ -488,7 +489,9 @@ { ButtonLockState = LOCK_FIRST_PRESS; } - +#ifdef ENABLE_HUD_SUPPORT + hud_Init(); +#endif /* @brief main LOOP * * this is executed while no IRQ interrupts it @@ -586,6 +589,16 @@ { t3_handleAutofocus(); } + + /* handle HUD status */ +#ifdef ENABLE_HUD_SUPPORT + if(hud_IsActive()) + { + hud_UpdateStatus(); + } +#endif + + #ifdef SIM_WRITES_LOGBOOK if(stateUsed == stateSimGetPointer()) logbook_InitAndWrite((SDiveState*)stateUsed);
--- a/Discovery/Src/data_exchange_main.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/data_exchange_main.c Sun Mar 15 21:40:35 2026 +0100 @@ -471,7 +471,7 @@ dataOut.displayVersion = 1; } #ifdef ENABLE_HUD_SUPPORT - memcpy (dataOut.data.externalInterface_HUD_Update, pStateReal->lifeData.HUD_led_sequence, EXT_INTERFACE_HUD_LED_MAX); + memcpy (dataOut.data.externalInterface_HUD_Update, stateUsed->lifeData.HUD_led_sequence, EXT_INTERFACE_HUD_LED_MAX); dataOut.data.externalInterface_HUD_Brightness = pStateReal->lifeData.HUD_led_brightness; #endif if(DataEX_check_header_and_footer_ok() && !told_reset_logik_alles_ok)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Discovery/Src/hud.c Sun Mar 15 21:40:35 2026 +0100 @@ -0,0 +1,290 @@ +/** + ****************************************************************************** + * @file hud.c + * @author heinrichs weikamp gmbh + * @version V0.0.1 + * @date 09-Mar-2026 + * @brief Support function for HUD configuration + * + @verbatim + ============================================================================== + ##### How to use ##### + ============================================================================== + @endverbatim + ****************************************************************************** + * @attention + * + * COPYRIGHT(c) 2026 heinrichs weikamp + * + ****************************************************************************** + */ + +#include "hud.h" +#include "settings.h" +#include "data_central.h" +#include "data_exchange.h" +#include "data_exchange_main.h" +#include "gfx_colors.h" +#include "math.h" +#include "tHome.h" + +uint8_t hudActive; +static uint8_t hudAddress; +static uint8_t hudVersion; + +static uint8_t hudLEDPerFct[NUM_OF_HUD_FCT]; /* array providing the version depending LED per function mapping */ +static uint8_t hudLEDNeedPerFct[HUD_FCT_END+1] = {0, 1, 2, 2, 2, 2, 2, 2, 0}; /* array providing information how many LEDs are needed to provide a function */ + +void hud_Init() +{ + uint8_t index = 0; + SDiveState * pStateReal = stateRealGetPointerWrite(); + SSettings *pSettings = settingsGetPointer(); + + memset(pStateReal->lifeData.HUD_led_sequence,0,EXT_INTERFACE_HUD_LED_MAX); + hudActive = 0; + hudAddress = 0xFF; + hudVersion = 0; + + for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT; index++) + { + if(pSettings->ext_sensor_map[index] == SENSOR_HUD) + { + hudActive = 1; + hudAddress = index; + break; + } + } +} + +uint8_t hud_IsActive() +{ + return hudActive; +} + +uint8_t hud_GetAddress(void) +{ + return hudAddress; +} + +void hud_GetString(uint8_t id, uint8_t* pText) +{ + switch(id) + { + case HUD_FCT_NONE: sprintf((char*)pText,"%c", TXT_Off); + break; + case HUD_FCT_WARNING: sprintf((char*)pText,"%c", TXT_Warning); + break; + case HUD_FCT_PPO2SUM: sprintf((char*)pText,"%c%c (1 - 3)", TXT_2BYTE, TXT2BYTE_O2monitor); + break; + case HUD_FCT_PPO2_0: + case HUD_FCT_PPO2_1: + case HUD_FCT_PPO2_2: sprintf((char*)pText,"%c%c (%d)", TXT_2BYTE, TXT2BYTE_O2monitor, (id - HUD_FCT_PPO2_0)); + break; + case HUD_FCT_ASCENT_SPEED: sprintf((char*)pText,"%c%c", TXT_2BYTE, TXT2BYTE_AscentSpeed); + break; + case HUD_FCT_DECO: sprintf((char*)pText,"%c%c", TXT_2BYTE, TXT2BYTE_WarnDecoMissed); + break; + default: + break; + } +} + +uint8_t hud_NextFct(uint8_t curFct, uint8_t fctId) +{ + uint8_t done = 0; + uint8_t nextFct = curFct; + SSettings *pSettings = settingsGetPointer(); + + + while (done == 0) + { + nextFct++; + if(nextFct < HUD_FCT_END) + { + if(hudLEDNeedPerFct[nextFct] <= hudLEDPerFct[fctId]) + { + switch(nextFct) /* this switch handles conditional function. e.g. monitor2 should be skipped if no sensor2 is connected */ + { + case HUD_FCT_PPO2_0: + case HUD_FCT_PPO2_1: + case HUD_FCT_PPO2_2: if((pSettings->ext_sensor_map[nextFct - HUD_FCT_PPO2_0] >= SENSOR_ANALOG) && (pSettings->ext_sensor_map[nextFct - HUD_FCT_PPO2_0] < SENSOR_TYPE_O2_END)) + { + done = 1; + } + break; + default: done = 1; + break; + } + } + } + else + { + nextFct = HUD_FCT_NONE; + break; + } + } + return nextFct; +} + +static void hud_UpdateWarning(uint8_t fctId) +{ +// SDiveState * pStateReal = stateRealGetPointerWrite(); + + if(stateUsed->warnings.numWarnings) + { + stateUsedWrite->lifeData.HUD_led_sequence[fctId * 2] = 0x32; + } + else + { + stateUsedWrite->lifeData.HUD_led_sequence[fctId * 2] = 0; + } +} + +static void hud_UpdatePPO2Monitor(uint8_t fctId, float ppO2) +{ +// SDiveState * pStateReal = stateRealGetPointerWrite(); + + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0; + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0; + + if(fabs(stateUsed->lifeData.actualGas.setPoint_cbar - ppO2) < 0.06) /* green constant */ + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0x01; + } + else if((stateUsed->lifeData.actualGas.setPoint_cbar - ppO2) < 0.2) /* to low => blink green */ + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0x13; + } + else if((stateUsed->lifeData.actualGas.setPoint_cbar - ppO2) < 0.2) /* to high => blink red */ + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x13; + } + else /* out of range => red */ + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x01; + } +} + +static void hud_UpdateAscentSpeed(uint8_t fctId) +{ +// SDiveState * pStateReal = stateRealGetPointerWrite(); + uint8_t indicatorColor = 0; + + indicatorColor = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0; + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0; + + switch(indicatorColor) /* map color to LED operation */ + { + case CLUT_NiceGreen: stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0x01; /* green constant */ + break; + case CLUT_WarningYellow: stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x55; /* fast blink red */ + break; + case CLUT_WarningRed: stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x01; /* red constant */ + break; + } +} + +static void hud_UpdateDecoIndicator(uint8_t fctId) +{ + uint16_t nextstopLengthSeconds = 0; + uint8_t nextstopDepthMeter = 0; + const SDecoinfo * pDecoinfo = getDecoInfo(); + + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0; + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0; + + if(pDecoinfo->output_time_to_surface_seconds) + { + tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); + if(nextstopDepthMeter > 0) + { + if(fabs(stateUsed->lifeData.depth_meter - nextstopDepthMeter) < 1.5) /* close to stop */ + { + if((stateUsed->lifeData.depth_meter + 0.1) >= nextstopDepthMeter) + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0x01; /* close below deco stop => green constant */ + } + else + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x55; /* close above deco stop => red fast blink */ + } + } + else if(((stateUsed->lifeData.depth_meter +0.1) > nextstopDepthMeter)) + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2) + 1] = 0x13; /* Ascent to deco stop => green slow blink */ + } + else + { + stateUsedWrite->lifeData.HUD_led_sequence[(fctId * 2)] = 0x01; /* Missed deco stop => red constant */ + } + } + } +} + +void hud_UpdateStatus() +{ + static uint32_t updateTick = 0; + + SDiveState * pStateReal = stateRealGetPointerWrite(); + SSettings *pSettings = settingsGetPointer(); + + uint8_t index = 0; + + if(hudVersion == 0) + { + if((pStateReal->lifeData.extIf_sensor_data[hudAddress][HUD_INFO_VERSION_OFFSET] > 0) && (pStateReal->lifeData.extIf_sensor_data[hudAddress][HUD_INFO_VERSION_OFFSET] <= 1)) + { + hudVersion = pStateReal->lifeData.extIf_sensor_data[hudAddress][HUD_INFO_VERSION_OFFSET]; + switch(hudVersion) + { + case 1: + default: hudLEDPerFct[0] = 2; + hudLEDPerFct[1] = 2; + hudLEDPerFct[2] = 2; + hudLEDPerFct[3] = 1; + break; + } + } + } + else + { + if(time_elapsed_ms(updateTick, HAL_GetTick()) > 2000) + { + if(stateUsed->mode == MODE_DIVE) + { + for( index = 0; index < NUM_OF_HUD_FCT; index++) + { + switch(pSettings->hudFunction[index]) + { + case HUD_FCT_WARNING: hud_UpdateWarning(index); + break; + case HUD_FCT_PPO2SUM: hud_UpdatePPO2Monitor(index, stateUsed->lifeData.ppO2); + break; + case HUD_FCT_PPO2_0: + case HUD_FCT_PPO2_1: + case HUD_FCT_PPO2_2: hud_UpdatePPO2Monitor(index, stateUsed->lifeData.ppO2Sensor_bar[pSettings->hudFunction[index] - HUD_FCT_PPO2_0]); + break; + case HUD_FCT_ASCENT_SPEED: hud_UpdateAscentSpeed(index); + break; + case HUD_FCT_DECO: hud_UpdateDecoIndicator(index); + break; + case HUD_FCT_NONE: + default: + break; + } + } + } + else + { +#ifndef ENABLE_HUD_TESTING + memset(pStateReal->lifeData.HUD_led_sequence,0,EXT_INTERFACE_HUD_LED_MAX); + pStateReal->lifeData.HUD_led_sequence[6] = 0x01; /* switch only blue LED on */ +#endif + } + DataEX_setExtInterface_Cmd(EXT_INTERFACE_HUD_UPDATE, hudAddress); + updateTick = HAL_GetTick(); + } + } +}
--- a/Discovery/Src/settings.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/settings.c Sun Mar 15 21:40:35 2026 +0100 @@ -40,6 +40,7 @@ #include "motion.h" #include "t7.h" #include "data_central.h" +#include "hud.h" static uint8_t settingsWarning = 0; /* Active if setting values have been corrected */ static SSettingsStatus SettingsStatus; /* Structure containing number of corrections and first occurrence */ @@ -95,7 +96,7 @@ * There might even be entries with fixed values that have no range */ const SSettings SettingsStandard = { - .header = 0xFFFF002E, + .header = 0xFFFF002F, .warning_blink_dsec = 8 * 2, .lastDiveLogId = 0, .logFlashNextSampleStartAddress = SAMPLESTART, @@ -355,6 +356,12 @@ .profileName[2] = "MCCR____", .profileName[3] = "ECCR____", .activeProfile = 0, + .hudFunction[0] = HUD_FCT_NONE, + .hudFunction[1] = HUD_FCT_NONE, + .hudFunction[2] = HUD_FCT_NONE, + .hudFunction[3] = HUD_FCT_NONE, + .hudFunction[4] = HUD_FCT_NONE, + .hudFunction[5] = HUD_FCT_NONE }; /* Private function prototypes -----------------------------------------------*/ @@ -667,7 +674,13 @@ { pSettings->tX_userselectedLeftLowerCornerPrimary++; } - + // no break; + case 0xFFFF002E: pSettings->hudFunction[0] = HUD_FCT_NONE; /* todo: define default setup */ + pSettings->hudFunction[1] = HUD_FCT_NONE; + pSettings->hudFunction[2] = HUD_FCT_NONE; + pSettings->hudFunction[3] = HUD_FCT_NONE; + pSettings->hudFunction[4] = HUD_FCT_NONE; + pSettings->hudFunction[5] = HUD_FCT_NONE; // no break; default: pSettings->header = pStandard->header;
--- a/Discovery/Src/tInfoSensor.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/tInfoSensor.c Sun Mar 15 21:40:35 2026 +0100 @@ -35,6 +35,7 @@ #include "tInfoSensor.h" #include "tMenuEdit.h" #include "data_exchange_main.h" +#include "hud.h" #include <string.h> #include <inttypes.h> @@ -207,10 +208,18 @@ { const SDiveState *pStateReal = stateRealGetPointer(); char text[50]; + char infostr[HUD_INFO_INFOSTR_LENGTH + 1]; - snprintf(text,50,"%s",pStateReal->lifeData.extIf_sensor_data[activeSensorId]); - tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); + uint8_t hudAddress = hud_GetAddress(); + if(hudAddress < EXT_INTERFACE_SENSOR_CNT) + { + memcpy(infostr, (char*)&pStateReal->lifeData.extIf_sensor_data[hudAddress][HUD_INFO_INFOSTR_OFFSET], HUD_INFO_INFOSTR_LENGTH); + infostr[HUD_INFO_INFOSTR_LENGTH] = 0; + + snprintf(text,50,"%s",infostr); + tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); + } tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); }
--- a/Discovery/Src/tMenuEdit.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/tMenuEdit.c Sun Mar 15 21:40:35 2026 +0100 @@ -2301,4 +2301,8 @@ return &tMEscreen; } - +uint8_t tMenuEdit_getActualId() +{ + uint8_t ret = actualId; + return ret; +}
--- a/Discovery/Src/tMenuEditHardware.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/tMenuEditHardware.c Sun Mar 15 21:40:35 2026 +0100 @@ -42,6 +42,7 @@ #include "tComm.h" #include "data_exchange_main.h" #include "tMenuCvOptionText.h" +#include "hud.h" //extern void tM_build_pages(void); @@ -68,6 +69,11 @@ uint8_t OnAction_ButtonLock (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_LedSequence (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_LedBrightness (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +#ifdef TOBEUSEDIFMORETHAN4FUNCTIONS +uint8_t OnAction_LedNumber (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +#endif +uint8_t OnAction_LedFunction (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); + /* Exported functions --------------------------------------------------------*/ @@ -79,6 +85,10 @@ static externalInterfaceSensorType sensorFilter = SENSOR_NONE; /* used to have only a specific type of sensor in the sensor list view */ static externalInterfaceSensorType localSensorMap[3]; /* reduce the complete external sensor map to the three entries which are displayed by the menu */ +#ifdef TOBEUSEDIFMORETHAN4FUNCTIONS +static uint8_t hudFunctionIndex = 0; /* used for selection of the LED to function mapping */ +#endif + void openEdit_Hardware(uint8_t line) { set_globalState_Menu_Line(line); @@ -150,8 +160,11 @@ char strSensorValue[30]; uint16_t y_line; uint8_t index = 0; + uint8_t index2 = 0; uint8_t uartSensorCnt = 0; - +#ifndef ENABLE_HUD_TESTING + uint8_t line; +#endif const SDiveState *pStateReal = stateRealGetPointer(); SSettings *pSettings = settingsGetPointer(); @@ -188,6 +201,10 @@ case SENSOR_CO2: case SENSOR_CO2M: pSettings->co2_sensor_active = 1; break; +#ifdef ENABLE_HUD_SUPPORT + case SENSOR_HUD: hud_Init(); + break; +#endif #ifdef ENABLE_SENTINEL_MODE case SENSOR_SENTINEL: case SENSOR_SENTINELM: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL; @@ -260,6 +277,9 @@ case SENSOR_HUD: strSensorId[3] = 'H'; strSensorId[4] = 'U'; strSensorId[5] = 'D'; +#ifdef ENABLE_HUD_TESTING + strSensorId[4] = 'X'; +#endif break; default: strSensorId[5] = 0; @@ -280,14 +300,52 @@ } else if(localSensorMap[index] == SENSOR_HUD) { - write_label_var( 30, 340, ME_Y_LINE2, &FontT48, "LED Sequence:"); - tMenuEdit_newInput(StMHARD3_O2_Sensor2, pStateReal->lifeData.HUD_led_sequence[0] - pStateReal->lifeData.HUD_led_sequence[1], + snprintf(strSensorValue, 30,"LED Brightness: %d",pStateReal->lifeData.HUD_led_brightness); + write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorValue); + + for(index2 = 0; index2 < NUM_OF_HUD_FCT; index2++) + { + hud_GetString(pSettings->hudFunction[index2], (uint8_t*)strSensorId); + snprintf(strSensorValue, 30,"%c%c: %s",TXT_2BYTE, TXT2BYTE_FUNCTION, strSensorId); + write_label_var( 30, 340, ME_Y_LINE2 + (index2 * ME_Y_LINE_STEP), &FontT48, strSensorValue); + } + +#ifdef TOBEUSEDIFMORETHAN4FUNCTIONS + snprintf(strSensorValue, 30,"LED #: %d", hudFunctionIndex); + write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorValue); + + hud_GetString(pSettings->hudFunction[hudFunctionIndex], (uint8_t*)strSensorId); + snprintf(strSensorValue, 30,"LED %c%c: %s",TXT_2BYTE, TXT2BYTE_FUNCTION, strSensorId); + write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorValue); +#endif + +#ifdef ENABLE_HUD_TESTING /* overwrite first line with test field */ + + write_label_var( 30, 340, ME_Y_LINE1, &FontT48, "LED Sequence:"); +#if 0 + tMenuEdit_newInput(StMHARD3_O2_Sensor1, pStateReal->lifeData.HUD_led_sequence[0] - pStateReal->lifeData.HUD_led_sequence[1], pStateReal->lifeData.HUD_led_sequence[2] - pStateReal->lifeData.HUD_led_sequence[3], pStateReal->lifeData.HUD_led_sequence[4] - pStateReal->lifeData.HUD_led_sequence[5], pStateReal->lifeData.HUD_led_sequence[6]); - snprintf(strSensorValue, 30,"LED Brightness: %d",pStateReal->lifeData.HUD_led_brightness); - write_label_var( 30, 340, ME_Y_LINE3, &FontT48, strSensorValue); - snprintf(strSensorValue, 20,"o o o \023o"); +#endif + strSensorValue[0] = 0; + +#else + line = tMenuEdit_getActualId(); + switch(line) + { + case 3: snprintf(strSensorValue, 20,"\ao\a o o \023o"); + break; + case 2: snprintf(strSensorValue, 20,"o \ao\a o \023o"); + break; + case 1: snprintf(strSensorValue, 20,"o o \ao\a \023o"); + break; + case 4: snprintf(strSensorValue, 20,"o o o \023\ao\a"); + break; + default: snprintf(strSensorValue, 20,"o o o \023o"); + break; + } +#endif } y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); if(strSensorValue[0] != 0) @@ -334,7 +392,7 @@ { for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT; index++) { - if(pSettings->ext_sensor_map[index] != SENSOR_NONE) + if((pSettings->ext_sensor_map[index] != SENSOR_NONE) && (pSettings->ext_sensor_map[index] != SENSOR_SEARCH)) { uartSensorCnt++; } @@ -400,7 +458,9 @@ { static externalInterfaceSensorType lastFilter; SSettings *pSettings = settingsGetPointer(); +#ifdef ENABLE_HUD_TESTING const SDiveState* pRealState = stateRealGetPointer(); +#endif uint8_t sensorActive[3]; uint8_t index = 0; char text[3]; @@ -497,6 +557,11 @@ { 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 */ break; + case SENSOR_HUD: +#ifndef ENABLE_HUD_TESTING + write_field_button(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, ""); +#endif + break; default: write_field_button(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, ""); break; } @@ -578,19 +643,36 @@ case SENSOR_CO2: setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); localSensorMap[0] = SENSOR_CO2M; break; - case SENSOR_HUD: write_label_var( 30, 340, ME_Y_LINE2, &FontT48, "LED Sequence:"); - write_field_sdigit(StMHARD3_O2_Sensor2, 400, 800, ME_Y_LINE2, &FontT48, "### ### ### ###", + case SENSOR_HUD: +#ifdef ENABLE_HUD_TESTING + write_label_var( 30, 340, ME_Y_LINE1, &FontT48, "LED Sequence:"); + write_field_sdigit(StMHARD3_O2_Sensor1, 400, 800, ME_Y_LINE1, &FontT48, "### ### ### ###", pRealState->lifeData.HUD_led_sequence[0] - pRealState->lifeData.HUD_led_sequence[1], pRealState->lifeData.HUD_led_sequence[2] - pRealState->lifeData.HUD_led_sequence[3], pRealState->lifeData.HUD_led_sequence[4] - pRealState->lifeData.HUD_led_sequence[5], pRealState->lifeData.HUD_led_sequence[6]); +#endif + write_field_button(StMHARD3_O2_Sensor2, 400, 800, ME_Y_LINE2, &FontT48, ""); /* LED #0 */ + write_field_button(StMHARD3_O2_Sensor3, 400, 800, ME_Y_LINE3, &FontT48, ""); /* LED #1 */ + write_field_button(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, ""); /* LED #2 */ + write_field_button(StMHARD3_Sensor_Info, 400, 800, ME_Y_LINE5, &FontT48, ""); /* LED #3 */ + write_field_button(StMHARD3_Sensor_Detect, 400, 800, ME_Y_LINE6, &FontT48, ""); /* LED brightness */ - write_field_button(StMHARD3_O2_Sensor3, 400, 800, ME_Y_LINE3, &FontT48, ""); +#ifndef ENABLE_HUD_TESTING setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); - setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_LedSequence); - setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_LedBrightness); +#else + setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_LedSequence); +#endif +#ifdef TOBEUSEDIFMORETHAN4FUNCTIONS + setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_LedNumber); +#endif + setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_LedFunction); + setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_LedFunction); + setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_LedFunction); + setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_LedFunction); + setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_LedBrightness); localSensorMap[0] = SENSOR_HUD; break; } @@ -1143,3 +1225,41 @@ return UNSPECIFIC_RETURN; } +#ifdef TOBEUSEDIFMORETHAN4FUNCTIONS +uint8_t OnAction_LedNumber(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + hudFunctionIndex++; + if(hudFunctionIndex == NUM_OF_HUD_FCT) + { + hudFunctionIndex = 0; + } + + return UNSPECIFIC_RETURN; +} +#endif + +uint8_t OnAction_LedFunction(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + SSettings *pSettings = settingsGetPointer(); + uint8_t hudFunctionIndex = 0; + + switch (editId) + { + case StMHARD3_O2_Sensor2: hudFunctionIndex = 0; + break; + case StMHARD3_O2_Sensor3: hudFunctionIndex = 1; + break; + case StMHARD3_O2_Calibrate: hudFunctionIndex = 2; + break; + case StMHARD3_Sensor_Info: hudFunctionIndex = 3; + break; + default: + break; + } + + pSettings->hudFunction[hudFunctionIndex] = hud_NextFct(pSettings->hudFunction[hudFunctionIndex], hudFunctionIndex); + + return UNSPECIFIC_RETURN; +} + +
--- a/Discovery/Src/text_multilanguage.c Sun Mar 15 21:28:53 2026 +0100 +++ b/Discovery/Src/text_multilanguage.c Sun Mar 15 21:40:35 2026 +0100 @@ -2030,6 +2030,19 @@ static uint8_t text_IT_Logger[] = ""; static uint8_t text_ES_Logger[] = ""; +static uint8_t text_EN_Function[] = "Function"; +static uint8_t text_DE_Function[] = "Funktion"; +static uint8_t text_FR_Function[] = ""; +static uint8_t text_IT_Function[] = ""; +static uint8_t text_ES_Function[] = ""; + +static uint8_t text_EN_AscentSpeed[] = "Ascent speed"; +static uint8_t text_DE_AscentSpeed[] = "Austiegsgeschwindigkeit"; +static uint8_t text_FR_AscentSpeed[] = ""; +static uint8_t text_IT_AscentSpeed[] = ""; +static uint8_t text_ES_AscentSpeed[] = ""; + + /* Lookup Table -------------------------------------------------------------*/ const tText text_array[] = @@ -2348,6 +2361,8 @@ {(uint8_t)TXT2BYTE_Pulse, {text_EN_Pulse, text_DE_Pulse, text_FR_Pulse, text_IT_Pulse, text_ES_Pulse}}, {(uint8_t)TXT2BYTE_Logger, {text_EN_Logger, text_DE_Logger, text_FR_Logger, text_IT_Logger, text_ES_Logger}}, + {(uint8_t)TXT2BYTE_FUNCTION, {text_EN_Function, text_DE_Function, text_FR_Function, text_IT_Function, text_ES_Function}}, + {(uint8_t)TXT2BYTE_AscentSpeed, {text_EN_AscentSpeed, text_DE_AscentSpeed, text_FR_AscentSpeed, text_IT_AscentSpeed, text_ES_AscentSpeed}}, };
