comparison Discovery/Src/settings.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 dfdfea8897f3
children 4abfb8a2a435
comparison
equal deleted inserted replaced
775:46c6d2380d4e 776:45b8f3c2acce
87 87
88 /* always adjust check_and_correct_settings() accordingly 88 /* always adjust check_and_correct_settings() accordingly
89 * There might even be entries with fixed values that have no range 89 * There might even be entries with fixed values that have no range
90 */ 90 */
91 const SSettings SettingsStandard = { 91 const SSettings SettingsStandard = {
92 .header = 0xFFFF0025, 92 .header = 0xFFFF0026,
93 .warning_blink_dsec = 8 * 2, 93 .warning_blink_dsec = 8 * 2,
94 .lastDiveLogId = 0, 94 .lastDiveLogId = 0,
95 .logFlashNextSampleStartAddress = SAMPLESTART, 95 .logFlashNextSampleStartAddress = SAMPLESTART,
96 96
97 .gas[0].oxygen_percentage = 21, 97 .gas[0].oxygen_percentage = 21,
330 .ext_sensor_map[0] = SENSOR_OPTIC, 330 .ext_sensor_map[0] = SENSOR_OPTIC,
331 .ext_sensor_map[1] = SENSOR_OPTIC, 331 .ext_sensor_map[1] = SENSOR_OPTIC,
332 .ext_sensor_map[2] = SENSOR_OPTIC, 332 .ext_sensor_map[2] = SENSOR_OPTIC,
333 .ext_sensor_map[3] = SENSOR_NONE, 333 .ext_sensor_map[3] = SENSOR_NONE,
334 .ext_sensor_map[4] = SENSOR_NONE, 334 .ext_sensor_map[4] = SENSOR_NONE,
335 .buttonLockActive = 0 335 .buttonLockActive = 0,
336 .compassDeclinationDeg = 0,
336 }; 337 };
337 338
338 /* Private function prototypes -----------------------------------------------*/ 339 /* Private function prototypes -----------------------------------------------*/
339 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); 340 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to);
340 341
532 pSettings->ext_sensor_map[3] = SENSOR_NONE; 533 pSettings->ext_sensor_map[3] = SENSOR_NONE;
533 pSettings->ext_sensor_map[4] = SENSOR_NONE; 534 pSettings->ext_sensor_map[4] = SENSOR_NONE;
534 // no break; 535 // no break;
535 case 0xFFFF0024: pSettings->buttonLockActive = 0; 536 case 0xFFFF0024: pSettings->buttonLockActive = 0;
536 // no break; 537 // no break;
538 case 0xFFFF0025:
539 pSettings->compassDeclinationDeg = pStandard->compassDeclinationDeg;
540
541 // no break;
537 default: 542 default:
538 pSettings->header = pStandard->header; 543 pSettings->header = pStandard->header;
539 break; // no break before!! 544 break; // no break before!!
540 } 545 }
541 } 546 }
1573 } 1578 }
1574 1579
1575 if(Settings.buttonLockActive > 1) 1580 if(Settings.buttonLockActive > 1)
1576 { 1581 {
1577 Settings.buttonLockActive = 1; 1582 Settings.buttonLockActive = 1;
1583 corrections++;
1584 }
1585
1586 if (Settings.compassDeclinationDeg > 99) {
1587 Settings.compassDeclinationDeg = 99;
1588
1589 corrections++;
1590 } else if (Settings.compassDeclinationDeg < -99) {
1591 Settings.compassDeclinationDeg = -99;
1592
1578 corrections++; 1593 corrections++;
1579 } 1594 }
1580 1595
1581 if(corrections) 1596 if(corrections)
1582 { 1597 {