ili9488 udisp version

This commit is contained in:
gemu2015 2021-04-21 17:11:19 +02:00
parent f46b6ebb6f
commit 2938c2c011
4 changed files with 234 additions and 112 deletions

View File

@ -60,7 +60,7 @@ struct MULTI_DISP {
uint8_t auto_draw; uint8_t auto_draw;
} displays[3]; } displays[3];
uint8_t cur_display; uint8_t cur_display;
Renderer *Init_uDisplay(const char *desc); Renderer *Init_uDisplay(const char *desc, int8_t cs);
void Set_display(uint8_t index) { void Set_display(uint8_t index) {
displays[index].display = renderer; displays[index].display = renderer;
@ -585,7 +585,7 @@ void DisplayText(void)
fp.read((uint8_t*)fdesc, size); fp.read((uint8_t*)fdesc, size);
fp.close(); fp.close();
Get_display(temp); Get_display(temp);
renderer = Init_uDisplay(fdesc); renderer = Init_uDisplay(fdesc, -1);
Set_display(temp); Set_display(temp);
AddLog(LOG_LEVEL_INFO, PSTR("DSP: File descriptor loaded %x"),renderer); AddLog(LOG_LEVEL_INFO, PSTR("DSP: File descriptor loaded %x"),renderer);
} }

View File

@ -22,118 +22,60 @@
#ifdef USE_DISPLAY_ILI9488 #ifdef USE_DISPLAY_ILI9488
#define XDSP_08 8 #define XDSP_08 8
#define XI2C_38 38 // See I2CDEVICES.md
#define COLORED 1
#define UNCOLORED 0
// using font 8 is opional (num=3)
// very badly readable, but may be useful for graphs
#define USE_TINY_FONT
#include <ILI9488.h>
uint8_t ili9488_ctouch_counter = 0;
bool ili9488_init_done = false; bool ili9488_init_done = false;
// currently fixed Renderer *Init_uDisplay(const char *desc, int8_t cs);
#define BACKPLANE_PIN 2 void udisp_CheckTouch(void);
extern uint8_t color_type;
ILI9488 *ili9488;
extern const uint16_t picture[];
/*********************************************************************************************/ /*********************************************************************************************/
const char ILI9488_DESC[] PROGMEM =
":H,ILI9488,480,320,16,SPI,1,*,*,*,*,*,*,*,10\n"
":S,2,1,1,0,40,20\n"
":I\n"
"E0,0F,00,03,09,08,16,0A,3F,78,4C,09,0A,08,16,1A,0F\n"
"E1,0F,00,16,19,03,0F,05,32,45,46,04,0E,0D,35,37,0F\n"
"C0,2,17,15\n"
"C1,1,41\n"
"C5,3,00,12,80\n"
"36,1,48\n"
"3A,1,66\n"
"B0,1,80\n"
"B1,1,A0\n"
"B4,1,02\n"
"B6,2,02,02\n"
"E9,1,00\n"
"F7,4,A9,51,2C,82\n"
"11,80\n"
"29,0\n"
":o,28\n"
":O,29\n"
":A,2A,2B,2C,16\n"
":R,36\n"
";:0,48,00,00,00\n"
":0,28,00,00,01\n"
":1,28,00,00,00\n"
":2,E8,00,00,03\n"
":3,88,00,00,02\n"
":P,18\n"
":i,20,21\n"
":TI1,38,*,*\n"
"#\n";
void ILI9488_InitDriver(void) { void ILI9488_InitDriver(void) {
if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) { if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) {
renderer = Init_uDisplay(ILI9488_DESC, Pin(GPIO_ILI9488_CS));
if (!renderer) return;
Settings.display_model = XDSP_08; Settings.display_model = XDSP_08;
if (Settings.display_width != ILI9488_TFTWIDTH) {
Settings.display_width = ILI9488_TFTWIDTH;
}
if (Settings.display_height != ILI9488_TFTHEIGHT) {
Settings.display_height = ILI9488_TFTHEIGHT;
}
// default colors
fg_color = ILI9488_WHITE;
bg_color = ILI9488_BLACK;
int8_t bppin = BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin = Pin(GPIO_BACKLIGHT);
}
// init renderer, must use hardware spi
ili9488 = new ILI9488(Pin(GPIO_ILI9488_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK), bppin);
ili9488->begin();
renderer = ili9488;
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font);
renderer->dim(Settings.display_dimmer);
#ifdef SHOW_SPLASH
// Welcome text
renderer->setTextFont(2);
renderer->setTextColor(ILI9488_WHITE,ILI9488_BLACK);
renderer->DrawStringAt(50, 50, "ILI9488 TFT Display!", ILI9488_WHITE,0);
delay(1000);
//renderer->drawRGBBitmap(100,100, picture,51,34);
#endif
color_type = COLOR_COLOR;
// start digitizer
#ifdef USE_FT5206
FT5206_Touch_Init(Wire);
#endif
ili9488_init_done = true; ili9488_init_done = true;
AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9488"));
} }
} }
#ifdef USE_FT5206
#ifdef USE_TOUCH_BUTTONS
void ILI9488_RotConvert(int16_t *x, int16_t *y) {
int16_t temp;
if (renderer) {
uint8_t rot=renderer->getRotation();
switch (rot) {
case 0:
temp=*y;
*y=renderer->height()-*x;
*x=temp;
break;
case 1:
break;
case 2:
break;
case 3:
temp=*y;
*y=*x;
*x=renderer->width()-temp;
break;
}
}
}
// check digitizer hit
void ILI9488_CheckTouch(void) {
ili9488_ctouch_counter++;
if (2 == ili9488_ctouch_counter) {
// every 100 ms should be enough
ili9488_ctouch_counter = 0;
Touch_Check(ILI9488_RotConvert);
}
}
#endif // USE_TOUCH_BUTTONS
#endif // USE_FT5206
/*********************************************************************************************/ /*********************************************************************************************/
/*********************************************************************************************\ /*********************************************************************************************\
* Interface * Interface
@ -151,11 +93,9 @@ bool Xdsp08(uint8_t function)
result = true; result = true;
break; break;
case FUNC_DISPLAY_EVERY_50_MSECOND: case FUNC_DISPLAY_EVERY_50_MSECOND:
#ifdef USE_TOUCH_BUTTONS if (FT5206_found || XPT2046_found) {
if (FT5206_found) { udisp_CheckTouch();
ILI9488_CheckTouch();
} }
#endif
break; break;
} }
} }

View File

@ -0,0 +1,169 @@
/*
xdsp_08_ILI9488.ino - Display ILI9488 support for Tasmota
Copyright (C) 2021 Theo Arends, Gerhard Mutz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if 0
#ifdef USE_SPI
#ifdef USE_DISPLAY
#ifdef USE_DISPLAY_ILI9488
#define XDSP_08 8
#define XI2C_38 38 // See I2CDEVICES.md
#define COLORED 1
#define UNCOLORED 0
// using font 8 is opional (num=3)
// very badly readable, but may be useful for graphs
#define USE_TINY_FONT
#include <ILI9488.h>
uint8_t ili9488_ctouch_counter = 0;
bool ili9488_init_done = false;
// currently fixed
#define BACKPLANE_PIN 2
extern uint8_t color_type;
ILI9488 *ili9488;
extern const uint16_t picture[];
/*********************************************************************************************/
void ILI9488_InitDriver(void) {
if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) {
Settings.display_model = XDSP_08;
if (Settings.display_width != ILI9488_TFTWIDTH) {
Settings.display_width = ILI9488_TFTWIDTH;
}
if (Settings.display_height != ILI9488_TFTHEIGHT) {
Settings.display_height = ILI9488_TFTHEIGHT;
}
// default colors
fg_color = ILI9488_WHITE;
bg_color = ILI9488_BLACK;
int8_t bppin = BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin = Pin(GPIO_BACKLIGHT);
}
// init renderer, must use hardware spi
ili9488 = new ILI9488(Pin(GPIO_ILI9488_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK), bppin);
ili9488->begin();
renderer = ili9488;
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font);
renderer->dim(Settings.display_dimmer);
#ifdef SHOW_SPLASH
// Welcome text
renderer->setTextFont(2);
renderer->setTextColor(ILI9488_WHITE,ILI9488_BLACK);
renderer->DrawStringAt(50, 50, "ILI9488 TFT Display!", ILI9488_WHITE,0);
delay(1000);
//renderer->drawRGBBitmap(100,100, picture,51,34);
#endif
color_type = COLOR_COLOR;
// start digitizer
#ifdef USE_FT5206
FT5206_Touch_Init(Wire);
#endif
ili9488_init_done = true;
AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9488"));
}
}
#ifdef USE_FT5206
#ifdef USE_TOUCH_BUTTONS
void ILI9488_RotConvert(int16_t *x, int16_t *y) {
int16_t temp;
if (renderer) {
uint8_t rot=renderer->getRotation();
switch (rot) {
case 0:
temp=*y;
*y=renderer->height()-*x;
*x=temp;
break;
case 1:
break;
case 2:
break;
case 3:
temp=*y;
*y=*x;
*x=renderer->width()-temp;
break;
}
}
}
// check digitizer hit
void ILI9488_CheckTouch(void) {
ili9488_ctouch_counter++;
if (2 == ili9488_ctouch_counter) {
// every 100 ms should be enough
ili9488_ctouch_counter = 0;
Touch_Check(ILI9488_RotConvert);
}
}
#endif // USE_TOUCH_BUTTONS
#endif // USE_FT5206
/*********************************************************************************************/
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdsp08(uint8_t function)
{
bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
ILI9488_InitDriver();
}
else if (ili9488_init_done && (XDSP_08 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_EVERY_50_MSECOND:
#ifdef USE_TOUCH_BUTTONS
if (FT5206_found) {
ILI9488_CheckTouch();
}
#endif
break;
}
}
return result;
}
#endif // USE_DISPLAY_ILI9488
#endif // USE_DISPLAY
#endif // USE_SPI
#endif

View File

