Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditXtra.c @ 967:9b418e63dbc2 Evo_2_23 tip
Add a 'Reverse' action to the compass heading dive menu.
This allows the compass heading to be reversed for the return leg of the
dive - as a bonus the reversal will be logged, establishing at which
point in the log the dive was turned (mikeller)
author | heinrichsweikamp |
---|---|
date | Wed, 15 Jan 2025 16:38:27 +0100 |
parents | 63c340abd70e |
children |
comparison
equal
deleted
inserted
replaced
966:90edc237d60f | 967:9b418e63dbc2 |
---|---|
312 setEvent(StMXTRA_PSCR_LUNG_RATIO, (uint32_t)OnAction_PSCRLungRation); | 312 setEvent(StMXTRA_PSCR_LUNG_RATIO, (uint32_t)OnAction_PSCRLungRation); |
313 } | 313 } |
314 | 314 |
315 | 315 |
316 | 316 |
317 static uint8_t OnAction_CompassHeadingReverse(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
318 { | |
319 setCompassHeading((stateUsed->diveSettings.compassHeading + 180) % 360); | |
320 | |
321 exitMenuEdit_to_Home_with_Menu_Update(); | |
322 | |
323 return EXIT_TO_HOME; | |
324 } | |
325 | |
326 | |
317 static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 327 static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
318 { | 328 { |
319 clearCompassHeading(); | 329 clearCompassHeading(); |
320 | 330 |
321 exitMenuEdit_to_Home_with_Menu_Update(); | 331 exitMenuEdit_to_Home_with_Menu_Update(); |
349 SSettings *settings = settingsGetPointer(); | 359 SSettings *settings = settingsGetPointer(); |
350 | 360 |
351 char text[32]; | 361 char text[32]; |
352 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_CompassHeading); | 362 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_CompassHeading); |
353 write_topline(text); | 363 write_topline(text); |
364 | |
365 if (!isRefresh) { | |
366 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set); | |
367 write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE1, &FontT48, text); | |
368 } else { | |
369 tMenuEdit_refresh_field(StMXTRA_CompassHeading); | |
370 } | |
354 | 371 |
355 uint16_t heading; | 372 uint16_t heading; |
356 if (settings->compassInertia) { | 373 if (settings->compassInertia) { |
357 heading = (uint16_t)compass_getCompensated(); | 374 heading = (uint16_t)compass_getCompensated(); |
358 } else { | 375 } else { |
359 heading = (uint16_t)stateUsed->lifeData.compass_heading; | 376 heading = (uint16_t)stateUsed->lifeData.compass_heading; |
360 } | 377 } |
361 snprintf(text,32,"\001%03i`",heading); | 378 snprintf(text,32,"\001%03i`",heading); |
362 write_label_var(0, 800, ME_Y_LINE1, &FontT54, text); | 379 write_label_var(0, 800, ME_Y_LINE1, &FontT54, text); |
363 | 380 |
364 if (!isRefresh) { | 381 bool headingIsSet = stateUsed->diveSettings.compassHeading; |
365 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set); | 382 snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Reverse); |
366 write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE2, &FontT48, text); | 383 if (headingIsSet) { |
384 if (!isRefresh) { | |
385 write_field_button(StMXTRA_CompassHeadingReverse, 20, 800, ME_Y_LINE2, &FontT48, text); | |
386 } else { | |
387 tMenuEdit_refresh_field(StMXTRA_CompassHeadingReverse); | |
388 } | |
367 } else { | 389 } else { |
368 tMenuEdit_refresh_field(StMXTRA_CompassHeading); | 390 write_label_var(20, 800, ME_Y_LINE2, &FontT48, text); |
369 } | 391 } |
370 | 392 |
371 bool headingIsSet = stateUsed->diveSettings.compassHeading; | |
372 snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Clear); | 393 snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Clear); |
373 if (headingIsSet) { | 394 if (headingIsSet) { |
374 if (!isRefresh) { | 395 if (!isRefresh) { |
375 write_field_button(StMXTRA_CompassHeadingClear, 20, 800, ME_Y_LINE3, &FontT48, text); | 396 write_field_button(StMXTRA_CompassHeadingClear, 20, 800, ME_Y_LINE3, &FontT48, text); |
376 } else { | 397 } else { |
405 write_label_var(20, 800, ME_Y_LINE6, &FontT48, text); | 426 write_label_var(20, 800, ME_Y_LINE6, &FontT48, text); |
406 } | 427 } |
407 | 428 |
408 if (!isRefresh) { | 429 if (!isRefresh) { |
409 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); | 430 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); |
431 setEvent(StMXTRA_CompassHeadingReverse, (uint32_t)OnAction_CompassHeadingReverse); | |
410 setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear); | 432 setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear); |
411 setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset); | 433 setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset); |
412 setEvent(StMXTRA_CompassHeadingLog, (uint32_t)OnAction_CompassHeadingLog); | 434 setEvent(StMXTRA_CompassHeadingLog, (uint32_t)OnAction_CompassHeadingLog); |
413 } | 435 } |
414 | 436 |