faster ili9488 fill

This commit is contained in:
gemu2015 2020-05-29 20:54:15 +02:00
parent 357341899c
commit 671942aa60
1 changed files with 28 additions and 2 deletions

View File

@ -74,6 +74,9 @@ uint8_t ili9488_start;
// ESP8266
#include "spi_register.h"
#define SWSPI_OPTMODE
// this enables the 27 bit packed mode
#define RGB_PACK_MODE
uint32_t ili9488_clock;
uint32_t ili9488_usr;
uint32_t ili9488_usr1;
@ -259,6 +262,8 @@ void ILI9488::writecommand(uint8_t c) {
#include "esp32-hal.h"
#include "soc/spi_struct.h"
#define RGB_PACK_MODE
// since ardunio transferBits ia completely disfunctional
// we use our own hardware driver for 9 bit spi
void ILI9488::fastSPIwrite(uint8_t d,uint8_t dc) {
@ -831,8 +836,7 @@ void ILI9488::fillScreen(uint16_t color) {
//#define WRITE_SPI_REG
// this enables the 27 bit packed mode
#define RGB_PACK_MODE
// extremely strange => if this code is merged into pack_rgb() the software crashes
// swap bytes
@ -1023,17 +1027,39 @@ void ILI9488::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t colo
g = (g * 255) / 63;
b = (b * 255) / 31;
#ifdef RGB_PACK_MODE
// init 27 bit mode
uint32_t data=pack_rgb(r,g,b);
REG_SET_BIT(SPI_USER_REG(3), SPI_USR_MOSI);
REG_WRITE(SPI_MOSI_DLEN_REG(3), 27 - 1);
uint32_t *dp=(uint32_t*)SPI_W0_REG(3);
digitalWrite( _cs, LOW);
#endif
for(y=h; y>0; y--) {
for(x=w; x>0; x--) {
#ifndef RGB_PACK_MODE
writedata(r);
writedata(g);
writedata(b);
#else
while (REG_GET_FIELD(SPI_CMD_REG(3), SPI_USR));
*dp=data;
REG_SET_BIT(SPI_CMD_REG(3), SPI_USR);
#endif
}
}
#ifdef RGB_PACK_MODE
while (REG_GET_FIELD(SPI_CMD_REG(3), SPI_USR));
digitalWrite( _cs, HIGH);
#endif
ILI9488_STOP
}
#endif
// Pass 8-bit (each) R,G,B, get back 16-bit packed color
uint16_t ILI9488::color565(uint8_t r, uint8_t g, uint8_t b) {
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);