@ -40,8 +40,7 @@ extern FS *ffsp;
//#define DSP_ROM_DESC //#define DSP_ROM_DESC
/*********************************************************************************************/ /*********************************************************************************************/
//#ifdef DSP_ROM_DESC #ifdef DSP_ROM_DESC
#if 1
/* sample descriptor */ /* sample descriptor */
const char DSP_SAMPLE_DESC[] PROGMEM = const char DSP_SAMPLE_DESC[] PROGMEM =
":H,SH1106,128,64,1,I2C,3c,*,*,*\n" ":H,SH1106,128,64,1,I2C,3c,*,*,*\n"
@ -71,19 +70,20 @@ const char DSP_SAMPLE_DESC[] PROGMEM =
#endif // DSP_ROM_DESC #endif // DSP_ROM_DESC
/*********************************************************************************************/ /*********************************************************************************************/
Renderer *Init_uDisplay(const char *desc) { Renderer *Init_uDisplay(const char *desc, int8_t cs) {
char *ddesc = 0; char *ddesc = 0;
char *fbuff; char *fbuff;
uDisplay *udisp; uDisplay *udisp;
if (TasmotaGlobal.gpio_optiona.udisplay_driver) { if (TasmotaGlobal.gpio_optiona.udisplay_driver || desc) {
Settings.display_model = XDSP_17; Settings.display_model = XDSP_17;
fbuff = (char*)calloc(DISPDESC_SIZE, 1); fbuff = (char*)calloc(DISPDESC_SIZE, 1);
if (!fbuff) return 0; if (!fbuff) return 0;
if (desc) { if (desc) {
memcpy(fbuff, desc, DISPDESC_SIZE - 1); memcpy_P(fbuff, desc, DISPDESC_SIZE - 1);
ddesc = fbuff; ddesc = fbuff;
AddLog(LOG_LEVEL_INFO, PSTR("DSP: const char descriptor used")); AddLog(LOG_LEVEL_INFO, PSTR("DSP: const char descriptor used"));
} }
@ -192,9 +192,22 @@ uDisplay *udisp;
cp += 4; cp += 4;
//; 7 params nr,cs,sclk,mosi,dc,bl,reset,miso //; 7 params nr,cs,sclk,mosi,dc,bl,reset,miso
//SPI,*,*,*,*,*,*,* //SPI,*,*,*,*,*,*,*
if (cs < 0) {
switch (*cp) {
case 1:
cs = Pin(GPIO_SPI_CS);
break;
case 2:
cs = Pin(GPIO_SPI_CS, 1);
break;
default:
cs = Pin(GPIO_SSPI_CS);
break;
}
}
if (*cp == '1') { if (*cp == '1') {
cp+=2; cp+=2;
replacepin(&cp, Pin(GPIO_SPI_CS)); replacepin(&cp, cs);
replacepin(&cp, Pin(GPIO_SPI_CLK)); replacepin(&cp, Pin(GPIO_SPI_CLK));
replacepin(&cp, Pin(GPIO_SPI_MOSI)); replacepin(&cp, Pin(GPIO_SPI_MOSI));
replacepin(&cp, Pin(GPIO_SPI_DC)); replacepin(&cp, Pin(GPIO_SPI_DC));
@ -203,7 +216,7 @@ uDisplay *udisp;
replacepin(&cp, Pin(GPIO_SPI_MISO)); replacepin(&cp, Pin(GPIO_SPI_MISO));
} else if (*cp == '2') { } else if (*cp == '2') {
cp+=2; cp+=2;
replacepin(&cp, Pin(GPIO_SPI_CS, 1)); replacepin(&cp, cs);
replacepin(&cp, Pin(GPIO_SPI_CLK, 1)); replacepin(&cp, Pin(GPIO_SPI_CLK, 1));
replacepin(&cp, Pin(GPIO_SPI_MOSI, 1)); replacepin(&cp, Pin(GPIO_SPI_MOSI, 1));
replacepin(&cp, Pin(GPIO_SPI_DC, 1)); replacepin(&cp, Pin(GPIO_SPI_DC, 1));
@ -213,7 +226,7 @@ uDisplay *udisp;
} else { } else {
// soft spi pins // soft spi pins
cp+=2; cp+=2;
replacepin(&cp, Pin(GPIO_SSPI_CS)); replacepin(&cp, cs);
replacepin(&cp, Pin(GPIO_SSPI_SCLK)); replacepin(&cp, Pin(GPIO_SSPI_SCLK));
replacepin(&cp, Pin(GPIO_SSPI_MOSI)); replacepin(&cp, Pin(GPIO_SSPI_MOSI));
replacepin(&cp, Pin(GPIO_SSPI_DC)); replacepin(&cp, Pin(GPIO_SSPI_DC));
@ -443,7 +456,7 @@ bool Xdsp17(uint8_t function)
bool result = false; bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) { if (FUNC_DISPLAY_INIT_DRIVER == function) {
Init_uDisplay(0); Init_uDisplay(0, -1);
} }
else if (udisp_init_done && (XDSP_17 == Settings.display_model)) { else if (udisp_init_done && (XDSP_17 == Settings.display_model)) {
switch (function) { switch (function) {