Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditHardware.c @ 745:b392524753fb
Update Sentinel protocol:
The Sentinel protocol is now supported by autodetection.
Added Autodetection indicator:
In the previous version no indicator showed that an auto detection is running. A new pseudo sensor type has been introduced which now causes the auto detection string to be displayed while the detection is running in the background.
author | Ideenmodellierer |
---|---|
date | Sun, 19 Feb 2023 21:52:02 +0100 |
parents | 5078da3845c0 |
children | 7e84ae1513b6 |
comparison
equal
deleted
inserted
replaced
744:dd5db6e2c9a4 | 745:b392524753fb |
---|---|
325 if(pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG) | 325 if(pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG) |
326 { | 326 { |
327 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_DIGITAL; | 327 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_DIGITAL; |
328 } | 328 } |
329 break; | 329 break; |
330 case SENSOR_SENTINEL: pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL; | |
331 break; | |
330 default: | 332 default: |
331 break; | 333 break; |
332 } | 334 } |
333 } | 335 } |
334 openEdit_O2Sensors(); | 336 openEdit_O2Sensors(); |
335 } | 337 } |
336 | 338 |
337 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 */ | 339 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 */ |
338 { | 340 { |
339 #if 0 | |
340 if(get_globalState() == StMHARD3_O2_Source) | |
341 { | |
342 y_line = 5; | |
343 } | |
344 #endif | |
345 haveSensorInfo = 1; | 341 haveSensorInfo = 1; |
346 openEdit_O2Sensors(); | 342 openEdit_O2Sensors(); |
347 #if 0 | |
348 if(y_line == 5) | |
349 { | |
350 tMenuEdit_select(StMHARD3_O2_Source); | |
351 } | |
352 #endif | |
353 } | 343 } |
354 else | 344 else |
355 { | 345 { |
356 if(pStateReal->lifeData.extIf_sensor_Id == 0) | 346 if(pStateReal->lifeData.extIf_sensor_Id == 0) |
357 { | 347 { |
377 strSensorId[4] = 'X'; | 367 strSensorId[4] = 'X'; |
378 strSensorId[5] = '1' + index; | 368 strSensorId[5] = '1' + index; |
379 | 369 |
380 switch(pSettings->ext_sensor_map[index]) | 370 switch(pSettings->ext_sensor_map[index]) |
381 { | 371 { |
372 case SENSOR_SEARCH: strSensorId[4] = TXT2BYTE_SensorDetect; | |
373 break; | |
382 case SENSOR_OPTIC: strSensorId[4] = TXT2BYTE_O2IFOptic; | 374 case SENSOR_OPTIC: strSensorId[4] = TXT2BYTE_O2IFOptic; |
383 break; | 375 break; |
384 case SENSOR_ANALOG: strSensorId[4] = TXT2BYTE_O2IFAnalog; | 376 case SENSOR_ANALOG: strSensorId[4] = TXT2BYTE_O2IFAnalog; |
385 break; | 377 break; |
386 case SENSOR_DIGO2: strSensorId[4] = TXT2BYTE_O2IFDigital; | 378 case SENSOR_DIGO2: strSensorId[4] = TXT2BYTE_O2IFDigital; |
387 break; | 379 break; |
388 case SENSOR_CO2: strSensorId[3] = 'C'; | 380 case SENSOR_CO2: strSensorId[3] = 'C'; |
389 strSensorId[4] = 'O'; | 381 strSensorId[4] = 'O'; |
390 break; | 382 break; |
383 case SENSOR_SENTINEL: strSensorId[3] = 'S'; | |
384 strSensorId[4] = 'e'; | |
385 break; | |
391 default: | 386 default: |
392 break; | 387 break; |
393 } | 388 } |
394 if(strSensorId[4] != 'X') | 389 if(strSensorId[4] != 'X') |
395 { | 390 { |
396 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId); | 391 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId); |
397 } | 392 } |
398 strSensorValue[0] = 0; | 393 strSensorValue[0] = 0; |
399 if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] <= SENSOR_DIGO2)) | 394 if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END)) |
400 { | 395 { |
401 snprintf(strSensorValue, 20,"%01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]); | 396 snprintf(strSensorValue, 20,"%01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]); |
402 } | 397 } |
403 else if(pSettings->ext_sensor_map[index] == SENSOR_CO2) | 398 else if(pSettings->ext_sensor_map[index] == SENSOR_CO2) |
404 { | 399 { |
407 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); | 402 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); |
408 if(strSensorValue[0] != 0) | 403 if(strSensorValue[0] != 0) |
409 { | 404 { |
410 write_label_var( 480, 800, y_line, &FontT48, strSensorValue); | 405 write_label_var( 480, 800, y_line, &FontT48, strSensorValue); |
411 } | 406 } |
412 | 407 } |
413 #if 0 | |
414 if(((pSettings->ext_sensor_map[index] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[index] > SENSOR_DIGO2))) | |
415 { | |
416 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, text); | |
417 } | |
418 if(pSettings->ext_sensor_map[index] == SENSOR_CO2) | |
419 { | |
420 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, "CO2"); | |
421 } | |
422 #endif | |
423 } | |
424 | |
425 | |
426 | |
427 | 408 |
428 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | 409 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) |
429 { | 410 { |
430 strSensorId[0] = TXT_2BYTE; | 411 strSensorId[0] = TXT_2BYTE; |
431 strSensorId[1] = TXT2BYTE_HUDbattery; | 412 strSensorId[1] = TXT2BYTE_HUDbattery; |
435 snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V()); | 416 snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V()); |
436 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId); | 417 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId); |
437 } | 418 } |
438 else | 419 else |
439 { | 420 { |
440 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) | 421 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)|| (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)) |
441 { | 422 { |
442 strSensorId[0] = TXT_2BYTE; | 423 strSensorId[0] = TXT_2BYTE; |
443 strSensorId[1] = TXT2BYTE_O2Calib; | 424 strSensorId[1] = TXT2BYTE_O2Calib; |
444 strSensorId[2] = 0; | 425 strSensorId[2] = 0; |
445 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId); | 426 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId); |
446 snprintf(strSensorId, 20,"%d%%", O2_calib_gas); | 427 snprintf(strSensorId, 20,"%d%%", O2_calib_gas); |
447 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId); | 428 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId); |
448 } | 429 } |
449 } | 430 } |
450 | 431 |
451 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, "Autodetect"); | 432 strSensorId[0] = TXT_2BYTE; |
452 | 433 strSensorId[1] = TXT2BYTE_SensorDetect; |
453 #if 0 | 434 strSensorId[2] = 0; |
454 if(DataEX_external_ADC_Present()) | 435 |
455 { | 436 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorId); |
456 strSensorId[0] = TXT_2BYTE; | 437 |
457 strSensorId[1] = TXT2BYTE_O2Interface; | |
458 strSensorId[2] = 0; | |
459 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorId); | |
460 strSensorId[0] = TXT_2BYTE; | |
461 switch(pSettings->ppo2sensors_source) | |
462 { | |
463 default: | |
464 case O2_SENSOR_SOURCE_OPTIC: strSensorId[1] = TXT2BYTE_O2IFOptic; | |
465 strSensorId[2] = 0; | |
466 break; | |
467 case O2_SENSOR_SOURCE_ANALOG: strSensorId[1] = TXT2BYTE_O2IFAnalog; | |
468 strSensorId[2] = 0; | |
469 break; | |
470 case O2_SENSOR_SOURCE_DIGITAL: strSensorId[1] = TXT2BYTE_O2IFDigital; | |
471 strSensorId[2] = 0; | |
472 break; | |
473 case O2_SENSOR_SOURCE_ANADIG: //write_label_var( 30, 340, ME_Y_LINE6, &FontT48, "Autodetect"); | |
474 strSensorId[1] = TXT2BYTE_O2IFAnalog; | |
475 strSensorId[2] = ' '; | |
476 strSensorId[3] = '+'; | |
477 strSensorId[4] = ' '; | |
478 strSensorId[5] = TXT_2BYTE; | |
479 strSensorId[6] = TXT2BYTE_O2IFDigital; | |
480 strSensorId[7] = 0; | |
481 break; | |
482 #ifdef ENABLE_SENTINEL_MODE | |
483 case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); | |
484 break; | |
485 #endif | |
486 } | |
487 write_label_var( 480, 800, ME_Y_LINE5, &FontT48, strSensorId); | |
488 | |
489 | |
490 } | |
491 #endif | |
492 if(haveSensorInfo == 1) | 438 if(haveSensorInfo == 1) |
493 { | 439 { |
494 strSensorId[0] = TXT_Sensor; | 440 strSensorId[0] = TXT_Sensor; |
495 strSensorId[1] = ' '; | 441 strSensorId[1] = ' '; |
496 strSensorId[2] = TXT_Information; | 442 strSensorId[2] = TXT_Information; |
497 strSensorId[3] = 0; | 443 strSensorId[3] = 0; |
498 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorId); | 444 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorId); |
499 } | 445 } |
500 | 446 |
501 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] <= SENSOR_DIGO2)) | 447 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END)) |
502 { | 448 { |
503 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | 449 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); |
504 } | 450 } |
505 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] <= SENSOR_DIGO2)) | 451 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END)) |
506 { | 452 { |
507 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | 453 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); |
508 } | 454 } |
509 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] <= SENSOR_DIGO2)) | 455 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END)) |
510 { | 456 { |
511 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | 457 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); |
512 } | 458 } |
513 } | 459 } |
514 | 460 |
525 | 471 |
526 void openEdit_O2Sensors(void) | 472 void openEdit_O2Sensors(void) |
527 { | 473 { |
528 SSettings *pSettings = settingsGetPointer(); | 474 SSettings *pSettings = settingsGetPointer(); |
529 uint8_t sensorActive[3]; | 475 uint8_t sensorActive[3]; |
476 uint8_t text[3]; | |
530 | 477 |
531 set_globalState(StMHARD3_Sensors); | 478 set_globalState(StMHARD3_Sensors); |
532 resetMenuEdit(CLUT_MenuPageHardware); | 479 resetMenuEdit(CLUT_MenuPageHardware); |
533 | 480 |
534 sensorActive[0] = 1; | 481 sensorActive[0] = 1; |
535 sensorActive[1] = 1; | 482 sensorActive[1] = 1; |
536 sensorActive[2] = 1; | 483 sensorActive[2] = 1; |
537 | 484 |
538 if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] > SENSOR_DIGO2))) | 485 if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END))) |
539 { | 486 { |
540 pSettings->ppo2sensors_deactivated |= 1; | 487 pSettings->ppo2sensors_deactivated |= 1; |
541 } | 488 } |
542 else | 489 else |
543 { | 490 { |
544 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | 491 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); |
545 } | 492 } |
546 if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] > SENSOR_DIGO2))) | 493 if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_TYPE_O2_END))) |
547 { | 494 { |
548 pSettings->ppo2sensors_deactivated |= 2; | 495 pSettings->ppo2sensors_deactivated |= 2; |
549 } | 496 } |
550 else | 497 else |
551 { | 498 { |
552 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | 499 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); |
553 } | 500 } |
554 if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] > SENSOR_DIGO2))) | 501 if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_TYPE_O2_END))) |
555 { | 502 { |
556 pSettings->ppo2sensors_deactivated |= 4; | 503 pSettings->ppo2sensors_deactivated |= 4; |
557 } | 504 } |
558 else | 505 else |
559 { | 506 { |
586 if(haveSensorInfo != 0) | 533 if(haveSensorInfo != 0) |
587 { | 534 { |
588 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE5, &FontT48, ""); | 535 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE5, &FontT48, ""); |
589 } | 536 } |
590 | 537 |
591 write_field_button(StMHARD3_Sensor_Detect, 30, 800, ME_Y_LINE6, &FontT48, "Autodetect"); | 538 text[0] = TXT_2BYTE; |
592 | 539 text[1] = TXT2BYTE_SensorDetect; |
593 if((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] > SENSOR_DIGO2)) | 540 text[2] = 0; |
541 | |
542 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text); | |
543 | |
544 write_field_button(StMHARD3_Sensor_Detect, 30, 800, ME_Y_LINE6, &FontT48, text); | |
545 | |
546 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END)) | |
594 { | 547 { |
595 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | 548 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); |
596 } | 549 } |
597 if((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] > SENSOR_DIGO2)) | 550 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END)) |
598 { | 551 { |
599 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | 552 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); |
600 } | 553 } |
601 if((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] > SENSOR_DIGO2)) | 554 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END)) |
602 { | 555 { |
603 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | 556 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); |
604 } | 557 } |
605 | 558 |
606 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) | 559 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) |
734 exitMenuEditField(); | 687 exitMenuEditField(); |
735 } | 688 } |
736 | 689 |
737 return retVal; | 690 return retVal; |
738 } | 691 } |
739 #if 0 | 692 |
740 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
741 { | |
742 uint8_t source = settingsGetPointer()->ppo2sensors_source; | |
743 SSettings* pSettings = settingsGetPointer(); | |
744 | |
745 source++; | |
746 if(source == O2_SENSOR_SOURCE_MAX) | |
747 { | |
748 source = O2_SENSOR_SOURCE_OPTIC; | |
749 } | |
750 | |
751 switch(source) | |
752 { | |
753 case O2_SENSOR_SOURCE_OPTIC: | |
754 case O2_SENSOR_SOURCE_ANALOG: | |
755 case O2_SENSOR_SOURCE_ANADIG: | |
756 pSettings->ext_sensor_map[0] = SENSOR_ANALOG; | |
757 pSettings->ext_sensor_map[1] = SENSOR_ANALOG; | |
758 pSettings->ext_sensor_map[2] = SENSOR_ANALOG; | |
759 | |
760 break; | |
761 case O2_SENSOR_SOURCE_DIGITAL: pSettings->ext_sensor_map[0] = SENSOR_DIGO2; | |
762 pSettings->ext_sensor_map[1] = SENSOR_NONE; | |
763 pSettings->ext_sensor_map[2] = SENSOR_NONE; | |
764 break; | |
765 default: | |
766 break; | |
767 } | |
768 pSettings->ext_sensor_map[3] = SENSOR_NONE; | |
769 pSettings->ext_sensor_map[4] = SENSOR_NONE; | |
770 | |
771 pSettings->ppo2sensors_source = source; | |
772 | |
773 DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP); | |
774 | |
775 openEdit_O2Sensors(); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ | |
776 // tMenuEdit_select(StMHARD3_O2_Source); | |
777 return UPDATE_DIVESETTINGS; | |
778 } | |
779 #endif | |
780 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 693 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
781 { | 694 { |
782 return EXIT_TO_INFO_SENSOR; | 695 return EXIT_TO_INFO_SENSOR; |
783 } | 696 } |
784 | 697 |