comparison Discovery/Src/t7.c @ 907:46a21ff3f5ab Evo_2_23

Adaptation custom view deco plan for VPM: The VPM deco plan now shows the start of deco zone as well as the state of the deco table state. In case the table defined when reaching the deco zone is updated then the header line will change to yellow to indicate this. In case a deco stop is missed the head line will change to red.
author ideenmodellierer
date Sun, 13 Oct 2024 18:13:35 +0200
parents 2225c467f1e9
children
comparison
equal deleted inserted replaced
906:49ee233c7a74 907:46a21ff3f5ab
45 #include "unit.h" 45 #include "unit.h"
46 #include "motion.h" 46 #include "motion.h"
47 #include "configuration.h" 47 #include "configuration.h"
48 #include "base.h" 48 #include "base.h"
49 #include "tMenuEditSetpoint.h" 49 #include "tMenuEditSetpoint.h"
50 #include "vpm.h"
50 51
51 #define TIMER_ACTION_DELAY_S 10 52 #define TIMER_ACTION_DELAY_S 10
52 53
53 /* Private function prototypes -----------------------------------------------*/ 54 /* Private function prototypes -----------------------------------------------*/
54 55
126 /* Private types -------------------------------------------------------------*/ 127 /* Private types -------------------------------------------------------------*/
127 128
128 typedef enum 129 typedef enum
129 { 130 {
130 SE_INIT = 0, 131 SE_INIT = 0,
132 SE_REINIT,
131 SE_ACTIVE, 133 SE_ACTIVE,
132 SE_END 134 SE_END
133 } SSlowExitState; 135 } SSlowExitState;
134 136
135 const uint8_t customviewsSurfaceStandard[] = 137 const uint8_t customviewsSurfaceStandard[] =
2179 uint8_t oxygen, helium; // CVIEW_Gaslist 2181 uint8_t oxygen, helium; // CVIEW_Gaslist
2180 float depth, surface, fraction_nitrogen, fraction_helium, ead, end; // CVIEW_EADTime 2182 float depth, surface, fraction_nitrogen, fraction_helium, ead, end; // CVIEW_EADTime
2181 SSettingsStatus SettingsStatus; 2183 SSettingsStatus SettingsStatus;
2182 SSettings* pSettings; 2184 SSettings* pSettings;
2183 pSettings = settingsGetPointer(); 2185 pSettings = settingsGetPointer();
2186 uint8_t decoPlanEntries = 6;
2187 uint8_t color = 0;
2184 2188
2185 uint8_t local_ppo2sensors_deactivated = 0; 2189 uint8_t local_ppo2sensors_deactivated = 0;
2186 2190
2187 if(stateUsed->mode == MODE_DIVE) /* show sensors based on current dive settings */ 2191 if(stateUsed->mode == MODE_DIVE) /* show sensors based on current dive settings */
2188 { 2192 {
2189 local_ppo2sensors_deactivated = stateUsed->diveSettings.ppo2sensors_deactivated; 2193 local_ppo2sensors_deactivated = stateUsed->diveSettings.ppo2sensors_deactivated;
2190 } 2194 }
2191 else 2195 else
2192 { 2196 {
2193 local_ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated; 2197 local_ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated;
2194 } 2198 }
2195 2199
2196 if(last_customview != selection_customview) /* check if current selection is disabled and should be skipped */ 2200 if(last_customview != selection_customview) /* check if current selection is disabled and should be skipped */
2197 { 2201 {
2198 if(t7_customview_disabled(selection_customview)) 2202 if(t7_customview_disabled(selection_customview))
2634 } 2638 }
2635 break; 2639 break;
2636 2640
2637 case CVIEW_Decolist: 2641 case CVIEW_Decolist:
2638 snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist); 2642 snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist);
2639 GFX_write_string(&FontT42,&t7cH,text,0); 2643
2640 2644 if(settingsGetPointer()->VPM_conservatism.ub.alternative == 0)
2645 {
2646 GFX_write_string(&FontT42,&t7cH,text,0);
2647 }
2648 else
2649 {
2650 switch(vpm_get_TableState())
2651 {
2652 case VPM_TABLE_MISSED: color = CLUT_WarningRed;
2653 break;
2654 case VPM_TABLE_WARNING: color = CLUT_WarningYellow;
2655 break;
2656 case VPM_TABLE_ACTIVE:
2657 case VPM_TABLE_INIT:
2658 default: color = 0;
2659 break;
2660 }
2661 GFX_write_string_color(&FontT42,&t7cH,text,0,color);
2662 }
2641 uint8_t depthNext, depthLast, depthSecond, depthInc; 2663 uint8_t depthNext, depthLast, depthSecond, depthInc;
2642 2664
2643 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); 2665 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10);
2644 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); 2666 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10);
2645 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); 2667 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10);
2648 { 2670 {
2649 depthLast = (uint8_t)unit_depth_integer(depthLast); 2671 depthLast = (uint8_t)unit_depth_integer(depthLast);
2650 depthSecond = (uint8_t)unit_depth_integer(depthSecond); 2672 depthSecond = (uint8_t)unit_depth_integer(depthSecond);
2651 depthInc = (uint8_t)unit_depth_integer(depthInc); 2673 depthInc = (uint8_t)unit_depth_integer(depthInc);
2652 } 2674 }
2675 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) /* show additional VPM data in last slot */
2676 {
2677 decoPlanEntries = 5;
2678 }
2653 2679
2654 const SDecoinfo * pDecoinfo = getDecoInfo(); 2680 const SDecoinfo * pDecoinfo = getDecoInfo();
2655 for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--) 2681 for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--)
2656 if(pDecoinfo->output_stop_length_seconds[start]) break; 2682 if(pDecoinfo->output_stop_length_seconds[start]) break;
2657 start -= 6; 2683 start -= decoPlanEntries;
2658 if(start < 0) start = 0; 2684 if(start < 0) start = 0;
2659 2685
2660 textpointer = 0; 2686 textpointer = 0;
2661 for(int i=start;i<6+start;i++) 2687 for(int i=start;i<decoPlanEntries+start;i++)
2662 { 2688 {
2663 if(i == 0) 2689 if(i == 0)
2664 depthNext = depthLast; 2690 depthNext = depthLast;
2665 else 2691 else
2666 depthNext = depthSecond + (( i - 1 )* depthInc); 2692 depthNext = depthSecond + (( i - 1 )* depthInc);
2668 if(pDecoinfo->output_stop_length_seconds[i]) 2694 if(pDecoinfo->output_stop_length_seconds[i])
2669 textpointer += snprintf(&text[textpointer],20,"\030\034 %2u\016\016%c%c\017%3i'\n\r",depthNext, unit_depth_char1(), unit_depth_char2(), (pDecoinfo->output_stop_length_seconds[i]+59)/60); 2695 textpointer += snprintf(&text[textpointer],20,"\030\034 %2u\016\016%c%c\017%3i'\n\r",depthNext, unit_depth_char1(), unit_depth_char2(), (pDecoinfo->output_stop_length_seconds[i]+59)/60);
2670 else 2696 else
2671 textpointer += snprintf(&text[textpointer],20,"\031\034 %2u\016\016%c%c\017\n\r",depthNext, unit_depth_char1(), unit_depth_char2()); 2697 textpointer += snprintf(&text[textpointer],20,"\031\034 %2u\016\016%c%c\017\n\r",depthNext, unit_depth_char1(), unit_depth_char2());
2672 if(textpointer > 200) break; 2698 if(textpointer > 200) break;
2699 }
2700 if(decoPlanEntries == 5) /* add VPM deco zone */
2701 {
2702 textpointer += snprintf(&text[textpointer],20,"\031\034 Zone %2u\016\016%c%c\017\n\r",vpm_get_decozone(), unit_depth_char1(), unit_depth_char2());
2673 } 2703 }
2674 if(!pSettings->FlipDisplay) 2704 if(!pSettings->FlipDisplay)
2675 { 2705 {
2676 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; 2706 t7cY0free.WindowY0 = t7cC.WindowY0 - 10;
2677 } 2707 }
4728 GFX_draw_thick_line(12,&t7screen, start, stop, color); 4758 GFX_draw_thick_line(12,&t7screen, start, stop, color);
4729 } 4759 }
4730 4760
4731 #define ASCENT_GRAPH_YPIXEL 120 4761 #define ASCENT_GRAPH_YPIXEL 120
4732 4762
4733 uint8_t t7_drawSlowExitGraph() 4763 uint8_t t7_drawSlowExitGraph() /* this function is only called if diver is below last last stop depth */
4734 { 4764 {
4735 static SSlowExitState slowExitState = SE_END; 4765 static SSlowExitState slowExitState = SE_END;
4736 static uint16_t countDownSec = 0; 4766 static uint16_t countDownSec = 0;
4737 static uint8_t drawingMeterStep; 4767 static uint8_t drawingMeterStep;
4738 static float exitDepthMeter = 0.0; 4768 static float exitDepthMeter = 0.0;
4739 static uint32_t exitSecTick = 0; 4769 static uint32_t exitSecTick = 0;
4770 static uint32_t lastSecTick = 0;
4740 4771
4741 uint8_t index = 0; 4772 uint8_t index = 0;
4742 static uint8_t color = 0; 4773 static uint8_t color = 0;
4743 point_t start, stop; 4774 point_t start, stop;
4744 4775
4745 SSettings* pSettings; 4776 SSettings* pSettings;
4746 pSettings = settingsGetPointer(); 4777 pSettings = settingsGetPointer();
4747 4778
4748 if(stateUsed->lifeData.max_depth_meter < pSettings->last_stop_depth_meter) /* start of dive => reinit timer */ 4779 if((stateUsed->lifeData.max_depth_meter < pSettings->last_stop_depth_meter) /* start of dive => reinit timer */
4780 || (slowExitState == SE_REINIT))
4749 { 4781 {
4750 if(slowExitState != SE_INIT) 4782 if(slowExitState != SE_INIT)
4751 { 4783 {
4752 //stepPerSecond = pSettings->last_stop_depth_meter / pSettings->slowExitTime;
4753 countDownSec = pSettings->slowExitTime * 60; 4784 countDownSec = pSettings->slowExitTime * 60;
4754 drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ 4785 drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */
4755 slowExitState = SE_INIT; 4786 slowExitState = SE_INIT;
4756 exitDepthMeter = pSettings->last_stop_depth_meter; 4787 exitDepthMeter = pSettings->last_stop_depth_meter;
4757 color = 0; 4788 color = 0;
4763 { 4794 {
4764 if((slowExitState == SE_INIT) && (stateUsed->lifeData.dive_time_seconds > 900)) /* min 15min divetime */ 4795 if((slowExitState == SE_INIT) && (stateUsed->lifeData.dive_time_seconds > 900)) /* min 15min divetime */
4765 { 4796 {
4766 slowExitState = SE_ACTIVE; 4797 slowExitState = SE_ACTIVE;
4767 exitSecTick = HAL_GetTick(); 4798 exitSecTick = HAL_GetTick();
4799 lastSecTick = exitSecTick;
4768 } 4800 }
4769 else if(slowExitState == SE_ACTIVE) 4801 else if(slowExitState == SE_ACTIVE)
4770 { 4802 {
4771 if(time_elapsed_ms(exitSecTick, HAL_GetTick()) > 1000) 4803 if(time_elapsed_ms(lastSecTick, HAL_GetTick()) > 60000) /* restart timer if diver go below exit zone */
4804 {
4805 slowExitState = SE_REINIT;
4806 }
4807 else if(time_elapsed_ms(exitSecTick, HAL_GetTick()) > 1000)
4772 { 4808 {
4773 exitSecTick = HAL_GetTick(); 4809 exitSecTick = HAL_GetTick();
4774 4810 lastSecTick = exitSecTick;
4775 /* select depth digit color */ 4811 /* select depth digit color */
4776 if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) < 0.5 ) 4812 if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) < 0.5 )
4777 { 4813 {
4778 color = CLUT_NiceGreen; 4814 color = CLUT_NiceGreen;
4779 } 4815 }
4796 countDownSec--; 4832 countDownSec--;
4797 if(countDownSec == 0) 4833 if(countDownSec == 0)
4798 { 4834 {
4799 slowExitState = SE_END; 4835 slowExitState = SE_END;
4800 color = 0; 4836 color = 0;
4837 exitDepthMeter = 0;
4801 } 4838 }
4802 exitDepthMeter -= (pSettings->last_stop_depth_meter / (float)(pSettings->slowExitTime * 60)); 4839 else
4840 {
4841 exitDepthMeter -= (pSettings->last_stop_depth_meter / (float)(pSettings->slowExitTime * 60));
4842 }
4803 } 4843 }
4804 } 4844 }
4805 if(!pSettings->FlipDisplay) 4845 if(!pSettings->FlipDisplay)
4806 { 4846 {
4807 start.y = t7l1.WindowY0 - 1; 4847 start.y = t7l1.WindowY0 - 1;