Velocity Closed Loop Dynamic error correction

Dependencies:   mbed QEI PID DmTftLibraryEx

Revision:
22:12c555cade79
Parent:
21:ab8027016a2c
Child:
23:b9d23a2f390e
diff -r ab8027016a2c -r 12c555cade79 Display/Menu.cpp
--- a/Display/Menu.cpp	Thu Jan 20 08:15:44 2022 +0000
+++ b/Display/Menu.cpp	Thu Jan 20 13:26:03 2022 +0000
@@ -1,48 +1,12 @@
-/*
-  ______                              _
- / _____)             _              | |
-( (____  _____ ____ _| |_ _____  ____| |__
- \____ \| ___ |    (_   _) ___ |/ ___)  _ \
- _____) ) ____| | | || |_| ____( (___| | | |
-(______/|_____)_|_|_| \__)_____)\____)_| |_|
-    (C)2016 Semtech
-
-Description: Display demo menus and manage touch sensor.
-
-Maintainer: Gregory Cristian & Gilbert Menth
-*/
-
-//#include "DmTftRa8875.h"
-//#include "mbed.h"
-//#include "Eeprom.h"
-//#include "DisplayDriver.h"
-#include "DmTftIli9341.h"
-#include "DmTouch.h"
-#include "DmTouchCalibration.h"
 
 #include <stdio.h>
 #include "mbed.h"
 #include "Menu.h"
 #include "DisplayDriver.h"
 #include "Eeprom.h"
-//#include "DemoApplication.h"
 #include "main.h"
 #include "app_config.h"
 
-#if defined(HAS_GPS_SENSOR)
-#include "GpsMax7.h"
-
-/*!
- * \brief Pointer to GPS Data, will be updated when Max7GpsgetData( ) is called.
- */
-GpsStruct *thisGps;
-#endif
-
-#if defined(HAS_PROXIMITY_SENSOR)
-#include "SX9306.h"
-#endif
-
-
 /*!
  * \brief Maximum character count on the same line with function DrawText
  * This include needed space for the outline (at the begin and the end of line).
@@ -50,22 +14,11 @@
  */
 #define MAX_CHAR_PER_LINE       28
 
-#define SCALE_LINE_COUNT        5
-#define RANGING_FULLSCALE_MIN   10
-#define RANGING_FULLSCALE_MAX   30000
-
-// DmTftIli9341( PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk )
-// DM_TFT28_105
-//DmTftIli9341 Tft( D10, D9, D11, D12, D13 );
-//DmTouch Touch( DmTouch::DM_TFT28_105, D9, D11, D12 );
-//DmTouchCalibration Calibration = DmTouchCalibration( &Tft, &Touch );
-
 /*!
  * \brief Bitmap of Semtech Logo stored here (copied from a C file).
  */
 extern uint8_t SemtechLogo[];
 
