38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Discovery/Src/tMenuEditHardware.c
+ − 5 /// \brief BUTTONS
+ − 6 /// \author heinrichs weikamp gmbh
+ − 7 /// \date 15-Sept-2016
+ − 8 ///
+ − 9 /// \details
+ − 10 ///
+ − 11 /// $Id$
+ − 12 ///////////////////////////////////////////////////////////////////////////////
+ − 13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+ − 14 ///
+ − 15 /// This program is free software: you can redistribute it and/or modify
+ − 16 /// it under the terms of the GNU General Public License as published by
+ − 17 /// the Free Software Foundation, either version 3 of the License, or
+ − 18 /// (at your option) any later version.
+ − 19 ///
+ − 20 /// This program is distributed in the hope that it will be useful,
+ − 21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ − 23 /// GNU General Public License for more details.
+ − 24 ///
+ − 25 /// You should have received a copy of the GNU General Public License
+ − 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
+ − 27 //////////////////////////////////////////////////////////////////////////////
+ − 28
+ − 29 /* Includes ------------------------------------------------------------------*/
+ − 30 #include "tMenuEditHardware.h"
783
+ − 31 #include "tMenuEdit.h"
38
+ − 32
+ − 33 #include "externCPU2bootloader.h"
+ − 34 #include "gfx_fonts.h"
+ − 35 #include "ostc.h"
+ − 36 #include "tCCR.h"
+ − 37 #include "tMenuEdit.h"
130
+ − 38 #include "tHome.h"
+ − 39 #include "tInfo.h"
+ − 40 #include "tInfoLog.h"
718
+ − 41 #include "tInfoSensor.h"
394
+ − 42 #include "tComm.h"
562
+ − 43 #include "data_exchange_main.h"
38
+ − 44
748
+ − 45
130
+ − 46 extern void tM_build_pages(void);
92
+ − 47
38
+ − 48 /* Private function prototypes -----------------------------------------------*/
+ − 49 void openEdit_Bluetooth(void);
+ − 50 void openEdit_Compass(void);
+ − 51 void openEdit_O2Sensors(void);
+ − 52 void openEdit_Brightness(void);
+ − 53 //void openEdit_Luftintegration(void);
+ − 54 void openEdit_ButtonSens(void);
110
+ − 55 void openEdit_FlipDisplay(void);
38
+ − 56
+ − 57 /* Announced function prototypes -----------------------------------------------*/
+ − 58 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 59 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 60 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
539
+ − 61 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
38
+ − 62 //uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 63 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 64 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 65 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
562
+ − 66 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
734
+ − 67 //uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
718
+ − 68 uint8_t OnAction_Sensor_Info (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
730
+ − 69 uint8_t OnAction_Sensor_Detect (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
38
+ − 70 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 71 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
740
+ − 72 uint8_t OnAction_ButtonLock (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
605
+ − 73 // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
38
+ − 74
+ − 75 /* Exported functions --------------------------------------------------------*/
+ − 76
562
+ − 77
+ − 78 #define O2_CALIB_FRACTION_AIR (0.209F)
605
+ − 79 #define O2_CALIB_FRACTION_O2 (0.98F)
562
+ − 80
584
+ − 81 static uint8_t O2_calib_gas = 21;
562
+ − 82
38
+ − 83 void openEdit_Hardware(uint8_t line)
+ − 84 {
+ − 85 set_globalState_Menu_Line(line);
+ − 86
+ − 87 switch(line)
+ − 88 {
+ − 89 case 1:
+ − 90 default:
+ − 91 openEdit_Bluetooth();
+ − 92 break;
+ − 93 case 2:
708
+ − 94 resetMenuEdit(CLUT_MenuPageHardware);
38
+ − 95 openEdit_Compass();
+ − 96 break;
+ − 97 case 3:
+ − 98 openEdit_O2Sensors();
+ − 99 break;
+ − 100 case 4:
+ − 101 openEdit_Brightness();
+ − 102 break;
+ − 103 case 5:
708
+ − 104 resetMenuEdit(CLUT_MenuPageHardware);
38
+ − 105 openEdit_ButtonSens();
+ − 106 break;
+ − 107 case 6:
138
+ − 108 openEdit_FlipDisplay();
38
+ − 109 break;
+ − 110 }
+ − 111 }
+ − 112
+ − 113 /* Private functions ---------------------------------------------------------*/
+ − 114 void openEdit_Bluetooth(void)
+ − 115 {
+ − 116 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */
+ − 117
+ − 118 SSettings *pSettings = settingsGetPointer();
+ − 119
+ − 120 if(pSettings->bluetoothActive == 0)
+ − 121 {
+ − 122 pSettings->bluetoothActive = 1;
+ − 123 MX_Bluetooth_PowerOn();
394
+ − 124 tComm_StartBlueModConfig();
38
+ − 125 }
+ − 126 else
+ − 127 {
+ − 128 pSettings->bluetoothActive = 0;
+ − 129 MX_Bluetooth_PowerOff();
+ − 130 }
+ − 131 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only();
+ − 132 }
+ − 133
110
+ − 134 void openEdit_FlipDisplay(void)
+ − 135 {
+ − 136 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */
+ − 137
+ − 138 SSettings *pSettings = settingsGetPointer();
+ − 139
+ − 140 if(pSettings->FlipDisplay == 0)
+ − 141 {
+ − 142 pSettings->FlipDisplay = 1;
+ − 143 }
+ − 144 else
+ − 145 {
+ − 146 pSettings->FlipDisplay = 0;
+ − 147 }
+ − 148 /* reinit all views */
+ − 149 tHome_init();
+ − 150 tI_init();
+ − 151 tM_init();
+ − 152 tMenuEdit_init();
+ − 153 tInfoLog_init();
+ − 154 tM_build_pages();
314
+ − 155 GFX_build_logo_frame();
+ − 156 GFX_build_hw_background_frame();
110
+ − 157
+ − 158 exitEditWithUpdate();
+ − 159 exitMenuEdit_to_Home();
+ − 160 }
38
+ − 161
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 162
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 163 static uint8_t togglePlusMinus(uint8_t input)
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 164 {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 165 if (input == '+') {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 166 return '-';
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 167 } else {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 168 return '+';
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 169 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 170 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 171
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 172
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 173 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 174 {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 175 SSettings *settings = settingsGetPointer();
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 176 uint8_t digitContentNew;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 177 switch (action) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 178 case ACTION_BUTTON_ENTER:
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 179
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 180 return digitContent;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 181 case ACTION_BUTTON_ENTER_FINAL:
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 182 {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 183 int32_t compassDeclinationDeg;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 184 evaluateNewString(editId, (uint32_t *)&compassDeclinationDeg, NULL, NULL, NULL);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 185
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 186 if (compassDeclinationDeg > 99) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 187 compassDeclinationDeg = 99;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 188 } else if (compassDeclinationDeg < -99) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 189 compassDeclinationDeg = -99;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 190 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 191
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 192 settings->compassDeclinationDeg = compassDeclinationDeg;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 193
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 194 tMenuEdit_newInput(editId, ((input_u)compassDeclinationDeg).uint32, 0, 0, 0);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 195 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 196
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 197 break;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 198 case ACTION_BUTTON_NEXT:
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 199 if (digitNumber == 0) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 200 digitContentNew = togglePlusMinus(digitContent);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 201 } else {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 202 digitContentNew = digitContent + 1;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 203 if (digitContentNew > '9') {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 204 digitContentNew = '0';
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 205 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 206 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 207
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 208 return digitContentNew;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 209 case ACTION_BUTTON_BACK:
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 210 if (digitNumber == 0) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 211 digitContentNew = togglePlusMinus(digitContent);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 212 } else {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 213 digitContentNew = digitContent - 1;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 214 if (digitContentNew < '0') {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 215 digitContentNew = '9';
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 216 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 217 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 218
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 219 return digitContentNew;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 220 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 221
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 222 return UNSPECIFIC_RETURN;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 223 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 224
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 225
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 226 static void showCompassDeclination(SSettings *settings, bool isRefresh)
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 227 {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 228 char text[16];
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 229 snprintf(text, 16, "%c%c:", TXT_2BYTE, TXT2BYTE_CompassDeclination);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 230 write_label_var(30, 800, ME_Y_LINE6, &FontT48, text);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 231 if (isRefresh) {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 232 tMenuEdit_refresh_field(StMHARD2_Compass_Declination);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 233 } else {
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 234 write_field_sdigit(StMHARD2_Compass_Declination, 500, 800, ME_Y_LINE6, &FontT48, "\034###`", settings->compassDeclinationDeg, 0, 0, 0);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 235 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 236 }
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 237
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 238
38
+ − 239 void refresh_CompassEdit(void)
+ − 240 {
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 241 SSettings *settings = settingsGetPointer();
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 242
38
+ − 243 uint16_t heading;
+ − 244 char text[32];
539
+ − 245 uint8_t textIndex = 0;
38
+ − 246
+ − 247 text[0] = '\001';
+ − 248 text[1] = TXT_2BYTE;
+ − 249 text[2] = TXT2BYTE_Compass;
+ − 250 text[3] = 0;
+ − 251 write_topline(text);
+ − 252
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 253 if(settings->compassInertia)
539
+ − 254 {
+ − 255 heading = (uint16_t)compass_getCompensated();
+ − 256 }
+ − 257 else
+ − 258 {
+ − 259 heading = (uint16_t)stateUsed->lifeData.compass_heading;
+ − 260 }
38
+ − 261 snprintf(text,32,"\001%03i`",heading);
+ − 262 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text);
+ − 263
+ − 264 tMenuEdit_refresh_field(StMHARD2_Compass_SetCourse);
+ − 265 tMenuEdit_refresh_field(StMHARD2_Compass_Calibrate);
+ − 266 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse);
539
+ − 267 text[textIndex++] = TXT_2BYTE;
+ − 268 text[textIndex++] = TXT2BYTE_CompassInertia;
+ − 269 text[textIndex++] = ':';
+ − 270 text[textIndex++] = ' ';
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 271 text[textIndex++] = '0' + settings->compassInertia;
539
+ − 272
+ − 273 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text);
38
+ − 274
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 275 showCompassDeclination(settings, true);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 276
38
+ − 277 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+ − 278 }
+ − 279
+ − 280
+ − 281 void openEdit_Compass(void)
+ − 282 {
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 283 SSettings *settings = settingsGetPointer();
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 284
539
+ − 285 char text[10];
+ − 286 uint8_t textIndex = 0;
38
+ − 287
854
+ − 288
+ − 289 set_globalState(StMHARD2_Compass);
+ − 290 resetMenuEdit(CLUT_MenuPageHardware);
+ − 291
539
+ − 292 text[textIndex++] = '\001';
+ − 293 text[textIndex++] = TXT_2BYTE;
+ − 294 text[textIndex++] = TXT2BYTE_Compass;
+ − 295 text[textIndex++] = 0;
38
+ − 296 write_topline(text);
+ − 297
+ − 298 text[0] = TXT_2BYTE;
+ − 299 text[2] = 0;
+ − 300
+ − 301 text[1] = TXT2BYTE_SetBearing;
+ − 302 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text);
+ − 303
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 304 text[1] = TXT2BYTE_ResetBearing;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 305 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE3, &FontT48, text);
38
+ − 306
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 307 text[1] = TXT2BYTE_CompassCalib;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 308 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, text);
38
+ − 309
539
+ − 310 text[1] = TXT2BYTE_CompassInertia;
+ − 311 textIndex = 2;
+ − 312 text[textIndex++] = ':';
+ − 313 text[textIndex++] = ' ';
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 314 text[textIndex++] = '0' + settings->compassInertia;
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 315 text[textIndex++] = 0;
539
+ − 316
+ − 317 write_field_button(StMHARD2_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text);
+ − 318
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 319 showCompassDeclination(settings, false);
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 320
38
+ − 321 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing);
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 322 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear);
38
+ − 323 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass);
539
+ − 324 setEvent(StMHARD2_Compass_Inertia, (uint32_t)OnAction_InertiaLevel);
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
diff
changeset
+ − 325 setEvent(StMHARD2_Compass_Declination, (uint32_t)OnAction_CompassDeclination);
38
+ − 326
854
+ − 327 tMenuEdit_select(StMHARD2_Compass_SetCourse);
+ − 328
38
+ − 329 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+ − 330 }
+ − 331
+ − 332
+ − 333 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 334 {
+ − 335 calibrateCompass();
+ − 336 return EXIT_TO_INFO_COMPASS;
+ − 337 }
+ − 338
+ − 339
+ − 340 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 341 {
709
+ − 342 if((int16_t)stateUsed->lifeData.compass_heading != -1)
+ − 343 {
+ − 344 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading;
+ − 345 }
+ − 346 else
+ − 347 {
+ − 348 settingsGetPointer()->compassBearing = 0;
+ − 349 }
+ − 350
38
+ − 351 if(settingsGetPointer()->compassBearing == 0)
+ − 352 settingsGetPointer()->compassBearing = 360;
+ − 353 return UPDATE_AND_EXIT_TO_MENU;
+ − 354 }
+ − 355
+ − 356
+ − 357 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 358 {
+ − 359 settingsGetPointer()->compassBearing = 0;
+ − 360 return UPDATE_AND_EXIT_TO_MENU;
+ − 361 }
+ − 362
539
+ − 363
+ − 364 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 365 {
+ − 366 uint8_t newLevel = 0;
+ − 367
+ − 368 newLevel = settingsGetPointer()->compassInertia + 1;
+ − 369 if(newLevel > MAX_COMPASS_COMP)
+ − 370 {
+ − 371 newLevel = 0;
+ − 372 }
+ − 373 settingsGetPointer()->compassInertia = newLevel;
+ − 374 return UPDATE_DIVESETTINGS;
+ − 375 }
+ − 376
38
+ − 377 /*
+ − 378 uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 379 {
+ − 380 return EXIT_TO_MENU;
+ − 381 }
+ − 382 */
+ − 383
+ − 384 void refresh_O2Sensors(void)
+ − 385 {
734
+ − 386 char strSensorId[20];
+ − 387 char strSensorValue[20];
38
+ − 388 uint16_t y_line;
730
+ − 389 uint8_t index = 0;
38
+ − 390
562
+ − 391 const SDiveState *pStateReal = stateRealGetPointer();
730
+ − 392 SSettings *pSettings = settingsGetPointer();
38
+ − 393
797
+ − 394 if(memcmp(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, EXT_INTERFACE_SENSOR_CNT) != 0)
734
+ − 395 {
797
+ − 396 memcpy(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, EXT_INTERFACE_SENSOR_CNT);
734
+ − 397 pSettings->ppo2sensors_deactivated = 0x0; /* deactivation will be done by openEditO2Sensor if need */
827
+ − 398 pSettings->co2_sensor_active = 0;
734
+ − 399 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC;
827
+ − 400 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT - 1; index++)
730
+ − 401 {
734
+ − 402 switch(pSettings->ext_sensor_map[index])
+ − 403 {
+ − 404 case SENSOR_OPTIC: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC;
+ − 405 break;
+ − 406 case SENSOR_ANALOG: if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL)
+ − 407 {
+ − 408 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_ANADIG;
+ − 409 }
+ − 410 if(pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG)
+ − 411 {
+ − 412 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_ANALOG;
+ − 413 }
+ − 414 break;
797
+ − 415 case SENSOR_DIGO2M: if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG)
734
+ − 416 {
+ − 417 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_ANADIG;
+ − 418 }
+ − 419 if(pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG)
+ − 420 {
+ − 421 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_DIGITAL;
+ − 422 }
+ − 423 break;
827
+ − 424 case SENSOR_CO2:
+ − 425 case SENSOR_CO2M: pSettings->co2_sensor_active = 1;
+ − 426 break;
746
+ − 427 #ifdef ENABLE_SENTINEL_MODE
842
+ − 428 case SENSOR_SENTINEL:
+ − 429 case SENSOR_SENTINELM: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL;
745
+ − 430 break;
746
+ − 431 #endif
734
+ − 432 default:
+ − 433 break;
+ − 434 }
730
+ − 435 }
734
+ − 436 openEdit_O2Sensors();
+ − 437 }
+ − 438
783
+ − 439 strSensorId[0] = '\001';
+ − 440 strSensorId[1] = TXT_o2Sensors;
+ − 441 strSensorId[2] = 0;
+ − 442 write_topline(strSensorId);
718
+ − 443
783
+ − 444 strSensorId[0] = TXT_2BYTE;
+ − 445 strSensorId[1] = TXT2BYTE_Sensor;
+ − 446 strSensorId[2] = ' ';
+ − 447 strSensorId[3] = TXT_2BYTE;
+ − 448 strSensorId[4] = 'X';
+ − 449 strSensorId[5] = '1';
+ − 450 strSensorId[6] = 0;
718
+ − 451
783
+ − 452 for(index = 0; index < 3; index++)
+ − 453 {
799
+ − 454 strSensorId[3] = TXT_2BYTE;
734
+ − 455 strSensorId[4] = 'X';
783
+ − 456 strSensorId[5] = '1' + index;
718
+ − 457
783
+ − 458 switch(pSettings->ext_sensor_map[index])
730
+ − 459 {
748
+ − 460 case SENSOR_SEARCH: strSensorId[1] = TXT2BYTE_SensorDetect;
+ − 461 strSensorId[2] = 0;
+ − 462 strSensorId[4] = 0;
745
+ − 463 break;
734
+ − 464 case SENSOR_OPTIC: strSensorId[4] = TXT2BYTE_O2IFOptic;
+ − 465 break;
+ − 466 case SENSOR_ANALOG: strSensorId[4] = TXT2BYTE_O2IFAnalog;
+ − 467 break;
797
+ − 468 case SENSOR_DIGO2:
+ − 469 case SENSOR_DIGO2M: strSensorId[4] = TXT2BYTE_O2IFDigital;
734
+ − 470 break;
799
+ − 471 case SENSOR_CO2:
+ − 472 case SENSOR_CO2M: strSensorId[3] = 'C';
734
+ − 473 strSensorId[4] = 'O';
+ − 474 break;
842
+ − 475 case SENSOR_SENTINEL:
+ − 476 case SENSOR_SENTINELM: strSensorId[3] = 'S';
920
+ − 477 strSensorId[4] = 'e';
745
+ − 478 break;
920
+ − 479 case SENSOR_GNSS:
+ − 480 case SENSOR_GNSSM: strSensorId[3] = 'G';
+ − 481 strSensorId[4] = 'N';
+ − 482 break;
734
+ − 483 default:
748
+ − 484 strSensorId[5] = 0;
734
+ − 485 break;
783
+ − 486 }
+ − 487 if(strSensorId[4] != 'X')
+ − 488 {
+ − 489 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId);
+ − 490 }
+ − 491 strSensorValue[0] = 0;
+ − 492 if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END))
+ − 493 {
+ − 494 snprintf(strSensorValue, 20,"%01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]);
+ − 495 }
799
+ − 496 else if(pSettings->ext_sensor_map[index] == SENSOR_CO2M)
783
+ − 497 {
+ − 498 snprintf(strSensorValue, 20,"%ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm);
730
+ − 499 }
783
+ − 500 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP);
+ − 501 if(strSensorValue[0] != 0)
718
+ − 502 {
783
+ − 503 write_label_var( 480, 800, y_line, &FontT48, strSensorValue);
+ − 504 }
+ − 505 }
562
+ − 506
783
+ − 507 if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC)
+ − 508 {
+ − 509 strSensorId[0] = TXT_2BYTE;
+ − 510 strSensorId[1] = TXT2BYTE_HUDbattery;
+ − 511 strSensorId[2] = 0;
+ − 512 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId);
+ − 513
+ − 514 snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V());
+ − 515 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId);
+ − 516 }
+ − 517 else
+ − 518 {
+ − 519 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
754
+ − 520 #ifdef ENABLE_SENTINEL_MODE
746
+ − 521 || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
+ − 522 #endif
+ − 523 )
783
+ − 524 {
+ − 525 strSensorId[0] = TXT_2BYTE;
+ − 526 strSensorId[1] = TXT2BYTE_O2Calib;
+ − 527 strSensorId[2] = 0;
+ − 528 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId);
+ − 529 snprintf(strSensorId, 20,"%d%%", O2_calib_gas);
+ − 530 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId);
562
+ − 531 }
783
+ − 532 }
+ − 533 if(DataEX_external_ADC_Present())
+ − 534 {
+ − 535 strSensorId[0] = TXT_2BYTE;
+ − 536 strSensorId[1] = TXT2BYTE_SensorDetect;
+ − 537 strSensorId[2] = 0;
734
+ − 538
783
+ − 539 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorId);
+ − 540 }
734
+ − 541
827
+ − 542 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_MUX))
783
+ − 543 {
+ − 544 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
+ − 545 }
827
+ − 546 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_MUX))
783
+ − 547 {
+ − 548 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
+ − 549 }
827
+ − 550 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_MUX))
783
+ − 551 {
+ − 552 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
718
+ − 553 }
38
+ − 554
584
+ − 555 if(get_globalState() == StMHARD3_O2_Calibrate)
+ − 556 {
+ − 557 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus);
+ − 558 }
+ − 559 else
+ − 560 {
+ − 561 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+ − 562 }
38
+ − 563 }
+ − 564
+ − 565
+ − 566 void openEdit_O2Sensors(void)
+ − 567 {
730
+ − 568 SSettings *pSettings = settingsGetPointer();
38
+ − 569 uint8_t sensorActive[3];
783
+ − 570 uint8_t index = 0;
746
+ − 571 char text[3];
926
+ − 572 uint32_t firstSensorId = 0;
38
+ − 573
718
+ − 574 set_globalState(StMHARD3_Sensors);
+ − 575 resetMenuEdit(CLUT_MenuPageHardware);
+ − 576
783
+ − 577 for(index = 0; index < 3; index++ )
+ − 578 {
+ − 579 if(pSettings->ppo2sensors_deactivated & (0x01 << index))
+ − 580 {
+ − 581 sensorActive[index] = 0;
+ − 582 }
+ − 583 else
+ − 584 {
+ − 585 sensorActive[index] = 1;
+ − 586 }
+ − 587 }
730
+ − 588
926
+ − 589 if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END)))
730
+ − 590 {
+ − 591 pSettings->ppo2sensors_deactivated |= 1;
930
+ − 592 if(pSettings->ext_sensor_map[0] == SENSOR_CO2M)
+ − 593 {
+ − 594 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", pSettings->co2_sensor_active);
+ − 595 }
730
+ − 596 }
+ − 597 else
+ − 598 {
+ − 599 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]);
926
+ − 600 if(firstSensorId == 0)
+ − 601 {
+ − 602 firstSensorId = StMHARD3_O2_Sensor1;
+ − 603 }
730
+ − 604 }
926
+ − 605 if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_TYPE_O2_END)))
730
+ − 606 {
+ − 607 pSettings->ppo2sensors_deactivated |= 2;
930
+ − 608 if(pSettings->ext_sensor_map[1] == SENSOR_CO2M)
+ − 609 {
+ − 610 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", pSettings->co2_sensor_active);
+ − 611 }
730
+ − 612 }
+ − 613 else
+ − 614 {
+ − 615 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]);
926
+ − 616 if(firstSensorId == 0)
+ − 617 {
+ − 618 firstSensorId = StMHARD3_O2_Sensor2;
+ − 619 }
730
+ − 620 }
926
+ − 621 if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_TYPE_O2_END)))
730
+ − 622 {
+ − 623 pSettings->ppo2sensors_deactivated |= 4;
930
+ − 624 if(pSettings->ext_sensor_map[2] == SENSOR_CO2M)
+ − 625 {
+ − 626 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", pSettings->co2_sensor_active);
+ − 627 }
730
+ − 628 }
+ − 629 else
+ − 630 {
+ − 631 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]);
926
+ − 632 if(firstSensorId == 0)
+ − 633 {
+ − 634 firstSensorId = StMHARD3_O2_Sensor3;
+ − 635 }
730
+ − 636 }
814
+ − 637
+ − 638 stateRealGetPointerWrite()->diveSettings.ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated;
+ − 639
38
+ − 640 if(settingsGetPointer()->ppo2sensors_deactivated & 1)
+ − 641 sensorActive[0] = 0;
+ − 642 if(settingsGetPointer()->ppo2sensors_deactivated & 2)
+ − 643 sensorActive[1] = 0;
+ − 644 if(settingsGetPointer()->ppo2sensors_deactivated & 4)
+ − 645 sensorActive[2] = 0;
+ − 646
730
+ − 647 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
689
+ − 648 #ifdef ENABLE_SENTINEL_MODE
+ − 649 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
+ − 650 #endif
+ − 651 )
562
+ − 652 {
584
+ − 653 write_label_fix( 30, 800, ME_Y_LINE4, &FontT48, TXT2BYTE_O2Calib);
+ − 654 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017");
+ − 655
673
+ − 656 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 98);
562
+ − 657 }
+ − 658
754
+ − 659 if(DataEX_external_ADC_Present())
+ − 660 {
+ − 661 text[0] = TXT_2BYTE;
+ − 662 text[1] = TXT2BYTE_SensorDetect;
+ − 663 text[2] = 0;
730
+ − 664
754
+ − 665 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text);
745
+ − 666
754
+ − 667 write_field_button(StMHARD3_Sensor_Detect, 30, 800, ME_Y_LINE6, &FontT48, text);
+ − 668 }
745
+ − 669
827
+ − 670 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_MUX))
730
+ − 671 {
+ − 672 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1);
+ − 673 }
827
+ − 674 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_MUX))
730
+ − 675 {
+ − 676 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2);
+ − 677 }
827
+ − 678 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_MUX))
730
+ − 679 {
+ − 680 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3);
+ − 681 }
+ − 682
703
+ − 683 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
689
+ − 684 #ifdef ENABLE_SENTINEL_MODE
+ − 685 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
+ − 686 #endif
+ − 687 )
562
+ − 688 {
+ − 689 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate);
+ − 690 }
708
+ − 691
754
+ − 692 if(DataEX_external_ADC_Present())
+ − 693 {
+ − 694 setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect);
+ − 695 }
38
+ − 696 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
926
+ − 697
+ − 698 switch(firstSensorId)
+ − 699 {
+ − 700 case StMHARD3_O2_Sensor2: tMenuEdit_select(StMHARD3_O2_Sensor2);
+ − 701 break;
+ − 702 case StMHARD3_O2_Sensor3: tMenuEdit_select(StMHARD3_O2_Sensor3);
+ − 703 break;
+ − 704 default: break;
+ − 705 }
38
+ − 706 }
+ − 707
+ − 708
+ − 709 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 710 {
783
+ − 711 const SDiveState *pStateReal = stateRealGetPointer();
+ − 712
827
+ − 713 if((pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_CO2M))
783
+ − 714 {
+ − 715 return EXIT_TO_INFO_SENSOR;
+ − 716 }
+ − 717 else
+ − 718 {
+ − 719 if(settingsGetPointer()->ppo2sensors_deactivated & 1)
+ − 720 {
+ − 721 settingsGetPointer()->ppo2sensors_deactivated &= 4+2;
+ − 722 tMenuEdit_set_on_off(editId, 1);
+ − 723 }
+ − 724 else
+ − 725 {
+ − 726 settingsGetPointer()->ppo2sensors_deactivated |= 1;
+ − 727 tMenuEdit_set_on_off(editId, 0);
+ − 728 }
+ − 729 }
38
+ − 730
+ − 731 return UPDATE_DIVESETTINGS;
+ − 732 }
+ − 733
+ − 734
+ − 735 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 736 {
783
+ − 737 const SDiveState *pStateReal = stateRealGetPointer();
38
+ − 738
827
+ − 739 if((pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_CO2M))
783
+ − 740 {
+ − 741 return EXIT_TO_INFO_SENSOR;
+ − 742 }
+ − 743 else
+ − 744 {
+ − 745 if(settingsGetPointer()->ppo2sensors_deactivated & 2)
+ − 746 {
+ − 747 settingsGetPointer()->ppo2sensors_deactivated &= 4+1;
+ − 748 tMenuEdit_set_on_off(editId, 1);
+ − 749 }
+ − 750 else
+ − 751 {
+ − 752 settingsGetPointer()->ppo2sensors_deactivated |= 2;
+ − 753 tMenuEdit_set_on_off(editId, 0);
+ − 754 }
+ − 755 }
38
+ − 756 return UPDATE_DIVESETTINGS;
+ − 757 }
+ − 758
+ − 759
+ − 760 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 761 {
783
+ − 762 const SDiveState *pStateReal = stateRealGetPointer();
+ − 763
827
+ − 764 if((pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_CO2M))
783
+ − 765 {
+ − 766 return EXIT_TO_INFO_SENSOR;
+ − 767 }
+ − 768 else
+ − 769 {
38
+ − 770
783
+ − 771 if(settingsGetPointer()->ppo2sensors_deactivated & 4)
+ − 772 {
+ − 773 settingsGetPointer()->ppo2sensors_deactivated &= 2+1;
+ − 774 tMenuEdit_set_on_off(editId, 1);
+ − 775 }
+ − 776 else
+ − 777 {
+ − 778 settingsGetPointer()->ppo2sensors_deactivated |= 4;
+ − 779 tMenuEdit_set_on_off(editId, 0);
+ − 780 }
+ − 781 }
38
+ − 782 return UPDATE_DIVESETTINGS;
+ − 783 }
+ − 784
+ − 785
562
+ − 786 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 787 {
+ − 788 uint8_t loop;
+ − 789 const SDiveState *pStateReal = stateRealGetPointer();
+ − 790 SSettings* pSettings = settingsGetPointer();
584
+ − 791 uint8_t retVal = UNSPECIFIC_RETURN;
+ − 792 float compensatedRef;
38
+ − 793
584
+ − 794 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 795 {
+ − 796 if(O2_calib_gas == 21)
+ − 797 {
+ − 798 compensatedRef = O2_CALIB_FRACTION_AIR * pStateReal->lifeData.pressure_ambient_bar / 1.0;
+ − 799 }
+ − 800 else
+ − 801 {
605
+ − 802 compensatedRef = O2_CALIB_FRACTION_O2 * pStateReal->lifeData.pressure_ambient_bar / 1.0;
584
+ − 803 }
+ − 804 for(loop=0;loop<3;loop++)
562
+ − 805 {
584
+ − 806 if((pSettings->ppo2sensors_deactivated & (0x1 << loop)) == 0)
+ − 807 {
+ − 808 if(pStateReal->lifeData.sensorVoltage_mV[loop] > 0.0001) /* sensor connected ?*/
+ − 809 {
724
+ − 810 #ifdef ENABLE_EXTERNAL_PRESSURE
+ − 811 if(loop == 2)
+ − 812 {
+ − 813 compensatedRef = pStateReal->lifeData.pressure_ambient_bar;
+ − 814 }
+ − 815 #endif
+ − 816
584
+ − 817 pSettings->ppo2sensors_calibCoeff[loop] = compensatedRef / pStateReal->lifeData.sensorVoltage_mV[loop];
+ − 818 }
+ − 819 else
+ − 820 {
+ − 821 pSettings->ppo2sensors_calibCoeff[loop] = 0.0;
+ − 822 settingsGetPointer()->ppo2sensors_deactivated |= 0x1 << loop;
+ − 823 }
+ − 824 }
562
+ − 825 }
584
+ − 826 tMenuEdit_newInput(editId, O2_calib_gas, 0, 0, 0);
+ − 827 retVal = UPDATE_DIVESETTINGS;
+ − 828 }
+ − 829 if(action == ACTION_BUTTON_NEXT)
+ − 830 {
+ − 831 if(O2_calib_gas == 21)
+ − 832 {
673
+ − 833 O2_calib_gas = 98;
562
+ − 834 }
584
+ − 835 else
+ − 836 {
+ − 837 O2_calib_gas = 21;
+ − 838 }
+ − 839 }
+ − 840 retVal = O2_calib_gas;
562
+ − 841
584
+ − 842 if(action == ACTION_BUTTON_BACK)
+ − 843 {
+ − 844 exitMenuEditField();
+ − 845 }
+ − 846
+ − 847 return retVal;
562
+ − 848 }
+ − 849
718
+ − 850 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 851 {
+ − 852 return EXIT_TO_INFO_SENSOR;
+ − 853 }
+ − 854
730
+ − 855 uint8_t OnAction_Sensor_Detect(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 856 {
+ − 857 DataEX_setExtInterface_Cmd(EXT_INTERFACE_AUTODETECT);
+ − 858 return UNSPECIFIC_RETURN;
+ − 859 }
718
+ − 860
38
+ − 861 void openEdit_Brightness(void)
+ − 862 {
+ − 863 uint8_t actualBrightness;
+ − 864 SSettings *pSettings = settingsGetPointer();
+ − 865
+ − 866 actualBrightness = pSettings->brightness;
+ − 867 actualBrightness++;
+ − 868 if(actualBrightness > 4)
+ − 869 actualBrightness = 0;
+ − 870 pSettings->brightness = actualBrightness;
+ − 871 exitEditWithUpdate();
+ − 872 }
+ − 873
+ − 874
+ − 875 void buttonBalanceText_helper(uint8_t idOfButton, char *textOutput)
+ − 876 {
+ − 877 uint8_t txtcount = 0;
+ − 878
+ − 879 if(idOfButton < 3)
+ − 880 {
+ − 881 textOutput[txtcount++] = '@' + settingsGetPointer()->buttonBalance[idOfButton];
+ − 882 textOutput[txtcount++] = ' ';
+ − 883 textOutput[txtcount++] = ' ';
+ − 884 textOutput[txtcount++] = '(';
+ − 885
+ − 886 switch(settingsGetPointer()->buttonBalance[idOfButton])
+ − 887 {
+ − 888 case 1:
+ − 889 textOutput[txtcount++] = '-';
+ − 890 textOutput[txtcount++] = '2';
+ − 891 textOutput[txtcount++] = '0';
+ − 892 break;
+ − 893 case 2:
+ − 894 textOutput[txtcount++] = '-';
+ − 895 textOutput[txtcount++] = '1';
+ − 896 textOutput[txtcount++] = '0';
+ − 897 break;
+ − 898 case 3:
+ − 899 default:
+ − 900 textOutput[txtcount++] = '0';
+ − 901 break;
+ − 902 case 4:
+ − 903 textOutput[txtcount++] = '+';
+ − 904 textOutput[txtcount++] = '1';
+ − 905 textOutput[txtcount++] = '0';
+ − 906 break;
+ − 907 case 5:
+ − 908 textOutput[txtcount++] = '+';
+ − 909 textOutput[txtcount++] = '2';
+ − 910 textOutput[txtcount++] = '0';
+ − 911 break;
+ − 912 }
+ − 913 textOutput[txtcount++] = ')';
+ − 914 }
+ − 915 textOutput[txtcount++] = 0;
+ − 916 }
+ − 917
+ − 918 /**#
+ − 919 ******************************************************************************
+ − 920 * @brief BUTTONS
+ − 921 * @author heinrichs weikamp gmbh
+ − 922 * @version V 01
+ − 923 * @date 15-Sept-2016
+ − 924 ******************************************************************************
+ − 925 * Button 0 is right, Button 1 is middle, Button 2 is left !!!!
+ − 926 * 2 1 0 (base value 3)
+ − 927 * Button 3 is used to store the base value, all others are balanced around this one!
+ − 928 *
+ − 929 */
+ − 930
+ − 931 void openEdit_ButtonSens(void)
+ − 932 {
+ − 933 char text[32];
+ − 934 uint8_t sens;
+ − 935 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3};
+ − 936
+ − 937 sens = (uint8_t)settingsGetPointer()->ButtonResponsiveness[3];
+ − 938 write_field_3digit(StMHARD5_Button1, 360, 780, ME_Y_LINE1, &FontT48, "###", sens, 0, 0, 0);
+ − 939
+ − 940 for(int i=2;i>=0;i--)
+ − 941 {
+ − 942 buttonBalanceText_helper(i,text);
+ − 943 write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text);
+ − 944 }
+ − 945
740
+ − 946 snprintf(text,32,"%c",TXT_ButtonLock);
884
+ − 947 write_field_on_off(StMHARD5_ButtonLock, 30, 700, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->buttonLockActive);
38
+ − 948
+ − 949 setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button);
+ − 950
+ − 951 for(int i=2;i>=0;i--)
+ − 952 {
+ − 953 setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance);
+ − 954 }
740
+ − 955 setEvent(StMHARD5_ButtonLock, (uint32_t)OnAction_ButtonLock);
38
+ − 956 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+ − 957 }
+ − 958
+ − 959
+ − 960 void refresh_ButtonValuesFromPIC(void)
+ − 961 {
+ − 962 uint8_t sens[3];
+ − 963 char text[64];
+ − 964
+ − 965 text[0] = '\001';
+ − 966 text[1] = TXT_2BYTE;
+ − 967 text[2] = TXT2BYTE_ButtonSensitivity;
+ − 968 text[3] = 0;
+ − 969 write_topline(text);
+ − 970
+ − 971 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+ − 972
+ − 973 for(int i=0;i<3;i++)
+ − 974 {
+ − 975 text[0] = TXT_2BYTE;
+ − 976 text[1] = TXT2BYTE_ButtonLeft+i;
+ − 977 text[2] = 0;
+ − 978 write_label_var( 20, 300, ME_Y_LINE2+(i*ME_Y_LINE_STEP), &FontT48, text);
+ − 979 }
+ − 980
+ − 981 for(int i=0;i<3;i++)
+ − 982 {
+ − 983 sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]);
+ − 984 }
740
+ − 985 snprintf(text,64,"\020\016\016%c%c \017 (%03u %03u %03u)",TXT_2BYTE,TXT2BYTE_LowerIsLess,sens[2],sens[1],sens[0]);
884
+ − 986 write_label_var( 20, 700, ME_Y_LINE6, &FontT42, text);
38
+ − 987
+ − 988 tMenuEdit_refresh_field(StMHARD5_Button1);
+ − 989 tMenuEdit_refresh_field(StMHARD5_ButtonBalance1);
+ − 990 tMenuEdit_refresh_field(StMHARD5_ButtonBalance2);
+ − 991 tMenuEdit_refresh_field(StMHARD5_ButtonBalance3);
740
+ − 992 tMenuEdit_refresh_field(StMHARD5_ButtonLock);
38
+ − 993 }
+ − 994
+ − 995
+ − 996 uint8_t OnAction_Button(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 997 {
+ − 998 uint8_t digitContentNew, remainder;
+ − 999 uint32_t newSensitivityGlobal;
+ − 1000
+ − 1001 if(action == ACTION_BUTTON_NEXT)
+ − 1002 {
+ − 1003 digitContentNew = digitContent - '0';
92
+ − 1004 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI)
38
+ − 1005 {
92
+ − 1006 digitContentNew = MIN_BUTTONRESPONSIVENESS_GUI;
38
+ − 1007 }
+ − 1008 else
+ − 1009 {
+ − 1010 remainder = digitContentNew%5;
+ − 1011 digitContentNew += 5 - remainder;
92
+ − 1012 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI)
+ − 1013 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI;
38
+ − 1014 }
+ − 1015 return '0' + digitContentNew;
+ − 1016 }
+ − 1017
+ − 1018 if(action == ACTION_BUTTON_BACK)
+ − 1019 {
+ − 1020 digitContentNew = digitContent - '0';
92
+ − 1021 if(digitContentNew <= MIN_BUTTONRESPONSIVENESS_GUI)
+ − 1022 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI;
38
+ − 1023 else
+ − 1024 {
+ − 1025 remainder = digitContentNew%5;
+ − 1026 if(remainder)
+ − 1027 digitContentNew -= remainder;
+ − 1028 else
+ − 1029 digitContentNew -= 5;
+ − 1030 }
+ − 1031 return '0' + digitContentNew;
+ − 1032 }
+ − 1033
+ − 1034 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 1035 {
+ − 1036 evaluateNewString(editId, &newSensitivityGlobal, 0, 0, 0);
+ − 1037 settingsHelperButtonSens_keepPercentageValues(newSensitivityGlobal, settingsGetPointer()->ButtonResponsiveness);
+ − 1038 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness);
+ − 1039 return UNSPECIFIC_RETURN;
+ − 1040 }
+ − 1041 return digitContent;
+ − 1042 }
+ − 1043
+ − 1044
+ − 1045 uint8_t OnAction_ButtonBalance(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 1046 {
+ − 1047 int8_t idBalance = -1;
+ − 1048 uint8_t *ptrSetting;
+ − 1049 char text[32];
+ − 1050
+ − 1051 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3};
+ − 1052
+ − 1053 idBalance = -1;
+ − 1054 for(int i=0;i<3;i++)
+ − 1055 {
+ − 1056 if(editId == eventListButtonBalance[i])
+ − 1057 {
+ − 1058 idBalance = i;
+ − 1059 break;
+ − 1060 }
+ − 1061 }
+ − 1062
+ − 1063 if((idBalance >= 0) && (idBalance < 3))
+ − 1064 {
+ − 1065 ptrSetting = &settingsGetPointer()->buttonBalance[idBalance];
+ − 1066
+ − 1067 *ptrSetting += 1;
+ − 1068
+ − 1069 if(*ptrSetting > 5)
+ − 1070 *ptrSetting = 2;
+ − 1071
+ − 1072 buttonBalanceText_helper(idBalance,text);
+ − 1073 tMenuEdit_newButtonText(eventListButtonBalance[idBalance],text);
+ − 1074 }
+ − 1075
+ − 1076 return UNSPECIFIC_RETURN;
+ − 1077 }
740
+ − 1078
+ − 1079 uint8_t OnAction_ButtonLock(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 1080 {
+ − 1081 SSettings *pSettings = settingsGetPointer();
+ − 1082
+ − 1083 if(pSettings->buttonLockActive)
+ − 1084 {
+ − 1085 pSettings->buttonLockActive = 0;
+ − 1086 tMenuEdit_set_on_off(editId, 0);
+ − 1087 }
+ − 1088 else
+ − 1089 {
+ − 1090 pSettings->buttonLockActive = 1;
+ − 1091 tMenuEdit_set_on_off(editId, 1);
+ − 1092 }
+ − 1093
+ − 1094 return UNSPECIFIC_RETURN;
+ − 1095 }