Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditCvOption.c @ 1073:734f84b72b30 Icon_Integration tip
CV Option Menu added sub menus for O2 and CO2 sensors:
In the previous implementation by the external sensor menu the problem exists that only three sensor could be displayed. If three o2 sensors were active then the CO2 sensor was not accessible. With the new dynamic view the CO2 sensor is a standalone menu element. The three sensor view was reused from the external sensor menu by introducing a filter (sensor type) functionality. O" and CO2 sensors may now be calibrated using the cv option sub menus.
| author | Ideenmodellierer |
|---|---|
| date | Fri, 20 Feb 2026 17:26:46 +0100 |
| parents | b4a79464caf7 |
| children |
| rev | line source |
|---|---|
| 999 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/tMenuEditCvOption.c | |
| 5 /// \brief Menu for configuration depended items | |
| 6 /// \author heinrichs weikamp gmbh | |
| 7 /// \date 24-Apr-2025 | |
| 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 "tMenuEditCvOption.h" | |
| 1071 | 31 #include "tMenuCvOptionText.h" |
|
1073
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
32 #include "tMenuEditHardware.h" |
| 999 | 33 #include "tMenuEdit.h" |
| 34 | |
| 35 #include "gfx_fonts.h" | |
| 36 #include "ostc.h" | |
| 37 #include "tMenuEdit.h" | |
| 38 #include "tHome.h" | |
| 39 | |
| 1032 | 40 #include "cv_heartbeat.h" |
| 41 | |
| 1071 | 42 |
| 43 static openFunc_t openFctPointerTable[MAXLINES]; /* function pointer for refresh */ | |
| 44 | |
| 999 | 45 /* Private function prototypes -----------------------------------------------*/ |
| 46 static void openEdit_Timer(void); | |
| 47 void openEdit_Compass(void); | |
| 48 | |
| 49 /* Announced function prototypes -----------------------------------------------*/ | |
| 50 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 51 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 52 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 53 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 54 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 55 static uint8_t OnAction_Timer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 56 | |
| 57 /* Exported functions --------------------------------------------------------*/ | |
| 58 | |
| 1071 | 59 |
| 60 void tMCvOption_SetOpenFnct(uint8_t cvOptId, uint8_t index) | |
| 61 { | |
| 62 if(index < MAXLINES) | |
| 63 { | |
| 64 switch(cvOptId) | |
| 65 { | |
| 66 case CVOPT_Compass: openFctPointerTable[index] = openEdit_Compass; | |
| 67 break; | |
| 68 case CVOPT_Timer: openFctPointerTable[index] = openEdit_Timer; | |
| 69 break; | |
| 70 case CVOPT_END: openFctPointerTable[index] = NULL; | |
| 71 break; | |
|
1073
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
72 case CVOPT_O2_Sensor: openFctPointerTable[index] = openEdit_SensorsO2; |
|
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
73 break; |
|
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
74 case CVOPT_CO2_Sensor: openFctPointerTable[index] = openEdit_SensorsCO2; |
|
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
75 break; |
|
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
76 default: |
|
734f84b72b30
CV Option Menu added sub menus for O2 and CO2 sensors:
Ideenmodellierer
parents:
1071
diff
changeset
|
77 break; |
| 1071 | 78 } |
| 79 } | |
| 80 } | |
| 81 | |
| 82 | |
| 999 | 83 void openEdit_CvOption(uint8_t line) |
| 84 { | |
| 1071 | 85 if(openFctPointerTable[line - 1] != NULL) |
| 999 | 86 { |
| 1071 | 87 openFctPointerTable[line - 1](); |
| 999 | 88 } |
| 89 } | |
| 90 | |
| 91 /* Private functions ---------------------------------------------------------*/ | |
| 92 | |
| 93 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 94 { | |
| 95 SSettings *settings = settingsGetPointer(); | |
| 96 uint8_t digitContentNew; | |
| 97 switch (action) { | |
| 98 case ACTION_BUTTON_ENTER: | |
| 99 | |
| 100 return digitContent; | |
| 101 case ACTION_BUTTON_ENTER_FINAL: | |
| 102 { | |
| 103 int32_t compassDeclinationDeg; | |
| 104 evaluateNewString(editId, (uint32_t *)&compassDeclinationDeg, NULL, NULL, NULL); | |
| 105 | |
| 106 if (compassDeclinationDeg > 99) { | |
| 107 compassDeclinationDeg = 99; | |
| 108 } else if (compassDeclinationDeg < -99) { | |
| 109 compassDeclinationDeg = -99; | |
| 110 } | |
| 111 | |
| 112 settings->compassDeclinationDeg = compassDeclinationDeg; | |
| 113 | |
| 114 tMenuEdit_newInput(editId, ((input_u)compassDeclinationDeg).uint32, 0, 0, 0); | |
| 115 } | |
| 116 | |
| 117 break; | |
| 118 case ACTION_BUTTON_NEXT: | |
| 119 if (digitNumber == 0) { | |
| 120 digitContentNew = togglePlusMinus(digitContent); | |
| 121 } else { | |
| 122 digitContentNew = digitContent + 1; | |
| 123 if (digitContentNew > '9') { | |
| 124 digitContentNew = '0'; | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 return digitContentNew; | |
| 129 case ACTION_BUTTON_BACK: | |
| 130 if (digitNumber == 0) { | |
| 131 digitContentNew = togglePlusMinus(digitContent); | |
| 132 } else { | |
| 133 digitContentNew = digitContent - 1; | |
| 134 if (digitContentNew < '0') { | |
| 135 digitContentNew = '9'; | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 return digitContentNew; | |
| 140 } | |
| 141 | |
| 142 return UNSPECIFIC_RETURN; | |
| 143 } | |
| 144 | |
| 145 | |
| 146 static void showCompassDeclination(SSettings *settings, bool isRefresh) | |
| 147 { | |
| 148 char text[16]; | |
| 149 snprintf(text, 16, "%c%c:", TXT_2BYTE, TXT2BYTE_CompassDeclination); | |
| 150 write_label_var(30, 800, ME_Y_LINE6, &FontT48, text); | |
| 151 if (isRefresh) { | |
| 152 tMenuEdit_refresh_field(StMOption_Compass_Declination); | |
| 153 } else { | |
| 154 write_field_sdigit(StMOption_Compass_Declination, 500, 800, ME_Y_LINE6, &FontT48, "\034###`", settings->compassDeclinationDeg, 0, 0, 0); | |
| 155 } | |
| 156 } | |
| 157 | |
| 158 | |
| 159 void refresh_CompassEdit(void) | |
| 160 { | |
| 161 SSettings *settings = settingsGetPointer(); | |
| 162 | |
| 163 uint16_t heading; | |
| 164 char text[32]; | |
| 165 uint8_t textIndex = 0; | |
| 166 | |
| 167 text[0] = '\001'; | |
| 168 text[1] = TXT_2BYTE; | |
| 169 text[2] = TXT2BYTE_Compass; | |
| 170 text[3] = 0; | |
| 171 write_topline(text); | |
| 172 | |
| 173 if(settings->compassInertia) | |
| 174 { | |
| 175 heading = (uint16_t)compass_getCompensated(); | |
| 176 } | |
| 177 else | |
| 178 { | |
| 179 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
| 180 } | |
| 181 snprintf(text,32,"\001%03i`",heading); | |
| 182 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
| 183 | |
| 184 tMenuEdit_refresh_field(StMOption_Compass_SetCourse); | |
| 185 tMenuEdit_refresh_field(StMOption_Compass_Calibrate); | |
| 186 tMenuEdit_refresh_field(StMOption_Compass_ResetCourse); | |
| 187 text[textIndex++] = TXT_2BYTE; | |
| 188 text[textIndex++] = TXT2BYTE_CompassInertia; | |
| 189 text[textIndex++] = ':'; | |
| 190 text[textIndex++] = ' '; | |
| 191 text[textIndex++] = '0' + settings->compassInertia; | |
| 192 | |
| 193 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text); | |
| 194 | |
| 195 showCompassDeclination(settings, true); | |
| 196 | |
| 197 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 198 } | |
| 199 | |
| 200 | |
| 201 void openEdit_Compass(void) | |
| 202 { | |
| 203 SSettings *settings = settingsGetPointer(); | |
| 204 | |
| 205 char text[10]; | |
| 206 uint8_t textIndex = 0; | |
| 207 | |
| 208 | |
| 209 set_globalState(StMOption_Compass); | |
| 210 resetMenuEdit(CLUT_MenuPageHardware); | |
| 211 | |
| 212 text[textIndex++] = '\001'; | |
| 213 text[textIndex++] = TXT_2BYTE; | |
| 214 text[textIndex++] = TXT2BYTE_Compass; | |
| 215 text[textIndex++] = 0; | |
| 216 write_topline(text); | |
| 217 | |
| 218 text[0] = TXT_2BYTE; | |
| 219 text[2] = 0; | |
| 220 | |
| 221 text[1] = TXT2BYTE_SetBearing; | |
| 222 write_field_button(StMOption_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
| 223 | |
| 224 text[1] = TXT2BYTE_ResetBearing; | |
| 225 write_field_button(StMOption_Compass_ResetCourse, 30, 800, ME_Y_LINE3, &FontT48, text); | |
| 226 | |
| 227 text[1] = TXT2BYTE_CompassCalib; | |
| 228 write_field_button(StMOption_Compass_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, text); | |
| 229 | |
| 230 text[1] = TXT2BYTE_CompassInertia; | |
| 231 textIndex = 2; | |
| 232 text[textIndex++] = ':'; | |
| 233 text[textIndex++] = ' '; | |
| 234 text[textIndex++] = '0' + settings->compassInertia; | |
| 235 text[textIndex++] = 0; | |
| 236 | |
| 237 write_field_button(StMOption_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text); | |
| 238 | |
| 239 showCompassDeclination(settings, false); | |
| 240 | |
| 241 setEvent(StMOption_Compass_SetCourse, (uint32_t)OnAction_Bearing); | |
| 242 setEvent(StMOption_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
| 243 setEvent(StMOption_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
| 244 setEvent(StMOption_Compass_Inertia, (uint32_t)OnAction_InertiaLevel); | |
| 245 setEvent(StMOption_Compass_Declination, (uint32_t)OnAction_CompassDeclination); | |
| 246 | |
| 247 tMenuEdit_select(StMOption_Compass_SetCourse); | |
| 248 | |
| 249 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 250 } | |
| 251 | |
| 252 | |
| 253 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 254 { | |
| 255 calibrateCompass(); | |
| 256 return EXIT_TO_INFO_COMPASS; | |
| 257 } | |
| 258 | |
| 259 | |
| 260 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 261 { | |
| 262 if((int16_t)stateUsed->lifeData.compass_heading != -1) | |
| 263 { | |
| 264 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
| 265 } | |
| 266 else | |
| 267 { | |
| 268 settingsGetPointer()->compassBearing = 0; | |
| 269 } | |
| 270 | |
| 271 if(settingsGetPointer()->compassBearing == 0) | |
| 272 settingsGetPointer()->compassBearing = 360; | |
| 273 return UPDATE_AND_EXIT_TO_MENU; | |
| 274 } | |
| 275 | |
| 276 | |
| 277 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 278 { | |
| 279 settingsGetPointer()->compassBearing = 0; | |
| 280 return UPDATE_AND_EXIT_TO_MENU; | |
| 281 } | |
| 282 | |
| 283 | |
| 284 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 285 { | |
| 286 uint8_t newLevel = 0; | |
| 287 | |
| 288 newLevel = settingsGetPointer()->compassInertia + 1; | |
| 289 if(newLevel > MAX_COMPASS_COMP) | |
| 290 { | |
| 291 newLevel = 0; | |
| 292 } | |
| 293 settingsGetPointer()->compassInertia = newLevel; | |
| 294 return UPDATE_DIVESETTINGS; | |
| 295 } | |
| 296 | |
| 297 static void openEdit_Timer(void) | |
| 298 { | |
| 299 SSettings *settings = settingsGetPointer(); | |
| 300 | |
| 301 char text[32]; | |
| 302 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
| 303 write_topline(text); | |
| 304 | |
|
1001
21142f4fa968
Cleanup menu structucture afer menu shift:
Ideenmodellierer
parents:
999
diff
changeset
|
305 set_globalState(StMOption_Timer); |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
306 resetMenuEdit(CLUT_MenuPageCvOption); |
|
1001
21142f4fa968
Cleanup menu structucture afer menu shift:
Ideenmodellierer
parents:
999
diff
changeset
|
307 |
| 999 | 308 uint16_t yPos = ME_Y_LINE_BASE + get_globalState_Menu_Line() * ME_Y_LINE_STEP; |
| 309 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
| 310 write_label_var(30, 299, yPos, &FontT48, text); | |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
311 write_field_udigit(StMOption_Timer_Value, 300, 392, yPos, &FontT48, "#:##", settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); |
| 999 | 312 write_label_var(393, 800, yPos, &FontT48, "\016\016 [m:ss]\017"); |
| 313 | |
| 314 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); | |
| 315 | |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
316 setEvent(StMOption_Timer_Value, (uint32_t)OnAction_Timer); |
| 999 | 317 startEdit(); |
| 318 } | |
| 319 static uint8_t OnAction_Timer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 320 { | |
| 321 SSettings *settings = settingsGetPointer(); | |
| 322 uint8_t digitContentNew; | |
| 323 switch (action) { | |
| 324 case ACTION_BUTTON_ENTER: | |
| 325 | |
| 326 return digitContent; | |
| 327 case ACTION_BUTTON_ENTER_FINAL: | |
| 328 { | |
| 329 uint32_t timerM; | |
| 330 uint32_t timerS; | |
| 331 evaluateNewString(editId, &timerM, &timerS, 0, 0); | |
| 332 if (timerM > 9) { | |
| 333 timerM = 9; | |
| 334 } | |
| 335 if (timerS > 59) { | |
| 336 timerS = 59; | |
| 337 } | |
| 338 | |
| 339 uint16_t timerDurationS = 60 * timerM + timerS; | |
| 340 | |
| 341 if (timerDurationS < 1) { | |
| 342 timerDurationS = 1; | |
| 343 } | |
| 344 | |
| 345 if (timerDurationS != settings->timerDurationS) { | |
| 346 settings->timerDurationS = timerDurationS; | |
| 347 | |
| 348 disableTimer(); | |
| 349 | |
| 350 tMenuEdit_newInput(editId, settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); | |
| 351 } | |
| 352 | |
|
1014
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
1005
diff
changeset
|
353 settings->cv_configuration |= (1 << CVIEW_Timer); |
|
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
1005
diff
changeset
|
354 |
| 999 | 355 return EXIT_TO_MENU; |
| 356 } | |
| 357 case ACTION_BUTTON_NEXT: | |
| 358 digitContentNew = digitContent + 1; | |
| 359 if ((blockNumber == 1 && digitNumber == 0 && digitContentNew > '5') || digitContentNew > '9') { | |
| 360 digitContentNew = '0'; | |
| 361 } | |
| 362 | |
| 363 return digitContentNew; | |
| 364 case ACTION_BUTTON_BACK: | |
| 365 digitContentNew = digitContent - 1; | |
| 366 if (digitContentNew < '0') { | |
| 367 if (blockNumber == 1 && digitNumber == 0) { | |
| 368 digitContentNew = '5'; | |
| 369 } else { | |
| 370 digitContentNew = '9'; | |
| 371 } | |
| 372 } | |
| 373 | |
| 374 return digitContentNew; | |
| 375 } | |
| 376 | |
| 377 return EXIT_TO_MENU; | |
| 378 } | |
| 379 | |
| 380 |
