1st Fork
Dependencies: mbed QEI DmTftLibrary
Diff: Display/DisplayDriver.cpp
- Revision:
- 27:654100855f5c
- Parent:
- 24:9f96fd6764d2
--- 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); +} +