fix pushcolors

This commit is contained in:
gemu2015 2021-04-28 08:34:11 +02:00
parent 22356d511b
commit df56218d9d
4 changed files with 98 additions and 32 deletions

View File

@ -946,6 +946,9 @@ for(y=h; y>0; y--) {
void uDisplay::Splash(void) { void uDisplay::Splash(void) {
if (splash_font < 0) return;
if (ep_mode) { if (ep_mode) {
Updateframe(); Updateframe();
delay(lut3time * 10); 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) { 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; return 1;
} }
else { else {
return 0; 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; uint16_t color;
//Serial.printf("push %x - %d\n", (uint32_t)data, len); //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) { if ( (col_mode != 18) && (spi_dc >= 0) && (spi_nr <= 2) ) {
// stupid monchrome version // special version 8 bit spi I or II
for (uint32_t y = seta_yp1; y < seta_yp2; y++) { #ifdef ESP8266
for (uint32_t x = seta_xp1; x < seta_xp2; x++) { lvgl_color_swap(data, len);
uint16_t color = *data++; while (len--) {
drawPixel(x, y, ulv_color_to1(color)); uspi->write(*data++);
len--; }
if (!len) return; #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 { } else {
while (len--) { // called from displaytext, no byte swap, currently no dma here
WriteColor(*data++); 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) { void uDisplay::WriteColor(uint16_t color) {

View File

@ -214,6 +214,7 @@ class uDisplay : public Renderer {
uint16_t seta_xp2; uint16_t seta_xp2;
uint16_t seta_yp1; uint16_t seta_yp1;
uint16_t seta_yp2; uint16_t seta_yp2;
void pushColorsMono(uint16_t *data, uint16_t len);
#ifdef ESP32 #ifdef ESP32
// dma section // dma section
bool DMA_Enabled = false; bool DMA_Enabled = false;

View File

@ -25,6 +25,7 @@ SOFTWARE.
#include "RA8876.h" #include "RA8876.h"
#include <limits.h> #include <limits.h>
uint8_t initdone;
/* TODO /* TODO
font 0 x and y size with line,col cmd 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) { void RA8876::writeReg(uint8_t reg, uint8_t x) {
writeCmd(reg); writeCmd(reg);
writeData(x); 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. // 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 // TODO: Track backlight pin and turn on backlight
SPI.endTransaction(); SPI.endTransaction();
initdone = 1;
return true; return true;
} }
@ -935,7 +939,14 @@ void RA8876::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
SPI.endTransaction(); 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); SPI.beginTransaction(m_spiSettings);
//RA8876_CS_LOW //RA8876_CS_LOW
while (len--) { while (len--) {

View File

@ -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 // stupid bw version
uint16_t x1 = seta_xp1; uint16_t x1 = seta_xp1;
uint16_t x2 = seta_xp2; uint16_t x2 = seta_xp2;