mirror of https://github.com/arendst/Tasmota.git
Merge pull request #10401 from gemu2015/picture_buttons
Picture buttons
This commit is contained in:
commit
c2cc343e38
|
@ -1579,6 +1579,8 @@ void Adafruit_GFX_Button::initButtonUL(
|
||||||
strncpy(_label, label, 9);
|
strncpy(_label, label, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_picture(char *path, uint32_t xp, uint32_t yp, uint32_t xs, uint32_t ys, bool inverted);
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Draw the button on the screen
|
@brief Draw the button on the screen
|
||||||
|
@ -1598,16 +1600,20 @@ void Adafruit_GFX_Button::drawButton(boolean inverted) {
|
||||||
text = _fillcolor;
|
text = _fillcolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t r = min(_w, _h) / 4; // Corner radius
|
if (_label[0]=='/') {
|
||||||
_gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill);
|
// picture path
|
||||||
_gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline);
|
draw_picture(_label, _x1, _y1, _w, _h, inverted);
|
||||||
|
_gfx->drawRect(_x1, _y1, _w, _h, text);
|
||||||
_gfx->setCursor(_x1 + (_w/2) - (strlen(_label) * 3 * _textsize_x),
|
} else {
|
||||||
_y1 + (_h/2) - (4 * _textsize_y));
|
uint8_t r = min(_w, _h) / 4; // Corner radius
|
||||||
_gfx->setTextColor(text);
|
_gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill);
|
||||||
_gfx->setTextSize(_textsize_x, _textsize_y);
|
_gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline);
|
||||||
_gfx->print(_label);
|
|
||||||
|
|
||||||
|
_gfx->setCursor(_x1 + (_w/2) - (strlen(_label) * 3 * _textsize_x), _y1 + (_h/2) - (4 * _textsize_y));
|
||||||
|
_gfx->setTextColor(text);
|
||||||
|
_gfx->setTextSize(_textsize_x, _textsize_y);
|
||||||
|
_gfx->print(_label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
|
@ -545,6 +545,12 @@ void ILI9341_2::DisplayOnff(int8_t on) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILI9341_2::invertDisplay(boolean i) {
|
||||||
|
ILI9341_2_CS_LOW
|
||||||
|
writecmd(i ? ILI9341_2_INVOFF : ILI9341_2_INVON);
|
||||||
|
ILI9341_2_CS_HIGH
|
||||||
|
}
|
||||||
|
|
||||||
void ili9342_dimm(uint8_t dim);
|
void ili9342_dimm(uint8_t dim);
|
||||||
|
|
||||||
// dimmer 0-100
|
// dimmer 0-100
|
||||||
|
|
|
@ -119,30 +119,6 @@ class ILI9341_2 : public Renderer {
|
||||||
ILI9341_2(int8_t cs, int8_t res, int8_t dc, int8_t bp);
|
ILI9341_2(int8_t cs, int8_t res, int8_t dc, int8_t bp);
|
||||||
|
|
||||||
void init(uint16_t width, uint16_t height);
|
void init(uint16_t width, uint16_t height);
|
||||||
/*
|
|
||||||
void begin(void);
|
|
||||||
void DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font);
|
|
||||||
void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
|
||||||
void setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea);
|
|
||||||
void scroll(uint16_t pixels);
|
|
||||||
void pushColor(uint16_t color);
|
|
||||||
void pushColors(uint16_t *data, uint8_t len, boolean first);
|
|
||||||
//void drawImage(const uint8_t* img, uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
|
||||||
void fillScreen(uint16_t color);
|
|
||||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
|
||||||
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
||||||
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
|
||||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color);
|
|
||||||
void setRotation(uint8_t r);
|
|
||||||
void invertDisplay(boolean i);
|
|
||||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
|
||||||
void DisplayOnff(int8_t on);
|
|
||||||
void writecommand(uint8_t c);
|
|
||||||
void writedata(uint8_t d);
|
|
||||||
void write16BitColor(uint16_t color);
|
|
||||||
void commandList(uint8_t *addr);
|
|
||||||
void hw_spi_init();
|
|
||||||
void dim(uint8_t contrast);*/
|
|
||||||
uint16_t GetColorFromIndex(uint8_t index);
|
uint16_t GetColorFromIndex(uint8_t index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -161,7 +137,7 @@ class ILI9341_2 : public Renderer {
|
||||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||||
void dim(uint8_t dim);
|
void dim(uint8_t dim);
|
||||||
void pushColors(uint16_t *data, uint8_t len, boolean first);
|
void pushColors(uint16_t *data, uint8_t len, boolean first);
|
||||||
|
void invertDisplay(boolean i);
|
||||||
void spiwrite(uint8_t c);
|
void spiwrite(uint8_t c);
|
||||||
void spiwrite16(uint16_t c);
|
void spiwrite16(uint16_t c);
|
||||||
void spiwrite32(uint32_t c);
|
void spiwrite32(uint32_t c);
|
||||||
|
|
|
@ -503,6 +503,16 @@ void ILI9488::scroll(uint16_t pixels){
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void ILI9488::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
void ILI9488::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
|
if (!x0 && !y0 && !x1 && !y1) {
|
||||||
|
x0=0;
|
||||||
|
y0=0;
|
||||||
|
x1=_width;
|
||||||
|
y1=_height;
|
||||||
|
}
|
||||||
|
setAddrWindow_int(x0, y0, x1-1, y1-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ILI9488::setAddrWindow_int(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
uint8_t flag=0;
|
uint8_t flag=0;
|
||||||
|
|
||||||
if (!x0 && !y0 && !x1 && !y1) {
|
if (!x0 && !y0 && !x1 && !y1) {
|
||||||
|
@ -594,6 +604,7 @@ void ILI9488::pushColor(uint16_t color) {
|
||||||
ILI9488_STOP
|
ILI9488_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
void ILI9488::pushColors(uint16_t *data, uint8_t len, boolean first) {
|
void ILI9488::pushColors(uint16_t *data, uint8_t len, boolean first) {
|
||||||
uint16_t color;
|
uint16_t color;
|
||||||
uint8_t buff[len*3+1];
|
uint8_t buff[len*3+1];
|
||||||
|
@ -616,6 +627,17 @@ void ILI9488::pushColors(uint16_t *data, uint8_t len, boolean first) {
|
||||||
ILI9488_STOP
|
ILI9488_STOP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
void ILI9488::pushColors(uint16_t *data, uint8_t len, boolean first) {
|
||||||
|
uint16_t color;
|
||||||
|
|
||||||
|
while (len--) {
|
||||||
|
write16BitColor(*data++);
|
||||||
|
}
|
||||||
|
ILI9488_STOP
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ILI9488::write16BitColor(uint16_t color){
|
void ILI9488::write16BitColor(uint16_t color){
|
||||||
// #if (__STM32F1__)
|
// #if (__STM32F1__)
|
||||||
|
@ -688,7 +710,7 @@ void ILI9488::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||||
|
|
||||||
if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return;
|
if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return;
|
||||||
|
|
||||||
setAddrWindow(x,y,x+1,y+1);
|
setAddrWindow_int(x,y,x+1,y+1);
|
||||||
write16BitColor(color);
|
write16BitColor(color);
|
||||||
ILI9488_STOP
|
ILI9488_STOP
|
||||||
}
|
}
|
||||||
|
@ -702,7 +724,7 @@ void ILI9488::drawFastVLine(int16_t x, int16_t y, int16_t h,
|
||||||
if((y+h-1) >= _height)
|
if((y+h-1) >= _height)
|
||||||
h = _height-y;
|
h = _height-y;
|
||||||
|
|
||||||
setAddrWindow(x, y, x, y+h-1);
|
setAddrWindow_int(x, y, x, y+h-1);
|
||||||
|
|
||||||
uint8_t r = (color & 0xF800) >> 11;
|
uint8_t r = (color & 0xF800) >> 11;
|
||||||
uint8_t g = (color & 0x07E0) >> 5;
|
uint8_t g = (color & 0x07E0) >> 5;
|
||||||
|
@ -770,7 +792,7 @@ void ILI9488::drawFastHLine(int16_t x, int16_t y, int16_t w,
|
||||||
if((x >= _width) || (y >= _height)) return;
|
if((x >= _width) || (y >= _height)) return;
|
||||||
if((x+w-1) >= _width) w = _width-x;
|
if((x+w-1) >= _width) w = _width-x;
|
||||||
|
|
||||||
setAddrWindow(x, y, x+w-1, y);
|
setAddrWindow_int(x, y, x+w-1, y);
|
||||||
|
|
||||||
uint8_t r = (color & 0xF800) >> 11;
|
uint8_t r = (color & 0xF800) >> 11;
|
||||||
uint8_t g = (color & 0x07E0) >> 5;
|
uint8_t g = (color & 0x07E0) >> 5;
|
||||||
|
@ -905,7 +927,7 @@ void ILI9488::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t colo
|
||||||
if((x + w - 1) >= _width) w = _width - x;
|
if((x + w - 1) >= _width) w = _width - x;
|
||||||
if((y + h - 1) >= _height) h = _height - y;
|
if((y + h - 1) >= _height) h = _height - y;
|
||||||
|
|
||||||
setAddrWindow(x, y, x+w-1, y+h-1);
|
setAddrWindow_int(x, y, x+w-1, y+h-1);
|
||||||
//ILI9488_START
|
//ILI9488_START
|
||||||
|
|
||||||
uint8_t r = (color & 0xF800) >> 11;
|
uint8_t r = (color & 0xF800) >> 11;
|
||||||
|
@ -1050,7 +1072,7 @@ void ILI9488::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t colo
|
||||||
if((x + w - 1) >= _width) w = _width - x;
|
if((x + w - 1) >= _width) w = _width - x;
|
||||||
if((y + h - 1) >= _height) h = _height - y;
|
if((y + h - 1) >= _height) h = _height - y;
|
||||||
|
|
||||||
setAddrWindow(x, y, x+w-1, y+h-1);
|
setAddrWindow_int(x, y, x+w-1, y+h-1);
|
||||||
|
|
||||||
uint8_t r = (color & 0xF800) >> 11;
|
uint8_t r = (color & 0xF800) >> 11;
|
||||||
uint8_t g = (color & 0x07E0) >> 5;
|
uint8_t g = (color & 0x07E0) >> 5;
|
||||||
|
|
|
@ -136,6 +136,7 @@ class ILI9488 : public Renderer {
|
||||||
|
|
||||||
void begin(void);
|
void begin(void);
|
||||||
void DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font);
|
void DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font);
|
||||||
|
void setAddrWindow_int(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea);
|
void setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea);
|
||||||
void scroll(uint16_t pixels);
|
void scroll(uint16_t pixels);
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
//#define USE_GFX_FONTS
|
//#define USE_GFX_FONTS
|
||||||
#define USE_TINY_FONT
|
#define USE_TINY_FONT
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
#define USE_ICON_FONT
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t wr_redir=0;
|
uint8_t wr_redir=0;
|
||||||
|
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
|
@ -223,27 +227,32 @@ void Renderer::setTextFont(uint8_t f) {
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
selected_font = &RAFont;
|
selected_font = &RAFont;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
font=0;
|
selected_font = &Font12;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef USE_EPD_FONTS
|
#ifdef USE_EPD_FONTS
|
||||||
if (1 == font) {
|
switch (font) {
|
||||||
selected_font = &Font12;
|
selected_font = &Font12;
|
||||||
} else {
|
break;
|
||||||
#ifdef USE_TINY_FONT
|
case 2:
|
||||||
if (2 == font) {
|
|
||||||
selected_font = &Font24;
|
|
||||||
} else {
|
|
||||||
selected_font = &Font8;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
selected_font = &Font24;
|
selected_font = &Font24;
|
||||||
#endif
|
break;
|
||||||
|
case 3:
|
||||||
|
#ifdef USE_TINY_FONT
|
||||||
|
selected_font = &Font8;
|
||||||
|
#else
|
||||||
|
selected_font = &Font24;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
selected_font = &Font12;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,6 +522,9 @@ void Renderer::setDrawMode(uint8_t mode) {
|
||||||
drawmode=mode;
|
drawmode=mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::invertDisplay(boolean i) {
|
||||||
|
}
|
||||||
|
|
||||||
void VButton::xdrawButton(bool inverted) {
|
void VButton::xdrawButton(bool inverted) {
|
||||||
wr_redir=1;
|
wr_redir=1;
|
||||||
drawButton(inverted);
|
drawButton(inverted);
|
||||||
|
@ -520,4 +532,6 @@ void VButton::xdrawButton(bool inverted) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* END OF FILE */
|
/* END OF FILE */
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
virtual void dim(uint8_t contrast);
|
virtual void dim(uint8_t contrast);
|
||||||
virtual void pushColors(uint16_t *data, uint8_t len, boolean first);
|
virtual void pushColors(uint16_t *data, uint8_t len, boolean first);
|
||||||
virtual void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
virtual void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
|
virtual void invertDisplay(boolean i);
|
||||||
void setDrawMode(uint8_t mode);
|
void setDrawMode(uint8_t mode);
|
||||||
uint8_t drawmode;
|
uint8_t drawmode;
|
||||||
virtual void FastString(uint16_t x,uint16_t y,uint16_t tcolor, const char* str);
|
virtual void FastString(uint16_t x,uint16_t y,uint16_t tcolor, const char* str);
|
||||||
|
|
|
@ -86,6 +86,11 @@ uint32_t FlashWriteMaxSector(void) {
|
||||||
uint8_t* FlashDirectAccess(void) {
|
uint8_t* FlashDirectAccess(void) {
|
||||||
return (uint8_t*)(0x40200000 + (FlashWriteStartSector() * SPI_FLASH_SEC_SIZE));
|
return (uint8_t*)(0x40200000 + (FlashWriteStartSector() * SPI_FLASH_SEC_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *special_malloc(uint32_t size) {
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
@ -414,4 +419,13 @@ uint8_t* FlashDirectAccess(void) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ESP32
|
|
||||||
|
void *special_malloc(uint32_t size) {
|
||||||
|
if (psramFound()) {
|
||||||
|
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
} else {
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ESP32
|
||||||
|
|
|
@ -29,9 +29,27 @@ uint8_t red, grn, blu;
|
||||||
uint16_t b , g, r;
|
uint16_t b , g, r;
|
||||||
|
|
||||||
for (uint32_t cnt=0; cnt<len; cnt++) {
|
for (uint32_t cnt=0; cnt<len; cnt++) {
|
||||||
red = *in++;
|
|
||||||
grn = *in++;
|
|
||||||
blu = *in++;
|
blu = *in++;
|
||||||
|
grn = *in++;
|
||||||
|
red = *in++;
|
||||||
|
|
||||||
|
b = (blu >> 3) & 0x1f;
|
||||||
|
g = ((grn >> 2) & 0x3f) << 5;
|
||||||
|
r = ((red >> 3) & 0x1f) << 11;
|
||||||
|
*out++ = (r | g | b);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rgb888_to_565i(uint8_t *in, uint16_t *out, uint32_t len) {
|
||||||
|
uint8_t red, grn, blu;
|
||||||
|
uint16_t b , g, r;
|
||||||
|
|
||||||
|
for (uint32_t cnt=0; cnt<len; cnt++) {
|
||||||
|
blu = 255-*in++;
|
||||||
|
grn = 255-*in++;
|
||||||
|
red = 255-*in++;
|
||||||
|
|
||||||
b = (blu >> 3) & 0x1f;
|
b = (blu >> 3) & 0x1f;
|
||||||
g = ((grn >> 2) & 0x3f) << 5;
|
g = ((grn >> 2) & 0x3f) << 5;
|
||||||
r = ((red >> 3) & 0x1f) << 11;
|
r = ((red >> 3) & 0x1f) << 11;
|
||||||
|
|
|
@ -503,7 +503,7 @@ void DisplayText(void)
|
||||||
if (ep) {
|
if (ep) {
|
||||||
*ep=0;
|
*ep=0;
|
||||||
ep++;
|
ep++;
|
||||||
Draw_RGB_Bitmap(cp,disp_xpos,disp_ypos);
|
Draw_RGB_Bitmap(cp,disp_xpos,disp_ypos, false);
|
||||||
cp=ep;
|
cp=ep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1423,7 +1423,7 @@ void CmndDisplayDimmer(void)
|
||||||
void CmndDisplayBlinkrate(void)
|
void CmndDisplayBlinkrate(void)
|
||||||
{
|
{
|
||||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 3)) {
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 3)) {
|
||||||
|
|
||||||
if (!renderer)
|
if (!renderer)
|
||||||
XdspCall(FUNC_DISPLAY_BLINKRATE);
|
XdspCall(FUNC_DISPLAY_BLINKRATE);
|
||||||
}
|
}
|
||||||
|
@ -1540,20 +1540,39 @@ void CmndDisplayRows(void)
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* optional drivers
|
* optional drivers
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef USE_TOUCH_BUTTONS
|
||||||
|
// very limited path size, so, add .jpg
|
||||||
|
void draw_picture(char *path, uint32_t xp, uint32_t yp, uint32_t xs, uint32_t ys, bool inverted) {
|
||||||
|
char ppath[16];
|
||||||
|
strcpy(ppath, path);
|
||||||
|
uint8_t plen = strlen(path) -1;
|
||||||
|
if (ppath[plen]=='1') {
|
||||||
|
// index mode
|
||||||
|
if (inverted) {
|
||||||
|
ppath[plen] = '2';
|
||||||
|
}
|
||||||
|
inverted = false;
|
||||||
|
}
|
||||||
|
strcat(ppath, ".jpg");
|
||||||
|
Draw_RGB_Bitmap(ppath, xp, yp, inverted);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#ifdef JPEG_PICTS
|
#ifdef JPEG_PICTS
|
||||||
#include "img_converters.h"
|
#include "img_converters.h"
|
||||||
#include "esp_jpg_decode.h"
|
#include "esp_jpg_decode.h"
|
||||||
bool jpg2rgb888(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale);
|
bool jpg2rgb888(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale);
|
||||||
char get_jpeg_size(unsigned char* data, unsigned int data_size, unsigned short *width, unsigned short *height);
|
char get_jpeg_size(unsigned char* data, unsigned int data_size, unsigned short *width, unsigned short *height);
|
||||||
void rgb888_to_565(uint8_t *in, uint16_t *out, uint32_t len);
|
|
||||||
#endif // JPEG_PICTS
|
#endif // JPEG_PICTS
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)
|
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) && defined(USE_DISPLAY)
|
||||||
extern FS *fsp;
|
extern FS *fsp;
|
||||||
#define XBUFF_LEN 128
|
#define XBUFF_LEN 128
|
||||||
void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp) {
|
void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
|
||||||
if (!renderer) return;
|
if (!renderer) return;
|
||||||
File fp;
|
File fp;
|
||||||
char *ending = strrchr(file,'.');
|
char *ending = strrchr(file,'.');
|
||||||
|
@ -1602,34 +1621,41 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp) {
|
||||||
// jpeg files on ESP32 with more memory
|
// jpeg files on ESP32 with more memory
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#ifdef JPEG_PICTS
|
#ifdef JPEG_PICTS
|
||||||
if (psramFound()) {
|
fp=fsp->open(file,FILE_READ);
|
||||||
fp=fsp->open(file,FILE_READ);
|
if (!fp) return;
|
||||||
if (!fp) return;
|
uint32_t size = fp.size();
|
||||||
uint32_t size = fp.size();
|
uint8_t *mem = (uint8_t *)special_malloc(size+4);
|
||||||
uint8_t *mem = (uint8_t *)heap_caps_malloc(size+4, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
if (mem) {
|
||||||
if (mem) {
|
uint8_t res=fp.read(mem, size);
|
||||||
uint8_t res=fp.read(mem, size);
|
if (res) {
|
||||||
if (res) {
|
uint16_t xsize;
|
||||||
uint16_t xsize;
|
uint16_t ysize;
|
||||||
uint16_t ysize;
|
if (mem[0]==0xff && mem[1]==0xd8) {
|
||||||
if (mem[0]==0xff && mem[1]==0xd8) {
|
get_jpeg_size(mem, size, &xsize, &ysize);
|
||||||
get_jpeg_size(mem, size, &xsize, &ysize);
|
//Serial.printf(" x,y,fs %d - %d - %d\n",xsize, ysize, size );
|
||||||
//Serial.printf(" x,y %d - %d\n",xsize, ysize );
|
if (xsize && ysize) {
|
||||||
if (xsize && ysize) {
|
uint8_t *out_buf = (uint8_t *)special_malloc((xsize*ysize*3)+4);
|
||||||
uint8_t *out_buf = (uint8_t *)heap_caps_malloc((xsize*ysize*3)+4, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
if (out_buf) {
|
||||||
if (out_buf) {
|
uint16_t *pixb = (uint16_t *)special_malloc((xsize*2)+4);
|
||||||
|
if (pixb) {
|
||||||
uint8_t *ob=out_buf;
|
uint8_t *ob=out_buf;
|
||||||
jpg2rgb888(mem, size, out_buf, (jpg_scale_t)JPG_SCALE_NONE);
|
if (jpg2rgb888(mem, size, out_buf, (jpg_scale_t)JPG_SCALE_NONE)) {
|
||||||
uint16_t pixels=xsize*ysize/XBUFF_LEN;
|
renderer->setAddrWindow(xp,yp,xp+xsize,yp+ysize);
|
||||||
renderer->setAddrWindow(xp,yp,xp+xsize,yp+ysize);
|
for(int32_t j=0; j<ysize; j++) {
|
||||||
for(int32_t j=0; j<pixels; j++) {
|
if (inverted==false) {
|
||||||
uint16_t rbuff[XBUFF_LEN*2];
|
rgb888_to_565(ob, pixb, xsize);
|
||||||
rgb888_to_565(ob, rbuff, XBUFF_LEN);
|
} else {
|
||||||
ob+=XBUFF_LEN*3;
|
rgb888_to_565i(ob, pixb, xsize);
|
||||||
renderer->pushColors(rbuff,XBUFF_LEN,true);
|
}
|
||||||
OsWatchLoop();
|
ob+=xsize*3;
|
||||||
|
renderer->pushColors(pixb, xsize, true);
|
||||||
|
OsWatchLoop();
|
||||||
|
}
|
||||||
|
renderer->setAddrWindow(0,0,0,0);
|
||||||
}
|
}
|
||||||
renderer->setAddrWindow(0,0,0,0);
|
free(out_buf);
|
||||||
|
free(pixb);
|
||||||
|
} else {
|
||||||
free(out_buf);
|
free(out_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ void EpdInitDriver29(void) {
|
||||||
|
|
||||||
#ifdef SHOW_SPLASH
|
#ifdef SHOW_SPLASH
|
||||||
// Welcome text
|
// Welcome text
|
||||||
|
delay(100);
|
||||||
renderer->setTextFont(1);
|
renderer->setTextFont(1);
|
||||||
renderer->DrawStringAt(50, 50, "Waveshare E-Paper Display!", COLORED,0);
|
renderer->DrawStringAt(50, 50, "Waveshare E-Paper Display!", COLORED,0);
|
||||||
renderer->Updateframe();
|
renderer->Updateframe();
|
||||||
|
|
|
@ -112,14 +112,8 @@ void ST7789_InitDriver(void) {
|
||||||
#ifdef SHOW_SPLASH
|
#ifdef SHOW_SPLASH
|
||||||
// Welcome text
|
// Welcome text
|
||||||
renderer->setTextColor(ST7789_WHITE,ST7789_BLACK);
|
renderer->setTextColor(ST7789_WHITE,ST7789_BLACK);
|
||||||
int fontSize = 2;
|
|
||||||
renderer->setTextFont(2);
|
renderer->setTextFont(2);
|
||||||
if (Settings.display_width<240) {
|
renderer->DrawStringAt(30, (Settings.display_height-12)/2, "ST7789 TFT!", ST7789_WHITE,0);
|
||||||
fontSize = 1;
|
|
||||||
}
|
|
||||||
renderer->setTextFont(fontSize);
|
|
||||||
int fontHeight = 12 * fontSize;
|
|
||||||
renderer->DrawStringAt(30, (Settings.display_height-fontHeight)/2, "ST7789 TFT!", ST7789_WHITE,0);
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,8 +125,8 @@ void ST7789_InitDriver(void) {
|
||||||
#define SDA_2 23
|
#define SDA_2 23
|
||||||
#define SCL_2 32
|
#define SCL_2 32
|
||||||
#ifdef USE_LANBON_L8
|
#ifdef USE_LANBON_L8
|
||||||
#undef SDA_2
|
#undef SDA_2
|
||||||
#undef SCL_2
|
#undef SCL_2
|
||||||
#define SDA_2 4
|
#define SDA_2 4
|
||||||
#define SCL_2 0
|
#define SCL_2 0
|
||||||
#endif // USE_LANBON_L8
|
#endif // USE_LANBON_L8
|
||||||
|
|
|
@ -94,10 +94,9 @@ void ILI9341_2_InitDriver()
|
||||||
#ifdef SHOW_SPLASH
|
#ifdef SHOW_SPLASH
|
||||||
// Welcome text
|
// Welcome text
|
||||||
renderer->setTextFont(2);
|
renderer->setTextFont(2);
|
||||||
renderer->setTextColor(ILI9341_2_WHITE,ILI9341_2_BLACK);
|
renderer->setTextColor(ILI9341_2_WHITE, ILI9341_2_BLACK);
|
||||||
renderer->DrawStringAt(20, 140, "ILI9341 TFT!", ILI9341_2_RED,0);
|
renderer->DrawStringAt(30, (Settings.display_height/2)-12, "ILI9341 TFT!", ILI9341_2_WHITE, 0);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
renderer->clearDisplay();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
color_type = COLOR_COLOR;
|
color_type = COLOR_COLOR;
|
||||||
|
|
Loading…
Reference in New Issue