mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
fix pushcolors
This commit is contained in:
parent
22356d511b
commit
df56218d9d
@ -946,6 +946,9 @@ for(y=h; y>0; y--) {
|
||||
|
||||
|
||||
void uDisplay::Splash(void) {
|
||||
|
||||
if (splash_font < 0) return;
|
||||
|
||||
if (ep_mode) {
|
||||
Updateframe();
|
||||
delay(lut3time * 10);
|
||||
@ -1033,51 +1036,95 @@ void uDisplay::setAddrWindow_int(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
}
|
||||
|
||||
|
||||
#define CNV_B1_OR ((0x10<<11) | (0x20<<5) | 0x10)
|
||||
static inline uint8_t ulv_color_to1(uint16_t color) {
|
||||
if (((color>>11) & 0x10) || ((color>>5) & 0x20) || (color & 0x10)) {
|
||||
if (color & CNV_B1_OR) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
// this needs optimization
|
||||
if (((color>>11) & 0x10) || ((color>>5) & 0x20) || (color & 0x10)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}*/
|
||||
}
|
||||
void uDisplay::pushColors(uint16_t *data, uint16_t len, boolean not_inverted) {
|
||||
|
||||
// convert to mono, these are framebuffer based
|
||||
void uDisplay::pushColorsMono(uint16_t *data, uint16_t len) {
|
||||
for (uint32_t y = seta_yp1; y < seta_yp2; y++) {
|
||||
for (uint32_t x = seta_xp1; x < seta_xp2; x++) {
|
||||
uint16_t color = *data++;
|
||||
if (bpp == 1) color = ulv_color_to1(color);
|
||||
drawPixel(x, y, color);
|
||||
len--;
|
||||
if (!len) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// swap high low byte
|
||||
static inline void lvgl_color_swap(uint16_t *data, uint16_t len) { for (uint32_t i = 0; i < len; i++) (data[i] = data[i] << 8 | data[i] >> 8); }
|
||||
|
||||
void uDisplay::pushColors(uint16_t *data, uint16_t len, boolean not_swapped) {
|
||||
uint16_t color;
|
||||
|
||||
//Serial.printf("push %x - %d\n", (uint32_t)data, len);
|
||||
if (not_swapped == false) {
|
||||
// called from LVGL bytes are swapped
|
||||
if (bpp != 16) {
|
||||
lvgl_color_swap(data, len);
|
||||
pushColorsMono(data, len);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bpp != 16) {
|
||||
// stupid monchrome version
|
||||
for (uint32_t y = seta_yp1; y < seta_yp2; y++) {
|
||||
for (uint32_t x = seta_xp1; x < seta_xp2; x++) {
|
||||
uint16_t color = *data++;
|
||||
drawPixel(x, y, ulv_color_to1(color));
|
||||
len--;
|
||||
if (!len) return;
|
||||
if ( (col_mode != 18) && (spi_dc >= 0) && (spi_nr <= 2) ) {
|
||||
// special version 8 bit spi I or II
|
||||
#ifdef ESP8266
|
||||
lvgl_color_swap(data, len);
|
||||
while (len--) {
|
||||
uspi->write(*data++);
|
||||
}
|
||||
#else
|
||||
if (lvgl_param.use_dma) {
|
||||
pushPixelsDMA(data, len );
|
||||
} else {
|
||||
uspi->writeBytes((uint8_t*)data, len * 2);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// 9 bit and others
|
||||
lvgl_color_swap(data, len);
|
||||
while (len--) {
|
||||
WriteColor(*data++);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (col_mode != 18) && (spi_dc >= 0) && (spi_nr <= 2) ) {
|
||||
// special version 8 bit spi I or II
|
||||
#ifdef ESP8266
|
||||
while (len--) {
|
||||
uspi->write(*data++);
|
||||
}
|
||||
#else
|
||||
if (lvgl_param.use_dma) {
|
||||
pushPixelsDMA(data, len );
|
||||
} else {
|
||||
uspi->writeBytes((uint8_t*)data, len * 2);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
while (len--) {
|
||||
WriteColor(*data++);
|
||||
// called from displaytext, no byte swap, currently no dma here
|
||||
if (bpp != 16) {
|
||||
pushColorsMono(data, len);
|
||||
return;
|
||||
}
|
||||
if ( (col_mode != 18) && (spi_dc >= 0) && (spi_nr <= 2) ) {
|
||||
// special version 8 bit spi I or II
|
||||
#ifdef ESP8266
|
||||
while (len--) {
|
||||
uspi->write(*data++);
|
||||
}
|
||||
#else
|
||||
uspi->writePixels(data, len * 2);
|
||||
#endif
|
||||
} else {
|
||||
// 9 bit and others
|
||||
while (len--) {
|
||||
WriteColor(*data++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void uDisplay::WriteColor(uint16_t color) {
|
||||
|
@ -214,6 +214,7 @@ class uDisplay : public Renderer {
|
||||
uint16_t seta_xp2;
|
||||
uint16_t seta_yp1;
|
||||
uint16_t seta_yp2;
|
||||
void pushColorsMono(uint16_t *data, uint16_t len);
|
||||
#ifdef ESP32
|
||||
// dma section
|
||||
bool DMA_Enabled = false;
|
||||
|
@ -25,6 +25,7 @@ SOFTWARE.
|
||||
#include "RA8876.h"
|
||||
#include <limits.h>
|
||||
|
||||
uint8_t initdone;
|
||||
/* TODO
|
||||
|
||||
font 0 x and y size with line,col cmd
|
||||
@ -123,6 +124,9 @@ uint8_t RA8876::readStatus(void) {
|
||||
void RA8876::writeReg(uint8_t reg, uint8_t x) {
|
||||
writeCmd(reg);
|
||||
writeData(x);
|
||||
if (!initdone) {
|
||||
// Serial.printf("%02x, %02x\n", reg, x);
|
||||
}
|
||||
}
|
||||
|
||||
// Like writeReg(), but does two successive register writes of a 16-bit value, low byte first.
|
||||
@ -593,7 +597,7 @@ bool RA8876::initDisplay() {
|
||||
// TODO: Track backlight pin and turn on backlight
|
||||
|
||||
SPI.endTransaction();
|
||||
|
||||
initdone = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -935,7 +939,14 @@ void RA8876::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
void RA8876::pushColors(uint16_t *data, uint16_t len, boolean first) {
|
||||
static inline void lvgl_color_swap1(uint16_t *data, uint16_t len) { for (uint32_t i = 0; i < len; i++) (data[i] = data[i] << 8 | data[i] >> 8); }
|
||||
|
||||
void RA8876::pushColors(uint16_t *data, uint16_t len, boolean not_swapped) {
|
||||
|
||||
if (not_swapped == false) {
|
||||
lvgl_color_swap1(data, len);
|
||||
}
|
||||
|
||||
SPI.beginTransaction(m_spiSettings);
|
||||
//RA8876_CS_LOW
|
||||
while (len--) {
|
||||
|
@ -170,7 +170,14 @@ void Epd47::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
|
||||
}
|
||||
|
||||
void Epd47::pushColors(uint16_t *data, uint16_t len, boolean first) {
|
||||
static inline void lvgl_color_swap2(uint16_t *data, uint16_t len) { for (uint32_t i = 0; i < len; i++) (data[i] = data[i] << 8 | data[i] >> 8); }
|
||||
|
||||
void Epd47::pushColors(uint16_t *data, uint16_t len, boolean not_swapped) {
|
||||
|
||||
if (not_swapped == false) {
|
||||
lvgl_color_swap2(data, len);
|
||||
}
|
||||
|
||||
// stupid bw version
|
||||
uint16_t x1 = seta_xp1;
|
||||
uint16_t x2 = seta_xp2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user