comparison Discovery/Src/data_exchange_main.c @ 776:45b8f3c2acce

Add support for a configurable compass declination in a range of -99 to 99 degrees. This allows the displayed compass reading to be configured to take into account the compass declination (difference between the measured magnetic North direction and the actual geographical North direction) that has different values for different locations around the globe. See https://magnetic-declination.com/ for more information. (mikeller)
author heinrichsweikamp
date Thu, 18 May 2023 09:49:17 +0200
parents aa6006975e76
children e40790a67165
comparison
equal deleted inserted replaced
775:46c6d2380d4e 776:45b8f3c2acce
1094 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time; 1094 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time;
1095 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth; 1095 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth;
1096 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds; 1096 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds;
1097 1097
1098 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading; 1098 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading;
1099 if(settingsGetPointer()->FlipDisplay) /* consider that diver is targeting into the opposite direction */ 1099 if (pStateReal->lifeData.compass_heading != -1) {
1100 { 1100 if (pSettings->FlipDisplay) { /* consider that diver is targeting into the opposite direction */
1101 pStateReal->lifeData.compass_heading -= 180.0; 1101 pStateReal->lifeData.compass_heading -= 180.0;
1102 if (pStateReal->lifeData.compass_heading < 0) pStateReal->lifeData.compass_heading +=360.0; 1102 }
1103 } 1103
1104 if (pSettings->compassDeclinationDeg != 0) {
1105 pStateReal->lifeData.compass_heading = pStateReal->lifeData.compass_heading + pSettings->compassDeclinationDeg - 360.0;
1106 }
1107
1108 while (pStateReal->lifeData.compass_heading < 0) {
1109 pStateReal->lifeData.compass_heading += 360.0;
1110 }
1111 }
1104 1112
1105 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll; 1113 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll;
1106 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch; 1114 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch;
1107 1115
1108 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f; 1116 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f;