Mercurial > public > ostc4
annotate Discovery/Src/tInfo.c @ 1034:195bfbdf961d Puls_Integration
Pulse measurement integration:
Added function to parse standart GATT pulse service. Added compile switch to remove code from non dev builds.
| author | Ideenmodellierer |
|---|---|
| date | Thu, 07 Aug 2025 20:18:52 +0200 |
| parents | cd4561c33758 |
| children | 5b913cdaa9dc |
| 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; | |
| 1031 | 231 case StILOGGER: tIscreen.FBStartAdress = getFrame(14); |
| 232 infoColor = CLUT_MenuPageCvOption; | |
| 233 refreshInfo_Logger(tIscreen); | |
| 234 break; | |
| 845 | 235 |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
236 default: |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
237 break; |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
238 } |
|
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 if(oldIscreen != tIscreen.FBStartAdress) |
|
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 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
243 if(oldIscreen) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
244 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
245 releaseFrame(14,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 } |
| 38 | 248 } |
| 249 | |
| 250 | |
| 251 void exitInfo(void) | |
| 252 { | |
| 253 set_globalState_tHome(); | |
| 254 releaseFrame(14,tIscreen.FBStartAdress); | |
| 255 exitDebugMode(); | |
| 256 } | |
| 257 | |
|
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
258 void exitInfoToBack(void) |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
259 { |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
260 releaseFrame(14,tIscreen.FBStartAdress); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
261 exitMenuEdit_to_BackMenu(); |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
262 } |
|
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
263 |
| 38 | 264 |
| 265 void sendActionToInfo(uint8_t sendAction) | |
| 266 { | |
| 267 if(inDebugMode()) | |
| 268 { | |
| 269 tDebugControl(sendAction); | |
| 270 return; | |
| 271 } | |
| 272 | |
| 273 if(get_globalState() == StICOMPASS) | |
| 274 return; | |
| 275 | |
| 276 switch(sendAction) | |
| 277 { | |
| 278 case ACTION_BUTTON_ENTER: | |
| 279 tI_enterInfoField(); | |
| 280 break; | |
| 281 case ACTION_BUTTON_NEXT: | |
| 282 tI_nextInfoField(); | |
| 283 break; | |
| 284 case ACTION_TIMEOUT: | |
| 285 case ACTION_MODE_CHANGE: | |
| 286 case ACTION_BUTTON_BACK: | |
| 287 exitInfo(); | |
|
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
288 break; |
| 38 | 289 default: |
| 290 break; | |
| 291 case ACTION_IDLE_TICK: | |
| 292 case ACTION_IDLE_SECOND: | |
| 293 break; | |
| 294 } | |
| 295 | |
| 296 } | |
| 297 | |
| 298 /* Private functions ---------------------------------------------------------*/ | |
| 299 | |
| 300 void tInfo_build_page(void) | |
| 301 { | |
| 302 tInfo_write_content_simple( 30, 340, 90, &FontT48, "Logbook", CLUT_Font020); | |
| 303 | |
| 304 } | |
| 305 | |
| 1007 | 306 |
| 307 void tInfo_drawPixel(int16_t x, int16_t y, uint8_t color) | |
| 308 { | |
| 309 int8_t xoff; | |
| 310 int8_t yoff; | |
| 311 | |
| 312 for (xoff = -1; xoff < 2; xoff++) | |
| 313 { | |
| 314 for (yoff = -1; yoff < 2; yoff++) | |
| 315 { | |
| 316 GFX_draw_pixel(&tIscreen, x + xoff, y + yoff, color); | |
| 317 } | |
| 318 } | |
| 319 GFX_draw_pixel(&tIscreen, x, y, color); | |
| 320 } | |
| 321 | |
| 322 void tInfo_draw_colorline(point_t start, point_t stop, uint8_t color) | |
| 323 { | |
| 324 GFX_draw_colorline(&tIscreen, start, stop, color); | |
| 325 } | |
| 326 | |
| 327 void t_Info_draw_circle(point_t center, uint8_t radius, int8_t color) | |
| 328 { | |
| 329 GFX_draw_circle(&tIscreen, center, radius, color); | |
| 330 } | |
| 331 | |
| 38 | 332 void tInfo_write_content_simple(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) |
| 333 { | |
| 334 GFX_DrawCfgWindow hgfx; | |
| 335 | |
| 336 if(XrightGimpStyle > 799) | |
| 337 XrightGimpStyle = 799; | |
| 338 if(XleftGimpStyle >= XrightGimpStyle) | |
| 339 XleftGimpStyle = 0; | |
| 340 if(YtopGimpStyle > 479) | |
| 341 YtopGimpStyle = 479; | |
| 342 hgfx.Image = &tIscreen; | |
| 343 hgfx.WindowNumberOfTextLines = 1; | |
| 344 hgfx.WindowLineSpacing = 0; | |
| 345 hgfx.WindowTab = 400; | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
346 |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
347 if(!settingsGetPointer()->FlipDisplay) |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
348 { |
| 848 | 349 hgfx.WindowX0 = XleftGimpStyle; |
| 350 hgfx.WindowX1 = XrightGimpStyle; | |
| 351 | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
352 hgfx.WindowY1 = 479 - YtopGimpStyle; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
353 if(hgfx.WindowY1 < Font->height) |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
354 hgfx.WindowY0 = 0; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
355 else |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
356 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
357 } |
| 38 | 358 else |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
359 { |
| 848 | 360 hgfx.WindowX0 = 800 - XrightGimpStyle; |
| 361 hgfx.WindowX1 = 800 - XleftGimpStyle; | |
|
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
362 hgfx.WindowY0 = YtopGimpStyle; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
363 hgfx.WindowY1 = YtopGimpStyle + Font->height; |
|
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
364 } |
| 38 | 365 |
| 366 GFX_write_string_color(Font, &hgfx, text, 0, color); | |
| 367 } | |
| 368 | |
| 369 /* Exported functions --------------------------------------------------------*/ | |
| 370 | |
| 371 void tI_startInfoFieldSelect(void) | |
| 372 { | |
| 373 TIid = 0; | |
| 374 tI_set_cursor(TIid); | |
| 375 } | |
| 376 | |
| 377 | |
| 378 void tI_nextInfoField(void) | |
| 379 { | |
| 380 if(TIid < TIidLast) | |
| 381 TIid++; | |
| 382 else | |
| 383 TIid = 0; | |
| 384 tI_set_cursor(TIid); | |
| 385 } | |
| 386 | |
| 387 | |
| 388 void tI_previousInfoField(void) | |
| 389 { | |
| 390 if(TIid > 0) | |
| 391 TIid--; | |
| 392 else | |
| 393 TIid = TIidLast; | |
| 394 tI_set_cursor(TIid); | |
| 395 } | |
| 396 | |
| 397 | |
| 398 uint8_t tI_get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
| 399 { | |
| 400 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
| 401 uint8_t content; | |
| 402 | |
| 403 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
| 404 return 0; | |
| 405 | |
| 406 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(TIevent[TIevid].pEventFunction); | |
| 407 | |
| 408 if(TIident[TIid].maintype == FIELD_ON_OFF) | |
| 409 content = TIident[TIid].input; | |
| 410 else | |
| 411 content = 0; /* just a default for protection */ | |
| 412 | |
| 413 return onActionFunc(TIident[TIid].callerID, 0, 0, content, action); | |
| 414 } | |
| 415 | |
| 416 | |
| 417 void tI_enterInfoField(void) | |
| 418 { | |
| 419 uint8_t newContent; | |
| 420 | |
| 421 TIevid = 0; | |
| 422 while((TIevid < TIevidLast) && (TIevent[TIevid].callerID != TIident[TIid].callerID)) | |
| 423 { | |
| 424 TIevid++; | |
| 425 } | |
| 426 | |
| 427 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
| 428 return; | |
| 429 | |
| 430 newContent = tI_get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
| 431 | |
| 432 if(newContent == 255) | |
| 433 { | |
| 434 exitInfo(); | |
| 435 return; | |
| 436 } | |
| 437 | |
| 438 switch(TIident[TIid].maintype) | |
| 439 { | |
| 440 case FIELD_BUTTON: | |
| 441 break; | |
| 442 case FIELD_ON_OFF: | |
| 443 break; | |
| 444 case FIELD_SYMBOL: | |
| 445 TIident[TIid].input += 1; | |
| 446 if(TIident[TIid].input >= TIident[TIid].symbolCounter) | |
| 447 TIident[TIid].input = 0; | |
| 448 TIident[TIid].newText[0] = TIident[TIid].orgText[TIident[TIid].input]; | |
| 449 tInfo_write_content_of_actual_Id(); | |
| 450 break; | |
| 451 } | |
| 452 } | |
| 453 | |
| 454 | |
| 455 void tI_evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
| 456 { | |
| 457 if(editID != TIident[TIid].callerID) | |
| 458 return; | |
| 459 | |
| 460 uint8_t i, digitCount, digit; | |
| 461 uint32_t sum[4], multiplier; | |
| 462 | |
| 463 for(i=0;i<4;i++) | |
| 464 sum[i] = 0; | |
| 465 | |
| 466 i = 0; | |
| 467 while( TIident[TIid].size[i] && (i < 4)) | |
| 468 { | |
| 469 multiplier = 1; | |
| 470 for(digitCount = 1; digitCount < TIident[TIid].size[i]; digitCount++) | |
| 471 multiplier *= 10; | |
| 472 | |
| 473 for(digitCount = 0; digitCount < TIident[TIid].size[i]; digitCount++) | |
| 474 { | |
| 475 digit = TIident[TIid].newText[TIident[TIid].begin[i] + digitCount]; | |
| 476 | |
| 477 if(digit > '0') | |
| 478 digit -= '0'; | |
| 479 else | |
| 480 digit = 0; | |
| 481 | |
| 482 if(digit > 9) | |
| 483 digit = 9; | |
| 484 | |
| 485 sum[i] += digit * multiplier; | |
| 486 | |
| 487 if(multiplier >= 10) | |
| 488 multiplier /= 10; | |
| 489 else | |
| 490 multiplier = 0; | |
| 491 } | |
| 492 i++; | |
| 493 } | |
| 494 | |
| 495 *pNewValue1 = sum[0]; | |
| 496 *pNewValue2 = sum[1]; | |
| 497 *pNewValue3 = sum[2]; | |
| 498 *pNewValue4 = sum[3]; | |
| 499 } | |
| 500 | |
| 501 | |
| 502 uint8_t tI_get_id_of(uint32_t editID) | |
| 503 { | |
| 504 uint8_t temp_id; | |
| 505 | |
| 506 if(editID == TIident[TIid].callerID) | |
| 507 return TIid; | |
| 508 else | |
| 509 { | |
| 510 temp_id = 0; | |
| 511 while((temp_id < 9) && (editID != TIident[temp_id].callerID)) | |
| 512 temp_id++; | |
| 513 if(editID != TIident[temp_id].callerID) | |
| 514 temp_id = 255; | |
| 515 return temp_id; | |
| 516 } | |
| 517 } | |
| 518 | |
| 519 | |
| 520 void tI_newButtonText(uint32_t editID, char *text) | |
| 521 { | |
| 522 uint8_t backup_id, temp_id; | |
| 523 | |
| 524 temp_id = tI_get_id_of(editID); | |
| 525 if(temp_id == 255) | |
| 526 return; | |
| 527 | |
| 528 backup_id = TIid; | |
| 529 TIid = temp_id; | |
| 530 | |
| 531 strncpy(TIident[TIid].newText, text, 32); | |
| 532 TIident[TIid].newText[31] = 0; | |
| 533 | |
| 534 tI_clean_content_of_actual_Id(); | |
| 535 tInfo_write_content_of_actual_Id(); | |
| 536 | |
| 537 TIid = backup_id; | |
| 538 } | |
| 539 | |
| 540 | |
| 699 | 541 void tInfo_set_on_off(uint32_t editID, uint8_t int1) |
| 38 | 542 { |
| 543 uint8_t backup_id, temp_id; | |
| 544 | |
| 545 temp_id = tI_get_id_of(editID); | |
| 546 if(temp_id == 255) | |
| 547 return; | |
| 548 | |
| 549 backup_id = TIid; | |
| 550 TIid = temp_id; | |
| 551 | |
| 552 TIident[TIid].input = int1; | |
| 553 | |
| 554 if(int1) | |
| 555 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
| 556 else | |
| 557 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
| 558 | |
| 559 tInfo_write_content_of_actual_Id(); | |
| 560 | |
| 561 TIid = backup_id; | |
| 562 } | |
| 563 | |
| 564 | |
| 565 void tInfo_write_content_without_Id(void) | |
| 566 { | |
| 567 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, CLUT_InfoFieldRegular); | |
| 568 } | |
| 569 | |
| 570 | |
| 571 void tInfo_write_content_of_actual_Id(void) | |
| 572 { | |
| 573 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, (CLUT_InfoField0 + TIid)); | |
| 574 } | |
| 575 | |
| 576 | |
| 577 void tI_clean_content_of_actual_Id(void) | |
| 578 { | |
| 579 tI_clean_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed); | |
| 580 } | |
| 581 | |
| 582 | |
| 583 void tInfo_write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
| 584 { | |
| 585 if(TIidLast >= 9) | |
| 586 return; | |
| 587 | |
| 588 TIident[TIid].maintype = FIELD_BUTTON; | |
| 589 TIident[TIid].subtype = FIELD_BUTTON; | |
| 590 | |
| 591 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 592 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 593 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 594 TIident[TIid].fontUsed = (tFont *)Font; | |
| 595 TIident[TIid].callerID = editID; | |
| 596 | |
| 597 strncpy(TIident[TIid].orgText, text, 32); | |
| 598 strncpy(TIident[TIid].newText, text, 32); | |
| 599 TIident[TIid].orgText[31] = 0; | |
| 600 TIident[TIid].newText[31] = 0; | |
| 601 | |
| 602 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
| 603 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
604 if(editID == 0) |
| 38 | 605 tInfo_write_content_without_Id(); |
| 606 else | |
| 607 { | |
| 608 tInfo_write_content_of_actual_Id(); | |
| 609 TIidLast = TIid; | |
| 610 TIid++; | |
| 611 } | |
| 612 } | |
| 613 | |
| 614 | |
| 615 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) | |
| 616 { | |
| 617 if(TIidLast >= 9) | |
| 618 return; | |
| 619 | |
| 620 TIident[TIid].maintype = FIELD_SYMBOL; | |
| 621 TIident[TIid].subtype = FIELD_SYMBOL; | |
| 622 | |
| 623 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 624 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 625 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 626 TIident[TIid].fontUsed = (tFont *)Font; | |
| 627 TIident[TIid].callerID = editID; | |
| 628 | |
| 629 strncpy(TIident[TIid].orgText, text, 32); | |
| 630 strncpy(TIident[TIid].newText, text, 32); | |
| 631 TIident[TIid].orgText[31] = 0; | |
| 632 | |
| 633 TIident[TIid].newText[0] = text[0]; | |
| 634 TIident[TIid].newText[1] = 0; | |
| 635 | |
| 636 TIident[TIid].input = int1; | |
| 637 TIident[TIid].symbolCounter = strlen(TIident[TIid].orgText); | |
| 638 | |
| 639 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
| 640 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
641 if(editID == 0) |
| 38 | 642 tInfo_write_content_without_Id(); |
| 643 else | |
| 644 { | |
| 645 tInfo_write_content_of_actual_Id(); | |
| 646 TIidLast = TIid; | |
| 647 TIid++; | |
| 648 } | |
| 649 } | |
| 650 | |
| 651 | |
| 652 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) | |
| 653 { | |
| 654 if(TIidLast >= 9) | |
| 655 return; | |
| 656 | |
| 657 TIident[TIid].maintype = FIELD_ON_OFF; | |
| 658 TIident[TIid].subtype = FIELD_ON_OFF; | |
| 659 | |
| 660 TIident[TIid].coord[0] = XleftGimpStyle; | |
| 661 TIident[TIid].coord[1] = XrightGimpStyle; | |
| 662 TIident[TIid].coord[2] = YtopGimpStyle; | |
| 663 TIident[TIid].fontUsed = (tFont *)Font; | |
| 664 TIident[TIid].callerID = editID; | |
| 665 | |
| 666 strncpy(TIident[TIid].orgText, text, 32); | |
| 667 strncpy(TIident[TIid].newText, text, 32); | |
| 668 TIident[TIid].orgText[31] = 0; | |
| 669 TIident[TIid].newText[31] = 0; | |
| 670 | |
| 671 | |
| 672 if(int1) | |
| 673 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
| 674 else | |
| 675 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
| 676 | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
677 if(editID == 0) |
| 38 | 678 tInfo_write_content_without_Id(); |
| 679 else | |
| 680 { | |
| 681 tInfo_write_content_of_actual_Id(); | |
| 682 TIidLast = TIid; | |
| 683 TIid++; | |
| 684 } | |
| 685 } | |
| 686 | |
| 687 | |
| 688 void tInfo_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
| 689 { | |
| 690 if(TIevidLast >= 9) | |
| 691 return; | |
| 692 | |
| 693 /* set cursor to first field */ | |
| 694 if(TIevidLast < 0) | |
| 695 { | |
| 696 tI_startInfoFieldSelect(); | |
| 697 } | |
| 698 | |
| 699 TIevent[TIevid].callerID = inputEventID; | |
| 700 TIevent[TIevid].pEventFunction = inputFunctionCall; | |
| 701 | |
| 702 TIevidLast = TIevid; | |
| 703 TIevid++; | |
| 704 } | |
| 705 | |
| 706 | |
| 707 void tI_set_cursor(uint8_t forThisIdentID) | |
| 708 { | |
| 709 int16_t x0, x1, y0, y1; | |
| 710 | |
| 711 uint32_t xtra_left_right = 10; | |
| 712 uint32_t xtra_top_bottom = 10; | |
| 713 | |
| 714 /* y geht von 0 bis 799 */ | |
| 715 /* x geht von 0 bis 479 */ | |
| 716 | |
| 717 x0 = (int16_t)TIident[forThisIdentID].coord[0]; | |
| 718 x1 = (int16_t)TIident[forThisIdentID].coord[1]; | |
| 719 y0 = (int16_t)TIident[forThisIdentID].coord[2]; | |
| 720 y1 = y0 + (int16_t)TIident[forThisIdentID].fontUsed->height; | |
| 721 | |
| 722 if(((int16_t)TIident[forThisIdentID].fontUsed->height) > 70) | |
| 723 { | |
| 724 xtra_left_right = 10; | |
| 725 xtra_top_bottom = 10; | |
| 726 } | |
| 727 else | |
| 728 { | |
| 729 xtra_left_right = 10; | |
| 730 xtra_top_bottom = 0; | |
| 731 } | |
| 732 | |
| 733 x0 -= xtra_left_right; | |
| 734 x1 += xtra_left_right; | |
| 735 y0 -= xtra_top_bottom; | |
| 736 y1 += xtra_top_bottom; | |
| 737 | |
| 738 GFX_SetWindowLayer0(tIcursor.FBStartAdress, x0, x1, y0, y1); | |
| 739 } | |
| 740 | |
| 741 | |
| 742 void tInfo_write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
| 743 { | |
| 744 GFX_DrawCfgWindow hgfx; | |
| 745 | |
| 746 if(XrightGimpStyle > 799) | |
| 747 XrightGimpStyle = 799; | |
| 748 if(XleftGimpStyle >= XrightGimpStyle) | |
| 749 XleftGimpStyle = 0; | |
| 750 if(YtopGimpStyle > 479) | |
| 751 YtopGimpStyle = 479; | |
| 752 hgfx.Image = &tIscreen; | |
| 753 hgfx.WindowNumberOfTextLines = 1; | |
| 754 hgfx.WindowLineSpacing = 0; | |
| 755 hgfx.WindowTab = 0; | |
| 756 hgfx.WindowX0 = XleftGimpStyle; | |
| 757 hgfx.WindowX1 = XrightGimpStyle; | |
| 758 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 759 if(hgfx.WindowY1 < Font->height) | |
| 760 hgfx.WindowY0 = 0; | |
| 761 else | |
| 762 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 763 | |
| 764 GFX_write_label(Font, &hgfx, text, infoColor); | |
| 765 } | |
| 766 | |
| 767 | |
| 768 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
| 769 { | |
| 770 GFX_DrawCfgWindow hgfx; | |
| 771 | |
| 772 if(XrightGimpStyle > 799) | |
| 773 XrightGimpStyle = 799; | |
| 774 if(XleftGimpStyle >= XrightGimpStyle) | |
| 775 XleftGimpStyle = 0; | |
| 776 if(YtopGimpStyle > 479) | |
| 777 YtopGimpStyle = 479; | |
| 778 hgfx.Image = &tIscreen; | |
| 779 hgfx.WindowNumberOfTextLines = 1; | |
| 780 hgfx.WindowLineSpacing = 0; | |
| 781 hgfx.WindowTab = 0; | |
| 782 hgfx.WindowX0 = XleftGimpStyle; | |
| 783 hgfx.WindowX1 = XrightGimpStyle; | |
| 784 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 785 if(hgfx.WindowY1 < Font->height) | |
| 786 hgfx.WindowY0 = 0; | |
| 787 else | |
| 788 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 789 | |
| 790 GFX_write_label(Font, &hgfx, text, color); | |
| 791 } | |
| 792 | |
| 793 | |
| 794 void tInfo_write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
| 795 { | |
| 796 char text[2]; | |
| 797 | |
| 798 text[0] = textId; | |
| 799 text[1] = 0; | |
| 800 | |
| 801 tInfo_write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
| 802 } | |
| 803 | |
| 804 | |
| 805 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
| 806 { | |
| 807 GFX_DrawCfgWindow hgfx; | |
| 808 | |
| 809 if(XrightGimpStyle > 799) | |
| 810 XrightGimpStyle = 799; | |
| 811 if(XleftGimpStyle >= XrightGimpStyle) | |
| 812 XleftGimpStyle = 0; | |
| 813 if(YtopGimpStyle > 479) | |
| 814 YtopGimpStyle = 479; | |
| 815 hgfx.Image = &tIscreen; | |
| 816 hgfx.WindowX0 = XleftGimpStyle; | |
| 817 hgfx.WindowX1 = XrightGimpStyle; | |
| 818 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
| 819 if(hgfx.WindowY1 < Font->height) | |
| 820 hgfx.WindowY0 = 0; | |
| 821 else | |
| 822 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
| 823 | |
| 824 GFX_clear_window_immediately(&hgfx); | |
| 825 } | |
| 826 | |
| 827 | |
| 828 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
| 829 { | |
| 830 GFX_clean_area(&tIscreen, 0, 800, 480-24,480); | |
| 831 | |
| 832 char localtext[32]; | |
| 833 | |
| 834 if(left2ByteCode) | |
| 835 { | |
| 836 localtext[0] = TXT_2BYTE; | |
| 837 localtext[1] = left2ByteCode; | |
| 838 localtext[2] = 0; | |
| 839 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 840 } | |
| 841 | |
| 842 if(middle2ByteCode) | |
| 843 { | |
| 844 localtext[0] = '\001'; | |
| 845 localtext[1] = TXT_2BYTE; | |
| 846 localtext[2] = middle2ByteCode; | |
| 847 localtext[3] = 0; | |
| 848 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 849 } | |
| 850 | |
| 851 if(right2ByteCode) | |
| 852 { | |
| 853 localtext[0] = '\002'; | |
| 854 localtext[1] = TXT_2BYTE; | |
| 855 localtext[2] = right2ByteCode; | |
| 856 localtext[3] = 0; | |
| 857 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 858 } | |
| 859 } | |
| 845 | 860 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
| 861 { | |
| 862 char localtext[32]; | |
| 863 | |
| 864 if(left2ByteCode) | |
| 865 { | |
| 866 localtext[0] = TXT_2BYTE; | |
| 867 localtext[1] = left2ByteCode; | |
| 868 localtext[2] = 0; | |
| 869 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 870 } | |
| 871 | |
| 872 if(middle2ByteCode) | |
| 873 { | |
| 874 localtext[0] = '\001'; | |
| 875 localtext[1] = TXT_2BYTE; | |
| 876 localtext[2] = middle2ByteCode; | |
| 877 localtext[3] = 0; | |
| 878 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 879 } | |
| 880 | |
| 881 if(right2ByteCode) | |
| 882 { | |
| 883 localtext[0] = '\002'; | |
| 884 localtext[1] = TXT_2BYTE; | |
| 885 localtext[2] = right2ByteCode; | |
| 886 localtext[3] = 0; | |
| 887 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
| 888 } | |
| 889 } |
