1st Fork

Dependencies:   mbed QEI DmTftLibrary

Revision:
27:654100855f5c
Parent:
26:bfca0c471a87
--- a/main.cpp	Thu Feb 10 13:46:17 2022 +0000
+++ b/main.cpp	Tue Feb 15 07:22:09 2022 +0000
@@ -4,7 +4,6 @@
 #define MBED_RAM_SIZE 0x00018000
 #endif
 
-//#include "mbed.h"
 #include "QEI.h"
 #include "SWPos.h"
 
@@ -14,6 +13,17 @@
 //#include "main.h"
 //#include "app_config.h"
 
+#define MAX_CHAR_PER_LINE   28
+#define TEXT_ROW_SPACING    16
+#define FONT_CHAR_WIDTH 8
+#define FONT_CHAR_HEIGHT    16
+
+//#include "mbed.h"
+#include "DisplayDriver.h"
+//#include "DmTftIli9341.h"
+//#include "DmTouch.h"
+//#include "DmTouchCalibration.h"
+
 // LA:  Theory of Operation
 //      ===================
 //
@@ -98,7 +108,13 @@
         FactoryReset();
     }
 
-    MenuInit();                                             // LA:  Inizializza il Display
+    DisplayDriverInit();
+//    LCM_SetTextColor(BLUE, BLACK);
+//    LCM_SetTextColor(GRAY1, BLACK);
+//    LCM_SetTextColor(GRAY2, WHITE);
+    LCM_SetTextColor(BLACK, WHITE);
+
+//    MenuInit();                                             // LA:  Inizializza il Display
 //    LCD_RefreshViews.attach_us  (&LCD____tScan, 250000);    //      Scansione LCD @100ms
 
     // LA:  Motion (1st) Setup
@@ -145,39 +161,238 @@
 
     PWM_PB3.period_us(100);         // LA:  TimeBase is 100us
 
+  #define RED     0xf800            //  1111 1000 0000 0000
+  #define GREEN   0x07e0            //  0000 0111 1110 0000
+  #define BLUE    0x001f            //  0000 0000 0001 1111
+  #define BLACK   0x0000            //  0000 0000 0000 0000
+  #define YELLOW  0xffe0            //  1111 1111 1110 0000
+  #define WHITE   0xffff            //  1111 1111 1111 1111
+
+  #define CYAN        0x07ff        //  0000 0111 1111 1111
+  #define BRIGHT_RED  0xf810        //  1111 1000 0001 0000
+  #define GRAY1       0x8410        //  1000 0100 0001 0000
+  #define GRAY2       0x4208        //  0100 0010 0000 1000
+
+// LA:  Color RGB Component(s)
+//      ======================
+//
+//  RED     0000 1000 0000 0000     min     0x0800  02048
+//          1111 1000 0000 0000     max     0xf800  63488
+//
+//  GREEN   0000 0000 0010 0000     min     0x0020  00032
+//          0000 0111 1110 0000     max     0x07e0  02016
+//
+//  BLUE    0000 0000 0000 0001     min     0x0001  00001
+//          0000 0000 0001 1111     max     0x001f  00031
+//
+//  La componente ROSSA ha  5 bit di escursione (0.. 31),
+//  La componente VERDE ha  6 bit di escursione (0.. 63),
+//  La componente BLU ha    5 bit di escursione (0.. 31),
+//
+//  Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue:
+//
+//  writeReg(RED,   (Color & 0xf800) >> 11);
+//  writeReg(GREEN, (Color & 0x07e0) >> 5);
+//  writeReg(BLUE,  (Color & 0x001f));
+//
+
+//    LCM_ClearScreen (GRAY1);
+//    LCM_ClearScreen (BLACK);
+//    LCM_ClearScreen (GRAY2);
+
+    char StringText[MAX_CHAR_PER_LINE + 1];  // don't forget the /0 (end of string)
+//    char StringText2[MAX_CHAR_PER_LINE + 1];
+//    char StringText3[MAX_CHAR_PER_LINE + 1];
+
+    uint16_t    ui16_TestColor = 0x0000;
+    uint16_t    ui16_TestStep = 0x0000;
+    //
+    uint16_t    ui16_R = 0x00;
+    uint16_t    ui16_G = 0x00;
+    uint16_t    ui16_B = 0x00;
+
+    while   (ui16_TestStep < 32) {
+
+        ui16_TestColor =    Scale2RGBColor  (ui16_R, ui16_G, ui16_B);
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %04x %04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+        sprintf (StringText,
+                "R:%02x G:%02x B:%02x ", ui16_R, ui16_G, ui16_B);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 5), StringText);
+//        delay (500);
+
+        ui16_R++;
+        ui16_G++;
+        ui16_B++;
+//        ui16_TestColor +=   0x0841;
+        ui16_TestStep ++;
+    }
+    delay (2500);
+
+/*
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0001;
+        ui16_TestStep ++;
+    }
+
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0040;
+        ui16_TestStep ++;
+    }
+
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0800;
+        ui16_TestStep ++;
+    }
+
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0041;
+        ui16_TestStep ++;
+    }
+
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0840;
+        ui16_TestStep ++;
+    }
+
+    ui16_TestColor = 0x0000;
+    ui16_TestStep = 0x0000;
+    while   (ui16_TestStep < 32) {
+
+        LCM_ClearScreen (ui16_TestColor);
+        LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
+        sprintf (StringText,
+                "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep);
+        LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), StringText);
+
+//      ui16_TestColor +=   0x0841;
+        ui16_TestColor +=   0x0801;
+        ui16_TestStep ++;
+    }
+
+    delay (5000);
+*/
+/*
+    LCM_ClearScreen (0x07e0);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x07e0");
+    delay (1000);
+    LCM_ClearScreen (0x07c0);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x07c0");
+    delay (1000);
+    LCM_ClearScreen (0x07e0);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x07e0");
+    delay (1000);
+    LCM_ClearScreen (0x07c0);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x07c0");
+    delay (1000);
+
+    LCM_ClearScreen (0x0000);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0000");
+    delay (1000);
+    LCM_ClearScreen (0x0020);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0020");
+    delay (1000);
+    LCM_ClearScreen (0x0040);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0040");
+    delay (1000);
+    LCM_ClearScreen (0x0020);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0020");
+    delay (1000);
+    LCM_ClearScreen (0x0040);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0040");
+    delay (1000);
+    LCM_ClearScreen (0x0000);
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 4), "0x0000");
+    delay (1000);
+
+*/
+    ui16_TestColor =    Scale2RGBColor  (ui16_R, ui16_G, ui16_B);
+    LCM_SetTextColor    (
+                        Scale2RGBColor  (0, 0, 0),
+                        Scale2RGBColor  (31, 31, 31)
+                        );
+    LCM_DrawString  (0, 0+(TEXT_ROW_SPACING* 0), "You Start Me Up ...");
+
     while   (1) {
-        int32_t i32_Pulses;
+    static int32_t  Pulses_Prec;
+    static uint32_t ms_0003_prec;
+    int32_t i32_Pulses;
+
         i32_Pulses =    Stabilus322699.getPulses();
 
         PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW);
         PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0);      //      0.. 100us ->   0.. 100%
 
         // LA:  Wedge 4 LCDRefresh
