Mercurial > public > ostc4
annotate Discovery/Src/tInfo.c @ 1007:65d35e66efb9 GasConsumption
Improve compass calibration dialog:
The previous calibration dialog showed some "magic" numbers and a 60 second count down. The new version is trying to guide the user through the calibration process: first rotate pitch, then roll and at last yaw angle. A step to the next angle is taken when enough data per angle is collected (change from red to green). To enable the yaw visualization a simple calibration is done while rotating the axis.
The function behind the calibration was not modified => the suggested process can be ignored and the same handling as the with old dialog may be applied. With the new process the dialog may be left early. Anyhow it will still be left after 60 seconds and the fine calibration is performed in the same way as before.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 05 May 2025 21:02:34 +0200 |
| parents | 92a5dc16d52b |
| children | cd4561c33758 |
| rev | line source |
|---|---|
| 38 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/tInfo.c | |
| 5 /// \brief Main Template file for Info menu page on left side | |
| 6 /// \author heinrichs weikamp gmbh | |
| 7 /// \date 11-Aug-2014 | |
| 8 /// | |
| 9 /// \details | |
| 10 /// | |
| 11 /// $Id$ | |
| 12 /////////////////////////////////////////////////////////////////////////////// | |
| 13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
| 14 /// | |
| 15 /// This program is free software: you can redistribute it and/or modify | |
| 16 /// it under the terms of the GNU General Public License as published by | |
| 17 /// the Free Software Foundation, either version 3 of the License, or | |
| 18 /// (at your option) any later version. | |
| 19 /// | |
| 20 /// This program is distributed in the hope that it will be useful, | |
| 21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 23 /// GNU General Public License for more details. | |
| 24 /// | |
| 25 /// You should have received a copy of the GNU General Public License | |
| 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 27 ////////////////////////////////////////////////////////////////////////////// | |
| 28 | |
| 29 /* Includes ------------------------------------------------------------------*/ | |
| 30 #include "tInfo.h" | |
| 31 | |
| 32 #include "data_exchange.h" | |
| 33 #include "tDebug.h" | |
| 34 #include "gfx_fonts.h" | |
| 35 #include "tHome.h" | |
| 36 //#include "tInfoDive.h" | |
| 37 //#include "tInfoSurface.h" | |
| 38 #include "tInfoCompass.h" | |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
39 #include "tInfoSensor.h" |
| 845 | 40 #include "tInfoPreDive.h" |
| 38 | 41 #include "tMenu.h" |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
42 #include "tMenuEdit.h" |
| 38 | 43 |
| 44 #include <string.h> | |
| 45 | |
| 46 /* Private types -------------------------------------------------------------*/ | |
| 47 | |
| 48 typedef struct | |
| 49 { | |
| 50 uint32_t pEventFunction; | |
| 51 uint32_t callerID; | |
| 52 } SInfoEventHandler; | |
| 53 | |
| 54 typedef struct | |
| 55 { | |
| 56 char orgText[32]; | |
| 57 char newText[32]; | |
| 699 | 58 uint8_t input; |
| 38 | 59 char symbolCounter; |
| 60 int8_t begin[4], size[4]; | |
| 61 uint16_t coord[3]; | |
| 62 tFont *fontUsed; | |
| 63 uint32_t callerID; | |
| 64 uint8_t maintype; | |
| 65 uint8_t subtype; | |
| 66 } SInfoIdent; | |
| 67 | |
| 68 typedef enum | |
| 69 { | |
| 70 FIELD_BUTTON = 1, | |
| 71 FIELD_SELECT, | |
| 72 FIELD_SYMBOL, | |
| 73 FIELD_TOGGLE, | |
| 74 FIELD_ON_OFF, | |
| 75 FIELD_END | |
| 76 } SInfoField; | |
| 77 | |
| 78 /* Private variables ---------------------------------------------------------*/ | |
| 79 GFX_DrawCfgScreen tIscreen; | |
| 80 GFX_DrawCfgScreen tIcursor; | |
| 81 | |
| 82 uint8_t infoColor = CLUT_InfoSurface; | |
| 83 | |
| 84 int8_t TIid = 0; | |
| 85 int8_t TIidLast = -1; | |
| 86 SInfoIdent TIident[10]; | |
| 87 | |
| 88 int8_t TIevid = 0; | |
| 89 int8_t TIevidLast = -1; | |
| 90 SInfoEventHandler TIevent[10]; | |
| 91 | |
| 92 /* Private function prototypes -----------------------------------------------*/ | |
| 93 void tInfo_build_page(void); | |
| 94 | |
| 95 void tI_set_cursor(uint8_t forThisIdentID); | |
| 96 void tI_startInfoFieldSelect(void); | |
| 97 void tInfo_write_content_of_actual_Id(void); | |
| 98 void tI_clean_content_of_actual_Id(void); | |
| 99 void tInfo_write_content_without_Id(void); | |
| 100 | |
| 101 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font); | |
| 102 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color); | |
| 103 | |
| 104 void tI_evaluateNewString (uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4); | |
| 105 | |
| 106 //void tI_tInfo_newInput (uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4); | |
| 107 //void tI_tInfo_newButtonText (uint32_t editID, char *text); | |
| 108 | |
| 109 void tI_enterInfoField(void); | |
| 110 void tI_nextInfoField(void); | |
| 111 | |
| 112 /* Announced function prototypes -----------------------------------------------*/ | |
| 113 //uint8_t OnAction_ILoglist (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 114 //uint8_t OnAction_ISimulator (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
| 115 | |
| 116 /* Exported functions --------------------------------------------------------*/ | |
| 117 | |
| 118 void tI_init(void) | |
| 119 { | |
| 120 tIscreen.FBStartAdress = 0; | |
| 121 tIscreen.ImageHeight = 480; | |
| 122 tIscreen.ImageWidth = 800; | |
| 123 tIscreen.LayerIndex = 1; | |
| 124 | |
| 125 tIcursor.FBStartAdress = getFrame(12); | |
| 126 tIcursor.ImageHeight = 480; | |
| 127 tIcursor.ImageWidth = 800; | |
| 128 tIcursor.LayerIndex = 0; | |
| 129 | |
| 130 GFX_fill_buffer(tIcursor.FBStartAdress, 0xFF, CLUT_InfoCursor); | |
| 131 } | |
| 132 | |
| 133 | |
| 134 void openInfo(uint32_t modeToStart) | |
| 135 { | |
| 136 if((modeToStart != StILOGLIST) && (modeToStart != StIDEBUG)) | |
| 137 return; | |
| 138 | |
| 139 TIid = 0; | |
| 140 TIidLast = -1; | |
| 141 TIevid = 0; | |
| 142 TIevidLast = -1; | |
| 143 | |
| 144 if(tIscreen.FBStartAdress) | |
| 145 releaseFrame(14,tIscreen.FBStartAdress); | |
| 146 tIscreen.FBStartAdress = getFrame(14); | |
| 147 | |
| 148 // GFX_SetFramesTopBottom(tIscreen.FBStartAdress, tIcursor.FBStartAdress,480); | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
149 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); |
| 38 | 150 infoColor = CLUT_InfoSurface; |
| 151 | |
| 152 if(modeToStart == StIDEBUG) | |
| 153 { | |
| 154 tDebug_start(); | |
| 155 } | |
| 156 else | |
| 157 { | |
| 158 openLog(0); | |
| 159 } | |
| 160 // openInfoLogLastDive(); | |
| 161 } | |
| 162 | |
| 163 /* | |
| 164 void openInfo(void) | |
| 165 { | |
| 166 if((stateUsed->mode == MODE_DIVE) && (!is_stateUsedSetToSim())) | |
| 167 { | |
| 168 return; | |
| 169 } | |
| 170 | |
| 171 TIid = 0; | |
| 172 TIidLast = -1; | |
| 173 TIevid = 0; | |
| 174 TIevidLast = -1; | |
| 175 | |
| 176 if(tIscreen.FBStartAdress) | |
| 177 releaseFrame(14,tIscreen.FBStartAdress); | |
| 178 tIscreen.FBStartAdress = getFrame(14); | |
| 179 | |
| 180 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, tIcursor.FBStartAdress,480); | |
| 181 | |
| 182 if(stateUsed->mode == MODE_DIVE) | |
| 183 { | |
| 184 infoColor = CLUT_InfoSurface; | |
| 185 openInfo_Dive(); | |
| 186 } | |
| 187 else | |
| 188 { | |
| 189 infoColor = CLUT_InfoDive; | |
| 190 openInfo_Surface(); | |
| 191 } | |
| 192 } | |
| 193 */ | |
| 194 | |
| 195 /* | |
| 196 uint8_t OnAction_ILoglist (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 197 { | |
| 198 return 255; | |
| 199 } | |
| 200 */ | |
| 201 | |
| 202 void tInfo_refresh(void) | |
| 203 { | |
| 204 uint32_t oldIscreen; | |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
205 uint32_t globalState = get_globalState(); |
| 38 | 206 oldIscreen = tIscreen.FBStartAdress; |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
207 |
| 38 | 208 if(inDebugMode()) |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
209 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
210 tIscreen.FBStartAdress = getFrame(14); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
211 infoColor = CLUT_InfoCompass; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
212 tDebug_refresh(); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
213 } |
| 38 | 214 else |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
215 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
216 switch(globalState) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
217 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
218 case StICOMPASS: tIscreen.FBStartAdress = getFrame(14); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
219 infoColor = CLUT_InfoCompass; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
220 refreshInfo_Compass(tIscreen); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
221 break; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
222 case StISENINFO: tIscreen.FBStartAdress = getFrame(14); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
223 infoColor = CLUT_MenuPageHardware; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
224 refreshInfo_Sensor(tIscreen); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
225 break; |
| 845 | 226 case StIPREDIVE: tIscreen.FBStartAdress = getFrame(14); |
| 227 infoColor = CLUT_MenuPageGasCC; | |
| 228 refreshInfo_PreDive(tIscreen); | |
| 229 break; | |
| 230 | |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
231 default: |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
232 break; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
233 } |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
234 } |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
235 if(oldIscreen != tIscreen.FBStartAdress) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
236 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
237 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
238 if(oldIscreen) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
239 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
240 releaseFrame(14,oldIscreen); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
241 } |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
242 } |
| 38 | 243 } |
| 244 | |
| 245 | |
| 246 void exitInfo(void) | |
| 247 { | |
| 248 set_globalState_tHome(); | |
| 249 releaseFrame(14,tIscreen.FBStartAdress); | |
| 250 exitDebugMode(); | |
| 251 } | |
| 252 | |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
253 void exitInfoToBack(void) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
254 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
255 releaseFrame(14,tIscreen.FBStartAdress); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
256 exitMenuEdit_to_BackMenu(); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
257 } |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
258 |
| 38 | 259 |
| 260 void sendActionToInfo(uint8_t sendAction) | |
| 261 { | |
| 262 if(inDebugMode()) | |
| 263 { | |
| 264 tDebugControl(sendAction); | |
| 265 return; | |
| 266 } | |
| 267 | |
| 268 if(get_globalState() == StICOMPASS) | |
| 269 return; | |
| 270 | |
| 271 switch(sendAction) | |
| 272 { | |
| 273 case ACTION_BUTTON_ENTER: | |
| 274 tI_enterInfoField(); | |
| 275 break; | |
| 276 case ACTION_BUTTON_NEXT: | |
| 277 tI_nextInfoField(); | |
| 278 break; | |
| 279 case ACTION_TIMEOUT: | |
| 280 case ACTION_MODE_CHANGE: | |
| 281 case ACTION_BUTTON_BACK: | |
| 282 exitInfo(); | |
|
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
283 break; |
| 38 | 284 default: |
| 285 break; | |
| 286 case ACTION_IDLE_TICK: | |
| 287 case ACTION_IDLE_SECOND: | |
| 288 break; | |
| 289 } | |
| 290 | |
| 291 } | |
| 292 | |
| 293 /* Private functions ---------------------------------------------------------*/ | |
| 294 | |
| 295 void tInfo_build_page(void) | |
| 296 { | |
| 297 tInfo_write_content_simple( 30, 340, 90, &FontT48, "Logbook", CLUT_Font020); | |
| 298 | |
| 299 } | |
| 300 | |
| 1007 | 301 |
| 302 void tInfo_drawPixel(int16_t x, int16_t y, uint8_t color) | |
| 303 { | |
| 304 int8_t xoff; | |
| 305 int8_t yoff; | |
| 306 | |
| 307 for (xoff = -1; xoff < 2; xoff++) | |
| 308 { | |
| 309 for (yoff = -1; yoff < 2; yoff++) | |
| 310 { | |
| 311 GFX_draw_pixel(&tIscreen, x + xoff, y + yoff, color); | |
| 312 } | |
| 313 } | |
| 314 GFX_draw_pixel(&tIscreen, x, y, color); | |
| 315 } | |
| 316 | |
| 317 void tInfo_draw_colorline(point_t start, point_t stop, uint8_t color) | |
| 318 { | |
| 319 GFX_draw_colorline(&tIscreen, start, stop, color); | |
| 320 } | |
| 321 | |
| 322 void t_Info_draw_circle(point_t center, uint8_t radius, int8_t color) | |
| 323 { | |
| 324 GFX_draw_circle(&tIscreen, center, radius, color); | |
| 325 } | |
| 326 | |
| 38 | 327 void tInfo_write_content_simple(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) |
| 328 { | |
| 329 GFX_DrawCfgWindow hgfx; | |
| 330 | |
| 331 if(XrightGimpStyle > 799) | |
| 332 XrightGimpStyle = 799; | |
| 333 if(XleftGimpStyle >= XrightGimpStyle) | |
| 334 XleftGimpStyle = 0; | |
| 335 if(YtopGimpStyle > 479) | |
| 336 YtopGimpStyle = 479; | |
| 337 hgfx.Image = &tIscreen; | |
| 338 hgfx.WindowNumberOfTextLines = 1; | |
| 339 hgfx.WindowLineSpacing = 0; | |
| 340 hgfx.WindowTab = 400; | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
341 |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
342 if(!settingsGetPointer()->FlipDisplay) |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
343 { |
| 848 | 344 hgfx.WindowX0 = XleftGimpStyle; |
| 345 hgfx.WindowX1 = XrightGimpStyle; | |
| 346 | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
347 hgfx.WindowY1 = 479 - YtopGimpStyle; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
348 if(hgfx.WindowY1 < Font->height) |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
349 hgfx.WindowY0 = 0; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
350 else |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
351 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
352 } |
| 38 | 353 else |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
354 { |
| 848 | 355 hgfx.WindowX0 = 800 - XrightGimpStyle; |
| 356 hgfx.WindowX1 = 800 - XleftGimpStyle; | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
357 hgfx.WindowY0 = YtopGimpStyle; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
358 hgfx.WindowY1 = YtopGimpStyle + Font->height; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
359 } |
| 38 | 360 |
| 361 GFX_write_string_color(Font, &hgfx, text, 0, color); | |
| 362 } | |
| 363 | |
| 364 /* Exported functions --------------------------------------------------------*/ | |
| 365 | |
| 366 void tI_startInfoFieldSelect(void) | |
| 367 { | |
| 368 TIid = 0; | |
| 369 tI_set_cursor(TIid); | |
| 370 } | |
| 371 | |
| 372 | |
| 373 void tI_nextInfoField(void) | |
| 374 { | |
| 375 if(TIid < TIidLast) | |
| 376 TIid++; | |
| 377 else | |
| 378 TIid = 0; | |
| 379 tI_set_cursor(TIid); | |
| 380 } | |
| 381 | |
| 382 | |
| 383 void tI_previousInfoField(void) | |
| 384 { | |
| 385 if(TIid > 0) | |
| 386 TIid--; | |
| 387 else | |
| 388 TIid = TIidLast; | |
| 389 tI_set_cursor(TIid); | |
| 390 } | |
| 391 | |
| 392 | |
| 393 uint8_t tI_get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
| 394 { | |
| 395 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
| 396 uint8_t content; | |
| 397 | |
| 398 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
| 399 return 0; | |
| 400 | |
| 401 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(TIevent[TIevid].pEventFunction); | |
| 402 | |
| 403 if(TIident[TIid].maintype == FIELD_ON_OFF) | |
| 404 content = TIident[TIid].input; | |
| 405 else | |
| 406 content = 0; /* just a default for protection */ | |
| 407 | |
| 408 return onActionFunc(TIident[TIid].callerID, 0, 0, content, action); | |
| 409 } | |
| 410 | |
| 411 | |
| 412 void tI_enterInfoField(void) | |
| 413 { | |
| 414 uint8_t newContent; | |
| 415 | |
| 416 TIevid = 0; | |
| 417 while((TIevid < TIevidLast) && (TIevent[TIevid].callerID != TIident[TIid].callerID)) | |
| 418 { | |
| 419 TIevid++; | |
| 420 } | |
| 421 | |
| 422 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
| 423 return; | |
| 424 | |
| 425 newContent = tI_get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
| 426 | |
| 427 if(newContent == 255) | |
| 428 { | |
| 429 exitInfo(); | |
| 430 return; | |
| 431 } | |
| 432 | |
| 433 switch(TIident[TIid].maintype) | |
| 434 { | |
| 435 case FIELD_BUTTON: | |
| 436 break; | |
| 437 case FIELD_ON_OFF: | |
| 438 break; | |
| 439 case FIELD_SYMBOL: | |
| 440 TIident[TIid].input += 1; | |
| 441 if(TIident[TIid].input >= TIident[TIid].symbolCounter) | |
| 442 TIident[TIid].input = 0; | |
| 443 TIident[TIid].newText[0] = TIident[TIid].orgText[TIident[TIid].input]; | |
| 444 tInfo_write_content_of_actual_Id(); | |
| 445 break; | |
| 446 } | |
| 447 } | |
| 448 | |
| 449 | |
| 450 void tI_evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
| 451 { | |
| 452 if(editID != TIident[TIid].callerID) | |
| 453 return; | |
| 454 | |
| 455 uint8_t i, digitCount, digit; | |
| 456 uint32_t sum[4], multiplier; | |
| 457 | |
| 458 for(i=0;i<4;i++) | |
| 459 sum[i] = 0; | |
| 460 | |
| 461 i = 0; | |
| 462 while( TIident[TIid].size[i] && (i < 4)) | |
| 463 { | |
| 464 multiplier = 1; | |
| 465 for(digitCount = 1; digitCount < TIident[TIid].size[i]; digitCount++) | |
| 466 multiplier *= 10; | |
| 467 | |
| 468 for(digitCount = 0; digitCount < TIident[TIid].size[i]; digitCount++) | |
| 469 { | |
| 470 digit = TIident[TIid].newText[TIident[TIid].begin[i] + digitCount]; | |
| 471 | |
| 472 if(digit > '0') | |
| 473 digit -= '0'; | |
| 474 else | |
| 475 digit = 0; | |
| 476 | |
| 477 if(digit > 9) | |
| 478 digit = 9; | |
| 479 | |
| 480 sum[i] += digit * multiplier; | |
| 481 | |
| 482 if(multiplier >= 10) | |
| 483 multiplier /= 10; | |
| 484 else | |
| 485 multiplier = 0; | |
| 486 } | |
| 487 i++; | |
| 488 } | |
| 489 | |
| 490 *pNewValue1 = sum[0]; | |
| 491 *pNewValue2 = sum[1]; | |
| 492 *pNewValue3 = sum[2]; | |
| 493 *pNewValue4 = sum[3]; | |
| 494 } | |
| 495 | |
| 496 | |
| 497 uint8_t tI_get_id_of(uint32_t editID) | |
| 498 { | |
| 499 uint8_t temp_id; | |
| 500 | |
| 501 if(editID == TIident[TIid].callerID) | |
| 502 return TIid; | |
| 503 else | |
| 504 { | |
| 505 temp_id = 0; | |
| 506 while((temp_id < 9) && (editID != TIident[temp_id].callerID)) | |
| 507 temp_id++; | |
| 508 if(editID != TIident[temp_id].callerID) | |
| 509 temp_id = 255; | |
| 510 return temp_id; | |
| 511 } | |
| 512 } | |
| 513 | |
| 514 | |
| 515 void tI_newButtonText(uint32_t editID, char *text) | |
| 516 { | |
| 517 uint8_t backup_id, temp_id; | |
| 518 | |
| 519 temp_id = tI_get_id_of(editID); | |
| 520 if(temp_id == 255) | |
| 521 return; | |
| 522 | |
| 523 backup_id = TIid; | |
| 524 TIid = temp_id; | |
| 525 | |
| 526 strncpy(TIident[TIid].newText, text, 32); | |
| 527 TIident[TIid].newText[31] = 0; | |
| 528 | |
| 529 tI_clean_content_of_actual_Id(); | |
| 530 tInfo_write_content_of_actual_Id(); | |
| 531 | |
| 532 TIid = backup_id; | |
| 533 } | |
| 534 | |
| 535 | |
| 699 | 536 void tInfo_set_on_off(uint32_t editID, uint8_t int1) |
| 38 | 537 { |
| 538 uint8_t backup_id, temp_id; | |
| 539 | |
| 540 temp_id = tI_get_id_of(editID); | |
| 541 if(temp_id == 255) | |
| 542 return; | |
| 543 | |
| 544 backup_id = TIid; | |
| 545 TIid = temp_id; | |
| 546 | |
| 547 TIident[TIid].input = int1; | |
| 548 | |
| 549 if(int1) | |
| 550 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
| 551 else | |
| 552 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
| 553 | |
| 554 tInfo_write_content_of_actual_Id(); | |
| 555 | |
| 556 TIid = backup_id; | |
| 557 } | |
| 558 | |
| 559 | |
| 560 void tInfo_write_content_without_Id(void) | |
| 561 { | |
| 562 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, CLUT_InfoFieldRegular); | |
| 563 } | |
| 564 | |
| 565 | |
| 566 void tInfo_write_content_of_actual_Id(void) | |
| 567 { | |
| 568 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, (CLUT_InfoField0 + TIid)); | |
| 569 } | |
| 570 | |
| 571 | |
| 572 void tI_clean_content_of_actual_Id(void) | |
| 573 { | |
| 574 tI_clean_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed); | |
| 575 } | |
| 576 | |
| 577 | |
| 578 void tInfo_write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
| 579 { | |
| 580 if(TIidLast >= 9) | |
| 581 return; | |
| 582 | |
| 583 TIident[TIid].maintype = FIELD_BUTTON; | |
| 584 TIident[TIid].subtype = FIELD_BUTTON; | |
| 585 | |
| 586 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 587 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 588 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 589 TIident[TIid].fontUsed = (tFont *)Font; | |
| 590 TIident[TIid].callerID = editID; | |
| 591 | |
| 592 strncpy(TIident[TIid].orgText, text, 32); | |
| 593 strncpy(TIident[TIid].newText, text, 32); | |
| 594 TIident[TIid].orgText[31] = 0; | |
| 595 TIident[TIid].newText[31] = 0; | |
| 596 | |
| 597 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
| 598 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
599 if(editID == 0) |
| 38 | 600 tInfo_write_content_without_Id(); |
| 601 else | |
| 602 { | |
| 603 tInfo_write_content_of_actual_Id(); | |
| 604 TIidLast = TIid; | |
| 605 TIid++; | |
| 606 } | |
| 607 } | |
| 608 | |
| 609 | |
| 610 void tInfo_write_field_symbol(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
| 611 { | |
| 612 if(TIidLast >= 9) | |
| 613 return; | |
| 614 | |
| 615 TIident[TIid].maintype = FIELD_SYMBOL; | |
| 616 TIident[TIid].subtype = FIELD_SYMBOL; | |
| 617 | |
| 618 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 619 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 620 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 621 TIident[TIid].fontUsed = (tFont *)Font; | |
| 622 TIident[TIid].callerID = editID; | |
| 623 | |
| 624 strncpy(TIident[TIid].orgText, text, 32); | |
| 625 strncpy(TIident[TIid].newText, text, 32); | |
| 626 TIident[TIid].orgText[31] = 0; | |
| 627 | |
| 628 TIident[TIid].newText[0] = text[0]; | |
| 629 TIident[TIid].newText[1] = 0; | |
| 630 | |
| 631 TIident[TIid].input = int1; | |
| 632 TIident[TIid].symbolCounter = strlen(TIident[TIid].orgText); | |
| 633 | |
| 634 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
| 635 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
636 if(editID == 0) |
| 38 | 637 tInfo_write_content_without_Id(); |
| 638 else | |
| 639 { | |
| 640 tInfo_write_content_of_actual_Id(); | |
| 641 TIidLast = TIid; | |
| 642 TIid++; | |
| 643 } | |
| 644 } | |
| 645 | |
| 646 | |
| 647 void tInfo_write_field_on_off(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
| 648 { | |
| 649 if(TIidLast >= 9) | |
| 650 return; | |
| 651 | |
| 652 TIident[TIid].maintype = FIELD_ON_OFF; | |
| 653 TIident[TIid].subtype = FIELD_ON_OFF; | |
| 654 | |
| 655 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 656 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 657 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 658 TIident[TIid].fontUsed = (tFont *)Font; | |
| 659 TIident[TIid].callerID = editID; | |
| 660 | |
| 661 strncpy(TIident[TIid].orgText, text, 32); | |
| 662 strncpy(TIident[TIid].newText, text, 32); | |
| 663 TIident[TIid].orgText[31] = 0; | |
| 664 TIident[TIid].newText[31] = 0; | |
| 665 | |
| 666 | |
| 667 if(int1) | |
| 668 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
| 669 else | |
| 670 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
| 671 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
672 if(editID == 0) |
| 38 | 673 tInfo_write_content_without_Id(); |
| 674 else | |
| 675 { | |
| 676 tInfo_write_content_of_actual_Id(); | |
| 677 TIidLast = TIid; | |
| 678 TIid++; | |
| 679 } | |
| 680 } | |
| 681 | |
| 682 | |
| 683 void tInfo_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
| 684 { | |
| 685 if(TIevidLast >= 9) | |
| 686 return; | |
| 687 | |
| 688 /* set cursor to first field */ | |
| 689 if(TIevidLast < 0) | |
| 690 { | |
| 691 tI_startInfoFieldSelect(); | |
| 692 } | |
| 693 | |
| 694 TIevent[TIevid].callerID = inputEventID; | |
| 695 TIevent[TIevid].pEventFunction = inputFunctionCall; | |
| 696 | |
| 697 TIevidLast = TIevid; | |
| 698 TIevid++; | |
| 699 } | |
| 700 | |
| 701 | |
| 702 void tI_set_cursor(uint8_t forThisIdentID) | |
| 703 { | |
| 704 int16_t x0, x1, y0, y1; | |
| 705 | |
| 706 uint32_t xtra_left_right = 10; | |
| 707 uint32_t xtra_top_bottom = 10; | |
| 708 | |
| 709 /* y geht von 0 bis 799 */ | |
| 710 /* x geht von 0 bis 479 */ | |
| 711 | |
| 712 x0 = (int16_t)TIident[forThisIdentID].coord[0]; | |
| 713 x1 = (int16_t)TIident[forThisIdentID].coord[1]; | |
| 714 y0 = (int16_t)TIident[forThisIdentID].coord[2]; | |
| 715 y1 = y0 + (int16_t)TIident[forThisIdentID].fontUsed->height; | |
| 716 | |
| 717 if(((int16_t)TIident[forThisIdentID].fontUsed->height) > 70) | |
| 718 { | |
| 719 xtra_left_right = 10; | |
| 720 xtra_top_bottom = 10; | |
| 721 } | |
| 722 else | |
| 723 { | |
| 724 xtra_left_right = 10; | |
| 725 xtra_top_bottom = 0; | |
| 726 } | |
| 727 | |
| 728 x0 -= xtra_left_right; | |
| 729 x1 += xtra_left_right; | |
| 730 y0 -= xtra_top_bottom; | |
| 731 y1 += xtra_top_bottom; | |
| 732 | |
| 733 GFX_SetWindowLayer0(tIcursor.FBStartAdress, x0, x1, y0, y1); | |
| 734 } | |
| 735 | |
| 736 | |
| 737 void tInfo_write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
| 738 { | |
| 739 GFX_DrawCfgWindow hgfx; | |
| 740 | |
| 741 if(XrightGimpStyle > 799) | |
| 742 XrightGimpStyle = 799; | |
| 743 if(XleftGimpStyle >= XrightGimpStyle) | |
| 744 XleftGimpStyle = 0; | |
| 745 if(YtopGimpStyle > 479) | |
| 746 YtopGimpStyle = 479; | |
| 747 hgfx.Image = &tIscreen; | |
| 748 hgfx.WindowNumberOfTextLines = 1; | |
| 749 hgfx.WindowLineSpacing = 0; | |
| 750 hgfx.WindowTab = 0; | |
| 751 hgfx.WindowX0 = XleftGimpStyle; | |
| 752 hgfx.WindowX1 = XrightGimpStyle; | |
| 753 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 754 if(hgfx.WindowY1 < Font->height) | |
| 755 hgfx.WindowY0 = 0; | |
| 756 else | |
| 757 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 758 | |
| 759 GFX_write_label(Font, &hgfx, text, infoColor); | |
| 760 } | |
| 761 | |
| 762 | |
| 763 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
| 764 { | |
| 765 GFX_DrawCfgWindow hgfx; | |
| 766 | |
| 767 if(XrightGimpStyle > 799) | |
| 768 XrightGimpStyle = 799; | |
| 769 if(XleftGimpStyle >= XrightGimpStyle) | |
| 770 XleftGimpStyle = 0; | |
| 771 if(YtopGimpStyle > 479) | |
| 772 YtopGimpStyle = 479; | |
| 773 hgfx.Image = &tIscreen; | |
| 774 hgfx.WindowNumberOfTextLines = 1; | |
| 775 hgfx.WindowLineSpacing = 0; | |
| 776 hgfx.WindowTab = 0; | |
| 777 hgfx.WindowX0 = XleftGimpStyle; | |
| 778 hgfx.WindowX1 = XrightGimpStyle; | |
| 779 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 780 if(hgfx.WindowY1 < Font->height) | |
| 781 hgfx.WindowY0 = 0; | |
| 782 else | |
| 783 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 784 | |
| 785 GFX_write_label(Font, &hgfx, text, color); | |
| 786 } | |
| 787 | |
| 788 | |
| 789 void tInfo_write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
| 790 { | |
| 791 char text[2]; | |
| 792 | |
| 793 text[0] = textId; | |
| 794 text[1] = 0; | |
| 795 | |
| 796 tInfo_write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
| 797 } | |
| 798 | |
| 799 | |
| 800 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
| 801 { | |
| 802 GFX_DrawCfgWindow hgfx; | |
| 803 | |
| 804 if(XrightGimpStyle > 799) | |
| 805 XrightGimpStyle = 799; | |
| 806 if(XleftGimpStyle >= XrightGimpStyle) | |
| 807 XleftGimpStyle = 0; | |
| 808 if(YtopGimpStyle > 479) | |
| 809 YtopGimpStyle = 479; | |
| 810 hgfx.Image = &tIscreen; | |
| 811 hgfx.WindowX0 = XleftGimpStyle; | |
| 812 hgfx.WindowX1 = XrightGimpStyle; | |
| 813 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 814 if(hgfx.WindowY1 < Font->height) | |
| 815 hgfx.WindowY0 = 0; | |
| 816 else | |
| 817 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 818 | |
| 819 GFX_clear_window_immediately(&hgfx); | |
| 820 } | |
| 821 | |
| 822 | |
| 823 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
| 824 { | |
| 825 GFX_clean_area(&tIscreen, 0, 800, 480-24,480); | |
| 826 | |
| 827 char localtext[32]; | |
| 828 | |
| 829 if(left2ByteCode) | |
| 830 { | |
| 831 localtext[0] = TXT_2BYTE; | |
| 832 localtext[1] = left2ByteCode; | |
| 833 localtext[2] = 0; | |
| 834 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 835 } | |
| 836 | |
| 837 if(middle2ByteCode) | |
| 838 { | |
| 839 localtext[0] = '\001'; | |
| 840 localtext[1] = TXT_2BYTE; | |
| 841 localtext[2] = middle2ByteCode; | |
| 842 localtext[3] = 0; | |
| 843 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 844 } | |
| 845 | |
| 846 if(right2ByteCode) | |
| 847 { | |
| 848 localtext[0] = '\002'; | |
| 849 localtext[1] = TXT_2BYTE; | |
| 850 localtext[2] = right2ByteCode; | |
| 851 localtext[3] = 0; | |
| 852 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 853 } | |
| 854 } | |
| 845 | 855 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
| 856 { | |
| 857 char localtext[32]; | |
| 858 | |
| 859 if(left2ByteCode) | |
| 860 { | |
| 861 localtext[0] = TXT_2BYTE; | |
| 862 localtext[1] = left2ByteCode; | |
| 863 localtext[2] = 0; | |
| 864 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 865 } | |
| 866 | |
| 867 if(middle2ByteCode) | |
| 868 { | |
| 869 localtext[0] = '\001'; | |
| 870 localtext[1] = TXT_2BYTE; | |
| 871 localtext[2] = middle2ByteCode; | |
| 872 localtext[3] = 0; | |
| 873 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 874 } | |
| 875 | |
| 876 if(right2ByteCode) | |
| 877 { | |
| 878 localtext[0] = '\002'; | |
| 879 localtext[1] = TXT_2BYTE; | |
| 880 localtext[2] = right2ByteCode; | |
| 881 localtext[3] = 0; | |
| 882 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 883 } | |
| 884 } |
