Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditCvOption.c @ 1033:5f66e44d69f0 Puls_Integration
Added functionality needed for subscription of standard Bluetooth pulse service notifications
| author | Ideenmodellierer |
|---|---|
| date | Sat, 02 Aug 2025 22:42:51 +0200 |
| parents | 33b91584d827 |
| children | 195bfbdf961d |
| 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" | |
| 31 #include "tMenuEdit.h" | |
| 32 | |
| 33 #include "gfx_fonts.h" | |
| 34 #include "ostc.h" | |
| 35 #include "tMenuEdit.h" | |
| 36 #include "tHome.h" | |
| 37 | |
| 1032 | 38 #include "cv_heartbeat.h" |
| 39 | |
| 999 | 40 /* Private function prototypes -----------------------------------------------*/ |
| 41 static void openEdit_Timer(void); | |
| 42 void openEdit_Compass(void); | |
| 43 | |
| 44 /* Announced function prototypes -----------------------------------------------*/ | |
| 45 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 46 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 47 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 48 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 49 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 50 static uint8_t OnAction_Timer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 51 | |
| 52 /* Exported functions --------------------------------------------------------*/ | |
| 53 | |
| 54 void openEdit_CvOption(uint8_t line) | |
| 55 { | |
| 56 set_globalState_Menu_Line(line); | |
| 57 | |
| 58 switch(line) | |
| 59 { | |
| 60 case 1: | |
| 1032 | 61 default: resetMenuEdit(CLUT_MenuPageHardware); |
| 62 openEdit_Compass(); | |
| 63 break; | |
| 64 case 2: openEdit_Timer(); | |
| 65 break; | |
| 66 case 3: openEdit_Heartbeat(); | |
| 67 break; | |
| 999 | 68 } |
| 69 } | |
| 70 | |
| 71 /* Private functions ---------------------------------------------------------*/ | |
| 72 | |
| 73 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 74 { | |
| 75 SSettings *settings = settingsGetPointer(); | |
| 76 uint8_t digitContentNew; | |
| 77 switch (action) { | |
| 78 case ACTION_BUTTON_ENTER: | |
| 79 | |
| 80 return digitContent; | |
| 81 case ACTION_BUTTON_ENTER_FINAL: | |
| 82 { | |
| 83 int32_t compassDeclinationDeg; | |
| 84 evaluateNewString(editId, (uint32_t *)&compassDeclinationDeg, NULL, NULL, NULL); | |
| 85 | |
| 86 if (compassDeclinationDeg > 99) { | |
| 87 compassDeclinationDeg = 99; | |
| 88 } else if (compassDeclinationDeg < -99) { | |
| 89 compassDeclinationDeg = -99; | |
| 90 } | |
| 91 | |
| 92 settings->compassDeclinationDeg = compassDeclinationDeg; | |
| 93 | |
| 94 tMenuEdit_newInput(editId, ((input_u)compassDeclinationDeg).uint32, 0, 0, 0); | |
| 95 } | |
| 96 | |
| 97 break; | |
| 98 case ACTION_BUTTON_NEXT: | |
| 99 if (digitNumber == 0) { | |
| 100 digitContentNew = togglePlusMinus(digitContent); | |
| 101 } else { | |
| 102 digitContentNew = digitContent + 1; | |
| 103 if (digitContentNew > '9') { | |
| 104 digitContentNew = '0'; | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 return digitContentNew; | |
| 109 case ACTION_BUTTON_BACK: | |
| 110 if (digitNumber == 0) { | |
| 111 digitContentNew = togglePlusMinus(digitContent); | |
| 112 } else { | |
| 113 digitContentNew = digitContent - 1; | |
| 114 if (digitContentNew < '0') { | |
| 115 digitContentNew = '9'; | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 return digitContentNew; | |
| 120 } | |
| 121 | |
| 122 return UNSPECIFIC_RETURN; | |
| 123 } | |
| 124 | |
| 125 | |
| 126 static void showCompassDeclination(SSettings *settings, bool isRefresh) | |
| 127 { | |
| 128 char text[16]; | |
| 129 snprintf(text, 16, "%c%c:", TXT_2BYTE, TXT2BYTE_CompassDeclination); | |
| 130 write_label_var(30, 800, ME_Y_LINE6, &FontT48, text); | |
| 131 if (isRefresh) { | |
| 132 tMenuEdit_refresh_field(StMOption_Compass_Declination); | |
| 133 } else { | |
| 134 write_field_sdigit(StMOption_Compass_Declination, 500, 800, ME_Y_LINE6, &FontT48, "\034###`", settings->compassDeclinationDeg, 0, 0, 0); | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 | |
| 139 void refresh_CompassEdit(void) | |
| 140 { | |
| 141 SSettings *settings = settingsGetPointer(); | |
| 142 | |
| 143 uint16_t heading; | |
| 144 char text[32]; | |
| 145 uint8_t textIndex = 0; | |
| 146 | |
| 147 text[0] = '\001'; | |
| 148 text[1] = TXT_2BYTE; | |
| 149 text[2] = TXT2BYTE_Compass; | |
| 150 text[3] = 0; | |
| 151 write_topline(text); | |
| 152 | |
| 153 if(settings->compassInertia) | |
| 154 { | |
| 155 heading = (uint16_t)compass_getCompensated(); | |
| 156 } | |
| 157 else | |
| 158 { | |
| 159 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
| 160 } | |
| 161 snprintf(text,32,"\001%03i`",heading); | |
| 162 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
| 163 | |
| 164 tMenuEdit_refresh_field(StMOption_Compass_SetCourse); | |
| 165 tMenuEdit_refresh_field(StMOption_Compass_Calibrate); | |
| 166 tMenuEdit_refresh_field(StMOption_Compass_ResetCourse); | |
| 167 text[textIndex++] = TXT_2BYTE; | |
| 168 text[textIndex++] = TXT2BYTE_CompassInertia; | |
| 169 text[textIndex++] = ':'; | |
| 170 text[textIndex++] = ' '; | |
| 171 text[textIndex++] = '0' + settings->compassInertia; | |
| 172 | |
| 173 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text); | |
| 174 | |
| 175 showCompassDeclination(settings, true); | |
| 176 | |
| 177 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 178 } | |
| 179 | |
| 180 | |
| 181 void openEdit_Compass(void) | |
| 182 { | |
| 183 SSettings *settings = settingsGetPointer(); | |
| 184 | |
| 185 char text[10]; | |
| 186 uint8_t textIndex = 0; | |
| 187 | |
| 188 | |
| 189 set_globalState(StMOption_Compass); | |
| 190 resetMenuEdit(CLUT_MenuPageHardware); | |
| 191 | |
| 192 text[textIndex++] = '\001'; | |
| 193 text[textIndex++] = TXT_2BYTE; | |
| 194 text[textIndex++] = TXT2BYTE_Compass; | |
| 195 text[textIndex++] = 0; | |
| 196 write_topline(text); | |
| 197 | |
| 198 text[0] = TXT_2BYTE; | |
| 199 text[2] = 0; | |
| 200 | |
| 201 text[1] = TXT2BYTE_SetBearing; | |
| 202 write_field_button(StMOption_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
| 203 | |
| 204 text[1] = TXT2BYTE_ResetBearing; | |
| 205 write_field_button(StMOption_Compass_ResetCourse, 30, 800, ME_Y_LINE3, &FontT48, text); | |
| 206 | |
| 207 text[1] = TXT2BYTE_CompassCalib; | |
| 208 write_field_button(StMOption_Compass_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, text); | |
| 209 | |
| 210 text[1] = TXT2BYTE_CompassInertia; | |
| 211 textIndex = 2; | |
| 212 text[textIndex++] = ':'; | |
| 213 text[textIndex++] = ' '; | |
| 214 text[textIndex++] = '0' + settings->compassInertia; | |
| 215 text[textIndex++] = 0; | |
| 216 | |
| 217 write_field_button(StMOption_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text); | |
| 218 | |
| 219 showCompassDeclination(settings, false); | |
| 220 | |
| 221 setEvent(StMOption_Compass_SetCourse, (uint32_t)OnAction_Bearing); | |
| 222 setEvent(StMOption_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
| 223 setEvent(StMOption_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
| 224 setEvent(StMOption_Compass_Inertia, (uint32_t)OnAction_InertiaLevel); | |
| 225 setEvent(StMOption_Compass_Declination, (uint32_t)OnAction_CompassDeclination); | |
| 226 | |
| 227 tMenuEdit_select(StMOption_Compass_SetCourse); | |
| 228 | |
| 229 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 230 } | |
| 231 | |
| 232 | |
| 233 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 234 { | |
| 235 calibrateCompass(); | |
| 236 return EXIT_TO_INFO_COMPASS; | |
| 237 } | |
| 238 | |
| 239 | |
| 240 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 241 { | |
| 242 if((int16_t)stateUsed->lifeData.compass_heading != -1) | |
| 243 { | |
| 244 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
| 245 } | |
| 246 else | |
| 247 { | |
| 248 settingsGetPointer()->compassBearing = 0; | |
| 249 } | |
| 250 | |
| 251 if(settingsGetPointer()->compassBearing == 0) | |
| 252 settingsGetPointer()->compassBearing = 360; | |
| 253 return UPDATE_AND_EXIT_TO_MENU; | |
| 254 } | |
| 255 | |
| 256 | |
| 257 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 258 { | |
| 259 settingsGetPointer()->compassBearing = 0; | |
| 260 return UPDATE_AND_EXIT_TO_MENU; | |
| 261 } | |
| 262 | |
| 263 | |
| 264 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 265 { | |
| 266 uint8_t newLevel = 0; | |
| 267 | |
| 268 newLevel = settingsGetPointer()->compassInertia + 1; | |
| 269 if(newLevel > MAX_COMPASS_COMP) | |
| 270 { | |
| 271 newLevel = 0; | |
| 272 } | |
| 273 settingsGetPointer()->compassInertia = newLevel; | |
| 274 return UPDATE_DIVESETTINGS; | |
| 275 } | |
| 276 | |
| 277 static void openEdit_Timer(void) | |
| 278 { | |
| 279 SSettings *settings = settingsGetPointer(); | |
| 280 | |
| 281 char text[32]; | |
| 282 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
| 283 write_topline(text); | |
| 284 | |
|
1001
21142f4fa968
Cleanup menu structucture afer menu shift:
Ideenmodellierer
parents:
999
diff
changeset
|
285 set_globalState(StMOption_Timer); |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
286 resetMenuEdit(CLUT_MenuPageCvOption); |
|
1001
21142f4fa968
Cleanup menu structucture afer menu shift:
Ideenmodellierer
parents:
999
diff
changeset
|
287 |
| 999 | 288 uint16_t yPos = ME_Y_LINE_BASE + get_globalState_Menu_Line() * ME_Y_LINE_STEP; |
| 289 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
| 290 write_label_var(30, 299, yPos, &FontT48, text); | |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
291 write_field_udigit(StMOption_Timer_Value, 300, 392, yPos, &FontT48, "#:##", settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); |
| 999 | 292 write_label_var(393, 800, yPos, &FontT48, "\016\016 [m:ss]\017"); |
| 293 | |
| 294 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); | |
| 295 | |
|
1005
85f7e19c6688
Switch menu position of Buzzer and flipdisplay option:
Ideenmodellierer
parents:
1001
diff
changeset
|
296 setEvent(StMOption_Timer_Value, (uint32_t)OnAction_Timer); |
| 999 | 297 startEdit(); |
| 298 } | |
| 299 static uint8_t OnAction_Timer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 300 { | |
| 301 SSettings *settings = settingsGetPointer(); | |
| 302 uint8_t digitContentNew; | |
| 303 switch (action) { | |
| 304 case ACTION_BUTTON_ENTER: | |
| 305 | |
| 306 return digitContent; | |
| 307 case ACTION_BUTTON_ENTER_FINAL: | |
| 308 { | |
| 309 uint32_t timerM; | |
| 310 uint32_t timerS; | |
| 311 evaluateNewString(editId, &timerM, &timerS, 0, 0); | |
| 312 if (timerM > 9) { | |
| 313 timerM = 9; | |
| 314 } | |
| 315 if (timerS > 59) { | |
| 316 timerS = 59; | |
| 317 } | |
| 318 | |
| 319 uint16_t timerDurationS = 60 * timerM + timerS; | |
| 320 | |
| 321 if (timerDurationS < 1) { | |
| 322 timerDurationS = 1; | |
| 323 } | |
| 324 | |
| 325 if (timerDurationS != settings->timerDurationS) { | |
| 326 settings->timerDurationS = timerDurationS; | |
| 327 | |
| 328 disableTimer(); | |
| 329 | |
| 330 tMenuEdit_newInput(editId, settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); | |
| 331 } | |
| 332 | |
|
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
|
333 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
|
334 |
| 999 | 335 return EXIT_TO_MENU; |
| 336 } | |
| 337 case ACTION_BUTTON_NEXT: | |
| 338 digitContentNew = digitContent + 1; | |
| 339 if ((blockNumber == 1 && digitNumber == 0 && digitContentNew > '5') || digitContentNew > '9') { | |
| 340 digitContentNew = '0'; | |
| 341 } | |
| 342 | |
| 343 return digitContentNew; | |
| 344 case ACTION_BUTTON_BACK: | |
| 345 digitContentNew = digitContent - 1; | |
| 346 if (digitContentNew < '0') { | |
| 347 if (blockNumber == 1 && digitNumber == 0) { | |
| 348 digitContentNew = '5'; | |
| 349 } else { | |
| 350 digitContentNew = '9'; | |
| 351 } | |
| 352 } | |
| 353 | |
| 354 return digitContentNew; | |
| 355 } | |
| 356 | |
| 357 return EXIT_TO_MENU; | |
| 358 } | |
| 359 | |
| 360 |
