Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditHardware.c @ 110:cc8e24374b83 FlipDisplay
Added option to handled mirrored display to existing functions
| author | Ideenmodellierer |
|---|---|
| date | Tue, 01 Jan 2019 21:02:17 +0100 |
| parents | 5f11787b4f42 |
| children | 3834b6272ee5 |
| rev | line source |
|---|---|
| 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" | |
| 31 | |
| 32 //#include "bonex4.h" | |
| 33 #include "externCPU2bootloader.h" | |
| 34 #include "gfx_fonts.h" | |
| 35 #include "ostc.h" | |
| 36 #include "tCCR.h" | |
| 37 #include "tMenuEdit.h" | |
| 38 | |
| 39 /* Private function prototypes -----------------------------------------------*/ | |
| 40 void openEdit_Bluetooth(void); | |
| 41 void openEdit_Compass(void); | |
| 42 void openEdit_O2Sensors(void); | |
| 43 void openEdit_Brightness(void); | |
| 44 //void openEdit_Luftintegration(void); | |
| 45 void openEdit_ButtonSens(void); | |
| 46 void openEdit_ScooterControl(void); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
47 void openEdit_FlipDisplay(void); |
| 38 | 48 |
| 49 /* Announced function prototypes -----------------------------------------------*/ | |
| 50 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 51 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 52 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 53 //uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 54 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 55 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 56 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 57 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 58 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 59 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 60 uint8_t OnAction_ScooterDrag (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 61 uint8_t OnAction_ScooterLoad (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 62 uint8_t OnAction_ScooterBatt (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 63 // nicht notwending uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 64 // nicht notwending uint8_t OnAction_ScooterControl (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 65 | |
| 66 /* Exported functions --------------------------------------------------------*/ | |
| 67 | |
| 68 void openEdit_Hardware(uint8_t line) | |
| 69 { | |
| 70 set_globalState_Menu_Line(line); | |
| 71 resetMenuEdit(CLUT_MenuPageHardware); | |
| 72 | |
| 73 switch(line) | |
| 74 { | |
| 75 case 1: | |
| 76 default: | |
| 77 openEdit_Bluetooth(); | |
| 78 break; | |
| 79 case 2: | |
| 80 openEdit_Compass(); | |
| 81 break; | |
| 82 case 3: | |
| 83 openEdit_O2Sensors(); | |
| 84 break; | |
| 85 case 4: | |
| 86 openEdit_Brightness(); | |
| 87 break; | |
| 88 case 5: | |
| 89 openEdit_ButtonSens(); | |
| 90 break; | |
| 91 case 6: | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
92 if(getLicence() == LICENCEBONEX) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
93 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
94 openEdit_ScooterControl(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
95 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
96 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
97 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
98 openEdit_FlipDisplay(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
99 } |
| 38 | 100 break; |
| 101 } | |
| 102 } | |
| 103 | |
| 104 /* Private functions ---------------------------------------------------------*/ | |
| 105 void openEdit_Bluetooth(void) | |
| 106 { | |
| 107 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */ | |
| 108 | |
| 109 SSettings *pSettings = settingsGetPointer(); | |
| 110 | |
| 111 if(pSettings->bluetoothActive == 0) | |
| 112 { | |
| 113 pSettings->bluetoothActive = 1; | |
| 114 MX_Bluetooth_PowerOn(); | |
| 115 } | |
| 116 else | |
| 117 { | |
| 118 pSettings->bluetoothActive = 0; | |
| 119 MX_Bluetooth_PowerOff(); | |
| 120 } | |
| 121 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); | |
| 122 } | |
| 123 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
124 void openEdit_FlipDisplay(void) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
125 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
126 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
127 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
128 SSettings *pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
129 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
130 if(pSettings->FlipDisplay == 0) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
131 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
132 pSettings->FlipDisplay = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
133 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
134 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
135 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
136 pSettings->FlipDisplay = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
137 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
138 /* reinit all views */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
139 tHome_init(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
140 tI_init(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
141 tM_init(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
142 tMenuEdit_init(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
143 tInfoLog_init(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
144 tM_build_pages(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
145 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
146 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
147 exitEditWithUpdate(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
148 exitMenuEdit_to_Home(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
149 } |
| 38 | 150 /* |
| 151 void refresh_ScooterControl(void) | |
| 152 { | |
| 153 char text[256]; | |
| 154 | |
| 155 text[0] = '\001'; | |
| 156 text[1] = TXT_2BYTE; | |
| 157 text[2] = TXT2BYTE_ScooterSetup; | |
| 158 text[3] = 0; | |
| 159 write_topline(text); | |
| 160 | |
| 161 // drag | |
| 162 text[0] = TXT_2BYTE; | |
| 163 text[1] = TXT2BYTE_ScooterDrag; | |
| 164 text[2] = 0; | |
| 165 write_label_var( 30, 180, ME_Y_LINE1, &FontT48, text); | |
| 166 // load | |
| 167 text[0] = TXT_2BYTE; | |
| 168 text[1] = TXT2BYTE_ScooterLoad; | |
| 169 text[2] = 0; | |
| 170 write_label_var( 30, 180, ME_Y_LINE2, &FontT48, text); | |
| 171 // batt type | |
| 172 text[0] = TXT_2BYTE; | |
| 173 text[1] = TXT2BYTE_ScooterBattTyp; | |
| 174 text[2] = 0; | |
| 175 write_label_var( 30, 180, ME_Y_LINE3, &FontT48, text); | |
| 176 | |
| 177 // drag | |
| 178 text[0] = TXT_2BYTE; | |
| 179 text[1] = 0; | |
| 180 text[2] = 0; | |
| 181 switch(settingsGetPointer()->scooterDrag) | |
| 182 { | |
| 183 case 0: | |
| 184 text[1] = TXT2BYTE_ScooterD0Apnoe; | |
| 185 break; | |
| 186 case 1: | |
| 187 text[1] = TXT2BYTE_ScooterD1Scuba; | |
| 188 break; | |
| 189 case 2: | |
| 190 text[1] = TXT2BYTE_ScooterD2Tech; | |
| 191 break; | |
| 192 case 3: | |
| 193 text[1] = TXT2BYTE_ScooterD3Heavy; | |
| 194 break; | |
| 195 default: | |
| 196 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterDrag); | |
| 197 break; | |
| 198 } | |
| 199 write_label_var( 200, 700, ME_Y_LINE1, &FontT48, text); | |
| 200 | |
| 201 // load | |
| 202 text[0] = TXT_2BYTE; | |
| 203 text[1] = 0; | |
| 204 text[2] = 0; | |
| 205 switch(settingsGetPointer()->scooterLoad) | |
| 206 { | |
| 207 case 0: | |
| 208 text[1] = TXT2BYTE_ScooterL0None; | |
| 209 break; | |
| 210 case 1: | |
| 211 text[1] = TXT2BYTE_ScooterL1Small; | |
| 212 break; | |
| 213 case 2: | |
| 214 text[1] = TXT2BYTE_ScooterL2Stages; | |
| 215 break; | |
| 216 case 3: | |
| 217 text[1] = TXT2BYTE_ScooterL3Full; | |
| 218 break; | |
| 219 case 4: | |
| 220 text[1] = TXT2BYTE_ScooterL4Towing; | |
| 221 break; | |
| 222 default: | |
| 223 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterLoad); | |
| 224 break; | |
| 225 } | |
| 226 write_label_var( 200, 700, ME_Y_LINE2, &FontT48, text); | |
| 227 | |
| 228 //batt type | |
| 229 | |
| 230 // txtptr = 0; | |
| 231 // txtptr += bo4GetBatteryName(text,settingsGetPointer()->scooterBattType); | |
| 232 // txtptr += snprintf(&text[txtptr],10," (%0.1f V)",bo4GetBatteryVoltage(settingsGetPointer()->scooterBattType)); | |
| 233 // write_label_var( 200, 700, ME_Y_LINE3, &FontT48, text); | |
| 234 } | |
| 235 */ | |
| 236 | |
| 237 void getButtonText_ScooterControl(char *text, uint8_t * pointer) | |
| 238 { | |
| 239 | |
| 240 if((pointer != &settingsGetPointer()->scooterLoad) && (pointer != &settingsGetPointer()->scooterDrag)) | |
| 241 return; | |
| 242 | |
| 243 text[0] = TXT_2BYTE; | |
| 244 text[1] = 0; | |
| 245 text[2] = 0; | |
| 246 | |
| 247 // drag | |
| 248 if(pointer == &settingsGetPointer()->scooterDrag) | |
| 249 { | |
| 250 switch(settingsGetPointer()->scooterDrag) | |
| 251 { | |
| 252 case 0: | |
| 253 text[1] = TXT2BYTE_ScooterD0Apnoe; | |
| 254 break; | |
| 255 case 1: | |
| 256 text[1] = TXT2BYTE_ScooterD1Scuba; | |
| 257 break; | |
| 258 case 2: | |
| 259 text[1] = TXT2BYTE_ScooterD2Tech; | |
| 260 break; | |
| 261 case 3: | |
| 262 text[1] = TXT2BYTE_ScooterD3Heavy; | |
| 263 break; | |
| 264 default: | |
| 265 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterDrag); | |
| 266 break; | |
| 267 } | |
| 268 } | |
| 269 else // load | |
| 270 if(pointer == &settingsGetPointer()->scooterLoad) | |
| 271 { | |
| 272 | |
| 273 switch(settingsGetPointer()->scooterLoad) | |
| 274 { | |
| 275 case 0: | |
| 276 text[1] = TXT2BYTE_ScooterL0None; | |
| 277 break; | |
| 278 case 1: | |
| 279 text[1] = TXT2BYTE_ScooterL1Small; | |
| 280 break; | |
| 281 case 2: | |
| 282 text[1] = TXT2BYTE_ScooterL2Stages; | |
| 283 break; | |
| 284 case 3: | |
| 285 text[1] = TXT2BYTE_ScooterL3Full; | |
| 286 break; | |
| 287 case 4: | |
| 288 text[1] = TXT2BYTE_ScooterL4Towing; | |
| 289 break; | |
| 290 default: | |
| 291 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterLoad); | |
| 292 break; | |
| 293 } | |
| 294 } | |
| 295 } | |
| 296 | |
| 297 | |
| 298 void openEdit_ScooterControl(void) | |
| 299 { | |
| 300 char text[256]; | |
| 301 uint16_t battWh; | |
| 302 | |
| 303 text[0] = '\001'; | |
| 304 text[1] = TXT_2BYTE; | |
| 305 text[2] = TXT2BYTE_ScooterSetup; | |
| 306 text[3] = 0; | |
| 307 write_topline(text); | |
| 308 | |
| 309 // drag | |
| 310 text[0] = TXT_2BYTE; | |
| 311 text[1] = TXT2BYTE_ScooterDrag; | |
| 312 text[2] = 0; | |
| 313 write_label_var( 30, 180, ME_Y_LINE1, &FontT48, text); | |
| 314 // load | |
| 315 text[0] = TXT_2BYTE; | |
| 316 text[1] = TXT2BYTE_ScooterLoad; | |
| 317 text[2] = 0; | |
| 318 write_label_var( 30, 180, ME_Y_LINE2, &FontT48, text); | |
| 319 // batt type | |
| 320 text[0] = TXT_2BYTE; | |
| 321 text[1] = TXT2BYTE_ScooterBattTyp; | |
| 322 text[2] = 0; | |
| 323 write_label_var( 30, 180, ME_Y_LINE3, &FontT48, text); | |
| 324 | |
| 325 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterDrag); | |
| 326 write_field_button(StMHARD6_ScooterDrag, 200, 770, ME_Y_LINE1, &FontT48, text); | |
| 327 | |
| 328 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterLoad); | |
| 329 write_field_button(StMHARD6_ScooterLoad, 200, 770, ME_Y_LINE2, &FontT48, text); | |
| 330 | |
| 331 battWh = settingsGetPointer()->scooterBattSize; | |
| 332 write_field_udigit(StMHARD6_ScooterBatt, 200, 770, ME_Y_LINE3, &FontT48, "####\016\016 Wh\017", battWh, 0, 0, 0); | |
| 333 | |
| 334 setEvent(StMHARD6_ScooterDrag, (uint32_t)OnAction_ScooterDrag); | |
| 335 setEvent(StMHARD6_ScooterLoad, (uint32_t)OnAction_ScooterLoad); | |
| 336 setEvent(StMHARD6_ScooterBatt, (uint32_t)OnAction_ScooterBatt); | |
| 337 | |
| 338 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 339 } | |
| 340 | |
| 341 | |
| 342 uint8_t OnAction_ScooterDrag(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 343 { | |
| 344 char text[256]; | |
| 345 | |
| 346 settingsGetPointer()->scooterDrag = settingsGetPointer()->scooterDrag + 1; | |
| 347 if(settingsGetPointer()->scooterDrag > 3) | |
| 348 settingsGetPointer()->scooterDrag = 0; | |
| 349 | |
| 350 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterDrag); | |
| 351 tMenuEdit_newButtonText(editId, text); | |
| 352 | |
| 353 return UPDATE_DIVESETTINGS; | |
| 354 } | |
| 355 | |
| 356 | |
| 357 uint8_t OnAction_ScooterLoad(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 358 { | |
| 359 char text[256]; | |
| 360 | |
| 361 settingsGetPointer()->scooterLoad = settingsGetPointer()->scooterLoad + 1; | |
| 362 if(settingsGetPointer()->scooterLoad > 4) | |
| 363 settingsGetPointer()->scooterLoad = 0; | |
| 364 | |
| 365 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterLoad); | |
| 366 tMenuEdit_newButtonText(editId, text); | |
| 367 | |
| 368 return UPDATE_DIVESETTINGS; | |
| 369 } | |
| 370 | |
| 371 | |
| 372 uint8_t OnAction_ScooterBatt(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 373 { | |
| 374 uint8_t digitContentNew; | |
| 375 uint32_t newWh; | |
| 376 | |
| 377 if(action == ACTION_BUTTON_ENTER) | |
| 378 { | |
| 379 return digitContent; | |
| 380 } | |
| 381 if(action == ACTION_BUTTON_ENTER_FINAL) | |
| 382 { | |
| 383 evaluateNewString(editId, &newWh, 0, 0, 0); | |
| 384 | |
| 385 if(newWh < 300) | |
| 386 newWh = 300; | |
| 387 if(newWh > 5000) | |
| 388 newWh = 5000; | |
| 389 | |
| 390 tMenuEdit_newInput(editId, newWh, 0, 0, 0); | |
| 391 settingsGetPointer()->scooterBattSize = newWh; | |
| 392 return UPDATE_DIVESETTINGS; | |
| 393 } | |
| 394 if(action == ACTION_BUTTON_NEXT) | |
| 395 { | |
| 396 digitContentNew = digitContent + 1; | |
| 397 if(digitNumber == 0) | |
| 398 { | |
| 399 if(digitContentNew > '5') | |
| 400 digitContentNew = '0'; | |
| 401 } | |
| 402 else if(digitContentNew > '9') | |
| 403 digitContentNew = '0'; | |
| 404 return digitContentNew; | |
| 405 } | |
| 406 if(action == ACTION_BUTTON_BACK) | |
| 407 { | |
| 408 digitContentNew = digitContent - 1; | |
| 409 if(digitNumber == 0) | |
| 410 { | |
| 411 if(digitContentNew < '0') | |
| 412 digitContentNew = '5'; | |
| 413 } | |
| 414 else if(digitContentNew < '0') | |
| 415 digitContentNew = '9'; | |
| 416 return digitContentNew; | |
| 417 } | |
| 418 return UNSPECIFIC_RETURN; | |
| 419 } | |
| 420 | |
| 421 | |
| 422 void refresh_CompassEdit(void) | |
| 423 { | |
| 424 uint16_t heading; | |
| 425 char text[32]; | |
| 426 | |
| 427 text[0] = '\001'; | |
| 428 text[1] = TXT_2BYTE; | |
| 429 text[2] = TXT2BYTE_Compass; | |
| 430 text[3] = 0; | |
| 431 write_topline(text); | |
| 432 | |
| 433 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
| 434 snprintf(text,32,"\001%03i`",heading); | |
| 435 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
| 436 | |
| 437 tMenuEdit_refresh_field(StMHARD2_Compass_SetCourse); | |
| 438 tMenuEdit_refresh_field(StMHARD2_Compass_Calibrate); | |
| 439 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); | |
| 440 | |
| 441 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 442 } | |
| 443 | |
| 444 | |
| 445 void openEdit_Compass(void) | |
| 446 { | |
| 447 char text[4]; | |
| 448 | |
| 449 text[0] = '\001'; | |
| 450 text[1] = TXT_2BYTE; | |
| 451 text[2] = TXT2BYTE_Compass; | |
| 452 text[3] = 0; | |
| 453 write_topline(text); | |
| 454 | |
| 455 text[0] = TXT_2BYTE; | |
| 456 text[2] = 0; | |
| 457 | |
| 458 text[1] = TXT2BYTE_SetBearing; | |
| 459 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
| 460 | |
| 461 text[1] = TXT2BYTE_CompassCalib; | |
| 462 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE3, &FontT48, text); | |
| 463 | |
| 464 text[1] = TXT2BYTE_ResetBearing; | |
| 465 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE4, &FontT48, text); | |
| 466 | |
| 467 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); | |
| 468 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
| 469 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
| 470 | |
| 471 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 472 } | |
| 473 | |
| 474 | |
| 475 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 476 { | |
| 477 calibrateCompass(); | |
| 478 return EXIT_TO_INFO_COMPASS; | |
| 479 } | |
| 480 | |
| 481 | |
| 482 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 483 { | |
| 484 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
| 485 if(settingsGetPointer()->compassBearing == 0) | |
| 486 settingsGetPointer()->compassBearing = 360; | |
| 487 return UPDATE_AND_EXIT_TO_MENU; | |
| 488 } | |
| 489 | |
| 490 | |
| 491 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 492 { | |
| 493 settingsGetPointer()->compassBearing = 0; | |
| 494 return UPDATE_AND_EXIT_TO_MENU; | |
| 495 } | |
| 496 | |
| 497 /* | |
| 498 uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 499 { | |
| 500 return EXIT_TO_MENU; | |
| 501 } | |
| 502 */ | |
| 503 | |
| 504 void refresh_O2Sensors(void) | |
| 505 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
506 char text[16]; |
| 38 | 507 uint16_t y_line; |
| 508 | |
| 509 text[0] = '\001'; | |
| 510 text[1] = TXT_o2Sensors; | |
| 511 text[2] = 0; | |
| 512 write_topline(text); | |
| 513 | |
| 514 | |
| 515 text[0] = TXT_2BYTE; | |
| 516 text[1] = TXT2BYTE_Sensor; | |
| 517 text[2] = ' '; | |
| 518 text[3] = '1'; | |
| 519 text[4] = 0; | |
| 520 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); | |
| 521 text[3] = '2'; | |
| 522 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); | |
| 523 text[3] = '3'; | |
| 524 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | |
| 525 | |
| 526 text[0] = TXT_2BYTE; | |
| 527 text[1] = TXT2BYTE_HUDbattery; | |
| 528 text[2] = 0; | |
| 529 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
| 530 // write_label_var( 30, 340, ME_Y_LINE4, &FontT48, "HUD Battery"); | |
| 531 | |
| 532 for(int i=0;i<3;i++) | |
| 533 { | |
| 534 snprintf(text, 20,"%01.2f, %01.1fmV",get_ppO2Sensor_bar(i),get_sensorVoltage_mV(i)); | |
| 535 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
| 536 write_label_var( 400, 800, y_line, &FontT48, text); | |
| 537 } | |
| 538 | |
| 539 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | |
| 540 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
| 541 | |
| 542 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
| 543 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
| 544 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
| 545 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); | |
| 546 | |
| 547 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 548 } | |
| 549 | |
| 550 | |
| 551 void openEdit_O2Sensors(void) | |
| 552 { | |
| 553 char text[2]; | |
| 554 uint8_t sensorActive[3]; | |
| 555 | |
| 556 sensorActive[0] = 1; | |
| 557 sensorActive[1] = 1; | |
| 558 sensorActive[2] = 1; | |
| 559 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
| 560 sensorActive[0] = 0; | |
| 561 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
| 562 sensorActive[1] = 0; | |
| 563 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
| 564 sensorActive[2] = 0; | |
| 565 | |
| 566 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | |
| 567 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | |
| 568 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | |
| 569 | |
| 570 text[0] = TXT_Fallback; | |
| 571 text[1] = 1; | |
| 572 write_field_on_off(StMHARD3_O2_Fallback, 30, 500, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->fallbackToFixedSetpoint); | |
| 573 | |
| 574 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | |
| 575 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | |
| 576 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | |
| 577 setEvent(StMHARD3_O2_Fallback, (uint32_t)OnAction_O2_Fallback); | |
| 578 | |
| 579 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 580 } | |
| 581 | |
| 582 | |
| 583 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 584 { | |
| 585 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
| 586 { | |
| 587 settingsGetPointer()->ppo2sensors_deactivated &= 4+2; | |
| 588 tMenuEdit_set_on_off(editId, 1); | |
| 589 } | |
| 590 else | |
| 591 { | |
| 592 settingsGetPointer()->ppo2sensors_deactivated |= 1; | |
| 593 tMenuEdit_set_on_off(editId, 0); | |
| 594 } | |
| 595 | |
| 596 return UPDATE_DIVESETTINGS; | |
| 597 } | |
| 598 | |
| 599 | |
| 600 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 601 { | |
| 602 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
| 603 { | |
| 604 settingsGetPointer()->ppo2sensors_deactivated &= 4+1; | |
| 605 tMenuEdit_set_on_off(editId, 1); | |
| 606 } | |
| 607 else | |
| 608 { | |
| 609 settingsGetPointer()->ppo2sensors_deactivated |= 2; | |
| 610 tMenuEdit_set_on_off(editId, 0); | |
| 611 } | |
| 612 | |
| 613 return UPDATE_DIVESETTINGS; | |
| 614 } | |
| 615 | |
| 616 | |
| 617 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 618 { | |
| 619 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
| 620 { | |
| 621 settingsGetPointer()->ppo2sensors_deactivated &= 2+1; | |
| 622 tMenuEdit_set_on_off(editId, 1); | |
| 623 } | |
| 624 else | |
| 625 { | |
| 626 settingsGetPointer()->ppo2sensors_deactivated |= 4; | |
| 627 tMenuEdit_set_on_off(editId, 0); | |
| 628 } | |
| 629 | |
| 630 return UPDATE_DIVESETTINGS; | |
| 631 } | |
| 632 | |
| 633 | |
| 634 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 635 { | |
| 636 uint8_t fallback = settingsGetPointer()->fallbackToFixedSetpoint; | |
| 637 | |
| 638 if(fallback) | |
| 639 fallback = 0; | |
| 640 else | |
| 641 fallback = 1; | |
| 642 | |
| 643 settingsGetPointer()->fallbackToFixedSetpoint = fallback; | |
| 644 tMenuEdit_set_on_off(editId, fallback); | |
| 645 return UPDATE_DIVESETTINGS; | |
| 646 } | |
| 647 | |
| 648 | |
| 649 void openEdit_Brightness(void) | |
| 650 { | |
| 651 uint8_t actualBrightness; | |
| 652 SSettings *pSettings = settingsGetPointer(); | |
| 653 | |
| 654 actualBrightness = pSettings->brightness; | |
| 655 actualBrightness++; | |
| 656 if(actualBrightness > 4) | |
| 657 actualBrightness = 0; | |
| 658 pSettings->brightness = actualBrightness; | |
| 659 exitEditWithUpdate(); | |
| 660 } | |
| 661 | |
| 662 | |
| 663 void buttonBalanceText_helper(uint8_t idOfButton, char *textOutput) | |
| 664 { | |
| 665 uint8_t txtcount = 0; | |
| 666 | |
| 667 if(idOfButton < 3) | |
| 668 { | |
| 669 textOutput[txtcount++] = '@' + settingsGetPointer()->buttonBalance[idOfButton]; | |
| 670 textOutput[txtcount++] = ' '; | |
| 671 textOutput[txtcount++] = ' '; | |
| 672 textOutput[txtcount++] = '('; | |
| 673 | |
| 674 switch(settingsGetPointer()->buttonBalance[idOfButton]) | |
| 675 { | |
| 676 case 1: | |
| 677 textOutput[txtcount++] = '-'; | |
| 678 textOutput[txtcount++] = '2'; | |
| 679 textOutput[txtcount++] = '0'; | |
| 680 break; | |
| 681 case 2: | |
| 682 textOutput[txtcount++] = '-'; | |
| 683 textOutput[txtcount++] = '1'; | |
| 684 textOutput[txtcount++] = '0'; | |
| 685 break; | |
| 686 case 3: | |
| 687 default: | |
| 688 textOutput[txtcount++] = '0'; | |
| 689 break; | |
| 690 case 4: | |
| 691 textOutput[txtcount++] = '+'; | |
| 692 textOutput[txtcount++] = '1'; | |
| 693 textOutput[txtcount++] = '0'; | |
| 694 break; | |
| 695 case 5: | |
| 696 textOutput[txtcount++] = '+'; | |
| 697 textOutput[txtcount++] = '2'; | |
| 698 textOutput[txtcount++] = '0'; | |
| 699 break; | |
| 700 } | |
| 701 textOutput[txtcount++] = ')'; | |
| 702 } | |
| 703 textOutput[txtcount++] = 0; | |
| 704 } | |
| 705 | |
| 706 /**# | |
| 707 ****************************************************************************** | |
| 708 * @brief BUTTONS | |
| 709 * @author heinrichs weikamp gmbh | |
| 710 * @version V 01 | |
| 711 * @date 15-Sept-2016 | |
| 712 ****************************************************************************** | |
| 713 * Button 0 is right, Button 1 is middle, Button 2 is left !!!! | |
| 714 * 2 1 0 (base value 3) | |
| 715 * Button 3 is used to store the base value, all others are balanced around this one! | |
| 716 * | |
| 717 */ | |
| 718 | |
| 719 void openEdit_ButtonSens(void) | |
| 720 { | |
| 721 char text[32]; | |
| 722 uint8_t sens; | |
| 723 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
| 724 | |
| 725 sens = (uint8_t)settingsGetPointer()->ButtonResponsiveness[3]; | |
| 726 write_field_3digit(StMHARD5_Button1, 360, 780, ME_Y_LINE1, &FontT48, "###", sens, 0, 0, 0); | |
| 727 | |
| 728 for(int i=2;i>=0;i--) | |
| 729 { | |
| 730 buttonBalanceText_helper(i,text); | |
| 731 write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text); | |
| 732 } | |
| 733 | |
| 734 | |
| 735 setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button); | |
| 736 | |
| 737 for(int i=2;i>=0;i--) | |
| 738 { | |
| 739 setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance); | |
| 740 } | |
| 741 | |
| 742 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 743 } | |
| 744 | |
| 745 | |
| 746 void refresh_ButtonValuesFromPIC(void) | |
| 747 { | |
| 748 uint8_t sens[3]; | |
| 749 char text[64]; | |
| 750 | |
| 751 text[0] = '\001'; | |
| 752 text[1] = TXT_2BYTE; | |
| 753 text[2] = TXT2BYTE_ButtonSensitivity; | |
| 754 text[3] = 0; | |
| 755 write_topline(text); | |
| 756 | |
| 757 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
| 758 | |
| 759 text[0] = '\020'; // '\021'; | |
| 760 text[1] = TXT_2BYTE; | |
| 761 text[2] = TXT2BYTE_LowerIsLess; | |
| 762 text[3] = 0; | |
| 763 write_label_var( 20, 780, ME_Y_LINE5, &FontT42, text); | |
| 764 | |
| 765 for(int i=0;i<3;i++) | |
| 766 { | |
| 767 text[0] = TXT_2BYTE; | |
| 768 text[1] = TXT2BYTE_ButtonLeft+i; | |
| 769 text[2] = 0; | |
| 770 write_label_var( 20, 300, ME_Y_LINE2+(i*ME_Y_LINE_STEP), &FontT48, text); | |
| 771 } | |
| 772 | |
| 773 for(int i=0;i<3;i++) | |
| 774 { | |
| 775 sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]); | |
| 776 } | |
| 777 snprintf(text,64,"(%03u %03u %03u)",sens[2],sens[1],sens[0]); | |
| 778 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
| 779 | |
| 780 tMenuEdit_refresh_field(StMHARD5_Button1); | |
| 781 tMenuEdit_refresh_field(StMHARD5_ButtonBalance1); | |
| 782 tMenuEdit_refresh_field(StMHARD5_ButtonBalance2); | |
| 783 tMenuEdit_refresh_field(StMHARD5_ButtonBalance3); | |
| 784 } | |
| 785 | |
| 786 | |
| 787 uint8_t OnAction_Button(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 788 { | |
| 789 uint8_t digitContentNew, remainder; | |
| 790 uint32_t newSensitivityGlobal; | |
| 791 | |
| 792 if(action == ACTION_BUTTON_NEXT) | |
| 793 { | |
| 794 digitContentNew = digitContent - '0'; | |
| 795 if(digitContentNew >= 110) | |
| 796 { | |
| 797 digitContentNew = 70; | |
| 798 } | |
| 799 else | |
| 800 { | |
| 801 remainder = digitContentNew%5; | |
| 802 digitContentNew += 5 - remainder; | |
| 803 if(digitContentNew >= 110) | |
| 804 digitContentNew = 110; | |
| 805 } | |
| 806 return '0' + digitContentNew; | |
| 807 } | |
| 808 | |
| 809 if(action == ACTION_BUTTON_BACK) | |
| 810 { | |
| 811 digitContentNew = digitContent - '0'; | |
| 812 if(digitContentNew <= 70) | |
| 813 digitContentNew = 110; | |
| 814 else | |
| 815 { | |
| 816 remainder = digitContentNew%5; | |
| 817 if(remainder) | |
| 818 digitContentNew -= remainder; | |
| 819 else | |
| 820 digitContentNew -= 5; | |
| 821 } | |
| 822 return '0' + digitContentNew; | |
| 823 } | |
| 824 | |
| 825 if(action == ACTION_BUTTON_ENTER_FINAL) | |
| 826 { | |
| 827 evaluateNewString(editId, &newSensitivityGlobal, 0, 0, 0); | |
| 828 settingsHelperButtonSens_keepPercentageValues(newSensitivityGlobal, settingsGetPointer()->ButtonResponsiveness); | |
| 829 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | |
| 830 return UNSPECIFIC_RETURN; | |
| 831 } | |
| 832 return digitContent; | |
| 833 } | |
| 834 | |
| 835 | |
| 836 uint8_t OnAction_ButtonBalance(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 837 { | |
| 838 int8_t idBalance = -1; | |
| 839 uint8_t *ptrSetting; | |
| 840 char text[32]; | |
| 841 | |
| 842 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
| 843 | |
| 844 idBalance = -1; | |
| 845 for(int i=0;i<3;i++) | |
| 846 { | |
| 847 if(editId == eventListButtonBalance[i]) | |
| 848 { | |
| 849 idBalance = i; | |
| 850 break; | |
| 851 } | |
| 852 } | |
| 853 | |
| 854 if((idBalance >= 0) && (idBalance < 3)) | |
| 855 { | |
| 856 ptrSetting = &settingsGetPointer()->buttonBalance[idBalance]; | |
| 857 | |
| 858 *ptrSetting += 1; | |
| 859 | |
| 860 if(*ptrSetting > 5) | |
| 861 *ptrSetting = 2; | |
| 862 | |
| 863 buttonBalanceText_helper(idBalance,text); | |
| 864 tMenuEdit_newButtonText(eventListButtonBalance[idBalance],text); | |
| 865 } | |
| 866 | |
| 867 return UNSPECIFIC_RETURN; | |
| 868 } |
