comparison Discovery/Src/data_central.c @ 929:63c340abd70e Evo_2_23 tip

Add a line to the compass heading dive menu that shows the currently set heading to enable the diver to confirm it / add it to notes. Also add a log entry every time a new compass heading is set or the heading is cleared. And add a way to add compass headings to the log without changing the currently set heading - this was added after discussion with cave divers who are interested in recording headings when mapping out caves. From mikeller
author heinrichsweikamp
date Mon, 02 Dec 2024 11:16:10 +0100
parents 57fc479745b0
children
comparison
equal deleted inserted replaced
928:9b7859554beb 929:63c340abd70e
890 bool isCompassCalibrated(void) 890 bool isCompassCalibrated(void)
891 { 891 {
892 return stateUsed->lifeData.compass_heading != -1; 892 return stateUsed->lifeData.compass_heading != -1;
893 } 893 }
894 894
895 static void internalLogCompassHeading(uint16_t heading, bool applyHeading, bool clearHeading)
896 {
897 uint16_t compassHeading = 0;
898 if (clearHeading) {
899 compassHeading |= 0x8000;
900 } else {
901 compassHeading = heading & 0x1FF;
902 }
903 if (applyHeading) {
904 compassHeading |= 0x4000;
905 }
906
907 stateUsedWrite->events.compassHeadingUpdate = 1;
908 stateUsedWrite->events.info_compassHeadingUpdate = compassHeading;
909 }
910
911 void logCompassHeading(uint16_t heading) {
912 internalLogCompassHeading(heading, false, false);
913 }
914
915 void clearCompassHeading(void) {
916 uint16_t clearHeading = 0;
917 stateUsedWrite->diveSettings.compassHeading = clearHeading;
918
919 internalLogCompassHeading(clearHeading, true, true);
920 }
895 921
896 void setCompassHeading(uint16_t heading) 922 void setCompassHeading(uint16_t heading)
897 { 923 {
898
899 // if heading == 0 set compassHeading to 360, because compassHeading == 0 means 'off'
900
901 stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360; 924 stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360;
925
926 internalLogCompassHeading(heading, true, false);
902 } 927 }
903 928
904 929
905 const SDecoinfo *getDecoInfo(void) 930 const SDecoinfo *getDecoInfo(void)
906 { 931 {