Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditDeco.c @ 662:1b995079c045 Betatest
PSCR Mode
author | heinrichs weikamp |
---|---|
date | Tue, 14 Dec 2021 15:36:10 +0100 |
parents | ba229a012ac7 |
children | e81afd727993 |
comparison
equal
deleted
inserted
replaced
661:87bee7cc77b3 | 662:1b995079c045 |
---|---|
30 #include "tMenuEditDeco.h" | 30 #include "tMenuEditDeco.h" |
31 | 31 |
32 #include "gfx_fonts.h" | 32 #include "gfx_fonts.h" |
33 #include "tMenuEdit.h" | 33 #include "tMenuEdit.h" |
34 #include "unit.h" | 34 #include "unit.h" |
35 #include "configuration.h" | |
35 | 36 |
36 /* Private variables ---------------------------------------------------------*/ | 37 /* Private variables ---------------------------------------------------------*/ |
37 static uint8_t lineSelected = 0; | 38 static uint8_t lineSelected = 0; |
38 | 39 |
39 /* Private function prototypes -----------------------------------------------*/ | 40 /* Private function prototypes -----------------------------------------------*/ |
44 static void openEdit_SafetyStop(void); | 45 static void openEdit_SafetyStop(void); |
45 static void openEdit_FutureTTS(void); | 46 static void openEdit_FutureTTS(void); |
46 static void openEdit_Salinity(void); | 47 static void openEdit_Salinity(void); |
47 | 48 |
48 /* Announced function prototypes -----------------------------------------------*/ | 49 /* Announced function prototypes -----------------------------------------------*/ |
49 | 50 static uint8_t OnAction_setMode (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
50 static uint8_t OnAction_OC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
51 static uint8_t OnAction_CC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
52 static uint8_t OnAction_Apnea (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
53 static uint8_t OnAction_Gauge (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
54 static uint8_t OnAction_FutureTTS (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 51 static uint8_t OnAction_FutureTTS (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
55 static uint8_t OnAction_ppO2Max (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 52 static uint8_t OnAction_ppO2Max (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
56 static uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 53 static uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
57 static uint8_t OnAction_Salinity (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 54 static uint8_t OnAction_Salinity (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
58 /* Exported functions --------------------------------------------------------*/ | 55 /* Exported functions --------------------------------------------------------*/ |
64 | 61 |
65 SSettings *data = settingsGetPointer(); | 62 SSettings *data = settingsGetPointer(); |
66 | 63 |
67 lineSelected = line; | 64 lineSelected = line; |
68 | 65 |
69 if((data->dive_mode != DIVEMODE_CCR )&& (line > 1)) | 66 if((!isLoopMode(data->dive_mode)) && (line > 1)) |
70 line += 1; | 67 line += 1; |
71 | 68 |
72 switch(line) | 69 switch(line) |
73 { | 70 { |
74 case 1: | 71 case 1: |
99 static void openEdit_DiveMode(void) | 96 static void openEdit_DiveMode(void) |
100 { | 97 { |
101 #define APNEAANDGAUGE | 98 #define APNEAANDGAUGE |
102 | 99 |
103 char text[32]; | 100 char text[32]; |
101 uint8_t lineOffset = 0; | |
104 uint8_t actualDiveMode, active; | 102 uint8_t actualDiveMode, active; |
105 SSettings *pSettings = settingsGetPointer(); | 103 SSettings *pSettings = settingsGetPointer(); |
106 actualDiveMode = pSettings->dive_mode; | 104 actualDiveMode = pSettings->dive_mode; |
107 | 105 |
108 text[0] = '\001'; | 106 text[0] = '\001'; |
111 write_topline(text); | 109 write_topline(text); |
112 | 110 |
113 text[1] = 0; | 111 text[1] = 0; |
114 | 112 |
115 | 113 |
114 #ifdef ENABLE_PSCR_MODE | |
115 lineOffset = ME_Y_LINE_STEP; | |
116 #endif | |
117 | |
116 text[0] = TXT_OpenCircuit; | 118 text[0] = TXT_OpenCircuit; |
117 if(actualDiveMode == DIVEMODE_OC) | 119 if(actualDiveMode == DIVEMODE_OC) |
118 active = 1; | 120 active = 1; |
119 else | 121 else |
120 active = 0; | 122 active = 0; |
125 active = 1; | 127 active = 1; |
126 else | 128 else |
127 active = 0; | 129 active = 0; |
128 write_field_on_off(StMDECO1_CC, 30, 500, ME_Y_LINE2, &FontT48, text, active); | 130 write_field_on_off(StMDECO1_CC, 30, 500, ME_Y_LINE2, &FontT48, text, active); |
129 | 131 |
130 #ifdef APNEAANDGAUGE | 132 #ifdef ENABLE_PSCR_MODE |
133 text[0] = TXT_PSClosedCircuit; | |
134 if(actualDiveMode == DIVEMODE_PSCR) | |
135 active = 1; | |
136 else | |
137 active = 0; | |
138 write_field_on_off(StMDECO1_PSCR, 30, 500, ME_Y_LINE3, &FontT48, text, active); | |
139 #endif | |
140 #ifdef APNEAANDGAUGE | |
131 text[0] = TXT_Apnoe; | 141 text[0] = TXT_Apnoe; |
132 if(actualDiveMode == DIVEMODE_Apnea) | 142 if(actualDiveMode == DIVEMODE_Apnea) |
133 active = 1; | 143 active = 1; |
134 else | 144 else |
135 active = 0; | 145 active = 0; |
136 write_field_on_off(StMDECO1_Apnea, 30, 500, ME_Y_LINE3, &FontT48, text, active); | 146 write_field_on_off(StMDECO1_Apnea, 30, 500, ME_Y_LINE3 + lineOffset, &FontT48, text, active); |
137 | 147 |
138 text[0] = TXT_Gauge; | 148 text[0] = TXT_Gauge; |
139 if(actualDiveMode == DIVEMODE_Gauge) | 149 if(actualDiveMode == DIVEMODE_Gauge) |
140 active = 1; | 150 active = 1; |
141 else | 151 else |
142 active = 0; | 152 active = 0; |
143 write_field_on_off(StMDECO1_Gauge, 30, 500, ME_Y_LINE4, &FontT48, text, active); | 153 write_field_on_off(StMDECO1_Gauge, 30, 500, ME_Y_LINE4 + lineOffset, &FontT48, text, active); |
144 #endif | 154 #endif |
145 | 155 |
146 setEvent(StMDECO1_OC, (uint32_t)OnAction_OC); | 156 setEvent(StMDECO1_OC, (uint32_t)OnAction_setMode); |
147 setEvent(StMDECO1_CC, (uint32_t)OnAction_CC); | 157 setEvent(StMDECO1_CC, (uint32_t)OnAction_setMode); |
148 #ifdef APNEAANDGAUGE | 158 #ifdef ENABLE_PSCR_MODE |
149 setEvent(StMDECO1_Apnea, (uint32_t)OnAction_Apnea); | 159 setEvent(StMDECO1_PSCR, (uint32_t)OnAction_setMode); |
150 setEvent(StMDECO1_Gauge, (uint32_t)OnAction_Gauge); | 160 #endif |
151 #endif | 161 |
162 #ifdef APNEAANDGAUGE | |
163 setEvent(StMDECO1_Apnea, (uint32_t)OnAction_setMode); | |
164 setEvent(StMDECO1_Gauge, (uint32_t)OnAction_setMode); | |
165 #endif | |
152 | 166 |
153 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 167 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
154 } | 168 } |
155 | 169 |
156 static uint8_t OnAction_OC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 170 |
157 { | 171 static uint8_t OnAction_setMode (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) //(uint32_t newMode) |
158 SSettings *pSettings = settingsGetPointer(); | 172 { |
159 if(pSettings->dive_mode == DIVEMODE_OC) | 173 uint32_t modeArray[] = {StMDECO1_OC, StMDECO1_CC, StMDECO1_Gauge, StMDECO1_Apnea /* definition needs to follow order of DIVEMODE (settings.h) */ |
160 return EXIT_TO_MENU; | 174 #ifdef ENABLE_PSCR_MODE |
161 pSettings->dive_mode = DIVEMODE_OC; | 175 , StMDECO1_PSCR |
162 setActualGasFirst(&stateRealGetPointerWrite()->lifeData); | 176 #endif |
163 tMenuEdit_set_on_off(editId, 1); | 177 }; |
164 tMenuEdit_set_on_off(StMDECO1_CC, 0); | 178 |
165 tMenuEdit_set_on_off(StMDECO1_Apnea, 0); | 179 uint8_t index = 0; |
166 tMenuEdit_set_on_off(StMDECO1_Gauge, 0); | 180 SSettings *pSettings = settingsGetPointer(); |
167 return UPDATE_DIVESETTINGS; | 181 uint8_t retVal = EXIT_TO_MENU; |
168 } | 182 uint8_t lastMode = pSettings->dive_mode; |
169 | 183 |
170 | 184 |
171 static uint8_t OnAction_CC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 185 setActualGasFirst(&stateRealGetPointerWrite()->lifeData); |
172 { | 186 while(index < sizeof(modeArray) / 4) /* calculate number of items out of array size (bytes) */ |
173 SSettings *pSettings = settingsGetPointer(); | 187 { |
174 if(pSettings->dive_mode == DIVEMODE_CCR) | 188 if(editId == modeArray[index]) |
175 return EXIT_TO_MENU; | 189 { |
176 pSettings->dive_mode = DIVEMODE_CCR; | 190 if(pSettings->dive_mode != index) |
177 setActualGasFirst(&stateRealGetPointerWrite()->lifeData); | 191 { |
178 tMenuEdit_set_on_off(editId, 1); | 192 tMenuEdit_set_on_off(modeArray[index], 1); |
179 tMenuEdit_set_on_off(StMDECO1_OC, 0); | 193 pSettings->dive_mode = index; |
180 tMenuEdit_set_on_off(StMDECO1_Apnea, 0); | 194 retVal = UPDATE_DIVESETTINGS; |
181 tMenuEdit_set_on_off(StMDECO1_Gauge, 0); | 195 } |
182 return UPDATE_DIVESETTINGS; | 196 } |
183 } | 197 else |
184 | 198 { |
185 | 199 if(lastMode == index) /* reset state of previous mode selection */ |
186 static uint8_t OnAction_Apnea (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 200 { |
187 { | 201 tMenuEdit_set_on_off(modeArray[index], 0); |
188 SSettings *pSettings = settingsGetPointer(); | 202 } |
189 if(pSettings->dive_mode == DIVEMODE_Apnea) | 203 } |
190 return EXIT_TO_MENU; | 204 index++; |
191 pSettings->dive_mode = DIVEMODE_Apnea; | 205 } |
192 setActualGasFirst(&stateRealGetPointerWrite()->lifeData); | 206 return retVal; |
193 tMenuEdit_set_on_off(editId, 1); | |
194 tMenuEdit_set_on_off(StMDECO1_CC, 0); | |
195 tMenuEdit_set_on_off(StMDECO1_OC, 0); | |
196 tMenuEdit_set_on_off(StMDECO1_Gauge, 0); | |
197 return UPDATE_DIVESETTINGS; | |
198 } | |
199 | |
200 | |
201 static uint8_t OnAction_Gauge (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
202 { | |
203 SSettings *pSettings = settingsGetPointer(); | |
204 if(pSettings->dive_mode == DIVEMODE_Gauge) | |
205 return EXIT_TO_MENU; | |
206 pSettings->dive_mode = DIVEMODE_Gauge; | |
207 setActualGasFirst(&stateRealGetPointerWrite()->lifeData); | |
208 tMenuEdit_set_on_off(editId, 1); | |
209 tMenuEdit_set_on_off(StMDECO1_CC, 0); | |
210 tMenuEdit_set_on_off(StMDECO1_Apnea, 0); | |
211 tMenuEdit_set_on_off(StMDECO1_OC, 0); | |
212 return UPDATE_DIVESETTINGS; | |
213 } | 207 } |
214 | 208 |
215 | 209 |
216 static void openEdit_CCRModeSensorOrFixedSP(void) | 210 static void openEdit_CCRModeSensorOrFixedSP(void) |
217 { | 211 { |