-        StabilusMenu (0, 0, out_PosizionatoreSW.ui32_PassedActual_ms, i32_Pulses);
+        if  (
+                (i32_Pulses !=  Pulses_Prec)
+            ) {
+            sprintf (StringText,
+                    "Pulses: %d     ", i32_Pulses);
+            LCM_SetTextColor    (Scale2RGBColor  (0, 0, 31), Scale2RGBColor  (31, 31, 0));
+            LCM_DrawString  (0, 0+ (TEXT_ROW_SPACING* 1), StringText);
+        }
+
+        if  (out_PosizionatoreSW.ui32_PassedActual_ms != ms_0003_prec) {
+            sprintf (StringText,
+                    "PassedActual_ms: %d     ", out_PosizionatoreSW.ui32_PassedActual_ms);
+            LCM_SetTextColor    (Scale2RGBColor  (0, 31, 0), Scale2RGBColor  (31, 0, 31));
+            LCM_DrawString  (0, 0+ (TEXT_ROW_SPACING* 2), StringText);
+            ms_0003_prec = out_PosizionatoreSW.ui32_PassedActual_ms;
+        }
+//        StabilusMenu (0, 0, out_PosizionatoreSW.ui32_PassedActual_ms, i32_Pulses);
     }
 }
-
-
-/*
-bool    PWM_0000    (uint32_t   ui32_Duty_x100) {
-static uint32_t ui32_PWM_Base;
-
-    if  (ui32_PWM_Base >= 100)
-        ui32_PWM_Base = 0;
-    else
-        ui32_PWM_Base ++;
-
-    if  (
-            (ui32_Duty_x100 > 0) &&
-            (ui32_Duty_x100 <= 100) &&
-            (ui32_PWM_Base <= ui32_Duty_x100)
-        )
-        return  (true);
-    else
-        return  (false);
-}
-
-void    PWM____tScan (void) {
-    PWM =   PWM_0000 (50);
-}
-*/