mirror of https://github.com/arendst/Tasmota.git
epd47 lvgl support
This commit is contained in:
parent
c875345c18
commit
3727ba977a
|
@ -624,6 +624,10 @@ char *Renderer::devname(void) {
|
||||||
return (char*)dname;
|
return (char*)dname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t Renderer::lvgl_pars(void) {
|
||||||
|
return lvgl_param;
|
||||||
|
}
|
||||||
|
|
||||||
void VButton::xdrawButton(bool inverted) {
|
void VButton::xdrawButton(bool inverted) {
|
||||||
wr_redir=1;
|
wr_redir=1;
|
||||||
drawButton(inverted);
|
drawButton(inverted);
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
virtual int8_t color_type(void);
|
virtual int8_t color_type(void);
|
||||||
virtual void Splash(void);
|
virtual void Splash(void);
|
||||||
virtual char *devname(void);
|
virtual char *devname(void);
|
||||||
|
virtual uint16_t lvgl_pars(void);
|
||||||
|
|
||||||
void setDrawMode(uint8_t mode);
|
void setDrawMode(uint8_t mode);
|
||||||
uint8_t drawmode;
|
uint8_t drawmode;
|
||||||
|
@ -59,6 +60,7 @@ public:
|
||||||
virtual uint8_t *allocate_framebuffer(uint32_t size);
|
virtual uint8_t *allocate_framebuffer(uint32_t size);
|
||||||
pwr_cb pwr_cbp = 0;
|
pwr_cb pwr_cbp = 0;
|
||||||
dim_cb dim_cbp = 0;
|
dim_cb dim_cbp = 0;
|
||||||
|
uint16_t lvgl_param = 0;
|
||||||
private:
|
private:
|
||||||
void DrawCharAt(int16_t x, int16_t y, char ascii_char,int16_t colored);
|
void DrawCharAt(int16_t x, int16_t y, char ascii_char,int16_t colored);
|
||||||
inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
|
inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
|
||||||
|
|
|
@ -282,6 +282,9 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
|
||||||
lutptime = next_val(&lp1);
|
lutptime = next_val(&lp1);
|
||||||
lut3time = next_val(&lp1);
|
lut3time = next_val(&lp1);
|
||||||
break;
|
break;
|
||||||
|
case 'B':
|
||||||
|
lvgl_param = next_val(&lp1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,7 +930,9 @@ void uDisplay::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
|
||||||
if (bpp != 16) {
|
if (bpp != 16) {
|
||||||
// just save params or update frame
|
// just save params or update frame
|
||||||
if (!x0 && !y0 && !x1 && !y1) {
|
if (!x0 && !y0 && !x1 && !y1) {
|
||||||
Updateframe();
|
if (!ep_mode) {
|
||||||
|
Updateframe();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
seta_xp1 = x0;
|
seta_xp1 = x0;
|
||||||
seta_xp2 = x1;
|
seta_xp2 = x1;
|
||||||
|
|
|
@ -61,7 +61,7 @@ int32_t Epd47::Init(void) {
|
||||||
epd_init(EPD_LUT_1K);
|
epd_init(EPD_LUT_1K);
|
||||||
hl = epd_hl_init(WAVEFORM);
|
hl = epd_hl_init(WAVEFORM);
|
||||||
epd47_buffer = epd_hl_get_framebuffer(&hl);
|
epd47_buffer = epd_hl_get_framebuffer(&hl);
|
||||||
|
lvgl_param = 10;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,26 +157,42 @@ void Epd47::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Epd47::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
void Epd47::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
xp = x0;
|
|
||||||
yp = y0;
|
// just save params or update frame
|
||||||
//setAddrWindow_int(x0,y0,x1-1,y1-1);
|
if (!x0 && !y0 && !x1 && !y1) {
|
||||||
|
//Updateframe();
|
||||||
|
} else {
|
||||||
|
seta_xp1 = x0;
|
||||||
|
seta_xp2 = x1;
|
||||||
|
seta_yp1 = y0;
|
||||||
|
seta_yp2 = y1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Epd47::pushColors(uint16_t *data, uint16_t len, boolean first) {
|
void Epd47::pushColors(uint16_t *data, uint16_t len, boolean first) {
|
||||||
uint16_t color;
|
// stupid bw version
|
||||||
uint16_t cxp = xp;
|
uint16_t x1 = seta_xp1;
|
||||||
while (len--) {
|
uint16_t x2 = seta_xp2;
|
||||||
color = *data++;
|
uint16_t y1 = seta_yp1;
|
||||||
uint8_t red = ((color >> 11) & 0x1f) << 3;
|
uint16_t y2 = seta_yp2;
|
||||||
uint8_t green = ((color >> 5) & 0x3f) << 2;
|
|
||||||
uint8_t blue = (color & 0x1f) << 3;
|
|
||||||
color = (red + green + blue) / 3;
|
|
||||||
color >>= 4;
|
|
||||||
drawPixel(cxp, yp, color);
|
|
||||||
cxp++;
|
|
||||||
}
|
|
||||||
yp++;
|
|
||||||
|
|
||||||
|
for (uint32_t y = y1; y < y2; y++) {
|
||||||
|
for (uint32_t x = x1; x < x2; x++) {
|
||||||
|
uint16_t color = *data++;
|
||||||
|
uint8_t red = ((color >> 11) & 0x1f) << 3;
|
||||||
|
uint8_t green = ((color >> 5) & 0x3f) << 2;
|
||||||
|
uint8_t blue = (color & 0x1f) << 3;
|
||||||
|
color = (red + green + blue) / 3;
|
||||||
|
color >>= 4;
|
||||||
|
drawPixel(x, y, color);
|
||||||
|
len--;
|
||||||
|
if (!len) {
|
||||||
|
seta_yp1 = y + 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* END OF FILE */
|
/* END OF FILE */
|
||||||
|
|
|
@ -57,6 +57,10 @@ private:
|
||||||
uint16_t height;
|
uint16_t height;
|
||||||
uint16_t xp;
|
uint16_t xp;
|
||||||
uint16_t yp;
|
uint16_t yp;
|
||||||
|
uint16_t seta_xp1;
|
||||||
|
uint16_t seta_xp2;
|
||||||
|
uint16_t seta_yp1;
|
||||||
|
uint16_t seta_yp2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* EPD4IN7_H */
|
#endif /* EPD4IN7_H */
|
||||||
|
|
|
@ -29,9 +29,11 @@ uint32_t Touch_Status(uint32_t sel);
|
||||||
static bool touchscreen_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data) {
|
static bool touchscreen_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data) {
|
||||||
//lv_coord_t last_x = 0, last_y = 0;
|
//lv_coord_t last_x = 0, last_y = 0;
|
||||||
//static uint8_t release_count = 0;
|
//static uint8_t release_count = 0;
|
||||||
|
#if defined(USE_FT5206) || defined(USE_XPT2046)
|
||||||
data->point.x = Touch_Status(1); // Last-pressed coordinates
|
data->point.x = Touch_Status(1); // Last-pressed coordinates
|
||||||
data->point.y = Touch_Status(2);
|
data->point.y = Touch_Status(2);
|
||||||
data->state = Touch_Status(0);
|
data->state = Touch_Status(0);
|
||||||
|
#endif
|
||||||
return false; /*No buffering now so no more data read*/
|
return false; /*No buffering now so no more data read*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ static bool touchscreen_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t
|
||||||
// Actual RAM usage will be 2X these figures, since using 2 DMA buffers...
|
// Actual RAM usage will be 2X these figures, since using 2 DMA buffers...
|
||||||
#define LV_BUFFER_ROWS 60 // Most others have a bit more space
|
#define LV_BUFFER_ROWS 60 // Most others have a bit more space
|
||||||
|
|
||||||
|
|
||||||
// This is the flush function required for LittlevGL screen updates.
|
// This is the flush function required for LittlevGL screen updates.
|
||||||
// It receives a bounding rect and an array of pixel data (conveniently
|
// It receives a bounding rect and an array of pixel data (conveniently
|
||||||
// already in 565 format, so the Earth was lucky there).
|
// already in 565 format, so the Earth was lucky there).
|
||||||
|
@ -216,8 +219,9 @@ LvGLStatus Adafruit_LvGL_Glue::begin(Renderer *tft, void *touch, bool debug) {
|
||||||
|
|
||||||
uint32_t lvgl_buffer_size;
|
uint32_t lvgl_buffer_size;
|
||||||
//lvgl_buffer_size = LV_HOR_RES_MAX * LV_BUFFER_ROWS;
|
//lvgl_buffer_size = LV_HOR_RES_MAX * LV_BUFFER_ROWS;
|
||||||
lvgl_buffer_size = tft->width() * LV_BUFFER_ROWS;
|
uint8_t flushlines = tft->lvgl_pars();
|
||||||
|
lvgl_buffer_size = tft->width() * flushlines ? flushlines:LV_BUFFER_ROWS;
|
||||||
|
|
||||||
|
|
||||||
if ((lv_pixel_buf = new lv_color_t[lvgl_buffer_size])) {
|
if ((lv_pixel_buf = new lv_color_t[lvgl_buffer_size])) {
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ extern FS *ffsp;
|
||||||
|
|
||||||
#define DISPDESC_SIZE 1000
|
#define DISPDESC_SIZE 1000
|
||||||
|
|
||||||
|
|
||||||
|
void Core2DisplayPower(uint8_t on);
|
||||||
|
void Core2DisplayDim(uint8_t dim);
|
||||||
|
|
||||||
//#define DSP_ROM_DESC
|
//#define DSP_ROM_DESC
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
@ -194,10 +198,10 @@ uDisplay *udisp;
|
||||||
//SPI,*,*,*,*,*,*,*
|
//SPI,*,*,*,*,*,*,*
|
||||||
if (cs < 0) {
|
if (cs < 0) {
|
||||||
switch (*cp) {
|
switch (*cp) {
|
||||||
case 1:
|
case '1':
|
||||||
cs = Pin(GPIO_SPI_CS);
|
cs = Pin(GPIO_SPI_CS);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case '2':
|
||||||
cs = Pin(GPIO_SPI_CS, 1);
|
cs = Pin(GPIO_SPI_CS, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -309,19 +313,25 @@ uDisplay *udisp;
|
||||||
|
|
||||||
Settings.display_width = renderer->width();
|
Settings.display_width = renderer->width();
|
||||||
Settings.display_height = renderer->height();
|
Settings.display_height = renderer->height();
|
||||||
fg_color = udisp->fgcol();
|
fg_color = renderer->fgcol();
|
||||||
bg_color = udisp->bgcol();
|
bg_color = renderer->bgcol();
|
||||||
color_type = udisp->color_type();
|
color_type = renderer->color_type();
|
||||||
|
|
||||||
|
#ifdef USE_M5STACK_CORE2
|
||||||
|
renderer->SetPwrCB(Core2DisplayPower);
|
||||||
|
renderer->SetDimCB(Core2DisplayDim);
|
||||||
|
#endif
|
||||||
|
|
||||||
renderer->DisplayInit(DISPLAY_INIT_MODE, Settings.display_size, Settings.display_rotate, Settings.display_font);
|
renderer->DisplayInit(DISPLAY_INIT_MODE, Settings.display_size, Settings.display_rotate, Settings.display_font);
|
||||||
renderer->dim(Settings.display_dimmer);
|
renderer->dim(Settings.display_dimmer);
|
||||||
|
|
||||||
#ifdef SHOW_SPLASH
|
#ifdef SHOW_SPLASH
|
||||||
udisp->Splash();
|
renderer->Splash();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
udisp_init_done = true;
|
udisp_init_done = true;
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("DSP: %s!"), udisp->devname());
|
AddLog(LOG_LEVEL_INFO, PSTR("DSP: %s!"), renderer->devname());
|
||||||
|
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -330,8 +340,7 @@ uDisplay *udisp;
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
void Core2DisplayPower(uint8_t on);
|
/*
|
||||||
void Core2DisplayDim(uint8_t dim);
|
|
||||||
|
|
||||||
void udisp_bpwr(uint8_t on) {
|
void udisp_bpwr(uint8_t on) {
|
||||||
#ifdef USE_M5STACK_CORE2
|
#ifdef USE_M5STACK_CORE2
|
||||||
|
@ -345,6 +354,8 @@ void udisp_dimm(uint8_t dim) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
void TS_RotConvert(int16_t *x, int16_t *y) {
|
void TS_RotConvert(int16_t *x, int16_t *y) {
|
||||||
if (renderer) renderer->TS_RotConvert(x, y);
|
if (renderer) renderer->TS_RotConvert(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue