Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditHardware.c @ 778:74253a41cf80
Zusammenf?hren
author | heinrichsweikamp |
---|---|
date | Mon, 22 May 2023 09:15:09 +0200 |
parents | 45b8f3c2acce |
children | c31237d20491 |
comparison
equal
deleted
inserted
replaced
777:6a8cf91e5b22 | 778:74253a41cf80 |
---|---|
157 | 157 |
158 exitEditWithUpdate(); | 158 exitEditWithUpdate(); |
159 exitMenuEdit_to_Home(); | 159 exitMenuEdit_to_Home(); |
160 } | 160 } |
161 | 161 |
162 | |
163 static uint8_t togglePlusMinus(uint8_t input) | |
164 { | |
165 if (input == '+') { | |
166 return '-'; | |
167 } else { | |
168 return '+'; | |
169 } | |
170 } | |
171 | |
172 | |
173 static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
174 { | |
175 SSettings *settings = settingsGetPointer(); | |
176 uint8_t digitContentNew; | |
177 switch (action) { | |
178 case ACTION_BUTTON_ENTER: | |
179 | |
180 return digitContent; | |
181 case ACTION_BUTTON_ENTER_FINAL: | |
182 { | |
183 int32_t compassDeclinationDeg; | |
184 evaluateNewString(editId, (uint32_t *)&compassDeclinationDeg, NULL, NULL, NULL); | |
185 | |
186 if (compassDeclinationDeg > 99) { | |
187 compassDeclinationDeg = 99; | |
188 } else if (compassDeclinationDeg < -99) { | |
189 compassDeclinationDeg = -99; | |
190 } | |
191 | |
192 settings->compassDeclinationDeg = compassDeclinationDeg; | |
193 | |
194 tMenuEdit_newInput(editId, ((input_u)compassDeclinationDeg).uint32, 0, 0, 0); | |
195 } | |
196 | |
197 break; | |
198 case ACTION_BUTTON_NEXT: | |
199 if (digitNumber == 0) { | |
200 digitContentNew = togglePlusMinus(digitContent); | |
201 } else { | |
202 digitContentNew = digitContent + 1; | |
203 if (digitContentNew > '9') { | |
204 digitContentNew = '0'; | |
205 } | |
206 } | |
207 | |
208 return digitContentNew; | |
209 case ACTION_BUTTON_BACK: | |
210 if (digitNumber == 0) { | |
211 digitContentNew = togglePlusMinus(digitContent); | |
212 } else { | |
213 digitContentNew = digitContent - 1; | |
214 if (digitContentNew < '0') { | |
215 digitContentNew = '9'; | |
216 } | |
217 } | |
218 | |
219 return digitContentNew; | |
220 } | |
221 | |
222 return UNSPECIFIC_RETURN; | |
223 } | |
224 | |
225 | |
226 static void showCompassDeclination(SSettings *settings, bool isRefresh) | |
227 { | |
228 char text[16]; | |
229 snprintf(text, 16, "%c%c:", TXT_2BYTE, TXT2BYTE_CompassDeclination); | |
230 write_label_var(30, 800, ME_Y_LINE6, &FontT48, text); | |
231 if (isRefresh) { | |
232 tMenuEdit_refresh_field(StMHARD2_Compass_Declination); | |
233 } else { | |
234 write_field_sdigit(StMHARD2_Compass_Declination, 500, 800, ME_Y_LINE6, &FontT48, "\034###`", settings->compassDeclinationDeg, 0, 0, 0); | |
235 } | |
236 } | |
237 | |
238 | |
162 void refresh_CompassEdit(void) | 239 void refresh_CompassEdit(void) |
163 { | 240 { |
241 SSettings *settings = settingsGetPointer(); | |
242 | |
164 uint16_t heading; | 243 uint16_t heading; |
165 char text[32]; | 244 char text[32]; |
166 uint8_t textIndex = 0; | 245 uint8_t textIndex = 0; |
167 | 246 |
168 text[0] = '\001'; | 247 text[0] = '\001'; |
169 text[1] = TXT_2BYTE; | 248 text[1] = TXT_2BYTE; |
170 text[2] = TXT2BYTE_Compass; | 249 text[2] = TXT2BYTE_Compass; |
171 text[3] = 0; | 250 text[3] = 0; |
172 write_topline(text); | 251 write_topline(text); |
173 | 252 |
174 if(settingsGetPointer()->compassInertia) | 253 if(settings->compassInertia) |
175 { | 254 { |
176 heading = (uint16_t)compass_getCompensated(); | 255 heading = (uint16_t)compass_getCompensated(); |
177 } | 256 } |
178 else | 257 else |
179 { | 258 { |
187 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); | 266 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); |
188 text[textIndex++] = TXT_2BYTE; | 267 text[textIndex++] = TXT_2BYTE; |
189 text[textIndex++] = TXT2BYTE_CompassInertia; | 268 text[textIndex++] = TXT2BYTE_CompassInertia; |
190 text[textIndex++] = ':'; | 269 text[textIndex++] = ':'; |
191 text[textIndex++] = ' '; | 270 text[textIndex++] = ' '; |
192 text[textIndex++] = '0' + settingsGetPointer()->compassInertia; | 271 text[textIndex++] = '0' + settings->compassInertia; |
193 | 272 |
194 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text); | 273 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text); |
195 | 274 |
275 showCompassDeclination(settings, true); | |
276 | |
196 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 277 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
197 } | 278 } |
198 | 279 |
199 | 280 |
200 void openEdit_Compass(void) | 281 void openEdit_Compass(void) |
201 { | 282 { |
283 SSettings *settings = settingsGetPointer(); | |
284 | |
202 char text[10]; | 285 char text[10]; |
203 uint8_t textIndex = 0; | 286 uint8_t textIndex = 0; |
204 | 287 |
205 text[textIndex++] = '\001'; | 288 text[textIndex++] = '\001'; |
206 text[textIndex++] = TXT_2BYTE; | 289 text[textIndex++] = TXT_2BYTE; |
212 text[2] = 0; | 295 text[2] = 0; |
213 | 296 |
214 text[1] = TXT2BYTE_SetBearing; | 297 text[1] = TXT2BYTE_SetBearing; |
215 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | 298 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); |
216 | 299 |
300 text[1] = TXT2BYTE_ResetBearing; | |
301 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE3, &FontT48, text); | |
302 | |
217 text[1] = TXT2BYTE_CompassCalib; | 303 text[1] = TXT2BYTE_CompassCalib; |
218 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE3, &FontT48, text); | 304 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, text); |
219 | |
220 text[1] = TXT2BYTE_ResetBearing; | |
221 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE4, &FontT48, text); | |
222 | 305 |
223 text[1] = TXT2BYTE_CompassInertia; | 306 text[1] = TXT2BYTE_CompassInertia; |
224 textIndex = 2; | 307 textIndex = 2; |
225 text[textIndex++] = ':'; | 308 text[textIndex++] = ':'; |
226 text[textIndex++] = ' '; | 309 text[textIndex++] = ' '; |
227 text[textIndex++] = '0' + settingsGetPointer()->compassInertia; | 310 text[textIndex++] = '0' + settings->compassInertia; |
311 text[textIndex++] = 0; | |
228 | 312 |
229 write_field_button(StMHARD2_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text); | 313 write_field_button(StMHARD2_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text); |
230 | 314 |
315 showCompassDeclination(settings, false); | |
316 | |
231 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); | 317 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); |
318 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
232 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); | 319 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); |
233 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
234 setEvent(StMHARD2_Compass_Inertia, (uint32_t)OnAction_InertiaLevel); | 320 setEvent(StMHARD2_Compass_Inertia, (uint32_t)OnAction_InertiaLevel); |
321 setEvent(StMHARD2_Compass_Declination, (uint32_t)OnAction_CompassDeclination); | |
235 | 322 |
236 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 323 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
237 } | 324 } |
238 | 325 |
239 | 326 |