Velocity Closed Loop Dynamic error correction

Dependencies:   mbed QEI PID DmTftLibraryEx

Committer:
lex9296
Date:
Thu Feb 10 09:39:01 2022 +0000
Revision:
23:b9d23a2f390e
Parent:
22:12c555cade79
Child:
27:654100855f5c
LA_0005 QEI che compila e legge tutti i Passi RT

Who changed what in which revision?

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