mirror of https://github.com/arendst/Tasmota.git
picture buttons part 1
This commit is contained in:
parent
aa943fc696
commit
448daed0d1
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue