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