-
 /*!
  * \brief This ticker give the rythme to check X and Y coordinates of activated
  * touched region (if pressed). CheckScreenFlag keep the status if Touchscreen
@@ -174,85 +127,85 @@
 #define GRAPH_OBJECTS_COUNT     78
 GraphObject_t MenuObjects[GRAPH_OBJECTS_COUNT] =
 {
-    // { Id,           Type,      Xpos, Ypos, Height, Width, LineW, BackColor, FrontColor, DoFill, FillCol, Source, TouchActive }
-    { PAGE_BORDER,     GO_RECTANGLE, 0,   0,   320,    240,   1, BACK_COLOR, PAGE_COLOR,    false, NULL, NULL,        false },
-    { TITLE_LINE,      GO_LINE,      0,   30,  1,      240,   1, BACK_COLOR, PAGE_COLOR,    false, NULL, NULL,        false },
-    { TITLE_TEXT,      GO_TEXT,      15,  9,   NULL,   208,   1, BACK_COLOR, WHITE,         false, NULL, NULL,        false },
-    { FIRM_LOGO,       GO_IMAGE,     20,  37,  95,     215,   1, BACK_COLOR, WHITE,         false, NULL, SemtechLogo, false },
-    { BTN0_BORDER,     GO_RECTANGLE, 10,  40,  30,     106,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN0_MENU_TEXT,  GO_TEXT,      15,  48,  NULL,   96,    1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN0_LABEL_TEXT, GO_TEXT,      15,  48,  NULL,   32,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN0_VALUE_TEXT, GO_TEXT,      47,  48,  NULL,   64,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN1_BORDER,     GO_RECTANGLE, 10,  75,  30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN1_MENU_TEXT,  GO_TEXT,      15,  83,  NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN1_LABEL_TEXT, GO_TEXT,      15,  83,  NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN1_VALUE_TEXT, GO_TEXT,      79,  83,  NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN2_BORDER,     GO_RECTANGLE, 10,  110, 30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN2_MENU_TEXT,  GO_TEXT,      15,  118, NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN2_LABEL_TEXT, GO_TEXT,      15,  118, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN2_VALUE_TEXT, GO_TEXT,      79,  118, NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN3_BORDER,     GO_RECTANGLE, 10,  145, 30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN3_MENU_TEXT,  GO_TEXT,      15,  153, NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN3_LABEL_TEXT, GO_TEXT,      15,  153, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN3_VALUE_TEXT, GO_TEXT,      79,  153, NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN4_BORDER,     GO_RECTANGLE, 10,  180, 30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN4_MENU_TEXT,  GO_TEXT,      15,  188, NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN4_LABEL_TEXT, GO_TEXT,      15,  188, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN4_VALUE_TEXT, GO_TEXT,      79,  188, NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN5_BORDER,     GO_RECTANGLE, 10,  215, 30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN5_MENU_TEXT,  GO_TEXT,      15,  223, NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN5_LABEL_TEXT, GO_TEXT,      15,  223, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN5_VALUE_TEXT, GO_TEXT,      79,  223, NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN6_BORDER,     GO_RECTANGLE, 10,  250, 30,     222,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN6_MENU_TEXT,  GO_TEXT,      15,  258, NULL,   200,   1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN6_LABEL_TEXT, GO_TEXT,      15,  258, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { BTN6_VALUE_TEXT, GO_TEXT,      79,  258, NULL,   152,   1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { BTN7_BORDER,     GO_RECTANGLE, 10,  285, 30,     106,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN7_MENU_TEXT,  GO_TEXT,      15,  293, NULL,   96,    1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN8_BORDER,     GO_RECTANGLE, 125, 285, 30,     107,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN8_MENU_TEXT,  GO_TEXT,      130, 293, NULL,   96,    1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { BTN9_BORDER,     GO_RECTANGLE, 125, 40,  30,     107,   1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL,        false },
-    { BTN9_MENU_TEXT,  GO_TEXT,      130, 48,  NULL,   96,    1, BACK_COLOR, MENU_TEXT,     false, NULL, NULL,        false },
-    { LINE0_TEXT,      GO_TEXT,      5,   80,  NULL,   232,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE1_TEXT,      GO_TEXT,      5,   100, NULL,   232,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE2_TEXT,      GO_TEXT,      5,   120, NULL,   232,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE2_COL0_TEXT, GO_TEXT,      5,   120, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE2_COL1_TEXT, GO_TEXT,      110, 120, NULL,   56,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE3_TEXT,      GO_TEXT,      5,   140, NULL,   232,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE3_COL0_TEXT, GO_TEXT,      5,   140, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE3_COL1_TEXT, GO_TEXT,      110, 140, NULL,   56,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE3_COL2_TEXT, GO_TEXT,      170, 140, NULL,   64,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE4_TEXT,      GO_TEXT,      5,   160, NULL,   232,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE4_COL0_TEXT, GO_TEXT,      5,   160, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE4_COL1_TEXT, GO_TEXT,      110, 160, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE4_COL2_TEXT, GO_TEXT,      170, 160, NULL,   64,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE5_COL0_TEXT, GO_TEXT,      5,   180, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE5_COL1_TEXT, GO_TEXT,      110, 180, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE5_COL2_TEXT, GO_TEXT,      170, 180, NULL,   64,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE6_COL0_TEXT, GO_TEXT,      5,   200, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE6_COL1_TEXT, GO_TEXT,      110, 200, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE6_COL2_TEXT, GO_TEXT,      170, 200, NULL,   64,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE7_COL0_TEXT, GO_TEXT,      5,   220, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE7_COL1_TEXT, GO_TEXT,      110, 220, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE7_COL2_TEXT, GO_TEXT,      170, 220, NULL,   64,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE8_COL0_TEXT, GO_TEXT,      5,   240, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE8_COL1_TEXT, GO_TEXT,      110, 240, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { LINE9_COL0_TEXT, GO_TEXT,      5,   260, NULL,   104,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { LINE9_COL1_TEXT, GO_TEXT,      110, 260, NULL,   56,    1, BACK_COLOR, TEXT_VALUE,    false, NULL, NULL,        false },
-    { RNG_DIST_TEXT,   GO_TEXT,      63,  75,  NULL,   120,   1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DIST_CIRCLE, GO_CIRCLE,    175, 270, 10,     10,    1, BACK_COLOR, GRAY1,         true, GRAY1, NULL,        false },
-    { RNG_DS1_TEXT,    GO_TEXT,      188, 230, NULL,   40,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DS2_TEXT,    GO_TEXT,      188, 198, NULL,   40,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DS3_TEXT,    GO_TEXT,      188, 166, NULL,   40,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DS4_TEXT,    GO_TEXT,      188, 134, NULL,   40,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DS5_TEXT,    GO_TEXT,      188, 102, NULL,   40,    1, BACK_COLOR, TEXT_COLOR,    false, NULL, NULL,        false },
-    { RNG_DS0_LINE,    GO_LINE,      185, 110, 160,    1,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_DS1_LINE,    GO_LINE,      183, 238, 1,      5,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_DS2_LINE,    GO_LINE,      183, 206, 1,      5,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_DS3_LINE,    GO_LINE,      183, 174, 1,      5,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_DS4_LINE,    GO_LINE,      183, 142, 1,      5,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_DS5_LINE,    GO_LINE,      183, 110, 1,      5,     1, BACK_COLOR, CIRCLE_FCOLOR, false, NULL, NULL,        false },
-    { RNG_MST_SCR,     GO_RECTANGLE, 1,   70,  214,    238,   1, BACK_COLOR, BACK_COLOR,    false, NULL, NULL,        false },
+//  (Id,                Type,           Xpos,   Ypos,   Height, Width,  LineW,  BackColor,  FrontColor,     DoFill, FillCol,    Source,         TouchActive}
+    {PAGE_BORDER,       GO_RECTANGLE,   0,      0,      320,    240,    1,      BACK_COLOR, PAGE_COLOR,     false,  NULL,       NULL,           false},
+    {TITLE_LINE,        GO_LINE,        0,      30,     1,      240,    1,      BACK_COLOR, PAGE_COLOR,     false,  NULL,       NULL,           false},
+    {TITLE_TEXT,        GO_TEXT,        15,     9,      NULL,   208,    1,      BACK_COLOR, WHITE,          false,  NULL,       NULL,           false},
+    {FIRM_LOGO,         GO_IMAGE,       20,     37,     95,     215,    1,      BACK_COLOR, WHITE,          false,  NULL,       SemtechLogo,    false},
+    {BTN0_BORDER,       GO_RECTANGLE,   10,     40,     30,     106,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN0_MENU_TEXT,    GO_TEXT,        15,     48,     NULL,   96,     1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN0_LABEL_TEXT,   GO_TEXT,        15,     48,     NULL,   32,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN0_VALUE_TEXT,   GO_TEXT,        47,     48,     NULL,   64,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN1_BORDER,       GO_RECTANGLE,   10,     75,     30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN1_MENU_TEXT,    GO_TEXT,        15,     83,     NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN1_LABEL_TEXT,   GO_TEXT,        15,     83,     NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN1_VALUE_TEXT,   GO_TEXT,        79,     83,     NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN2_BORDER,       GO_RECTANGLE,   10,     110,    30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN2_MENU_TEXT,    GO_TEXT,        15,     118,    NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN2_LABEL_TEXT,   GO_TEXT,        15,     118,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN2_VALUE_TEXT,   GO_TEXT,        79,     118,    NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN3_BORDER,       GO_RECTANGLE,   10,     145,    30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN3_MENU_TEXT,    GO_TEXT,        15,     153,    NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN3_LABEL_TEXT,   GO_TEXT,        15,     153,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN3_VALUE_TEXT,   GO_TEXT,        79,     153,    NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN4_BORDER,       GO_RECTANGLE,   10,     180,    30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN4_MENU_TEXT,    GO_TEXT,        15,     188,    NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN4_LABEL_TEXT,   GO_TEXT,        15,     188,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN4_VALUE_TEXT,   GO_TEXT,        79,     188,    NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN5_BORDER,       GO_RECTANGLE,   10,     215,    30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN5_MENU_TEXT,    GO_TEXT,        15,     223,    NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN5_LABEL_TEXT,   GO_TEXT,        15,     223,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN5_VALUE_TEXT,   GO_TEXT,        79,     223,    NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN6_BORDER,       GO_RECTANGLE,   10,     250,    30,     222,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN6_MENU_TEXT,    GO_TEXT,        15,     258,    NULL,   200,    1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN6_LABEL_TEXT,   GO_TEXT,        15,     258,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {BTN6_VALUE_TEXT,   GO_TEXT,        79,     258,    NULL,   152,    1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {BTN7_BORDER,       GO_RECTANGLE,   10,     285,    30,     106,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN7_MENU_TEXT,    GO_TEXT,        15,     293,    NULL,   96,     1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN8_BORDER,       GO_RECTANGLE,   125,    285,    30,     107,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN8_MENU_TEXT,    GO_TEXT,        130,    293,    NULL,   96,     1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {BTN9_BORDER,       GO_RECTANGLE,   125,    40,     30,     107,    1,      BACK_COLOR, BUTTON_BORDER,  false,  NULL,       NULL,           false},
+    {BTN9_MENU_TEXT,    GO_TEXT,        130,    48,     NULL,   96,     1,      BACK_COLOR, MENU_TEXT,      false,  NULL,       NULL,           false},
+    {LINE0_TEXT,        GO_TEXT,        5,      80,     NULL,   232,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE1_TEXT,        GO_TEXT,        5,      100,    NULL,   232,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE2_TEXT,        GO_TEXT,        5,      120,    NULL,   232,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE2_COL0_TEXT,   GO_TEXT,        5,      120,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE2_COL1_TEXT,   GO_TEXT,        110,    120,    NULL,   56,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE3_TEXT,        GO_TEXT,        5,      140,    NULL,   232,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE3_COL0_TEXT,   GO_TEXT,        5,      140,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE3_COL1_TEXT,   GO_TEXT,        110,    140,    NULL,   56,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE3_COL2_TEXT,   GO_TEXT,        170,    140,    NULL,   64,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE4_TEXT,        GO_TEXT,        5,      160,    NULL,   232,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE4_COL0_TEXT,   GO_TEXT,        5,      160,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE4_COL1_TEXT,   GO_TEXT,        110,    160,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE4_COL2_TEXT,   GO_TEXT,        170,    160,    NULL,   64,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE5_COL0_TEXT,   GO_TEXT,        5,      180,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE5_COL1_TEXT,   GO_TEXT,        110,    180,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE5_COL2_TEXT,   GO_TEXT,        170,    180,    NULL,   64,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE6_COL0_TEXT,   GO_TEXT,        5,      200,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE6_COL1_TEXT,   GO_TEXT,        110,    200,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE6_COL2_TEXT,   GO_TEXT,        170,    200,    NULL,   64,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE7_COL0_TEXT,   GO_TEXT,        5,      220,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE7_COL1_TEXT,   GO_TEXT,        110,    220,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE7_COL2_TEXT,   GO_TEXT,        170,    220,    NULL,   64,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE8_COL0_TEXT,   GO_TEXT,        5,      240,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE8_COL1_TEXT,   GO_TEXT,        110,    240,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {LINE9_COL0_TEXT,   GO_TEXT,        5,      260,    NULL,   104,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {LINE9_COL1_TEXT,   GO_TEXT,        110,    260,    NULL,   56,     1,      BACK_COLOR, TEXT_VALUE,     false,  NULL,       NULL,           false},
+    {RNG_DIST_TEXT,     GO_TEXT,        63,     75,     NULL,   120,    1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DIST_CIRCLE,   GO_CIRCLE,      175,    270,    10,     10,     1,      BACK_COLOR, GRAY1,          true,   GRAY1,      NULL,           false},
+    {RNG_DS1_TEXT,      GO_TEXT,        188,    230,    NULL,   40,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DS2_TEXT,      GO_TEXT,        188,    198,    NULL,   40,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DS3_TEXT,      GO_TEXT,        188,    166,    NULL,   40,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DS4_TEXT,      GO_TEXT,        188,    134,    NULL,   40,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DS5_TEXT,      GO_TEXT,        188,    102,    NULL,   40,     1,      BACK_COLOR, TEXT_COLOR,     false,  NULL,       NULL,           false},
+    {RNG_DS0_LINE,      GO_LINE,        185,    110,    160,    1,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_DS1_LINE,      GO_LINE,        183,    238,    1,      5,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_DS2_LINE,      GO_LINE,        183,    206,    1,      5,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_DS3_LINE,      GO_LINE,        183,    174,    1,      5,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_DS4_LINE,      GO_LINE,        183,    142,    1,      5,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_DS5_LINE,      GO_LINE,        183,    110,    1,      5,      1,      BACK_COLOR, CIRCLE_FCOLOR,  false,  NULL,       NULL,           false},
+    {RNG_MST_SCR,       GO_RECTANGLE,   1,      70,     214,    238,    1,      BACK_COLOR, BACK_COLOR,     false,  NULL,       NULL,           false},
 };
 
 /*!
@@ -322,45 +275,38 @@
     StabilusMainPage( graphObjectTouched );
 }
 
+extern DigitalIn userButton;
+
 void    StabilusMainPage (uint8_t graphObjectTouched) {
 
     uint16_t x, y = 0;
     bool touched = false;
-
-    // remove all button and text (except title, page border and line)
-    // and disable all button (touchActive = false).
-
-/*
-    GraphObject_t clearRect =   {NULL,
-                                GO_RECTANGLE, 3, 35, 282, 230, 1,
-                                BACK_COLOR,
-                                BACK_COLOR,
-                                true,
-                                BACK_COLOR,
-                                NULL,
-                                false};
-    //
-    GraphObjectClear    (&clearRect,
-                        true );
-*/
-
-//    for (uint8_t i = 0; i < GRAPH_OBJECTS_COUNT; i++ ) {
-//        MenuObjects[i].TouchActive = false;
-//    }
+    bool PBPushed = false;
 
     TouchedXYT (&x, &y, &touched);
     sprintf (StringText,
-            "%d", touched);
-    sprintf (StringText2,
-            "%d", x);
-    sprintf (StringText3,
-            "%d", y);
-    DrawText(TITLE_TEXT, (uint8_t*)StringText, NULL, NULL );
+            "Screen Touched: %d", touched);
+    DrawText    (TITLE_TEXT, (uint8_t*)StringText, NULL , NULL);
+
+    if  (touched == true) {
+        sprintf (StringText,
+                "x: %d", x);
+        DrawActiveButton    (BTN2_BORDER, (uint8_t*)StringText, NULL);
     
-    //    DisplayDriverDrawLogo( SemtechLogo, 20, 37 );
-        DrawActiveButton( BTN2_BORDER, ( uint8_t* )StringText2, NULL );
-        DrawActiveButton( BTN3_BORDER, ( uint8_t* )StringText3, NULL );
-    //    DrawActiveButton( BTN4_BORDER, ( uint8_t* )"Outdoor ranging demo", NULL );
+        sprintf (StringText,
+                "Y: %d", y);
+        DrawActiveButton    (BTN3_BORDER, (uint8_t*)StringText, NULL);
+    }
+    else {
+        DrawActiveButton    (BTN2_BORDER, (uint8_t*) "No Touch ...", NULL);
+        DrawActiveButton    (BTN3_BORDER, (uint8_t*) "No Touch ...", NULL);
+    }
+
+    PBPushed = userButton;
+    sprintf (StringText,
+            "PB Released: %d", PBPushed);
+    DrawActiveButton    (BTN4_BORDER, (uint8_t*)StringText, NULL);
+    
     //    DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Radio Test Modes", NULL );
     //    DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Radio Settings", NULL );
     //    DrawActiveButton( BTN7_BORDER, ( uint8_t* )"Utilities", NULL );