comparison Discovery/Src/tMenuEditHardware.c @ 730:9c65d226f4f6

Update sensor menu support for automatic sensor detection: In previous version the three ppo2 sensor slots were always displayed with digital sensor hard mapped to channel 0 in case a digital sensor is available. The new function is able to merge the available sensors into one view and can hide unused slots.
author Ideenmodellierer
date Sat, 14 Jan 2023 20:49:40 +0100
parents f285424f04d9
children 190e5814b2f5
comparison
equal deleted inserted replaced
729:d646a0f724a7 730:9c65d226f4f6
62 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 62 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
63 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 63 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
64 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 64 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 65 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
66 uint8_t OnAction_Sensor_Info (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 66 uint8_t OnAction_Sensor_Info (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
67 uint8_t OnAction_Sensor_Detect (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
67 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 68 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
68 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 69 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
69 // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 70 // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
70 71
71 /* Exported functions --------------------------------------------------------*/ 72 /* Exported functions --------------------------------------------------------*/
285 } 286 }
286 */ 287 */
287 288
288 void refresh_O2Sensors(void) 289 void refresh_O2Sensors(void)
289 { 290 {
291 static uint8_t stableMapCntDown = 10;
290 char text[32]; 292 char text[32];
291 uint16_t y_line; 293 uint16_t y_line;
294 uint8_t index = 0;
292 295
293 const SDiveState *pStateReal = stateRealGetPointer(); 296 const SDiveState *pStateReal = stateRealGetPointer();
294 297 SSettings *pSettings = settingsGetPointer();
295 298
296 299 // if((pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_OPTIC))
300 {
301 if(memcmp(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, 5) != 0)
302 {
303 if(stableMapCntDown == 0)
304 {
305 stableMapCntDown = 10;
306 memcpy(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, 5);
307 pSettings->ppo2sensors_deactivated = 0x0; /* deactivation will be done by openEditO2Sensor if need */
308 openEdit_O2Sensors();
309 }
310 else
311 {
312 stableMapCntDown--;
313 }
314 }
315 }
316 #if 0 /*TODO: reactivate sensor information dialog */
297 if((pStateReal->lifeData.extIf_sensor_Id != 0) && (haveSensorInfo == 0)) /* the sensor is detected after the interface has been selected => add button if info become available */ 317 if((pStateReal->lifeData.extIf_sensor_Id != 0) && (haveSensorInfo == 0)) /* the sensor is detected after the interface has been selected => add button if info become available */
298 { 318 {
299 if(get_globalState() == StMHARD3_O2_Source) 319 if(get_globalState() == StMHARD3_O2_Source)
300 { 320 {
301 y_line = 5; 321 y_line = 5;
306 { 326 {
307 tMenuEdit_select(StMHARD3_O2_Source); 327 tMenuEdit_select(StMHARD3_O2_Source);
308 } 328 }
309 } 329 }
310 else 330 else
331 #endif
311 { 332 {
312 if(pStateReal->lifeData.extIf_sensor_Id == 0) 333 if(pStateReal->lifeData.extIf_sensor_Id == 0)
313 { 334 {
314 haveSensorInfo = 0; 335 haveSensorInfo = 0;
315 } 336 }
323 text[0] = TXT_2BYTE; 344 text[0] = TXT_2BYTE;
324 text[1] = TXT2BYTE_Sensor; 345 text[1] = TXT2BYTE_Sensor;
325 text[2] = ' '; 346 text[2] = ' ';
326 text[3] = '1'; 347 text[3] = '1';
327 text[4] = 0; 348 text[4] = 0;
328 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); 349
329 text[3] = '2'; 350
330 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); 351 for(index = 0; index < 3; index++)
331 text[3] = '3'; 352 {
332 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); 353 text[3] = '1' + index;
333 354 if((pSettings->ext_sensor_map[index] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[index] == SENSOR_DIGO2))
334 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) 355 {
356 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, text);
357 }
358 if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
359 {
360 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, "CO2");
361 }
362 }
363
364 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
335 { 365 {
336 text[0] = TXT_2BYTE; 366 text[0] = TXT_2BYTE;
337 text[1] = TXT2BYTE_HUDbattery; 367 text[1] = TXT2BYTE_HUDbattery;
338 text[2] = 0; 368 text[2] = 0;
339 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); 369 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text);
340 370
341
342 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); 371 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V());
343 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); 372 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text);
344 } 373 }
345 else 374 else
346 { 375 {
347 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) 376 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))
348 { 377 {
349 text[0] = TXT_2BYTE; 378 text[0] = TXT_2BYTE;
350 text[1] = TXT2BYTE_O2Calib; 379 text[1] = TXT2BYTE_O2Calib;
351 text[2] = 0; 380 text[2] = 0;
352 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); 381 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text);
355 } 384 }
356 } 385 }
357 386
358 for(int i=0;i<3;i++) 387 for(int i=0;i<3;i++)
359 { 388 {
360 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); 389 text[0] = 0;
390 if((pSettings->ext_sensor_map[i] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[i] == SENSOR_DIGO2))
391 {
392 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]);
393 }
394 else if(pSettings->ext_sensor_map[i] == SENSOR_CO2)
395 {
396 snprintf(text, 20,"%d ppm", pStateReal->lifeData.CO2_data.CO2_ppm);
397 }
361 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); 398 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP);
362 write_label_var( 400, 800, y_line, &FontT48, text); 399 if(text[0] != 0)
400 {
401 write_label_var( 400, 800, y_line, &FontT48, text);
402 }
363 } 403 }
364 404
365 if(DataEX_external_ADC_Present()) 405 if(DataEX_external_ADC_Present())
366 { 406 {
367 text[0] = TXT_2BYTE; 407 text[0] = TXT_2BYTE;
368 text[1] = TXT2BYTE_O2Interface; 408 text[1] = TXT2BYTE_O2Interface;
369 text[2] = 0; 409 text[2] = 0;
370 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text); 410 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text);
371 text[0] = TXT_2BYTE; 411 text[0] = TXT_2BYTE;
372 switch(settingsGetPointer()->ppo2sensors_source) 412 switch(pSettings->ppo2sensors_source)
373 { 413 {
374 default: 414 default:
375 case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic; 415 case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic;
376 text[2] = 0; 416 text[2] = 0;
377 break; 417 break;
379 text[2] = 0; 419 text[2] = 0;
380 break; 420 break;
381 case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital; 421 case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital;
382 text[2] = 0; 422 text[2] = 0;
383 break; 423 break;
384 case O2_SENSOR_SOURCE_ANADIG: text[1] = TXT2BYTE_O2IFAnalog; 424 case O2_SENSOR_SOURCE_ANADIG: write_label_var( 30, 340, ME_Y_LINE6, &FontT48, "Autodetect");
425 text[1] = TXT2BYTE_O2IFAnalog;
385 text[2] = ' '; 426 text[2] = ' ';
386 text[3] = '+'; 427 text[3] = '+';
387 text[4] = ' '; 428 text[4] = ' ';
388 text[5] = TXT_2BYTE; 429 text[5] = TXT_2BYTE;
389 text[6] = TXT2BYTE_O2IFDigital; 430 text[6] = TXT2BYTE_O2IFDigital;
393 case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); 434 case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel");
394 break; 435 break;
395 #endif 436 #endif
396 } 437 }
397 write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text); 438 write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text);
398 439 #if 0
399 if(haveSensorInfo == 1) 440 if(haveSensorInfo == 1)
400 { 441 {
401 text[0] = TXT_Sensor; 442 text[0] = TXT_Sensor;
402 text[1] = ' '; 443 text[1] = ' ';
403 text[2] = TXT_Information; 444 text[2] = TXT_Information;
404 text[3] = 0; 445 text[3] = 0;
405 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text); 446 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text);
406 } 447 }
407 } 448 #endif
408 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); 449 }
409 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); 450 if((pSettings->ext_sensor_map[0] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[0] == SENSOR_DIGO2))
410 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); 451 {
452 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
453 }
454 if((pSettings->ext_sensor_map[1] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[1] == SENSOR_DIGO2))
455 {
456 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
457 }
458 if((pSettings->ext_sensor_map[2] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[2] == SENSOR_DIGO2))
459 {
460 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
461 }
411 } 462 }
412 463
413 if(get_globalState() == StMHARD3_O2_Calibrate) 464 if(get_globalState() == StMHARD3_O2_Calibrate)
414 { 465 {
415 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); 466 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus);
421 } 472 }
422 473
423 474
424 void openEdit_O2Sensors(void) 475 void openEdit_O2Sensors(void)
425 { 476 {
477 SSettings *pSettings = settingsGetPointer();
426 uint8_t sensorActive[3]; 478 uint8_t sensorActive[3];
427 479
428 set_globalState(StMHARD3_Sensors); 480 set_globalState(StMHARD3_Sensors);
429 resetMenuEdit(CLUT_MenuPageHardware); 481 resetMenuEdit(CLUT_MenuPageHardware);
430 482
431 sensorActive[0] = 1; 483 sensorActive[0] = 1;
432 sensorActive[1] = 1; 484 sensorActive[1] = 1;
433 sensorActive[2] = 1; 485 sensorActive[2] = 1;
486
487
488 if(((pSettings->ext_sensor_map[0] != SENSOR_ANALOG) && (pSettings->ext_sensor_map[0] != SENSOR_DIGO2)))
489 {
490 pSettings->ppo2sensors_deactivated |= 1;
491 }
492 else
493 {
494 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]);
495 }
496 if(((pSettings->ext_sensor_map[1] != SENSOR_ANALOG) && (pSettings->ext_sensor_map[1] != SENSOR_DIGO2)))
497 {
498 pSettings->ppo2sensors_deactivated |= 2;
499 }
500 else
501 {
502 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]);
503 }
504 if(((pSettings->ext_sensor_map[2] != SENSOR_ANALOG) && (pSettings->ext_sensor_map[2] != SENSOR_DIGO2)))
505 {
506 pSettings->ppo2sensors_deactivated |= 4;
507 }
508 else
509 {
510 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]);
511 }
434 if(settingsGetPointer()->ppo2sensors_deactivated & 1) 512 if(settingsGetPointer()->ppo2sensors_deactivated & 1)
435 sensorActive[0] = 0; 513 sensorActive[0] = 0;
436 if(settingsGetPointer()->ppo2sensors_deactivated & 2) 514 if(settingsGetPointer()->ppo2sensors_deactivated & 2)
437 sensorActive[1] = 0; 515 sensorActive[1] = 0;
438 if(settingsGetPointer()->ppo2sensors_deactivated & 4) 516 if(settingsGetPointer()->ppo2sensors_deactivated & 4)
439 sensorActive[2] = 0; 517 sensorActive[2] = 0;
440 518
441 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); 519 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
442 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]);
443 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]);
444
445 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
446 { 520 {
447 haveSensorInfo = 0; /* as long as we do not move the HUD battery into the information page... */ 521 haveSensorInfo = 0; /* as long as we do not move the HUD battery into the information page... */
448 } 522 }
523
524 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
525 #ifdef ENABLE_SENTINEL_MODE
526 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
527 #endif
528 )
529 {
530 write_label_fix( 30, 800, ME_Y_LINE4, &FontT48, TXT2BYTE_O2Calib);
531 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017");
532
533 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 98);
534 }
535
536
537 if(DataEX_external_ADC_Present())
538 {
539 write_field_button(StMHARD3_O2_Source, 30, 800, ME_Y_LINE5, &FontT48, "");
540 #if 0
541 if(haveSensorInfo != 0)
542 {
543 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE6, &FontT48, "");
544 }
545 #endif
546 }
547
548
549 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
550 {
551 write_field_button(StMHARD3_Sensor_Detect, 30, 800, ME_Y_LINE6, &FontT48, "Autodetect");
552 }
553
554 if((pSettings->ext_sensor_map[0] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[0] == SENSOR_DIGO2))
555 {
556 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1);
557 }
558 if((pSettings->ext_sensor_map[1] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[1] == SENSOR_DIGO2))
559 {
560 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2);
561 }
562 if((pSettings->ext_sensor_map[2] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[2] == SENSOR_DIGO2))
563 {
564 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3);
565 }
449 566
450 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) 567 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
451 #ifdef ENABLE_SENTINEL_MODE 568 #ifdef ENABLE_SENTINEL_MODE
452 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) 569 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
453 #endif 570 #endif
454 ) 571 )
455 { 572 {
456 write_label_fix( 30, 800, ME_Y_LINE4, &FontT48, TXT2BYTE_O2Calib); 573 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate);
457 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017");
458
459 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 98);
460 } 574 }
461 575
462 if(DataEX_external_ADC_Present()) 576 if(DataEX_external_ADC_Present())
463 { 577 {
464 write_field_button(StMHARD3_O2_Source, 30, 800, ME_Y_LINE5, &FontT48, "");
465 if(haveSensorInfo != 0)
466 {
467 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE6, &FontT48, "");
468 }
469 }
470
471 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1);
472 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2);
473 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3);
474 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
475 #ifdef ENABLE_SENTINEL_MODE
476 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
477 #endif
478 )
479 {
480 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate);
481 }
482
483 if(DataEX_external_ADC_Present())
484 {
485 setEvent(StMHARD3_O2_Source, (uint32_t)OnAction_O2_Source); 578 setEvent(StMHARD3_O2_Source, (uint32_t)OnAction_O2_Source);
579 #if 0
486 if(haveSensorInfo != 0) 580 if(haveSensorInfo != 0)
487 { 581 {
488 setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info); 582 setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info);
489 } 583 }
490 } 584 #endif
585 }
586
587 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
588 {
589 setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect);
590 }
591
491 592
492 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 593 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
493 } 594 }
494 595
495 596
608 return retVal; 709 return retVal;
609 } 710 }
610 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 711 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
611 { 712 {
612 uint8_t source = settingsGetPointer()->ppo2sensors_source; 713 uint8_t source = settingsGetPointer()->ppo2sensors_source;
714 SSettings* pSettings = settingsGetPointer();
613 715
614 source++; 716 source++;
615 if(source == O2_SENSOR_SOURCE_MAX) 717 if(source == O2_SENSOR_SOURCE_MAX)
616 { 718 {
617 source = O2_SENSOR_SOURCE_OPTIC; 719 source = O2_SENSOR_SOURCE_OPTIC;
618 } 720 }
619 721
620 settingsGetPointer()->ppo2sensors_source = source; 722 switch(source)
723 {
724 case O2_SENSOR_SOURCE_OPTIC:
725 case O2_SENSOR_SOURCE_ANALOG:
726 case O2_SENSOR_SOURCE_ANADIG:
727 pSettings->ext_sensor_map[0] = SENSOR_ANALOG;
728 pSettings->ext_sensor_map[1] = SENSOR_ANALOG;
729 pSettings->ext_sensor_map[2] = SENSOR_ANALOG;
730
731 break;
732 case O2_SENSOR_SOURCE_DIGITAL: pSettings->ext_sensor_map[0] = SENSOR_DIGO2;
733 pSettings->ext_sensor_map[1] = SENSOR_NONE;
734 pSettings->ext_sensor_map[2] = SENSOR_NONE;
735 break;
736 default:
737 break;
738 }
739 pSettings->ext_sensor_map[3] = SENSOR_NONE;
740 pSettings->ext_sensor_map[4] = SENSOR_NONE;
741
742 pSettings->ppo2sensors_source = source;
743
744 DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP);
621 745
622 openEdit_O2Sensors(); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ 746 openEdit_O2Sensors(); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */
623 tMenuEdit_select(StMHARD3_O2_Source); 747 tMenuEdit_select(StMHARD3_O2_Source);
624 return UPDATE_DIVESETTINGS; 748 return UPDATE_DIVESETTINGS;
625 } 749 }
627 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 751 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
628 { 752 {
629 return EXIT_TO_INFO_SENSOR; 753 return EXIT_TO_INFO_SENSOR;
630 } 754 }
631 755
756 uint8_t OnAction_Sensor_Detect(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
757 {
758 DataEX_setExtInterface_Cmd(EXT_INTERFACE_AUTODETECT);
759 return UNSPECIFIC_RETURN;
760 }
632 761
633 void openEdit_Brightness(void) 762 void openEdit_Brightness(void)
634 { 763 {
635 uint8_t actualBrightness; 764 uint8_t actualBrightness;
636 SSettings *pSettings = settingsGetPointer(); 765 SSettings *pSettings = settingsGetPointer();