Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI DmTftLibrary
Revision 27:654100855f5c, committed 2022-02-15
- Comitter:
- lex9296
- Date:
- Tue Feb 15 07:22:09 2022 +0000
- Parent:
- 26:bfca0c471a87
- Commit message:
- Release "Stabile"
Changed in this revision
--- a/Display/DisplayDriver.cpp Thu Feb 10 13:46:17 2022 +0000
+++ b/Display/DisplayDriver.cpp Tue Feb 15 07:22:09 2022 +0000
@@ -19,7 +19,6 @@
#include "DmTouch.h"
#include "DmTouchCalibration.h"
-
//If DISPLAY_INVERT is defined as 1 then the display will be inverted from its native orientation
#define DISPLAY_INVERT 1
@@ -44,7 +43,6 @@
MenuSettings_t MenuSettings;
char GoTmpString[MAX_GO_STRING];
-
static int BmpWidth;
static int BmpHeight;
static uint8_t BmpImageoffset;
@@ -55,20 +53,19 @@
static void DrawBmpFromFlash( uint8_t *thisBmp, int x, int y );
-void DisplayDriverInit( void )
-{
- Tft.init( );
- Touch.init( );
+void DisplayDriverInit (void) {
+ Tft.init();
+ Touch.init();
- DisplayDriverCalibrate( );
- Tft.clearScreen( );
+ DisplayDriverCalibrate();
+ Tft.clearScreen();
- for( uint8_t i = 0; i < MAX_GO_STRING; i++) GoTmpString[i] = SPACE_ASCII;
+ for (uint8_t i = 0; i < MAX_GO_STRING; i++)
+ GoTmpString[i] = SPACE_ASCII;
}
// Calibrates the touch screen
-void DisplayDriverCalibrate( void )
-{
+void DisplayDriverCalibrate (void) {
uint16_t x, y = 0;
bool touched = false;
@@ -103,8 +100,7 @@
Tft.clearScreen( );
Tft.drawString( 5, 5, "Calibration failed" );
Tft.drawString( 5, 25, "Please try again." );
-// delay( 2000 );
- wait(2000);
+ delay( 2000 );
Tft.clearScreen( );
return;
@@ -480,3 +476,50 @@
}
}
+void LCM_ClearScreen (uint16_t color) {
+ Tft.clearScreen (color);
+}
+
+void LCM_DrawString (uint16_t x, uint16_t y, const char *p) {
+ Tft.drawString (x, y, (char *)p);
+}
+
+void LCM_SetTextColor (uint16_t background, uint16_t foreground) {
+ Tft.setTextColor (background, foreground);
+}
+
+// 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 Real
+// 0000 0111 1110 0000 max 0x07e0 02016
+//
+// GREEN 0000 0000 0100 0000 min 0x0040 00064 This
+// 0000 0111 1100 0000 max 0x07c0 01984
+//
+// 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), Normalmente
+// La componente VERDE ha 5 bit di escursione (0.. 31), In qst applicazione
+// 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));
+//
+uint16_t Scale2RGBColor (uint16_t R, uint16_t G, uint16_t B) {
+
+ R = ((R& 0x1f)<< 11)& 0xf800;
+ G = ((G& 0x1f)<< 6)& 0x07c0;
+ B &= 0x001f;
+ //
+ return (R+ G+ B);
+}
+
--- a/Display/DisplayDriver.h Thu Feb 10 13:46:17 2022 +0000
+++ b/Display/DisplayDriver.h Tue Feb 15 07:22:09 2022 +0000
@@ -15,10 +15,8 @@
#ifndef TFT_DISPLAY_DRIVER_H
#define TFT_DISPLAY_DRIVER_H
-
#include "DmTftBase.h"
-
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
@@ -135,5 +133,15 @@
*/
void DisplayDriverDrawLogo( uint8_t *thisBmp, uint8_t xPos, uint8_t yPos );
+// LA: Addon(s)
+// ========
+//
+
+void LCM_ClearScreen (uint16_t color);
+void LCM_DrawString (uint16_t x, uint16_t y, const char *p);
+void LCM_SetTextColor (uint16_t background, uint16_t foreground);
+//
+uint16_t Scale2RGBColor (uint16_t R, uint16_t G, uint16_t B);
+
#endif //TFT_DISPLAY_DRIVER_H
--- a/Display/Menu.cpp Thu Feb 10 13:46:17 2022 +0000
+++ b/Display/Menu.cpp Tue Feb 15 07:22:09 2022 +0000
@@ -1,7 +1,6 @@
#include <stdio.h>
#include "mbed.h"
-//#include "QEI.h"
#include "Menu.h"
#include "DisplayDriver.h"
@@ -21,26 +20,6 @@
*/
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
- * has been checked or not, until checked.
- */
-//Ticker CheckScreenTouch;
-volatile bool CheckScreenFlag = false;
-
-/*!
- * \brief This ticker give the rythme to refresh a page when continuous info
- * has to be printed in the same page.
- */
-//Ticker CheckPageRefresh;
-volatile bool PageRefresh = false;
-
-/*!
- * \brief This ticker give the rythme to avoid quick menu change
- */
-//Ticker DebouncedScreenTouch;
-volatile bool ScreenBeenDebounced = false;
/*!
* \brief List og graphical object in the application.
@@ -241,8 +220,9 @@
void MenuInit( void )
{
- DisplayDriverInit( );
- GraphObjectDraw( &( MenuObjects[PAGE_BORDER] ), NULL, false, false );
+ DisplayDriverInit ();
+// GraphObjectDraw( &( MenuObjects[PAGE_BORDER] ), NULL, false, false );
+
// GraphObjectDraw( &( MenuObjects[TITLE_LINE] ), NULL, false, false );
// MenuSetPage( START_PAGE );
--- 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);
-}
-*/