38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Discovery/Src/tMenu.c
+ − 5 /// \brief Major menu with extra page 0 for edit functionality since V0.0.2
+ − 6 /// \author heinrichs weikamp gmbh
+ − 7 /// \date 30-April-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 "tMenu.h"
+ − 31
+ − 32 #include "gfx_fonts.h"
+ − 33 #include "tHome.h"
+ − 34 #include "tMenuDeco.h"
+ − 35 #include "tMenuDecoParameter.h"
+ − 36 #include "tMenuEditDeco.h"
+ − 37 #include "tMenuEditDecoParameter.h"
+ − 38 #include "tMenuEditGasOC.h"
+ − 39 #include "tMenuEditHardware.h"
+ − 40 #include "tMenuEditPlanner.h"
+ − 41 #include "tMenuEditSetpoint.h"
+ − 42 #include "tMenuEditSystem.h"
+ − 43 #include "tMenuEditXtra.h"
507
+ − 44 #include "tMenuEditCustom.h"
38
+ − 45 #include "tMenuGas.h"
+ − 46 #include "tMenuHardware.h"
+ − 47 #include "tMenuPlanner.h"
+ − 48 #include "tMenuSetpoint.h"
+ − 49 #include "tMenuSystem.h"
+ − 50 #include "tMenuXtra.h"
507
+ − 51 #include "tMenuCustom.h"
38
+ − 52
+ − 53 /* Private types -------------------------------------------------------------*/
521
+ − 54 #define MAXPAGES 11
110
+ − 55 #define CURSOR_HIGH 25
+ − 56 #define TAB_HEADER_HIGH 25
+ − 57 #define TAB_BAR_HIGH 5
+ − 58 #define MENU_WDW_HIGH 390
+ − 59 #define KEY_LABEL_HIGH 25 /* Height of the label used for the the user keys */
38
+ − 60
662
+ − 61 #define SLOW_UPDATE_CNT 10 /* Some content shall not be update in short intervals => add prescalar */
811
+ − 62 #define MAXLINES 6
662
+ − 63
38
+ − 64 typedef struct
+ − 65 {
+ − 66 uint32_t StartAddressForPage[MAXPAGES+1];
+ − 67 uint8_t lineMemoryForNavigationForPage[MAXPAGES+1];
+ − 68 uint8_t pageMemoryForNavigation;
+ − 69 uint8_t linesAvailableForPage[MAXPAGES+1];
+ − 70 uint8_t pagesAvailable;
+ − 71 uint8_t pageCountNumber[MAXPAGES+1];
+ − 72 uint8_t pageCountTotal;
+ − 73 uint8_t modeFlipPages;
811
+ − 74 uint8_t shadowPage[MAXPAGES+1]; /* the page is switched in the context of another page */
+ − 75 uint8_t activeShadow; /* Base page which is used for the shadow */
+ − 76 uint8_t disableLineMask[MAXPAGES+1]; /* Bitfield used to disable a line. The line is visible but will not be selected by cursor) */
38
+ − 77 } SMenuMemory;
+ − 78
+ − 79 /* Exported variables --------------------------------------------------------*/
+ − 80
+ − 81 /* Announced Private variables -----------------------------------------------*/
167
+ − 82 static GFX_DrawCfgScreen tMdesignSolo;
+ − 83 static GFX_DrawCfgScreen tMdesignCursor;
38
+ − 84
+ − 85 /* Private variables ---------------------------------------------------------*/
167
+ − 86 static GFX_DrawCfgWindow tMwindow;
+ − 87 static GFX_DrawCfgScreen tMscreen;
38
+ − 88
167
+ − 89 static SMenuMemory menu;
38
+ − 90
+ − 91 uint8_t actual_menu_content = MENU_UNDEFINED;
+ − 92
811
+ − 93
+ − 94
+ − 95
38
+ − 96 /* Private function prototypes -----------------------------------------------*/
167
+ − 97 static void draw_tMheader(uint8_t page);
+ − 98 static void draw_tMcursorDesign(void);
38
+ − 99
167
+ − 100 static void draw_tMdesignSubUnselected(uint32_t *ppDestination);
+ − 101 static void draw_tMdesignSubSelected(uint32_t *ppDestination);
+ − 102 static void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination);
+ − 103 static void tMenu_write(uint8_t page, char *text, char *subtext);
647
+ − 104 static void nextLine(void);
167
+ − 105 static void clean_line_actual_page(void);
38
+ − 106 void tM_build_pages(void);
+ − 107
167
+ − 108 static void gotoMenuEdit(void);
38
+ − 109
+ − 110 /* Exported functions --------------------------------------------------------*/
+ − 111
+ − 112 GFX_DrawCfgScreen * get_PointerMenuCursorScreen(void)
+ − 113 {
+ − 114 return &tMdesignCursor;
+ − 115 }
+ − 116
+ − 117
+ − 118 GFX_DrawCfgScreen * get_PointerMenuCursorDesignSoloScreen(void)
+ − 119 {
+ − 120 return &tMdesignSolo;
+ − 121 }
+ − 122
+ − 123
+ − 124 void nextline(char * text, uint8_t *textPointer)
+ − 125 {
+ − 126 text[(*textPointer)++] = '\n';
+ − 127 text[(*textPointer)++] = '\r';
+ − 128 text[*textPointer] = 0;
+ − 129 }
+ − 130
+ − 131
816
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 132 void clearDisabledMenuLines(void)
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 133 {
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 134 for(unsigned i = 0; i <= MAXPAGES; i++) {
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 135 menu.disableLineMask[i] = 0;
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 136 }
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 137 }
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 138
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 139
38
+ − 140 void tM_init(void)
+ − 141 {
+ − 142 uint8_t i;
+ − 143
110
+ − 144 SSettings* pSettings;
+ − 145 pSettings = settingsGetPointer();
+ − 146
38
+ − 147 tMdesignCursor.FBStartAdress = getFrame(3);
+ − 148 tMdesignCursor.ImageHeight = 390;
+ − 149 tMdesignCursor.ImageWidth = 800;
+ − 150 tMdesignCursor.LayerIndex = 0;
+ − 151
+ − 152 tMdesignSolo.FBStartAdress = getFrame(4);
+ − 153 tMdesignSolo.ImageHeight = 390;
+ − 154 tMdesignSolo.ImageWidth = 800;
+ − 155 tMdesignSolo.LayerIndex = 0;
+ − 156
+ − 157 menu.pagesAvailable = 0;
+ − 158 menu.pageMemoryForNavigation = 0;
+ − 159 for(i=0;i<=MAXPAGES;i++)
+ − 160 {
+ − 161 menu.lineMemoryForNavigationForPage[i] = 0;
+ − 162 menu.StartAddressForPage[i] = 0;
+ − 163 menu.linesAvailableForPage[i] = 0;
647
+ − 164 menu.shadowPage[i] = 0;
38
+ − 165 }
+ − 166
816
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 167 clearDisabledMenuLines();
c4ee952b9425
Fix a bug that disables arbitrary menu lines in dive mode if lines are disabled / inactive in surface mode. (mikeller)
heinrichsweikamp
diff
changeset
+ − 168
38
+ − 169 tMscreen.FBStartAdress = 0;
+ − 170 tMscreen.ImageHeight = 480;
+ − 171 tMscreen.ImageWidth = 800;
+ − 172 tMscreen.LayerIndex = 1;
+ − 173
+ − 174 draw_tMcursorDesign();
+ − 175
+ − 176 tMwindow.Image = &tMscreen;
+ − 177 tMwindow.WindowNumberOfTextLines = 6;
+ − 178 tMwindow.WindowLineSpacing = 65;
+ − 179 tMwindow.WindowTab = 400;
+ − 180 tMwindow.WindowX0 = 20;
+ − 181 tMwindow.WindowX1 = 779;
+ − 182
110
+ − 183 if(!pSettings->FlipDisplay)
+ − 184 {
+ − 185 tMwindow.WindowY0 = 4 + KEY_LABEL_HIGH;
+ − 186 tMwindow.WindowY1 = 390 + KEY_LABEL_HIGH;
+ − 187 }
+ − 188 else
+ − 189 {
+ − 190 tMwindow.WindowY0 = 480 - MENU_WDW_HIGH - TAB_HEADER_HIGH;// - TAB_BAR_HIGH;
+ − 191 tMwindow.WindowY1 = 480 - TAB_HEADER_HIGH - TAB_BAR_HIGH;
+ − 192 }
38
+ − 193 actual_menu_content = MENU_UNDEFINED;
+ − 194 }
+ − 195
+ − 196 void tM_refresh(char *text, uint8_t *textPointer, uint8_t line, const char content[6])
+ − 197 {
+ − 198 for(uint8_t i=0; i<6; i++)
+ − 199 {
+ − 200 if(((line == 0) || (line == i)) && content[i])
+ − 201 {
+ − 202 text[(*textPointer)++] = content[i];
+ − 203 }
+ − 204 text[(*textPointer)++] = '\n';
+ − 205 text[(*textPointer)++] = '\r';
+ − 206 text[*textPointer] = 0;
+ − 207 }
+ − 208 }
+ − 209
+ − 210
+ − 211 void tM_rebuild_pages(void)
+ − 212 {
+ − 213 menu.pagesAvailable = 0;
+ − 214 // menu.pageMemoryForNavigation = 0;
+ − 215 for(int i=0;i<=MAXPAGES;i++)
+ − 216 {
+ − 217 menu.lineMemoryForNavigationForPage[i] = 0;
+ − 218 menu.linesAvailableForPage[i] = 0;
+ − 219 menu.StartAddressForPage[i] = 0; // only with GFX_forceReleaseFramesWithId(5); !!!!!
+ − 220 }
+ − 221 GFX_forceReleaseFramesWithId(5);
+ − 222 tM_build_pages();
+ − 223 }
+ − 224
+ − 225
+ − 226 void tM_rebuild_menu_after_tComm(void)
+ − 227 {
+ − 228 tM_rebuild_pages();
+ − 229 }
+ − 230
110
+ − 231 void tM_check_content(void)
38
+ − 232 {
+ − 233 uint8_t mode = 0;
+ − 234
+ − 235 if(stateUsed->mode == MODE_DIVE)
+ − 236 {
+ − 237 if(stateUsed == stateRealGetPointer())
+ − 238 mode = MENU_DIVE_REAL;
+ − 239 else
+ − 240 mode = MENU_DIVE_SIM;
+ − 241 }
+ − 242 else
+ − 243 mode = MENU_SURFACE;
+ − 244
+ − 245 if(actual_menu_content != mode)
+ − 246 {
+ − 247 actual_menu_content = mode;
+ − 248 tM_rebuild_pages();
+ − 249 }
+ − 250 }
+ − 251
811
+ − 252 void disableLine(uint32_t lineId)
+ − 253 {
+ − 254 SStateList idList;
+ − 255
+ − 256 get_idSpecificStateList(lineId, &idList);
+ − 257
+ − 258 if((idList.page < MAXPAGES) && (idList.line < MAXLINES))
+ − 259 {
+ − 260 menu.disableLineMask[idList.page] |= (1 << idList.line);
+ − 261 }
+ − 262 }
+ − 263
850
+ − 264 uint8_t getLineMask(uint32_t lineId)
+ − 265 {
+ − 266 SStateList idList;
+ − 267 get_idSpecificStateList(lineId, &idList);
+ − 268 return(menu.disableLineMask[idList.page]);
+ − 269 }
+ − 270
815
+ − 271 void resetLineMask(uint32_t lineId)
+ − 272 {
+ − 273 SStateList idList;
+ − 274 get_idSpecificStateList(lineId, &idList);
+ − 275 if(idList.page < MAXPAGES)
+ − 276 {
+ − 277 menu.disableLineMask[idList.page] = 0;
+ − 278 }
+ − 279 }
811
+ − 280 void enableLine(uint32_t lineId)
+ − 281 {
+ − 282 SStateList idList;
+ − 283
+ − 284 get_idSpecificStateList(lineId, &idList);
+ − 285
+ − 286 if((idList.page < MAXPAGES) && (idList.line < MAXLINES))
+ − 287 {
+ − 288 menu.disableLineMask[idList.page] &= ~(1 << idList.line);
+ − 289 }
+ − 290 }
38
+ − 291
167
+ − 292 static void clean_line_actual_page(void)
38
+ − 293 {
+ − 294 uint8_t line, page;
+ − 295
+ − 296 page = menu.pageMemoryForNavigation;
+ − 297 line = menu.lineMemoryForNavigationForPage[page];
122
+ − 298 if(settingsGetPointer()->FlipDisplay) /* Reselect line to be deleted if display is rotated */
+ − 299 {
+ − 300 line = 6 - line + 1;
+ − 301 }
38
+ − 302 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 303 GFX_clean_line(&tMwindow, line);
+ − 304 }
+ − 305
+ − 306
167
+ − 307 static void update_content_actual_page(char *text, uint16_t tab, char *subtext)
38
+ − 308 {
+ − 309 uint8_t page;
+ − 310
+ − 311 page = menu.pageMemoryForNavigation;
+ − 312
+ − 313 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 314 if(tab == 0)
+ − 315 tMwindow.WindowTab = 400;
+ − 316 else
+ − 317 tMwindow.WindowTab = tab;
+ − 318
+ − 319 tMenu_write(page, text, subtext);
+ − 320 }
+ − 321
+ − 322
167
+ − 323 static void update_content_with_new_frame(uint8_t page, char *text, uint16_t tab, char *subtext)
38
+ − 324 {
+ − 325 char localtext[32];
+ − 326
+ − 327 uint32_t rememberPage = menu.StartAddressForPage[page];
+ − 328 menu.StartAddressForPage[page] = getFrame(5);
+ − 329 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 330
+ − 331 if(tab == 0)
+ − 332 tMwindow.WindowTab = 400;
+ − 333 else
+ − 334 tMwindow.WindowTab = tab;
+ − 335
+ − 336 draw_tMheader(page);
+ − 337 tMenu_write(page, text, subtext);
+ − 338
+ − 339 localtext[0] = TXT_2BYTE;
+ − 340 localtext[1] = TXT2BYTE_ButtonBack;
+ − 341 localtext[2] = 0;
110
+ − 342 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 343
+ − 344 localtext[0] = '\001';
+ − 345 localtext[1] = TXT_2BYTE;
+ − 346 localtext[2] = TXT2BYTE_ButtonEnter;
+ − 347 localtext[3] = 0;
110
+ − 348 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 349
+ − 350 localtext[0] = '\002';
+ − 351 localtext[1] = TXT_2BYTE;
+ − 352 localtext[2] = TXT2BYTE_ButtonNext;
+ − 353 localtext[3] = 0;
110
+ − 354 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 355
+ − 356 // gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0);
+ − 357
+ − 358 if(page == menu.pageMemoryForNavigation)
+ − 359 GFX_SetFrameTop(tMscreen.FBStartAdress);
+ − 360 releaseFrame(5,rememberPage);
+ − 361 }
+ − 362
+ − 363
169
+ − 364 static void tM_create_pagenumbering(void)
38
+ − 365 {
+ − 366 menu.pageCountTotal = 0;
+ − 367
+ − 368 for(int i=0;i<=MAXPAGES;i++)
+ − 369 {
+ − 370 if(menu.pageCountNumber[i])
+ − 371 {
+ − 372 menu.pageCountTotal++;
+ − 373 menu.pageCountNumber[i] = menu.pageCountTotal;
+ − 374 }
+ − 375 }
+ − 376 }
+ − 377
+ − 378
379
+ − 379 void tM_build_page(uint32_t id, char *text, uint16_t tab, char *subtext)
38
+ − 380 {
+ − 381 uint8_t linesFound;
+ − 382 uint16_t i;
+ − 383 SStateList idList;
+ − 384 uint8_t page;
+ − 385
+ − 386 char localtext[32];
+ − 387
+ − 388 if(menu.pagesAvailable > MAXPAGES)
+ − 389 return;
+ − 390
+ − 391 get_idSpecificStateList(id, &idList);
+ − 392
+ − 393 if(idList.base != BaseMenu)
+ − 394 return;
+ − 395
+ − 396 if(idList.page == 0)
+ − 397 return;
+ − 398
+ − 399 if(idList.page > MAXPAGES)
+ − 400 return;
+ − 401
+ − 402 page = idList.page;
+ − 403
647
+ − 404 if((!menu.pageCountNumber[page]) && (!menu.shadowPage[page])) /* shadow pages are not visible on top level */
+ − 405 {
+ − 406 return;
+ − 407 }
38
+ − 408
647
+ − 409 if(menu.pagesAvailable == 0)
+ − 410 tM_create_pagenumbering();
38
+ − 411
+ − 412 if(*text == 0)
+ − 413 return;
+ − 414
+ − 415 linesFound = 1;
+ − 416
+ − 417 if(menu.StartAddressForPage[page])
+ − 418 releaseFrame(5,menu.StartAddressForPage[page]);
+ − 419
+ − 420 menu.StartAddressForPage[page] = getFrame(5);
+ − 421
+ − 422 if(menu.StartAddressForPage[page] == 0)
+ − 423 return;
+ − 424
+ − 425 i = 0;
+ − 426 while((i < MAX_PAGE_TEXTSIZE) && text[i])
+ − 427 {
+ − 428 if((text[i] == '\n') && ((i + 2) < MAX_PAGE_TEXTSIZE) && text[i+1] && text[i+2])
+ − 429 linesFound += 1;
+ − 430 i++;
+ − 431 }
+ − 432
+ − 433 menu.linesAvailableForPage[page] = linesFound;
+ − 434 menu.pagesAvailable++; /* even if it was used before */
+ − 435
+ − 436 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 437 if(tab == 0)
+ − 438 tMwindow.WindowTab = 400;
+ − 439 else
+ − 440 tMwindow.WindowTab = tab;
+ − 441
+ − 442 draw_tMheader(page);
+ − 443
+ − 444 tMenu_write(page, text, subtext);
+ − 445
+ − 446 localtext[0] = TXT_2BYTE;
+ − 447 localtext[1] = TXT2BYTE_ButtonBack;
+ − 448 localtext[2] = 0;
110
+ − 449 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 450
+ − 451 localtext[0] = '\001';
+ − 452 localtext[1] = TXT_2BYTE;
+ − 453 localtext[2] = TXT2BYTE_ButtonEnter;
+ − 454 localtext[3] = 0;
110
+ − 455 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 456
+ − 457 localtext[0] = '\002';
+ − 458 localtext[1] = TXT_2BYTE;
+ − 459 localtext[2] = TXT2BYTE_ButtonNext;
+ − 460 localtext[3] = 0;
110
+ − 461 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
38
+ − 462 }
+ − 463
167
+ − 464 static void findValidPosition(uint8_t *pageOuput, uint8_t *lineOutput)
38
+ − 465 {
51
+ − 466 uint8_t page = 0;
+ − 467 uint8_t line = 0;
+ − 468 uint8_t first = 0;
38
+ − 469
+ − 470 *pageOuput = 0;
+ − 471 *lineOutput = 0;
+ − 472
+ − 473 /* test */
+ − 474 if(menu.pagesAvailable == 0)
+ − 475 return;
+ − 476
+ − 477 for(int i=1;i<=MAXPAGES;i++)
+ − 478 {
+ − 479 if((menu.pageCountNumber[i] != 0)
+ − 480 && (menu.linesAvailableForPage[i] != 0)
+ − 481 && (menu.StartAddressForPage[i] != 0))
+ − 482 {
+ − 483 first = i;
+ − 484 break;
+ − 485 }
+ − 486 }
+ − 487
+ − 488 /* select */
+ − 489 if(menu.pageMemoryForNavigation > MAXPAGES)
+ − 490 menu.pageMemoryForNavigation = first;
+ − 491
+ − 492 page = menu.pageMemoryForNavigation;
+ − 493
+ − 494 if(page == 0)
+ − 495 page = first;
+ − 496
647
+ − 497 while((page <= MAXPAGES) && ((menu.linesAvailableForPage[page] == 0) || (menu.StartAddressForPage[page] == 0) || ((menu.pageCountNumber[page] == 0) && !((menu.shadowPage[page]) && (menu.pageMemoryForNavigation == page)))))
38
+ − 498 page += 1;
+ − 499
+ − 500 if(page > MAXPAGES)
+ − 501 page = first;
+ − 502
+ − 503 line = menu.lineMemoryForNavigationForPage[page];
+ − 504
+ − 505 if(line == 0)
+ − 506 line = 1;
+ − 507
815
+ − 508 while(menu.disableLineMask[page] & ( 1 << line))
811
+ − 509 {
+ − 510 line++;
815
+ − 511 if(line > menu.linesAvailableForPage[page])
+ − 512 {
+ − 513 line = 1;
+ − 514 }
811
+ − 515 }
+ − 516
38
+ − 517 if(line > menu.linesAvailableForPage[page])
+ − 518 line = 1;
+ − 519
+ − 520 *pageOuput = page;
+ − 521 *lineOutput = line;
+ − 522 }
+ − 523
+ − 524
167
+ − 525 static void tM_add(uint32_t id)
38
+ − 526 {
+ − 527 SStateList idList;
+ − 528 uint8_t page;
+ − 529
+ − 530 get_idSpecificStateList(id, &idList);
+ − 531
+ − 532 page = idList.page;
+ − 533
+ − 534 if(page > MAXPAGES)
+ − 535 return;
+ − 536
+ − 537 menu.pageCountNumber[page] = 1;
+ − 538 }
+ − 539
647
+ − 540 static void tM_addShadow(uint32_t id)
+ − 541 {
+ − 542 SStateList idList;
+ − 543 uint8_t page;
+ − 544
+ − 545 get_idSpecificStateList(id, &idList);
+ − 546
+ − 547 page = idList.page;
+ − 548
+ − 549 if(page > MAXPAGES)
+ − 550 return;
+ − 551
+ − 552 menu.shadowPage[page] = 1;
+ − 553 }
+ − 554
38
+ − 555
+ − 556 void tM_build_pages(void)
+ − 557 {
+ − 558 char text[MAX_PAGE_TEXTSIZE];
+ − 559 char subtext[MAX_PAGE_TEXTSIZE];
+ − 560 uint32_t id;
+ − 561 uint16_t tabPosition;
+ − 562 SSettings *pSettings = settingsGetPointer();
+ − 563
+ − 564 menu.pagesAvailable = 0;
+ − 565 for(int i=0;i<=MAXPAGES;i++)
+ − 566 menu.pageCountNumber[i] = 0;
+ − 567
+ − 568 tabPosition = 400;
+ − 569 *text = 0;
+ − 570 *subtext = 0;
+ − 571
+ − 572 /* 2015 Feb 02, hw
+ − 573 * max 8 Menu Pages
+ − 574 */
+ − 575
+ − 576
+ − 577 tM_add(StMSYS); //now in both modes
+ − 578 if(actual_menu_content == MENU_SURFACE)
+ − 579 {
+ − 580 tM_add(StMDECO);
+ − 581 tM_add(StMHARD);
507
+ − 582 tM_add(StMCustom);
38
+ − 583 // tM_add(StMSYS); now in both modes
+ − 584 }
+ − 585 else
+ − 586 {
+ − 587 tM_add(StMXTRA);
+ − 588 }
+ − 589 if(actual_menu_content == MENU_SURFACE)
+ − 590 {
+ − 591 tM_add(StMPLAN);
+ − 592 }
+ − 593 // if((pSettings->dive_mode != DIVEMODE_Gauge) && (pSettings->dive_mode != DIVEMODE_Apnea))
+ − 594 // {
+ − 595 tM_add(StMDECOP);
+ − 596 // }
647
+ − 597
662
+ − 598 if((isLoopMode(pSettings->dive_mode)) || (stateUsed->diveSettings.ccrOption == 1))
38
+ − 599 {
+ − 600 tM_add(StMCG);
856
+ − 601 if((stateUsed->diveSettings.diveMode != DIVEMODE_PSCR) || (actual_menu_content != MENU_SURFACE))
+ − 602 {
+ − 603 tM_add(StMSP);
+ − 604 }
647
+ − 605 if (actual_menu_content == MENU_SURFACE) /* StMOG is now accessed using StMCG in CCR mode*/
+ − 606 {
+ − 607 tM_add(StMXTRA);
+ − 608 tM_addShadow(StMOG);
+ − 609 }
+ − 610 else
+ − 611 {
+ − 612 tM_add(StMOG);
+ − 613 }
+ − 614 }
+ − 615 else
+ − 616 {
+ − 617 tM_add(StMOG);
38
+ − 618 }
+ − 619
+ − 620 id = tMOG_refresh(0, text, &tabPosition, subtext);
+ − 621 tM_build_page(id, text, tabPosition, subtext);
+ − 622
+ − 623 id = tMCG_refresh(0, text, &tabPosition, subtext);
+ − 624 tM_build_page(id, text, tabPosition, subtext);
+ − 625
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 626 id = tMSP_refresh(text, &tabPosition, subtext);
38
+ − 627 tM_build_page(id, text, tabPosition, subtext);
+ − 628
+ − 629 id = tMXtra_refresh(0, text, &tabPosition, subtext);
+ − 630 tM_build_page(id, text, tabPosition, subtext);
+ − 631
+ − 632 id = tMPlanner_refresh(0, text, &tabPosition, subtext);
+ − 633 tM_build_page(id, text, tabPosition, subtext);
+ − 634
+ − 635 id = tMDeco_refresh(0, text, &tabPosition, subtext);
+ − 636 tM_build_page(id, text, tabPosition, subtext);
+ − 637
+ − 638 id = tMDecoParameters_refresh(0, text, &tabPosition, subtext);
+ − 639 tM_build_page(id, text, tabPosition, subtext);
+ − 640
+ − 641 id = tMPlanner_refresh(0, text, &tabPosition, subtext);
+ − 642 tM_build_page(id, text, tabPosition, subtext);
+ − 643
+ − 644 id = tMHardware_refresh(0, text, &tabPosition, subtext);
+ − 645 tM_build_page(id, text, tabPosition, subtext);
+ − 646
+ − 647 id = tMSystem_refresh(0, text, &tabPosition, subtext);
+ − 648 tM_build_page(id, text, tabPosition, subtext);
507
+ − 649
+ − 650 id = tMCustom_refresh(0, text, &tabPosition, subtext);
+ − 651 tM_build_page(id, text, tabPosition, subtext);
38
+ − 652 }
+ − 653
+ − 654
+ − 655 void tM_refresh_live_content(void)
+ − 656 {
662
+ − 657 static uint8_t slowUpdate = SLOW_UPDATE_CNT;
51
+ − 658 uint8_t page = 0;
38
+ − 659 char text[MAX_PAGE_TEXTSIZE];
+ − 660 char subtext[MAX_PAGE_TEXTSIZE];
+ − 661 uint16_t tabPosition;
+ − 662
662
+ − 663 uint32_t globalState = get_globalState();
+ − 664
+ − 665 slowUpdate--;
+ − 666 page = menu.pageMemoryForNavigation;
+ − 667 switch(globalState)
38
+ − 668 {
662
+ − 669 case StMSYS: if(actual_menu_content == MENU_SURFACE)
+ − 670 {
+ − 671 tMSystem_refresh(0, text, &tabPosition, subtext);
+ − 672 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 673 }
+ − 674 break;
+ − 675 case StMHARD: tMHardware_refresh(0, text, &tabPosition, subtext);
+ − 676 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 677 break;
+ − 678 case StMOG: if((actual_menu_content != MENU_SURFACE) && (slowUpdate == 0))
+ − 679 {
+ − 680 tMOG_refresh(0, text, &tabPosition, subtext);
+ − 681 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 682 }
+ − 683 break;
+ − 684 case StMCG: if((actual_menu_content != MENU_SURFACE) && (slowUpdate == 0))
+ − 685 {
+ − 686 tMCG_refresh(0, text, &tabPosition, subtext);
+ − 687 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 688 }
+ − 689 break;
+ − 690 default:
+ − 691 break;
38
+ − 692 }
662
+ − 693 if(slowUpdate == 0)
38
+ − 694 {
662
+ − 695 slowUpdate = SLOW_UPDATE_CNT;
38
+ − 696 }
+ − 697
+ − 698 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 699 tHome_show_lost_connection_count(&tMscreen);
+ − 700 /*
+ − 701 SStateList idList;
+ − 702 if(actual_menu_content == MENU_SURFACE)
+ − 703 {
+ − 704 page = menu.pageMemoryForNavigation;
+ − 705 get_idSpecificStateList(StMSYS, &idList);
+ − 706 if(page == idList.page)
+ − 707 {
+ − 708 tMSystem_refresh(0, text, &tabPosition, subtext);
+ − 709 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 710 }
+ − 711 }
+ − 712 */
+ − 713 }
+ − 714
+ − 715
+ − 716 /* new frame only! */
+ − 717 void updateSpecificMenu(uint32_t id)
+ − 718 {
+ − 719 uint8_t page;
+ − 720 SStateList idList;
+ − 721
+ − 722 char text[MAX_PAGE_TEXTSIZE];
+ − 723 char subtext[MAX_PAGE_TEXTSIZE];
+ − 724 uint16_t tabPosition;
+ − 725
+ − 726 *subtext = 0;
+ − 727 *text = 0;
+ − 728 tabPosition = 400;
+ − 729
+ − 730 get_idSpecificStateList(id, &idList);
+ − 731 page = idList.page;
+ − 732
+ − 733 switch(id)
+ − 734 {
+ − 735 case StMOG:
+ − 736 tMOG_refresh(0, text, &tabPosition, subtext);
+ − 737 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 738 break;
+ − 739 case StMCG:
+ − 740 tMCG_refresh(0, text, &tabPosition, subtext);
+ − 741 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 742 break;
+ − 743 case StMSP:
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 744 tMSP_refresh(text, &tabPosition, subtext);
38
+ − 745 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 746 break;
815
+ − 747 case StMSYS:
+ − 748 tMSystem_refresh(0, text, &tabPosition, NULL);
+ − 749 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 750 break;
+ − 751
38
+ − 752 default:
+ − 753 break;
+ − 754 }
+ − 755 }
+ − 756
+ − 757
+ − 758 void updateMenu(void)
+ − 759 {
+ − 760 uint8_t page, line;
+ − 761
+ − 762 char text[MAX_PAGE_TEXTSIZE];
+ − 763 char subtext[MAX_PAGE_TEXTSIZE];
+ − 764 uint16_t tabPosition;
+ − 765
+ − 766 *subtext = 0;
+ − 767 *text = 0;
+ − 768 tabPosition = 400;
+ − 769
+ − 770 page = menu.pageMemoryForNavigation;
+ − 771 line = menu.lineMemoryForNavigationForPage[page];
+ − 772
+ − 773 switch(get_globalState())
+ − 774 {
+ − 775 case StMOG:
+ − 776 tMOG_refresh(0, text, &tabPosition, subtext);
+ − 777 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 778 break;
+ − 779 case StMCG:
+ − 780 tMCG_refresh(0, text, &tabPosition, subtext);
+ − 781 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 782 break;
+ − 783 case StMSP:
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 784 tMSP_refresh(text, &tabPosition, subtext);
38
+ − 785 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 786 break;
+ − 787 case StMXTRA:
+ − 788 tMXtra_refresh(0, text, &tabPosition, subtext);
+ − 789 update_content_with_new_frame(page, text, tabPosition, subtext);
+ − 790 break;
+ − 791 case StMDECO:
+ − 792 if((line == 1) || (line == 3)) // dive mode or ppO2 limits (the later for correct MOD in gaslists)
+ − 793 {
+ − 794 tM_rebuild_pages();
+ − 795 menu.lineMemoryForNavigationForPage[page] = line; // fix 160623
+ − 796 GFX_SetFrameTop(menu.StartAddressForPage[page]);
+ − 797 }
+ − 798 else
+ − 799 {
+ − 800 tMDeco_refresh(line, text, &tabPosition, subtext);
+ − 801 clean_line_actual_page();
+ − 802 update_content_actual_page(text, tabPosition, subtext);
+ − 803 }
+ − 804 break;
+ − 805 case StMDECOP:
+ − 806 tMDecoParameters_refresh(line, text, &tabPosition, subtext);
+ − 807 clean_line_actual_page();
+ − 808 update_content_actual_page(text, tabPosition, subtext);
+ − 809 break;
+ − 810 case StMPLAN:
+ − 811 tMPlanner_refresh(line, text, &tabPosition, subtext);
+ − 812 clean_line_actual_page();
+ − 813 update_content_actual_page(text, tabPosition, subtext);
+ − 814 break;
+ − 815 case StMHARD:
+ − 816 tMHardware_refresh(line, text, &tabPosition, subtext);
+ − 817 clean_line_actual_page();
+ − 818 update_content_actual_page(text, tabPosition, subtext);
+ − 819 break;
+ − 820 case StMSYS:
+ − 821 if((line == 2) || (line == 3) || (line == 6))
+ − 822 {
+ − 823 tM_rebuild_pages();
+ − 824 menu.lineMemoryForNavigationForPage[page] = line; // fix 160623
+ − 825 GFX_SetFrameTop(menu.StartAddressForPage[page]);
+ − 826 menu.lineMemoryForNavigationForPage[page] = line;
+ − 827 }
+ − 828 else
+ − 829 {
+ − 830 tMSystem_refresh(line, text, &tabPosition, subtext);
+ − 831 clean_line_actual_page();
+ − 832 update_content_actual_page(text, tabPosition, subtext);
+ − 833 }
+ − 834 break;
507
+ − 835 case StMCustom:
+ − 836 tMCustom_refresh(line, text, &tabPosition, subtext);
+ − 837 clean_line_actual_page();
+ − 838 update_content_actual_page(text, tabPosition, subtext);
+ − 839 break;
38
+ − 840 default:
+ − 841 break;
+ − 842 }
+ − 843 }
+ − 844
+ − 845 void openMenu_first_page_with_OC_gas_update(void)
+ − 846 {
+ − 847 menu.pageMemoryForNavigation = 1;
+ − 848 for(int i=0;i<=MAXPAGES;i++)
+ − 849 menu.lineMemoryForNavigationForPage[i] = 0;
+ − 850
+ − 851 set_globalState(StMOG);
+ − 852 updateMenu();
+ − 853 openMenu(1);
+ − 854 }
+ − 855
+ − 856
+ − 857 void openMenu(uint8_t freshWithFlipPages)
+ − 858 {
+ − 859 uint8_t page, line;
110
+ − 860 SSettings* pSettings;
+ − 861 pSettings = settingsGetPointer();
38
+ − 862
+ − 863 findValidPosition(&page, &line);
+ − 864 if((page == 0) || (line == 0))
+ − 865 return;
+ − 866
951
+ − 867 requestBuzzerActivation(0);
+ − 868
38
+ − 869 menu.pageMemoryForNavigation = page;
+ − 870 /* new test for 3button design */
+ − 871 if(freshWithFlipPages)
+ − 872 {
+ − 873 menu.lineMemoryForNavigationForPage[page] = 0;
+ − 874 menu.modeFlipPages = 1;
+ − 875 }
+ − 876 else
+ − 877 {
+ − 878 menu.lineMemoryForNavigationForPage[page] = line;
+ − 879 menu.modeFlipPages = 0;
+ − 880 }
+ − 881
+ − 882 set_globalState_Menu_Page(page);
+ − 883
+ − 884
+ − 885 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1));
+ − 886 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
+ − 887
+ − 888
+ − 889 if(((page == 6) || (page == 8)) && (menu.pageCountNumber[page-1] == 0))
+ − 890 {
+ − 891 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 2));
+ − 892 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 2));
+ − 893
+ − 894 }
+ − 895
+ − 896 GFX_SetFrameTop(menu.StartAddressForPage[page]);
+ − 897 /* new test for 3button design */
110
+ − 898
+ − 899 if(!pSettings->FlipDisplay)
+ − 900 {
+ − 901 if(freshWithFlipPages)
+ − 902 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
+ − 903 else
+ − 904 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
+ − 905 }
38
+ − 906 else
110
+ − 907 {
+ − 908 if(freshWithFlipPages)
+ − 909 {
+ − 910 GFX_SetFrameBottom((tMdesignSolo.FBStartAdress), 0, 480-390-KEY_LABEL_HIGH, 800, 390); //- (25 * 2 * 800), 0, 25, 800, 390);
+ − 911 }
+ − 912 else
+ − 913 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress + (390 - 65 *(line)) *2), 0,480-390-KEY_LABEL_HIGH, 800, 390); //480-390-KEY_LABEL_HIGH + 65*2*(line - 1)
+ − 914 }
+ − 915
38
+ − 916 }
+ − 917
167
+ − 918 static void block_diluent_handler(_Bool Unblock)
38
+ − 919 {
+ − 920 SStateList list;
+ − 921 static uint8_t linesAvailableForPageDiluent = 0;
+ − 922 get_idSpecificStateList(StMCG, &list);
+ − 923
+ − 924 if(Unblock && linesAvailableForPageDiluent)
+ − 925 {
+ − 926 menu.linesAvailableForPage[list.page] = linesAvailableForPageDiluent;
+ − 927 }
+ − 928 else
+ − 929 {
+ − 930 linesAvailableForPageDiluent = menu.linesAvailableForPage[list.page];
+ − 931 menu.linesAvailableForPage[list.page] = 0;
+ − 932 }
+ − 933 }
+ − 934
+ − 935 void block_diluent_page(void)
+ − 936 {
+ − 937 block_diluent_handler(0);
+ − 938 }
+ − 939
+ − 940
+ − 941 void unblock_diluent_page(void)
+ − 942 {
+ − 943 block_diluent_handler(1);
+ − 944 }
+ − 945
850
+ − 946 static void checkLineStatus()
+ − 947 {
+ − 948 switch(get_globalState())
+ − 949 {
851
+ − 950 case StMSYS: tMSystem_checkLineStatus();
+ − 951 break;
850
+ − 952 case StMXTRA: tMXtra_checkLineStatus();
+ − 953 break;
+ − 954 default:
+ − 955 break;
+ − 956 }
+ − 957 }
38
+ − 958
167
+ − 959 static void nextPage(void)
38
+ − 960 {
+ − 961 uint8_t page, line;
+ − 962
110
+ − 963 SSettings* pSettings;
+ − 964 pSettings = settingsGetPointer();
+ − 965
38
+ − 966 menu.pageMemoryForNavigation += 1;
+ − 967
+ − 968 findValidPosition(&page, &line);
+ − 969 menu.pageMemoryForNavigation = page;
+ − 970 /* new test for 3button design */
+ − 971 //menu.lineMemoryForNavigationForPage[page] = line;
+ − 972 menu.lineMemoryForNavigationForPage[page] = 0;
+ − 973 menu.modeFlipPages = 1;
+ − 974
+ − 975 set_globalState_Menu_Page(page);
+ − 976
850
+ − 977 checkLineStatus(); /* some lines may be enabled / disabled depending on condition occuring outside the page scope => check if update is necessary */
+ − 978
38
+ − 979 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1));
+ − 980 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
+ − 981
+ − 982 GFX_SetFrameTop(menu.StartAddressForPage[page]);
+ − 983 /* new test for 3button design */
110
+ − 984 //GFX_SetFrameBottom((.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
+ − 985 if(!pSettings->FlipDisplay)
+ − 986 {
+ − 987 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
+ − 988 }
+ − 989 else
+ − 990 {
+ − 991 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390);
+ − 992 }
38
+ − 993 }
+ − 994
647
+ − 995 void selectPage(uint32_t selection)
+ − 996 {
650
+ − 997 uint8_t page;
647
+ − 998 SStateList idList;
+ − 999
+ − 1000 SSettings* pSettings;
+ − 1001 pSettings = settingsGetPointer();
+ − 1002
+ − 1003 // menu.pageMemoryForNavigation = selection;
+ − 1004
+ − 1005 // findValidPosition(&page, &line);
+ − 1006 if(selection > MAXPAGES) /* selection via structure */
+ − 1007 {
+ − 1008 get_idSpecificStateList(selection, &idList);
+ − 1009 page = idList.page;
+ − 1010 }
+ − 1011 else
+ − 1012 {
+ − 1013 page = selection;
+ − 1014 }
+ − 1015
+ − 1016 if(menu.shadowPage[page]) /* backup base page in case a shadow was selected */
+ − 1017 {
+ − 1018 menu.activeShadow = menu.pageMemoryForNavigation;
+ − 1019 }
+ − 1020
+ − 1021 menu.pageMemoryForNavigation = page;
+ − 1022 /* new test for 3button design */
+ − 1023 //menu.lineMemoryForNavigationForPage[page] = line;
+ − 1024 menu.lineMemoryForNavigationForPage[page] = 0;
+ − 1025 menu.modeFlipPages = 1;
+ − 1026
+ − 1027 set_globalState_Menu_Page(page);
+ − 1028
+ − 1029 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1));
+ − 1030 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
+ − 1031
+ − 1032 GFX_SetFrameTop(menu.StartAddressForPage[page]);
+ − 1033 /* new test for 3button design */
+ − 1034 //GFX_SetFrameBottom((.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
+ − 1035 if(!pSettings->FlipDisplay)
+ − 1036 {
+ − 1037 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
+ − 1038 }
+ − 1039 else
+ − 1040 {
+ − 1041 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390);
+ − 1042 }
+ − 1043 nextLine();
+ − 1044 }
+ − 1045
38
+ − 1046
167
+ − 1047 static void nextLine(void)
38
+ − 1048 {
+ − 1049 uint8_t page, line;
110
+ − 1050 SSettings* pSettings;
+ − 1051 pSettings = settingsGetPointer();
38
+ − 1052
+ − 1053 page = menu.pageMemoryForNavigation;
+ − 1054 menu.lineMemoryForNavigationForPage[page] += 1;
+ − 1055
+ − 1056 findValidPosition(&page, &line);
+ − 1057 menu.lineMemoryForNavigationForPage[page] = line;
+ − 1058
+ − 1059 /* new test for 3button design */
+ − 1060 menu.modeFlipPages = 0;
110
+ − 1061 if(!pSettings->FlipDisplay)
+ − 1062 {
+ − 1063 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
+ − 1064 }
+ − 1065 else
+ − 1066 {
+ − 1067 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-KEY_LABEL_HIGH, 800, 390);
+ − 1068 }
38
+ − 1069 }
+ − 1070
+ − 1071
167
+ − 1072 static void stepBackMenu(void)
38
+ − 1073 {
647
+ − 1074 if(menu.activeShadow) /* restore base page */
+ − 1075 {
+ − 1076 selectPage(menu.activeShadow);
+ − 1077 menu.activeShadow = 0;
+ − 1078 }
38
+ − 1079 if(menu.modeFlipPages == 0)
+ − 1080 {
+ − 1081 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0;
+ − 1082 menu.modeFlipPages = 1;
110
+ − 1083 if(!settingsGetPointer()->FlipDisplay)
+ − 1084 {
+ − 1085 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
+ − 1086 }
+ − 1087 else
+ − 1088 {
+ − 1089 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 480-390-KEY_LABEL_HIGH, 800, 390);
+ − 1090 }
38
+ − 1091 }
+ − 1092 else
110
+ − 1093 {
38
+ − 1094 exitMenu();
110
+ − 1095 }
38
+ − 1096 }
+ − 1097
+ − 1098
+ − 1099 void exitMenu(void)
+ − 1100 {
+ − 1101 set_globalState_tHome();
+ − 1102 }
+ − 1103
+ − 1104
167
+ − 1105 static void stepForwardMenu(void)
38
+ − 1106 {
+ − 1107 if(menu.modeFlipPages == 1)
+ − 1108 {
+ − 1109 nextLine();
+ − 1110 }
+ − 1111 else
+ − 1112 gotoMenuEdit();
+ − 1113 }
+ − 1114
167
+ − 1115 static void gotoMenuEdit(void)
38
+ − 1116 {
+ − 1117 uint8_t line;
+ − 1118
+ − 1119 line = menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation];
+ − 1120
+ − 1121 switch(get_globalState())
+ − 1122 {
+ − 1123 case StMOG:
+ − 1124 openEdit_GasOC(line);
+ − 1125 break;
+ − 1126 case StMCG:
+ − 1127 openEdit_GasCC(line);
+ − 1128 break;
+ − 1129 case StMSP:
+ − 1130 openEdit_Setpoint(line);
+ − 1131 break;
+ − 1132 case StMXTRA:
+ − 1133 openEdit_Xtra(line);
+ − 1134 break;
+ − 1135 case StMDECO:
+ − 1136 openEdit_Deco(line);
+ − 1137 break;
+ − 1138 case StMDECOP:
+ − 1139 openEdit_DecoParameter(line);
+ − 1140 break;
+ − 1141 case StMPLAN:
+ − 1142 openEdit_Planner(line);
+ − 1143 break;
+ − 1144 case StMHARD:
+ − 1145 openEdit_Hardware(line);
+ − 1146 break;
+ − 1147 case StMSYS:
+ − 1148 openEdit_System(line);
+ − 1149 break;
507
+ − 1150 case StMCustom:
+ − 1151 openEdit_Custom(line);
+ − 1152 break;
38
+ − 1153 default:
+ − 1154 break;
+ − 1155 }
+ − 1156 }
+ − 1157
+ − 1158
+ − 1159 void sendActionToMenu(uint8_t sendAction)
+ − 1160 {
+ − 1161 switch(sendAction)
+ − 1162 {
+ − 1163 case ACTION_BUTTON_ENTER:
+ − 1164 stepForwardMenu();
+ − 1165 break;
+ − 1166 case ACTION_BUTTON_NEXT:
+ − 1167 if(menu.modeFlipPages)
+ − 1168 nextPage();
+ − 1169 else
+ − 1170 nextLine();
+ − 1171 break;
+ − 1172 case ACTION_TIMEOUT:
+ − 1173 case ACTION_MODE_CHANGE:
+ − 1174 case ACTION_BUTTON_BACK:
+ − 1175 /* new test for 3button design */
+ − 1176 stepBackMenu();
+ − 1177 break;
+ − 1178 default:
+ − 1179 break;
+ − 1180 case ACTION_IDLE_TICK:
+ − 1181 case ACTION_IDLE_SECOND:
+ − 1182 break;
+ − 1183 }
+ − 1184 /* tMC_OC_Gas(StMOG1, pSettings); */
+ − 1185 }
+ − 1186
167
+ − 1187 static void tMenu_write(uint8_t page, char *text, char *subtext)
38
+ − 1188 {
+ − 1189 if(page > MAXPAGES)
+ − 1190 return;
+ − 1191 if(menu.linesAvailableForPage[page] == 0)
+ − 1192 return;
+ − 1193
+ − 1194 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
+ − 1195 GFX_write_string(&FontT48, &tMwindow, text,1);
+ − 1196 if((*subtext) && (menu.linesAvailableForPage[page] < 6))
+ − 1197 {
+ − 1198 GFX_write_string(&FontT42, &tMwindow, subtext, (menu.linesAvailableForPage[page] + 1));
+ − 1199 }
+ − 1200 }
+ − 1201
+ − 1202
+ − 1203 /* Private functions ---------------------------------------------------------*/
+ − 1204
167
+ − 1205 static void draw_tMdesignSubUnselected(uint32_t *ppDestination)
38
+ − 1206 {
+ − 1207 union al88_u
+ − 1208 {
+ − 1209 uint8_t al8[2];
+ − 1210 uint16_t al88;
+ − 1211 };
+ − 1212
130
+ − 1213 uint16_t* prunning = (uint16_t*)*ppDestination;
110
+ − 1214
38
+ − 1215 union al88_u color_seperator;
+ − 1216 union al88_u color_unselected;
+ − 1217 int i;
+ − 1218
+ − 1219 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator;
+ − 1220 color_unselected.al8[0] = CLUT_MenuLineUnselected;
+ − 1221
+ − 1222 color_seperator.al8[1] = 0xFF;
+ − 1223 color_unselected.al8[1] = 0xFF;
+ − 1224
110
+ − 1225 *(__IO uint16_t*)prunning++ = color_seperator.al88;
+ − 1226 *(__IO uint16_t*)prunning++ = color_seperator.al88;
38
+ − 1227
+ − 1228 for(i = 61; i > 0; i--)
+ − 1229 {
110
+ − 1230 *(__IO uint16_t*)prunning++ = color_unselected.al88;
38
+ − 1231 }
+ − 1232
110
+ − 1233 *(__IO uint16_t*)prunning++ = color_seperator.al88;
+ − 1234 *(__IO uint16_t*)prunning++ = color_seperator.al88;
+ − 1235
130
+ − 1236 *ppDestination = (uint32_t)prunning;
38
+ − 1237 }
+ − 1238
+ − 1239
167
+ − 1240 static void draw_tMdesignSubSelected(uint32_t *ppDestination)
38
+ − 1241 {
+ − 1242 union al88_u
+ − 1243 {
+ − 1244 uint8_t al8[2];
+ − 1245 uint16_t al88;
+ − 1246 };
+ − 1247
+ − 1248 union al88_u color_selected;
+ − 1249 union al88_u color_seperator;
+ − 1250 int i;
+ − 1251
+ − 1252 color_selected.al8[0] = CLUT_MenuLineSelected;
+ − 1253 color_selected.al8[1] = 0xFF;
+ − 1254
+ − 1255 color_seperator.al8[0] = CLUT_MenuLineSelectedSeperator;
+ − 1256 color_seperator.al8[1] = 0xFF;
+ − 1257
+ − 1258 *(__IO uint16_t*)*ppDestination = color_seperator.al88;
+ − 1259 *ppDestination += 2;
+ − 1260 *(__IO uint16_t*)*ppDestination = color_seperator.al88;
+ − 1261 *ppDestination += 2;
+ − 1262
+ − 1263 for(i = 61; i > 0; i--)
+ − 1264 {
+ − 1265 *(__IO uint16_t*)*ppDestination = color_selected.al88;
+ − 1266 *ppDestination += 2;
+ − 1267 }
+ − 1268
+ − 1269 *(__IO uint16_t*)*ppDestination = color_seperator.al88;
+ − 1270 *ppDestination += 2;
+ − 1271 *(__IO uint16_t*)*ppDestination = color_seperator.al88;
+ − 1272 *ppDestination += 2;
+ − 1273 }
+ − 1274
+ − 1275
167
+ − 1276 static void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination)
38
+ − 1277 {
+ − 1278 union al88_u
+ − 1279 {
+ − 1280 uint8_t al8[2];
+ − 1281 uint16_t al88;
+ − 1282 };
+ − 1283
+ − 1284 union al88_u color_selected_sides;
+ − 1285
+ − 1286 int i;
+ − 1287
+ − 1288 color_selected_sides.al8[0] = CLUT_MenuLineSelectedSides;
+ − 1289 color_selected_sides.al8[1] = 0xFF;
+ − 1290
+ − 1291 for(i = 65; i > 0; i--)
+ − 1292 {
+ − 1293 *(__IO uint16_t*)*ppDestination = color_selected_sides.al88;
+ − 1294 *ppDestination += 2;
+ − 1295 }
+ − 1296 }
+ − 1297
+ − 1298
167
+ − 1299 static void draw_tMcursorDesign(void)
38
+ − 1300 {
+ − 1301 int i,j;
+ − 1302 uint32_t pDestination;
+ − 1303
+ − 1304 pDestination = tMdesignCursor.FBStartAdress;
+ − 1305
+ − 1306 for(j = 801; j > 0; j--)
+ − 1307 {
+ − 1308 for(i = 5; i > 0; i--)
+ − 1309 {
+ − 1310 draw_tMdesignSubUnselected(&pDestination);
+ − 1311 }
+ − 1312 if((j > 787) || (j < 17))
+ − 1313 draw_tMdesignSubSelectedBorder(&pDestination);
+ − 1314 else
+ − 1315 draw_tMdesignSubSelected(&pDestination);
+ − 1316 }
+ − 1317
110
+ − 1318 /* Draw menu background boxes which are visible if nothing is selected */
38
+ − 1319 pDestination = tMdesignSolo.FBStartAdress;
+ − 1320
+ − 1321 for(j = 801; j > 0; j--)
+ − 1322 {
+ − 1323 for(i = 6; i > 0; i--)
+ − 1324 {
+ − 1325 draw_tMdesignSubUnselected(&pDestination);
+ − 1326 }
+ − 1327 }
+ − 1328 }
+ − 1329
+ − 1330
167
+ − 1331 static void draw_tMheader(uint8_t page)
38
+ − 1332 {
+ − 1333 union al88_u
+ − 1334 {
+ − 1335 uint8_t al8[2];
+ − 1336 uint16_t al88;
+ − 1337 };
+ − 1338 union al88_u color_top;
+ − 1339 int i,j, k, k4text;
+ − 1340 uint32_t pBackup;
110
+ − 1341 uint16_t* pDestination;
38
+ − 1342 uint8_t colorText;
+ − 1343 uint16_t positionText;
+ − 1344 uint8_t pageText;
+ − 1345
647
+ − 1346 char text8max[MAXPAGES+1][8] =
38
+ − 1347 { "",
+ − 1348 "OC",
+ − 1349 "CC",
+ − 1350 "SP",
+ − 1351 "DATA",
+ − 1352 "DECO",
+ − 1353 "",
+ − 1354 "SYS",
+ − 1355 "",
507
+ − 1356 "",
+ − 1357 "SIM"
38
+ − 1358 };
+ − 1359
647
+ − 1360 _Bool spacing[MAXPAGES+1] =
38
+ − 1361 { 0,
+ − 1362 0, // behind OC
+ − 1363 0, // behind CC
+ − 1364 1, // behind SP
+ − 1365 1, // behind DATA
+ − 1366 0, // behind DECO1
+ − 1367 1, // behind DECO2
+ − 1368 0, // behind SYS1
507
+ − 1369 0, // behind SYS2
+ − 1370 1, // behind SYS3
38
+ − 1371 1, // behind SIM
+ − 1372 0
+ − 1373 };
+ − 1374
647
+ − 1375 if(actual_menu_content == MENU_SURFACE)
+ − 1376 {
+ − 1377 spacing[3] = 0; /* Display extra menu directly after setpoint */
+ − 1378 sprintf(text8max[4],"OP");
+ − 1379 }
+ − 1380
38
+ − 1381 pBackup = tMscreen.FBStartAdress;
+ − 1382 tMscreen.FBStartAdress = menu.StartAddressForPage[page];
130
+ − 1383 pDestination = (uint16_t*) menu.StartAddressForPage[page];
38
+ − 1384 positionText = 10;
+ − 1385 pageText = page;
+ − 1386
+ − 1387 gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0);
+ − 1388
+ − 1389 while((text8max[pageText][0] == 0) && (pageText > 1))
+ − 1390 {
+ − 1391 pageText--;
+ − 1392 }
+ − 1393
+ − 1394 for(k = 1; k <= MAXPAGES; k++)
+ − 1395 {
+ − 1396 if(menu.pageCountNumber[k] != 0)
+ − 1397 {
+ − 1398 k4text = k; // new hw 170522
+ − 1399 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0))
+ − 1400 k4text = k-1;
+ − 1401
+ − 1402 color_top.al8[0] = CLUT_MenuPageGasOC + k - 1;
169
+ − 1403 if (k == page)
38
+ − 1404 {
+ − 1405 color_top.al8[1] = 0xFF;
+ − 1406 }
+ − 1407 else
+ − 1408 {
+ − 1409 color_top.al8[1] = 0x50;
+ − 1410 }
+ − 1411
+ − 1412 if(k4text == pageText)
+ − 1413 {
+ − 1414 colorText = CLUT_Font020;
+ − 1415 }
+ − 1416 else
+ − 1417 {
+ − 1418 colorText = CLUT_Font021;
+ − 1419 }
+ − 1420
+ − 1421 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k4text],colorText);
+ − 1422 /*
+ − 1423 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k],colorText);
+ − 1424 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0))
+ − 1425 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k-1],colorText);
+ − 1426 */
110
+ − 1427 /* Draw color bars */
+ − 1428 if(!settingsGetPointer()->FlipDisplay)
+ − 1429 {
+ − 1430 pDestination += 5 * 480;
38
+ − 1431
110
+ − 1432 for(j = 60; j > 0; j--)
+ − 1433 {
+ − 1434 pDestination += (390 + 26);
38
+ − 1435
110
+ − 1436 for(i = 16; i > 0; i--)
+ − 1437 {
+ − 1438 *(__IO uint16_t*)pDestination++ = color_top.al88;
+ − 1439 }
+ − 1440 pDestination += 48;
+ − 1441 }
+ − 1442
+ − 1443 pDestination += 5 * 480;
+ − 1444 positionText += 70;
+ − 1445
647
+ − 1446 if(((k == 4) && (actual_menu_content != MENU_SURFACE)) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
110
+ − 1447 {
+ − 1448 pDestination += 70 * 480;
+ − 1449 positionText += 70;
+ − 1450 }
38
+ − 1451
110
+ − 1452 if(spacing[k])
+ − 1453 {
+ − 1454 pDestination += 35 * 480;
+ − 1455 positionText += 35;
+ − 1456 }
+ − 1457 }
+ − 1458 else
+ − 1459 {
+ − 1460 pDestination += (800 - 5)* 480;
+ − 1461
+ − 1462 for(j = 60; j > 0; j--)
+ − 1463 {
+ − 1464 pDestination -= (390 + 26);
38
+ − 1465
110
+ − 1466 for(i = 16; i > 0; i--)
+ − 1467 {
+ − 1468 *(__IO uint16_t*)pDestination-- = color_top.al88;
+ − 1469 }
+ − 1470 pDestination -= 48;
+ − 1471 }
+ − 1472
+ − 1473 pDestination -= (800) * 480;
824
+ − 1474 positionText += 66;
38
+ − 1475
658
+ − 1476 if(((k == 4) && (actual_menu_content != MENU_SURFACE)) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
110
+ − 1477 {
+ − 1478 pDestination -= 70 * 480;
824
+ − 1479 positionText += 66;
110
+ − 1480 }
+ − 1481
+ − 1482 if(spacing[k])
+ − 1483 {
+ − 1484 pDestination -= 35 * 480;
824
+ − 1485 positionText += 31;
110
+ − 1486 }
+ − 1487 }
38
+ − 1488 }
+ − 1489 }
+ − 1490 tMscreen.FBStartAdress = pBackup;
+ − 1491 }
774
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1492
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1493
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1494 char *makeGrey(bool isGrey)
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1495 {
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1496 return isGrey ? "\031" : "";
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
diff
changeset
+ − 1497 }