# HG changeset patch # User heinrichsweikamp # Date 1678114980 -3600 # Node ID 5071d554aaa57372052dd1aedf7d988dce446df1 # Parent 8a2337c7af5295139f0aff8420dd65d50d46a0b2 NEW: Add mini compass with marker declination indication Contribution from mikeller diff -r 8a2337c7af52 -r 5071d554aaa5 Discovery/Inc/t7.h --- a/Discovery/Inc/t7.h Fri Mar 03 10:41:44 2023 +0100 +++ b/Discovery/Inc/t7.h Mon Mar 06 16:03:00 2023 +0100 @@ -52,6 +52,7 @@ #ifdef ENABLE_PSCR_MODE LCC_SimPpo2, #endif + LLC_Compass, LLC_END } customview_llc_t; diff -r 8a2337c7af52 -r 5071d554aaa5 Discovery/Src/gfx_engine.c --- a/Discovery/Src/gfx_engine.c Fri Mar 03 10:41:44 2023 +0100 +++ b/Discovery/Src/gfx_engine.c Mon Mar 06 16:03:00 2023 +0100 @@ -2084,7 +2084,7 @@ else /* Font style changes */ if(*pText == '\a') - settings.invert = 1; + settings.invert = settings.invert ? 0 : 1; else if((*pText == '\016') && !minimal) { diff -r 8a2337c7af52 -r 5071d554aaa5 Discovery/Src/t7.c --- a/Discovery/Src/t7.c Fri Mar 03 10:41:44 2023 +0100 +++ b/Discovery/Src/t7.c Mon Mar 06 16:03:00 2023 +0100 @@ -27,6 +27,8 @@ ////////////////////////////////////////////////////////////////////////////// /* Includes ------------------------------------------------------------------*/ +#include + #include "t7.h" #include "t3.h" #include "settings.h" @@ -2898,8 +2900,91 @@ snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]); break; #endif + case LLC_Compass: + headerText[2] = TXT_2BYTE; + headerText[3] = TXT2BYTE_Compass; + tinyHeaderFont = 1; + + uint16_t heading; + if(settingsGetPointer()->compassInertia) { + heading = (uint16_t)compass_getCompensated(); + } else { + heading = (uint16_t)stateUsed->lifeData.compass_heading; + } + + uint16_t userSetHeading = stateUsed->diveSettings.compassHeading; + if (!userSetHeading) { + snprintf(text, TEXTSIZE, "\020\002\034%u ", heading); + } else { + snprintf(text, TEXTSIZE, "\020\002\034\016\016%u ", heading); + + int16_t declinationFromForwardMark = ((userSetHeading - heading + 180 + 360) % 360) - 180; + int16_t declinationFromNearestMark = ((declinationFromForwardMark + 90 + 180) % 180) - 90; + + uint16_t colour; + if (abs(declinationFromForwardMark) <= 90) { + colour = CLUT_CompassUserHeadingTick; + } else { + colour = CLUT_CompassUserBackHeadingTick; + } + + char direction[] = "\001 \004 \004 "; + if (abs(declinationFromNearestMark) <= 10) { + direction[2] = '>'; + direction[6] = '<'; + + if (abs(declinationFromForwardMark) <= 10) { + direction[4] = 'X'; + } else { + direction[4] = 'O'; + } + + if (abs(declinationFromNearestMark) <= 3) { + direction[3] = '\a'; + direction[5] = '\a'; + } + } else { + if (declinationFromForwardMark < -90) { + direction[7] = 'O'; + } else if (declinationFromForwardMark < 0) { + direction[1] = 'X'; + } else if (declinationFromForwardMark <= 90) { + direction[7] = 'X'; + } else { + direction[1] = 'O'; + } + + if (declinationFromNearestMark >= 0) { + direction[6] = '>'; + } + if (declinationFromNearestMark > 30) { + direction[4] = '>'; + } + if (declinationFromNearestMark > 60 || declinationFromForwardMark == 90) { + direction[2] = '>'; + } + if (declinationFromNearestMark < 0) { + direction[2] = '<'; + } + if (declinationFromNearestMark < -30) { + direction[4] = '<'; + } + if (declinationFromNearestMark < -60 || declinationFromForwardMark == -90) { + direction[6] = '<'; + } + } + + GFX_write_string_color(&FontT48, &t7l3, direction, 1, colour); + } + + break; } - headerText[3] = 0; + + if (headerText[2] != TXT_2BYTE) { + headerText[3] = 0; + } else { + headerText[4] = 0; + } if(tinyHeaderFont) GFX_write_string(&FontT24,&t7l3,headerText,0); diff -r 8a2337c7af52 -r 5071d554aaa5 Discovery/Src/tMenuEditCustom.c --- a/Discovery/Src/tMenuEditCustom.c Fri Mar 03 10:41:44 2023 +0100 +++ b/Discovery/Src/tMenuEditCustom.c Mon Mar 06 16:03:00 2023 +0100 @@ -175,6 +175,11 @@ text[4] = TXT_SimPpo2; break; #endif + case LLC_Compass: + text[4] = TXT_2BYTE; + text[5] = TXT2BYTE_Compass; + + break; /* none */ case LLC_Empty: text[4] = '-'; @@ -183,7 +188,12 @@ text[4] = 'X'; break; } - text[5] = 0; + if (text[4] != TXT_2BYTE) { + text[5] = 0; + } else { + text[6] = 0; + } + write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text); write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);