Velocity Closed Loop Dynamic error correction
Dependencies: mbed QEI PID DmTftLibraryEx
Display/Menu.cpp@39:be7055a0e9a4, 2022-04-15 (annotated)
- Committer:
- lex9296
- Date:
- Fri Apr 15 07:01:02 2022 +0000
- Revision:
- 39:be7055a0e9a4
- Parent:
- 27:654100855f5c
Retroazione di velocita e correzione
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lex9296 | 21:ab8027016a2c | 1 | |
mverdy | 20:626b92b70bf7 | 2 | #include <stdio.h> |
mverdy | 20:626b92b70bf7 | 3 | #include "mbed.h" |
lex9296 | 23:b9d23a2f390e | 4 | |
mverdy | 20:626b92b70bf7 | 5 | #include "Menu.h" |
mverdy | 20:626b92b70bf7 | 6 | #include "DisplayDriver.h" |
mverdy | 20:626b92b70bf7 | 7 | #include "Eeprom.h" |
mverdy | 20:626b92b70bf7 | 8 | #include "main.h" |
mverdy | 20:626b92b70bf7 | 9 | #include "app_config.h" |
mverdy | 20:626b92b70bf7 | 10 | |
mverdy | 20:626b92b70bf7 | 11 | /*! |
mverdy | 20:626b92b70bf7 | 12 | * \brief Maximum character count on the same line with function DrawText |
mverdy | 20:626b92b70bf7 | 13 | * This include needed space for the outline (at the begin and the end of line). |
mverdy | 20:626b92b70bf7 | 14 | * MAX_CHAR_PER_BTN is the same, but for a button. |
mverdy | 20:626b92b70bf7 | 15 | */ |
mverdy | 20:626b92b70bf7 | 16 | #define MAX_CHAR_PER_LINE 28 |
mverdy | 20:626b92b70bf7 | 17 | |
mverdy | 20:626b92b70bf7 | 18 | /*! |
mverdy | 20:626b92b70bf7 | 19 | * \brief Bitmap of Semtech Logo stored here (copied from a C file). |
mverdy | 20:626b92b70bf7 | 20 | */ |
mverdy | 20:626b92b70bf7 | 21 | extern uint8_t SemtechLogo[]; |
mverdy | 20:626b92b70bf7 | 22 | |
mverdy | 20:626b92b70bf7 | 23 | |
mverdy | 20:626b92b70bf7 | 24 | /*! |
mverdy | 20:626b92b70bf7 | 25 | * \brief List og graphical object in the application. |
mverdy | 20:626b92b70bf7 | 26 | */ |
mverdy | 20:626b92b70bf7 | 27 | enum MenuObjectsId |
mverdy | 20:626b92b70bf7 | 28 | { |
mverdy | 20:626b92b70bf7 | 29 | PAGE_BORDER = 0, |
mverdy | 20:626b92b70bf7 | 30 | TITLE_LINE, |
mverdy | 20:626b92b70bf7 | 31 | TITLE_TEXT, |
mverdy | 20:626b92b70bf7 | 32 | FIRM_LOGO, |
mverdy | 20:626b92b70bf7 | 33 | BTN0_BORDER, // to accord with DrawActiveButton( ), each button should |
mverdy | 20:626b92b70bf7 | 34 | BTN0_MENU_TEXT, // have consecutively MENU_TEXT (full large text), |
mverdy | 20:626b92b70bf7 | 35 | BTN0_LABEL_TEXT, // LABEL_TEXT (left side of the button) and VALUE_TEXT |
mverdy | 20:626b92b70bf7 | 36 | BTN0_VALUE_TEXT, // (right side of the button). |
mverdy | 20:626b92b70bf7 | 37 | BTN1_BORDER, |
mverdy | 20:626b92b70bf7 | 38 | BTN1_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 39 | BTN1_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 40 | BTN1_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 41 | BTN2_BORDER, |
mverdy | 20:626b92b70bf7 | 42 | BTN2_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 43 | BTN2_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 44 | BTN2_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 45 | BTN3_BORDER, |
mverdy | 20:626b92b70bf7 | 46 | BTN3_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 47 | BTN3_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 48 | BTN3_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 49 | BTN4_BORDER, |
mverdy | 20:626b92b70bf7 | 50 | BTN4_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 51 | BTN4_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 52 | BTN4_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 53 | BTN5_BORDER, |
mverdy | 20:626b92b70bf7 | 54 | BTN5_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 55 | BTN5_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 56 | BTN5_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 57 | BTN6_BORDER, |
mverdy | 20:626b92b70bf7 | 58 | BTN6_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 59 | BTN6_LABEL_TEXT, |
mverdy | 20:626b92b70bf7 | 60 | BTN6_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 61 | BTN7_BORDER, |
mverdy | 20:626b92b70bf7 | 62 | BTN7_MENU_TEXT, |
lex9296 | 23:b9d23a2f390e | 63 | BTN7_LABEL_TEXT, |
lex9296 | 23:b9d23a2f390e | 64 | BTN7_VALUE_TEXT, |
mverdy | 20:626b92b70bf7 | 65 | BTN8_BORDER, |
mverdy | 20:626b92b70bf7 | 66 | BTN8_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 67 | BTN9_BORDER, |
mverdy | 20:626b92b70bf7 | 68 | BTN9_MENU_TEXT, |
mverdy | 20:626b92b70bf7 | 69 | LINE0_TEXT, |
mverdy | 20:626b92b70bf7 | 70 | LINE1_TEXT, |
mverdy | 20:626b92b70bf7 | 71 | LINE2_TEXT, |
mverdy | 20:626b92b70bf7 | 72 | LINE2_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 73 | LINE2_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 74 | LINE3_TEXT, |
mverdy | 20:626b92b70bf7 | 75 | LINE3_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 76 | LINE3_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 77 | LINE3_COL2_TEXT, |
mverdy | 20:626b92b70bf7 | 78 | LINE4_TEXT, // to accord with DrawText( ), each text line should |
mverdy | 20:626b92b70bf7 | 79 | LINE4_COL0_TEXT, // have consecutively TEXT (full large text), |
mverdy | 20:626b92b70bf7 | 80 | LINE4_COL1_TEXT, // COL0_TEXT (left side of the line), COL1_TEXT (center |
mverdy | 20:626b92b70bf7 | 81 | LINE4_COL2_TEXT, // region of the line) and COL2_TEXT (right side of the |
mverdy | 20:626b92b70bf7 | 82 | LINE5_COL0_TEXT, // line). COL0..2 are optionals if doesn't exist. |
mverdy | 20:626b92b70bf7 | 83 | LINE5_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 84 | LINE5_COL2_TEXT, |
mverdy | 20:626b92b70bf7 | 85 | LINE6_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 86 | LINE6_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 87 | LINE6_COL2_TEXT, |
mverdy | 20:626b92b70bf7 | 88 | LINE7_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 89 | LINE7_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 90 | LINE7_COL2_TEXT, |
mverdy | 20:626b92b70bf7 | 91 | LINE8_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 92 | LINE8_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 93 | LINE9_COL0_TEXT, |
mverdy | 20:626b92b70bf7 | 94 | LINE9_COL1_TEXT, |
mverdy | 20:626b92b70bf7 | 95 | RNG_DIST_TEXT, |
mverdy | 20:626b92b70bf7 | 96 | RNG_DIST_CIRCLE, |
mverdy | 20:626b92b70bf7 | 97 | RNG_DS1_TEXT, |
mverdy | 20:626b92b70bf7 | 98 | RNG_DS2_TEXT, |
mverdy | 20:626b92b70bf7 | 99 | RNG_DS3_TEXT, |
mverdy | 20:626b92b70bf7 | 100 | RNG_DS4_TEXT, |
mverdy | 20:626b92b70bf7 | 101 | RNG_DS5_TEXT, |
mverdy | 20:626b92b70bf7 | 102 | RNG_DS0_LINE, |
mverdy | 20:626b92b70bf7 | 103 | RNG_DS1_LINE, |
mverdy | 20:626b92b70bf7 | 104 | RNG_DS2_LINE, |
mverdy | 20:626b92b70bf7 | 105 | RNG_DS3_LINE, |
mverdy | 20:626b92b70bf7 | 106 | RNG_DS4_LINE, |
mverdy | 20:626b92b70bf7 | 107 | RNG_DS5_LINE, |
mverdy | 20:626b92b70bf7 | 108 | RNG_MST_SCR, |
mverdy | 20:626b92b70bf7 | 109 | }; |
lex9296 | 23:b9d23a2f390e | 110 | #define GRAPH_OBJECTS_COUNT 80 |
mverdy | 20:626b92b70bf7 | 111 | GraphObject_t MenuObjects[GRAPH_OBJECTS_COUNT] = |
mverdy | 20:626b92b70bf7 | 112 | { |
lex9296 | 22:12c555cade79 | 113 | // (Id, Type, Xpos, Ypos, Height, Width, LineW, BackColor, FrontColor, DoFill, FillCol, Source, TouchActive} |
lex9296 | 22:12c555cade79 | 114 | {PAGE_BORDER, GO_RECTANGLE, 0, 0, 320, 240, 1, BACK_COLOR, PAGE_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 115 | {TITLE_LINE, GO_LINE, 0, 30, 1, 240, 1, BACK_COLOR, PAGE_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 116 | {TITLE_TEXT, GO_TEXT, 15, 9, NULL, 208, 1, BACK_COLOR, WHITE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 117 | {FIRM_LOGO, GO_IMAGE, 20, 37, 95, 215, 1, BACK_COLOR, WHITE, false, NULL, SemtechLogo, false}, |
lex9296 | 22:12c555cade79 | 118 | {BTN0_BORDER, GO_RECTANGLE, 10, 40, 30, 106, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 119 | {BTN0_MENU_TEXT, GO_TEXT, 15, 48, NULL, 96, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 120 | {BTN0_LABEL_TEXT, GO_TEXT, 15, 48, NULL, 32, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 121 | {BTN0_VALUE_TEXT, GO_TEXT, 47, 48, NULL, 64, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 122 | {BTN1_BORDER, GO_RECTANGLE, 10, 75, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 123 | {BTN1_MENU_TEXT, GO_TEXT, 15, 83, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 124 | {BTN1_LABEL_TEXT, GO_TEXT, 15, 83, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 125 | {BTN1_VALUE_TEXT, GO_TEXT, 79, 83, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 126 | {BTN2_BORDER, GO_RECTANGLE, 10, 110, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 127 | {BTN2_MENU_TEXT, GO_TEXT, 15, 118, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 128 | {BTN2_LABEL_TEXT, GO_TEXT, 15, 118, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 129 | {BTN2_VALUE_TEXT, GO_TEXT, 79, 118, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 130 | {BTN3_BORDER, GO_RECTANGLE, 10, 145, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 131 | {BTN3_MENU_TEXT, GO_TEXT, 15, 153, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 132 | {BTN3_LABEL_TEXT, GO_TEXT, 15, 153, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 133 | {BTN3_VALUE_TEXT, GO_TEXT, 79, 153, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 134 | {BTN4_BORDER, GO_RECTANGLE, 10, 180, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 135 | {BTN4_MENU_TEXT, GO_TEXT, 15, 188, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 136 | {BTN4_LABEL_TEXT, GO_TEXT, 15, 188, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 137 | {BTN4_VALUE_TEXT, GO_TEXT, 79, 188, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 138 | {BTN5_BORDER, GO_RECTANGLE, 10, 215, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 139 | {BTN5_MENU_TEXT, GO_TEXT, 15, 223, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 140 | {BTN5_LABEL_TEXT, GO_TEXT, 15, 223, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 141 | {BTN5_VALUE_TEXT, GO_TEXT, 79, 223, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 142 | {BTN6_BORDER, GO_RECTANGLE, 10, 250, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 143 | {BTN6_MENU_TEXT, GO_TEXT, 15, 258, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 144 | {BTN6_LABEL_TEXT, GO_TEXT, 15, 258, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 145 | {BTN6_VALUE_TEXT, GO_TEXT, 79, 258, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 23:b9d23a2f390e | 146 | {BTN7_BORDER, GO_RECTANGLE, 10, 285, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 23:b9d23a2f390e | 147 | {BTN7_MENU_TEXT, GO_TEXT, 15, 293, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 23:b9d23a2f390e | 148 | {BTN7_LABEL_TEXT, GO_TEXT, 15, 293, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 23:b9d23a2f390e | 149 | {BTN7_VALUE_TEXT, GO_TEXT, 79, 293, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 150 | {BTN8_BORDER, GO_RECTANGLE, 125, 285, 30, 107, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 151 | {BTN8_MENU_TEXT, GO_TEXT, 130, 293, NULL, 96, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 152 | {BTN9_BORDER, GO_RECTANGLE, 125, 40, 30, 107, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 153 | {BTN9_MENU_TEXT, GO_TEXT, 130, 48, NULL, 96, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 154 | {LINE0_TEXT, GO_TEXT, 5, 80, NULL, 232, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 155 | {LINE1_TEXT, GO_TEXT, 5, 100, NULL, 232, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 156 | {LINE2_TEXT, GO_TEXT, 5, 120, NULL, 232, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 157 | {LINE2_COL0_TEXT, GO_TEXT, 5, 120, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 158 | {LINE2_COL1_TEXT, GO_TEXT, 110, 120, NULL, 56, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 159 | {LINE3_TEXT, GO_TEXT, 5, 140, NULL, 232, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 160 | {LINE3_COL0_TEXT, GO_TEXT, 5, 140, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 161 | {LINE3_COL1_TEXT, GO_TEXT, 110, 140, NULL, 56, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 162 | {LINE3_COL2_TEXT, GO_TEXT, 170, 140, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 163 | {LINE4_TEXT, GO_TEXT, 5, 160, NULL, 232, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 164 | {LINE4_COL0_TEXT, GO_TEXT, 5, 160, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 165 | {LINE4_COL1_TEXT, GO_TEXT, 110, 160, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 166 | {LINE4_COL2_TEXT, GO_TEXT, 170, 160, NULL, 64, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 167 | {LINE5_COL0_TEXT, GO_TEXT, 5, 180, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 168 | {LINE5_COL1_TEXT, GO_TEXT, 110, 180, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 169 | {LINE5_COL2_TEXT, GO_TEXT, 170, 180, NULL, 64, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 170 | {LINE6_COL0_TEXT, GO_TEXT, 5, 200, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 171 | {LINE6_COL1_TEXT, GO_TEXT, 110, 200, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 172 | {LINE6_COL2_TEXT, GO_TEXT, 170, 200, NULL, 64, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 173 | {LINE7_COL0_TEXT, GO_TEXT, 5, 220, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 174 | {LINE7_COL1_TEXT, GO_TEXT, 110, 220, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 175 | {LINE7_COL2_TEXT, GO_TEXT, 170, 220, NULL, 64, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 176 | {LINE8_COL0_TEXT, GO_TEXT, 5, 240, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 177 | {LINE8_COL1_TEXT, GO_TEXT, 110, 240, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 178 | {LINE9_COL0_TEXT, GO_TEXT, 5, 260, NULL, 104, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 179 | {LINE9_COL1_TEXT, GO_TEXT, 110, 260, NULL, 56, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 180 | {RNG_DIST_TEXT, GO_TEXT, 63, 75, NULL, 120, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 181 | {RNG_DIST_CIRCLE, GO_CIRCLE, 175, 270, 10, 10, 1, BACK_COLOR, GRAY1, true, GRAY1, NULL, false}, |
lex9296 | 22:12c555cade79 | 182 | {RNG_DS1_TEXT, GO_TEXT, 188, 230, NULL, 40, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 183 | {RNG_DS2_TEXT, GO_TEXT, 188, 198, NULL, 40, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 184 | {RNG_DS3_TEXT, GO_TEXT, 188, 166, NULL, 40, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 185 | {RNG_DS4_TEXT, GO_TEXT, 188, 134, NULL, 40, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 186 | {RNG_DS5_TEXT, GO_TEXT, 188, 102, NULL, 40, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 187 | {RNG_DS0_LINE, GO_LINE, 185, 110, 160, 1, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 188 | {RNG_DS1_LINE, GO_LINE, 183, 238, 1, 5, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 189 | {RNG_DS2_LINE, GO_LINE, 183, 206, 1, 5, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 190 | {RNG_DS3_LINE, GO_LINE, 183, 174, 1, 5, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 191 | {RNG_DS4_LINE, GO_LINE, 183, 142, 1, 5, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 192 | {RNG_DS5_LINE, GO_LINE, 183, 110, 1, 5, 1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL, false}, |
lex9296 | 22:12c555cade79 | 193 | {RNG_MST_SCR, GO_RECTANGLE, 1, 70, 214, 238, 1, BACK_COLOR, BACK_COLOR, false, NULL, NULL, false}, |
mverdy | 20:626b92b70bf7 | 194 | }; |
mverdy | 20:626b92b70bf7 | 195 | |
mverdy | 20:626b92b70bf7 | 196 | /*! |
mverdy | 20:626b92b70bf7 | 197 | * \brief DrawText( ) need char* to display a text. It can display until |
mverdy | 20:626b92b70bf7 | 198 | * 3 different texts on the same line. To avoid recursive use of the same |
mverdy | 20:626b92b70bf7 | 199 | * ressource, 3 temporary string are declared. |
mverdy | 20:626b92b70bf7 | 200 | */ |
mverdy | 20:626b92b70bf7 | 201 | char StringText[MAX_CHAR_PER_LINE + 1]; // don't forget the /0 (end of string) |
mverdy | 20:626b92b70bf7 | 202 | char StringText2[MAX_CHAR_PER_LINE + 1]; |
mverdy | 20:626b92b70bf7 | 203 | char StringText3[MAX_CHAR_PER_LINE + 1]; |
mverdy | 20:626b92b70bf7 | 204 | |
mverdy | 20:626b92b70bf7 | 205 | /*! |
mverdy | 20:626b92b70bf7 | 206 | * \brief CurrentPage store current displayed page (cf.: list of availlable |
mverdy | 20:626b92b70bf7 | 207 | * pages in Menu.h). PeviousPage is used only when navigate through "Radio |
mverdy | 20:626b92b70bf7 | 208 | * Config" to be able to restore the page before "Radio Congig", witch can be |
mverdy | 20:626b92b70bf7 | 209 | * PingPong, PER or START_PAGE. The goal is to speed menu navigation. |
mverdy | 20:626b92b70bf7 | 210 | */ |
lex9296 | 21:ab8027016a2c | 211 | //static uint8_t CurrentPage = START_PAGE; |
lex9296 | 21:ab8027016a2c | 212 | //static uint8_t PreviousPage = START_PAGE; |
mverdy | 20:626b92b70bf7 | 213 | |
mverdy | 20:626b92b70bf7 | 214 | /*! |
mverdy | 20:626b92b70bf7 | 215 | * \brief In "Radio Config Freq", we can update the central frequency. To avoid |
mverdy | 20:626b92b70bf7 | 216 | * keyboard, we use (+) et (-) keys. CurrentFreqBase is the offset to be applied |
mverdy | 20:626b92b70bf7 | 217 | * when we increase or decrease the frequency. |
mverdy | 20:626b92b70bf7 | 218 | */ |
lex9296 | 21:ab8027016a2c | 219 | //static FreqBase CurrentFreqBase = FB100K; |
mverdy | 20:626b92b70bf7 | 220 | |
mverdy | 20:626b92b70bf7 | 221 | void MenuInit( void ) |
mverdy | 20:626b92b70bf7 | 222 | { |
lex9296 | 27:654100855f5c | 223 | DisplayDriverInit (); |
lex9296 | 27:654100855f5c | 224 | // GraphObjectDraw( &( MenuObjects[PAGE_BORDER] ), NULL, false, false ); |
lex9296 | 27:654100855f5c | 225 | |
lex9296 | 21:ab8027016a2c | 226 | // GraphObjectDraw( &( MenuObjects[TITLE_LINE] ), NULL, false, false ); |
lex9296 | 21:ab8027016a2c | 227 | // MenuSetPage( START_PAGE ); |
lex9296 | 23:b9d23a2f390e | 228 | |
lex9296 | 23:b9d23a2f390e | 229 | // CheckScreenTouch.attach_us( &CheckScreen, 100000 ); // every 100 ms |
mverdy | 20:626b92b70bf7 | 230 | |
mverdy | 20:626b92b70bf7 | 231 | // Page Utilities only for GPS and proximity sensor : |
lex9296 | 23:b9d23a2f390e | 232 | // CheckPageRefresh.attach_us( &CheckRefresh, 1000000 ); // every 1 s |
mverdy | 20:626b92b70bf7 | 233 | } |
mverdy | 20:626b92b70bf7 | 234 | |
lex9296 | 23:b9d23a2f390e | 235 | extern DigitalIn userButton; |
lex9296 | 23:b9d23a2f390e | 236 | // |
lex9296 | 23:b9d23a2f390e | 237 | extern AnalogIn adc_temp; |
lex9296 | 23:b9d23a2f390e | 238 | extern AnalogIn adc_vref; |
lex9296 | 23:b9d23a2f390e | 239 | extern AnalogIn adc_vbat; |
lex9296 | 23:b9d23a2f390e | 240 | // |
lex9296 | 23:b9d23a2f390e | 241 | //extern QEI Stabilus322699; |
lex9296 | 21:ab8027016a2c | 242 | |
lex9296 | 23:b9d23a2f390e | 243 | //void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, uint32_t ms_0003, int32_t i32_Pulses) { |
lex9296 | 23:b9d23a2f390e | 244 | //void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, int32_t i32_Pulses) { |
lex9296 | 23:b9d23a2f390e | 245 | //void StabilusMenu (int32_t i32_Pulses) { |
lex9296 | 23:b9d23a2f390e | 246 | //void StabilusMenu (void) { |
lex9296 | 23:b9d23a2f390e | 247 | void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, uint32_t ms_0003, int32_t i32_Pulses) { |
lex9296 | 23:b9d23a2f390e | 248 | //int32_t i32_Pulses; |
lex9296 | 21:ab8027016a2c | 249 | |
lex9296 | 23:b9d23a2f390e | 250 | static bool InProgress = false; |
lex9296 | 23:b9d23a2f390e | 251 | uint8_t graphObjectTouched = 0xFF; |
lex9296 | 21:ab8027016a2c | 252 | |
lex9296 | 23:b9d23a2f390e | 253 | if (InProgress) |
lex9296 | 23:b9d23a2f390e | 254 | return; |
lex9296 | 23:b9d23a2f390e | 255 | else { |
lex9296 | 23:b9d23a2f390e | 256 | static uint32_t ms_0001_prec; |
lex9296 | 23:b9d23a2f390e | 257 | static uint32_t ms_0002_prec; |
lex9296 | 23:b9d23a2f390e | 258 | static uint32_t ms_0003_prec; |
lex9296 | 23:b9d23a2f390e | 259 | static bool PBPushed_prec; |
lex9296 | 23:b9d23a2f390e | 260 | |
lex9296 | 23:b9d23a2f390e | 261 | static bool Touched_Prec; |
lex9296 | 23:b9d23a2f390e | 262 | static int32_t Pulses_Prec; |
lex9296 | 23:b9d23a2f390e | 263 | |
lex9296 | 23:b9d23a2f390e | 264 | static uint16_t x_Prec; |
lex9296 | 23:b9d23a2f390e | 265 | static uint16_t y_Prec; |
lex9296 | 23:b9d23a2f390e | 266 | |
lex9296 | 21:ab8027016a2c | 267 | uint16_t x, y = 0; |
lex9296 | 21:ab8027016a2c | 268 | bool touched = false; |
lex9296 | 22:12c555cade79 | 269 | bool PBPushed = false; |
lex9296 | 21:ab8027016a2c | 270 | |
lex9296 | 23:b9d23a2f390e | 271 | InProgress = true; |
mverdy | 20:626b92b70bf7 | 272 | |
lex9296 | 23:b9d23a2f390e | 273 | GraphObjectTouched (MenuObjects, |
lex9296 | 23:b9d23a2f390e | 274 | GRAPH_OBJECTS_COUNT, |
lex9296 | 23:b9d23a2f390e | 275 | &graphObjectTouched); |
mverdy | 20:626b92b70bf7 | 276 | |
lex9296 | 23:b9d23a2f390e | 277 | TouchedXYT (&x, &y, &touched); |
lex9296 | 23:b9d23a2f390e | 278 | if ( |
lex9296 | 23:b9d23a2f390e | 279 | (touched != Touched_Prec) || |
lex9296 | 23:b9d23a2f390e | 280 | (x != x_Prec) || |
lex9296 | 23:b9d23a2f390e | 281 | (y != y_Prec) || |
lex9296 | 23:b9d23a2f390e | 282 | (i32_Pulses != Pulses_Prec) |
lex9296 | 23:b9d23a2f390e | 283 | // (Stabilus322699.getPulses() != Pulses_Prec) |
lex9296 | 23:b9d23a2f390e | 284 | ) { |
lex9296 | 23:b9d23a2f390e | 285 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 286 | "Screen Touched: %d %d", touched, i32_Pulses); |
lex9296 | 23:b9d23a2f390e | 287 | DrawText (TITLE_TEXT, (uint8_t*)StringText, NULL , NULL); |
lex9296 | 23:b9d23a2f390e | 288 | |
lex9296 | 23:b9d23a2f390e | 289 | if (touched == true) { |
lex9296 | 23:b9d23a2f390e | 290 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 291 | "x: %d", x); |
lex9296 | 23:b9d23a2f390e | 292 | DrawActiveButton (BTN2_BORDER, (uint8_t*)StringText, NULL); |
lex9296 | 23:b9d23a2f390e | 293 | |
lex9296 | 23:b9d23a2f390e | 294 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 295 | // "Y: %d %f", y, adc_vref.read()); |
lex9296 | 23:b9d23a2f390e | 296 | "Y: %d", y); |
lex9296 | 23:b9d23a2f390e | 297 | DrawActiveButton (BTN3_BORDER, (uint8_t*)StringText, NULL); |
mverdy | 20:626b92b70bf7 | 298 | } |
lex9296 | 23:b9d23a2f390e | 299 | else { |
lex9296 | 23:b9d23a2f390e | 300 | DrawActiveButton (BTN2_BORDER, (uint8_t*) "No Touch ...", NULL); |
lex9296 | 23:b9d23a2f390e | 301 | DrawActiveButton (BTN3_BORDER, (uint8_t*) "No Touch ...", NULL); |
mverdy | 20:626b92b70bf7 | 302 | } |
lex9296 | 23:b9d23a2f390e | 303 | |
lex9296 | 23:b9d23a2f390e | 304 | Touched_Prec = touched; |
lex9296 | 23:b9d23a2f390e | 305 | x_Prec = x; |
lex9296 | 23:b9d23a2f390e | 306 | y_Prec = y; |
lex9296 | 23:b9d23a2f390e | 307 | // |
lex9296 | 23:b9d23a2f390e | 308 | Pulses_Prec = i32_Pulses; |
lex9296 | 23:b9d23a2f390e | 309 | } |
mverdy | 20:626b92b70bf7 | 310 | |
lex9296 | 23:b9d23a2f390e | 311 | if (ms_0001 != ms_0001_prec) { |
lex9296 | 23:b9d23a2f390e | 312 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 313 | // "adc_temp: %f", (adc_temp.read()* 100)); |
lex9296 | 23:b9d23a2f390e | 314 | "PreviousStep_ms: %d", ms_0001); |
lex9296 | 23:b9d23a2f390e | 315 | DrawActiveButton (BTN4_BORDER, (uint8_t*)StringText, NULL); |
lex9296 | 23:b9d23a2f390e | 316 | ms_0001_prec = ms_0001; |
mverdy | 20:626b92b70bf7 | 317 | } |
lex9296 | 23:b9d23a2f390e | 318 | |
lex9296 | 23:b9d23a2f390e | 319 | if (ms_0002 != ms_0002_prec) { |
lex9296 | 23:b9d23a2f390e | 320 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 321 | // "adc_vref: %f", (adc_vref.read())); |
lex9296 | 23:b9d23a2f390e | 322 | "StepSampled_ms : %d", ms_0002); |
lex9296 | 23:b9d23a2f390e | 323 | DrawActiveButton (BTN5_BORDER, (uint8_t*)StringText, NULL); |
lex9296 | 23:b9d23a2f390e | 324 | ms_0002_prec = ms_0002; |
mverdy | 20:626b92b70bf7 | 325 | } |
lex9296 | 23:b9d23a2f390e | 326 | |
lex9296 | 23:b9d23a2f390e | 327 | if (ms_0003 != ms_0003_prec) { |
lex9296 | 23:b9d23a2f390e | 328 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 329 | // "adc_vbat: %f", (adc_vbat.read())); |
lex9296 | 23:b9d23a2f390e | 330 | "PassedActual_ms: %d", ms_0003); |
lex9296 | 23:b9d23a2f390e | 331 | DrawActiveButton (BTN6_BORDER, (uint8_t*)StringText, NULL); |
lex9296 | 23:b9d23a2f390e | 332 | ms_0003_prec = ms_0003; |
mverdy | 20:626b92b70bf7 | 333 | } |
mverdy | 20:626b92b70bf7 | 334 | |
lex9296 | 23:b9d23a2f390e | 335 | PBPushed = userButton; |
lex9296 | 23:b9d23a2f390e | 336 | if (PBPushed != PBPushed_prec) { |
lex9296 | 23:b9d23a2f390e | 337 | sprintf (StringText, |
lex9296 | 23:b9d23a2f390e | 338 | "PB Released: %d", PBPushed); |
lex9296 | 23:b9d23a2f390e | 339 | DrawActiveButton (BTN7_BORDER, (uint8_t*)StringText, NULL); |
lex9296 | 23:b9d23a2f390e | 340 | PBPushed_prec = PBPushed; |
lex9296 | 23:b9d23a2f390e | 341 | } |
lex9296 | 23:b9d23a2f390e | 342 | // |
lex9296 | 23:b9d23a2f390e | 343 | // StabilusMainPage (graphObjectTouched, ms_0001, ms_0002, ms_0003, i32_Pulses); |
lex9296 | 23:b9d23a2f390e | 344 | InProgress = false; |
mverdy | 20:626b92b70bf7 | 345 | } |
mverdy | 20:626b92b70bf7 | 346 | } |
mverdy | 20:626b92b70bf7 | 347 | |
mverdy | 20:626b92b70bf7 | 348 | /*! |
mverdy | 20:626b92b70bf7 | 349 | * \brief Draw button |
mverdy | 20:626b92b70bf7 | 350 | * |
mverdy | 20:626b92b70bf7 | 351 | * \param [in] buttonId Id of the button to draw |
mverdy | 20:626b92b70bf7 | 352 | * \param [in] *text1 Text to draw as label |
mverdy | 20:626b92b70bf7 | 353 | * \param [in] *text2 Text to draw as value |
mverdy | 20:626b92b70bf7 | 354 | */ |
lex9296 | 23:b9d23a2f390e | 355 | void DrawActiveButton( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ){ |
mverdy | 20:626b92b70bf7 | 356 | GraphObjectDraw( &( MenuObjects[buttonId] ), NULL, NULL, true ); |
lex9296 | 23:b9d23a2f390e | 357 | if( text2 == NULL ) { |
lex9296 | 23:b9d23a2f390e | 358 | if( text1 != NULL ) { |
mverdy | 20:626b92b70bf7 | 359 | GraphObjectDraw( &( MenuObjects[buttonId + 1] ), text1, NULL, false ); |
mverdy | 20:626b92b70bf7 | 360 | } |
mverdy | 20:626b92b70bf7 | 361 | } |
lex9296 | 23:b9d23a2f390e | 362 | else { |
lex9296 | 23:b9d23a2f390e | 363 | if( text1 != NULL ) { |
mverdy | 20:626b92b70bf7 | 364 | GraphObjectDraw( &( MenuObjects[buttonId + 2] ), text1, NULL, false ); |
mverdy | 20:626b92b70bf7 | 365 | } |
mverdy | 20:626b92b70bf7 | 366 | GraphObjectDraw( &( MenuObjects[buttonId + 3] ), text2, NULL, false ); |
mverdy | 20:626b92b70bf7 | 367 | } |
mverdy | 20:626b92b70bf7 | 368 | } |
mverdy | 20:626b92b70bf7 | 369 | |
lex9296 | 23:b9d23a2f390e | 370 | void ButtonChangeText( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ){ |
lex9296 | 23:b9d23a2f390e | 371 | if( text2 == NULL ) { |
lex9296 | 23:b9d23a2f390e | 372 | if( text1 != NULL ) { |
mverdy | 20:626b92b70bf7 | 373 | GraphObjectDraw( &( MenuObjects[buttonId + 1] ), text1, NULL, false ); |
mverdy | 20:626b92b70bf7 | 374 | } |
mverdy | 20:626b92b70bf7 | 375 | } |
lex9296 | 23:b9d23a2f390e | 376 | else { |
lex9296 | 23:b9d23a2f390e | 377 | if( text1 != NULL ) { |
mverdy | 20:626b92b70bf7 | 378 | GraphObjectDraw( &( MenuObjects[buttonId + 2] ), text1, NULL, false ); |
mverdy | 20:626b92b70bf7 | 379 | } |
mverdy | 20:626b92b70bf7 | 380 | GraphObjectDraw( &( MenuObjects[buttonId + 3] ), text2, NULL, false ); |
mverdy | 20:626b92b70bf7 | 381 | } |
mverdy | 20:626b92b70bf7 | 382 | } |
mverdy | 20:626b92b70bf7 | 383 | |
lex9296 | 23:b9d23a2f390e | 384 | void RemoveButton( uint8_t buttonId ){ |
mverdy | 20:626b92b70bf7 | 385 | GraphObjectClear( &( MenuObjects[buttonId] ), true ); |
mverdy | 20:626b92b70bf7 | 386 | } |
mverdy | 20:626b92b70bf7 | 387 | |
lex9296 | 23:b9d23a2f390e | 388 | void DrawText( uint8_t lineId, uint8_t* text0, uint8_t* text1, uint8_t* text2 ){ |
lex9296 | 23:b9d23a2f390e | 389 | if( text0 != NULL ) { |
mverdy | 20:626b92b70bf7 | 390 | GraphObjectDraw( &( MenuObjects[lineId] ), text0, NULL, false ); |
mverdy | 20:626b92b70bf7 | 391 | } |
lex9296 | 23:b9d23a2f390e | 392 | if( text1 != NULL ) { |
mverdy | 20:626b92b70bf7 | 393 | GraphObjectDraw( &( MenuObjects[lineId + 1] ), text1, NULL, false ); |
mverdy | 20:626b92b70bf7 | 394 | } |
lex9296 | 23:b9d23a2f390e | 395 | if( text2 != NULL ) { |
mverdy | 20:626b92b70bf7 | 396 | GraphObjectDraw( &( MenuObjects[lineId + 2] ), text2, NULL, false ); |
mverdy | 20:626b92b70bf7 | 397 | } |
mverdy | 20:626b92b70bf7 | 398 | } |