Mercurial > public > ostc4
annotate Discovery/Src/tMenuCvOptionText.c @ 1078:082825daccb5 Icon_Integration tip
Added control views for HUD:
The HUD implementation may now be activated by the compile switch ENABLE_HUD_SUPPORT. The HUD will become visible onces detected in the CvOpt overview menu. The first implementation is for testing only => The LEDs may be operated by a number field. Positiv values activate the red, negativ the green LEDs. Depending on the value blink sequences will be scheduled.
At the moment no dive specific data is mapped to the LED operation (like e.g. warnings).
| author | Ideenmodellierer |
|---|---|
| date | Mon, 02 Mar 2026 17:30:38 +0100 |
| parents | c87753e73eb8 |
| children |
| rev | line source |
|---|---|
| 1071 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/tMenuCvOptionText.c | |
| 5 /// \brief File providing functions for generation of text lines | |
| 6 /// \author heinrichs weikamp gmbh | |
| 7 /// \date 03-Feb-2026 | |
| 8 /// | |
| 9 /// \details | |
| 10 /// | |
| 11 /// $Id$ | |
| 12 /////////////////////////////////////////////////////////////////////////////// | |
| 13 /// \par Copyright (c) 2014-2025 Heinrichs Weikamp gmbh | |
| 14 /// | |
| 15 /// This program is free software: you can redistribute it and/or modify | |
| 16 /// it under the terms of the GNU General Public License as published by | |
| 17 /// the Free Software Foundation, either version 3 of the License, or | |
| 18 /// (at your option) any later version. | |
| 19 /// | |
| 20 /// This program is distributed in the hope that it will be useful, | |
| 21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 23 /// GNU General Public License for more details. | |
| 24 /// | |
| 25 /// You should have received a copy of the GNU General Public License | |
| 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 27 ////////////////////////////////////////////////////////////////////////////// | |
| 28 | |
| 29 /* Includes ------------------------------------------------------------------*/ | |
| 30 #include "tMenuCvOptionText.h" | |
| 31 #include "tMenuEditCvOption.h" | |
| 32 #include "tMenu.h" | |
| 33 #include "tHome.h" // for enum CUSTOMVIEWS and init_t7_compass() | |
| 34 #include "t3.h" | |
| 35 #include "t7.h" | |
| 36 | |
| 37 /* Private function prototypes -----------------------------------------------*/ | |
| 38 | |
| 39 /* Exported functions --------------------------------------------------------*/ | |
| 40 | |
| 41 | |
| 42 static refreshFunc_t refreshFctPointerTable[MAXLINES]; /* function pointer for refresh */ | |
| 43 static uint8_t activeLines = 0; /* number of active lines */ | |
| 44 | |
| 45 refreshFunc_t* tMCvOptText_GetTable() | |
| 46 { | |
| 47 return refreshFctPointerTable; | |
| 48 } | |
| 49 uint8_t tMCvOptText_GetTableItemCnt() | |
| 50 { | |
| 51 return activeLines; | |
| 52 } | |
| 53 | |
| 54 uint8_t tMCvOptText_refreshCompass(char* pText) | |
| 55 { | |
| 56 uint8_t textPointer = 0; | |
| 57 pText[textPointer++] = TXT_2BYTE; | |
| 58 pText[textPointer++] = TXT2BYTE_Compass; | |
| 59 pText[textPointer++] = '\t'; | |
| 60 | |
| 61 if(settingsGetPointer()->compassBearing != 0) | |
| 62 { | |
| 63 textPointer += snprintf(&pText[textPointer], 20, "(%03u`)", settingsGetPointer()->compassBearing % 360); | |
| 64 } | |
| 65 pText[textPointer] = 0; | |
| 66 return strlen(pText); | |
| 67 } | |
| 68 | |
| 69 uint8_t tMCvOptText_refreshTimer(char* pText) | |
| 70 { | |
| 71 SSettings *settings = settingsGetPointer(); | |
| 72 snprintf(pText, 21, "%c%c\t%u:%02u \016\016[m:ss]\017", TXT_2BYTE, TXT2BYTE_Timer, settings->timerDurationS / 60, settings->timerDurationS % 60); | |
| 73 return strlen(pText); | |
| 74 } | |
| 75 | |
| 76 uint8_t tMCvOptText_refreshO2(char* pText) | |
| 77 { | |
| 78 char sensorStatusColor[3]; | |
| 79 uint8_t textPointer = 0; | |
| 80 SSettings *pSettings = settingsGetPointer(); | |
| 81 | |
| 82 | |
| 83 pText[textPointer++] = TXT_2BYTE; | |
| 84 pText[textPointer++] = TXT2BYTE_Sensor; | |
| 85 | |
| 86 textPointer += snprintf(&pText[textPointer],20,"O2 %c%c",TXT_2BYTE,TXT2BYTE_Sensor); | |
| 87 | |
| 88 if((stateUsed->lifeData.ppO2Sensor_bar[0] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[1] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[2] != 0)) | |
| 89 { | |
| 90 pText[textPointer++] = '\t'; | |
| 91 sensorStatusColor[0] = '\020'; | |
| 92 sensorStatusColor[1] = '\020'; | |
| 93 sensorStatusColor[2] = '\020'; | |
| 94 | |
| 95 /* Warning */ | |
| 96 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[0] = '\024'; | |
| 97 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[1] = '\024'; | |
| 98 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[2] = '\024'; | |
| 99 /* Grey out */ | |
| 100 if(stateUsed->diveSettings.ppo2sensors_deactivated & 1) sensorStatusColor[0] = '\031'; | |
| 101 if(stateUsed->diveSettings.ppo2sensors_deactivated & 2) sensorStatusColor[1] = '\031'; | |
| 102 if(stateUsed->diveSettings.ppo2sensors_deactivated & 4) sensorStatusColor[2] = '\031'; | |
| 103 | |
| 104 if((pSettings->ext_sensor_map[0] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[0] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[0] == SENSOR_SENTINELM)) | |
| 105 { | |
| 1076 | 106 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f \020\033",sensorStatusColor[0], stateUsed->lifeData.ppO2Sensor_bar[0]); |
| 1071 | 107 } |
| 108 if((pSettings->ext_sensor_map[1] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[1] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[1] == SENSOR_SENTINELM)) | |
| 109 { | |
| 1076 | 110 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f \020\033",sensorStatusColor[1], stateUsed->lifeData.ppO2Sensor_bar[1]); |
| 1071 | 111 } |
| 112 if((pSettings->ext_sensor_map[2] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[2] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[2] == SENSOR_SENTINELM)) | |
| 113 { | |
| 114 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f",sensorStatusColor[2], stateUsed->lifeData.ppO2Sensor_bar[2]); | |
| 115 } | |
| 116 } | |
| 117 pText[textPointer++] = '\020'; | |
| 118 pText[textPointer] = 0; | |
| 119 return strlen(pText); | |
| 120 } | |
| 121 | |
| 122 uint8_t tMCvOptText_refreshCO2(char* pText) | |
| 123 { | |
| 124 char sensorStatusColor; | |
| 125 uint8_t textPointer = 0; | |
| 126 SSettings *pSettings = settingsGetPointer(); | |
| 127 | |
| 128 | |
| 129 pText[textPointer++] = TXT_2BYTE; | |
| 130 pText[textPointer++] = TXT2BYTE_Sensor; | |
| 131 | |
| 132 textPointer += snprintf(&pText[textPointer],20,"CO2 %c%c",TXT_2BYTE,TXT2BYTE_Sensor); | |
| 133 | |
| 134 | |
| 135 pText[textPointer++] = '\t'; | |
| 136 sensorStatusColor = '\020'; | |
| 137 | |
| 138 /* Warning */ | |
| 139 if(stateUsed->warnings.co2High) sensorStatusColor = '\024'; | |
| 140 /* Grey out */ | |
| 141 if(pSettings->co2_sensor_active == 0) sensorStatusColor = '\031'; | |
| 142 | |
| 1076 | 143 textPointer += snprintf(&pText[textPointer],20,"%c%ld \020\033",sensorStatusColor, stateUsed->lifeData.CO2_data.CO2_ppm); |
| 1071 | 144 |
| 145 pText[textPointer++] = '\020'; | |
| 146 pText[textPointer] = 0; | |
| 147 return strlen(pText); | |
| 148 } | |
| 149 | |
| 1078 | 150 uint8_t tMCvOptText_refreshHUD(char* pText) |
| 151 { | |
| 152 uint8_t textPointer = 0; | |
| 153 textPointer += snprintf(&pText[textPointer],20,"HUD"); | |
| 154 pText[textPointer] = 0; | |
| 155 return strlen(pText); | |
| 156 } | |
| 1071 | 157 |
| 158 uint8_t tMCvOptText_BuildDynamicContentList() | |
| 159 { | |
| 160 uint8_t cvOptIndex = 0; | |
| 161 uint8_t CvOptAvailable = 0; | |
| 162 uint8_t index = 0; | |
| 163 uint8_t SensorActive[SENSOR_END]; | |
| 164 SSettings *settings = settingsGetPointer(); | |
| 165 | |
| 166 memset(SensorActive, 0, sizeof(SensorActive)); | |
|
1073
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
167 activeLines = 0; |
| 1071 | 168 |
| 169 for (index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++) | |
| 170 { | |
| 171 switch(settings->ext_sensor_map[index]) | |
| 172 { | |
| 173 case SENSOR_ANALOG: SensorActive[SENSOR_ANALOG] = 1; | |
| 174 break; | |
| 175 case SENSOR_SENTINEL: | |
| 176 case SENSOR_DIGO2M: SensorActive[SENSOR_DIGO2] = 1; | |
| 177 break; | |
| 178 case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; | |
| 179 break; | |
| 180 #if defined ENABLE_GNSS_INTERNAL || defined ENABLE_GNSS_EXTERN | |
| 181 case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1; | |
| 182 break; | |
| 183 #endif | |
| 1078 | 184 #ifdef ENABLE_HUD_SUPPORT |
| 185 case SENSOR_HUD: SensorActive[SENSOR_HUD] = 1; | |
| 186 break; | |
| 187 #endif | |
| 1071 | 188 default: |
| 189 break; | |
| 190 } | |
| 191 } | |
| 192 | |
| 193 do | |
| 194 { | |
| 195 CvOptAvailable = 0; | |
| 196 switch(cvOptIndex) | |
| 197 { | |
| 198 case CVOPT_Compass: if((!t3_customview_disabled(CVIEW_T3_Compass)) || (!t3_customview_disabled(CVIEW_T3_Navigation)) || (!t7_customview_disabled(CVIEW_Compass))) | |
| 199 { | |
| 200 refreshFctPointerTable[activeLines] = tMCvOptText_refreshCompass; | |
| 201 CvOptAvailable = 1; | |
| 202 } | |
| 203 break; | |
| 204 case CVOPT_Timer: if(!t7_customview_disabled(CVIEW_Timer)) | |
| 205 { | |
| 206 refreshFctPointerTable[activeLines] = tMCvOptText_refreshTimer; | |
| 207 CvOptAvailable = 1; | |
| 208 } | |
| 209 break; | |
| 210 case CVOPT_O2_Sensor: if((SensorActive[SENSOR_ANALOG]) || (SensorActive[SENSOR_DIGO2])) | |
| 211 { | |
| 212 refreshFctPointerTable[activeLines] = tMCvOptText_refreshO2; | |
| 213 CvOptAvailable = 1; | |
| 214 } | |
| 215 break; | |
| 216 case CVOPT_CO2_Sensor: if(SensorActive[SENSOR_CO2]) | |
| 217 { | |
| 218 refreshFctPointerTable[activeLines] = tMCvOptText_refreshCO2; | |
| 219 CvOptAvailable = 1; | |
| 220 } | |
| 1078 | 221 break; |
| 222 case CVOPT_HUD: if(SensorActive[SENSOR_HUD]) | |
| 223 { | |
| 224 refreshFctPointerTable[activeLines] = tMCvOptText_refreshHUD; | |
| 225 CvOptAvailable = 1; | |
| 226 } | |
| 227 break; | |
| 1071 | 228 default: |
| 229 break; | |
| 230 } | |
| 231 if(CvOptAvailable) | |
| 232 { | |
| 233 tMCvOption_SetOpenFnct(cvOptIndex,activeLines); | |
| 234 activeLines++; | |
| 235 } | |
| 236 cvOptIndex++; | |
| 237 } while((activeLines < MAXLINES) && (cvOptIndex != CVOPT_END)); | |
| 238 | |
| 239 for(index = activeLines; index < MAXLINES; index++) /* delete pointers not in use */ | |
| 240 { | |
| 241 tMCvOption_SetOpenFnct(CVOPT_END, index); | |
| 242 } | |
| 243 return activeLines; | |
| 244 } | |
| 245 | |
| 246 | |
| 247 /* Private functions ---------------------------------------------------------*/ |
