You've already forked TEF6686_ESP32
major clean ups in tft_espi
This commit is contained in:
BIN
images/IMG_20260217_180651.png
Normal file
BIN
images/IMG_20260217_180651.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 MiB |
BIN
images/IMG_20260217_180735.png
Normal file
BIN
images/IMG_20260217_180735.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 MiB |
1
images/readme.txt
Normal file
1
images/readme.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Sorry for the bad quality, but no one asked for photos, so you still should congratulate me for them
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -106,6 +106,7 @@
|
|||||||
#include <pgmspace.h>
|
#include <pgmspace.h>
|
||||||
|
|
||||||
#include "soc/spi_reg.h"
|
#include "soc/spi_reg.h"
|
||||||
|
#include "soc/rtc.h"
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#include "hal/gpio_ll.h"
|
#include "hal/gpio_ll.h"
|
||||||
|
|
||||||
@@ -127,7 +128,7 @@
|
|||||||
#define WR_L
|
#define WR_L
|
||||||
#define WR_H
|
#define WR_H
|
||||||
|
|
||||||
#define TFT_MISO -1
|
#define TFT_MISO 19
|
||||||
#define TFT_MOSI 23
|
#define TFT_MOSI 23
|
||||||
#define TFT_SCLK 18
|
#define TFT_SCLK 18
|
||||||
#define TFT_CS 5
|
#define TFT_CS 5
|
||||||
@@ -163,7 +164,7 @@
|
|||||||
// Write same value twice
|
// Write same value twice
|
||||||
#define tft_Write_32D(C) TFT_WRITE_BITS((uint16_t)((C)<<8 | (C)>>8)<<16 | (uint16_t)((C)<<8 | (C)>>8), 32)
|
#define tft_Write_32D(C) TFT_WRITE_BITS((uint16_t)((C)<<8 | (C)>>8)<<16 | (uint16_t)((C)<<8 | (C)>>8), 32)
|
||||||
|
|
||||||
#define tft_Read_8() transfer(0)
|
#define tft_Read_8() spi_transfer(0)
|
||||||
|
|
||||||
#define DAT8TO32(P) ( (uint32_t)P[0]<<8 | P[1] | P[2]<<24 | P[3]<<16 )
|
#define DAT8TO32(P) ( (uint32_t)P[0]<<8 | P[1] | P[2]<<24 | P[3]<<16 )
|
||||||
|
|
||||||
@@ -218,28 +219,6 @@
|
|||||||
// Convenient for 8-bit and 16-bit transparent sprites.
|
// Convenient for 8-bit and 16-bit transparent sprites.
|
||||||
#define TFT_TRANSPARENT 0x0120 // This is actually a dark green
|
#define TFT_TRANSPARENT 0x0120 // This is actually a dark green
|
||||||
|
|
||||||
// Default palette for 4-bit colour sprites
|
|
||||||
static const uint16_t default_4bit_palette[] PROGMEM = {
|
|
||||||
TFT_BLACK, // 0 ^
|
|
||||||
TFT_BROWN, // 1 |
|
|
||||||
TFT_RED, // 2 |
|
|
||||||
TFT_ORANGE, // 3 |
|
|
||||||
TFT_YELLOW, // 4 Colours 0-9 follow the resistor colour code!
|
|
||||||
TFT_GREEN, // 5 |
|
|
||||||
TFT_BLUE, // 6 |
|
|
||||||
TFT_PURPLE, // 7 |
|
|
||||||
TFT_DARKGREY, // 8 |
|
|
||||||
TFT_WHITE, // 9 v
|
|
||||||
TFT_CYAN, // 10 Blue+green mix
|
|
||||||
TFT_MAGENTA, // 11 Blue+red mix
|
|
||||||
TFT_MAROON, // 12 Darker red colour
|
|
||||||
TFT_DARKGREEN,// 13 Darker green colour
|
|
||||||
TFT_NAVY, // 14 Darker blue colour
|
|
||||||
TFT_PINK // 15
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef uint16_t (*getColorCallback)(uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
class TFT_eSPI { friend class TFT_eSprite;
|
class TFT_eSPI { friend class TFT_eSprite;
|
||||||
public:
|
public:
|
||||||
void setSPISpeed(uint8_t speed_Mhz);
|
void setSPISpeed(uint8_t speed_Mhz);
|
||||||
@@ -254,7 +233,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
|
|
||||||
virtual int16_t height(),
|
virtual int16_t height(),
|
||||||
width();
|
width();
|
||||||
virtual uint16_t readPixel(int32_t x, int32_t y);
|
|
||||||
virtual void setWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
virtual void setWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||||
virtual void pushColor(uint16_t color);
|
virtual void pushColor(uint16_t color);
|
||||||
virtual void begin_nin_write();
|
virtual void begin_nin_write();
|
||||||
@@ -281,7 +259,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
bool getSwapBytes();
|
bool getSwapBytes();
|
||||||
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||||
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor);
|
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor);
|
||||||
void setPivot(int16_t x, int16_t y);
|
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
||||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
||||||
@@ -351,7 +328,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
||||||
|
|
||||||
uint8_t textfont, // Current selected font number
|
uint8_t textfont, // Current selected font number
|
||||||
textsize, // Current font size multiplier
|
|
||||||
textdatum, // Text reference datum
|
textdatum, // Text reference datum
|
||||||
rotation; // Display rotation (0-3)
|
rotation; // Display rotation (0-3)
|
||||||
|
|
||||||
@@ -401,23 +377,20 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
|
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
|
||||||
void setTouch(uint16_t *data);
|
void setTouch(uint16_t *data);
|
||||||
|
|
||||||
//--------------------------------------- private ------------------------------------//
|
void begin_tft_write();
|
||||||
|
void end_tft_write();
|
||||||
|
|
||||||
|
void begin_tft_read();
|
||||||
|
void end_tft_read();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void begin_tft_write() __attribute__((always_inline));
|
|
||||||
inline void end_tft_write() __attribute__((always_inline));
|
|
||||||
|
|
||||||
inline void begin_tft_read() __attribute__((always_inline));
|
|
||||||
inline void end_tft_read() __attribute__((always_inline));
|
|
||||||
|
|
||||||
void initBus();
|
void initBus();
|
||||||
|
|
||||||
void pushSwapBytePixels(const void* data_in, uint32_t len);
|
void pushSwapBytePixels(const void* data_in, uint32_t len);
|
||||||
|
|
||||||
void readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
void readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
||||||
|
|
||||||
getColorCallback getColor = nullptr; // Smooth font callback function pointer
|
void loadMetrics(uint8_t font);
|
||||||
|
|
||||||
void loadMetrics(uint8_t font); // FoF
|
|
||||||
uint32_t readInt32();
|
uint32_t readInt32();
|
||||||
|
|
||||||
uint8_t* fontPtr = nullptr;
|
uint8_t* fontPtr = nullptr;
|
||||||
@@ -430,9 +403,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
int32_t _width, _height; // Display w/h as modified by current rotation
|
int32_t _width, _height; // Display w/h as modified by current rotation
|
||||||
int32_t addr_row, addr_col; // Window position - used to minimise window commands
|
int32_t addr_row, addr_col; // Window position - used to minimise window commands
|
||||||
|
|
||||||
int16_t _xPivot; // TFT x pivot point coordinate for rotated Sprites
|
|
||||||
int16_t _yPivot; // TFT x pivot point coordinate for rotated Sprites
|
|
||||||
|
|
||||||
// Viewport variables
|
// Viewport variables
|
||||||
int32_t _vpX, _vpY, _vpW, _vpH; // Note: x start, y start, x end + 1, y end + 1
|
int32_t _vpX, _vpY, _vpW, _vpH; // Note: x start, y start, x end + 1, y end + 1
|
||||||
int32_t _xDatum;
|
int32_t _xDatum;
|
||||||
@@ -470,16 +440,10 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
public:
|
public:
|
||||||
explicit TFT_eSprite(TFT_eSPI *tft);
|
explicit TFT_eSprite(TFT_eSPI *tft);
|
||||||
~TFT_eSprite();
|
~TFT_eSprite();
|
||||||
void* createSprite(int16_t width = TFT_WIDTH, int16_t height = TFT_HEIGHT, uint8_t frames = 1);
|
void* createSprite(int16_t width = TFT_WIDTH, int16_t height = TFT_HEIGHT);
|
||||||
void* getPointer();
|
void* getPointer();
|
||||||
bool created();
|
bool created();
|
||||||
void deleteSprite();
|
void deleteSprite();
|
||||||
void* setColorDepth(int8_t b);
|
|
||||||
int8_t getColorDepth();
|
|
||||||
void createPalette(uint16_t *palette = nullptr, uint8_t colors = 16);
|
|
||||||
void createPalette(const uint16_t *palette = nullptr, uint8_t colors = 16);
|
|
||||||
void setPaletteColor(uint8_t index, uint16_t color);
|
|
||||||
uint16_t getPaletteColor(uint8_t index);
|
|
||||||
void drawPixel(int32_t x, int32_t y, uint32_t color);
|
void drawPixel(int32_t x, int32_t y, uint32_t color);
|
||||||
void fillSprite(uint32_t color),
|
void fillSprite(uint32_t color),
|
||||||
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
||||||
@@ -490,8 +454,6 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
||||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||||
uint16_t readPixel(int32_t x0, int32_t y0);
|
|
||||||
uint16_t readPixelValue(int32_t x, int32_t y);
|
|
||||||
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp = 0);
|
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp = 0);
|
||||||
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, const uint16_t *data);
|
void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, const uint16_t *data);
|
||||||
void pushSprite(int32_t x, int32_t y);
|
void pushSprite(int32_t x, int32_t y);
|
||||||
@@ -509,18 +471,11 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
|
|
||||||
TFT_eSPI *_tft;
|
TFT_eSPI *_tft;
|
||||||
|
|
||||||
void* callocSprite(int16_t width, int16_t height, uint8_t frames = 1);
|
void* callocSprite(int16_t width, int16_t height);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint8_t _bpp; // bits per pixel (1, 4, 8 or 16)
|
|
||||||
uint16_t *_img; // pointer to 16-bit sprite
|
uint16_t *_img; // pointer to 16-bit sprite
|
||||||
uint8_t *_img8; // pointer to 1 and 8-bit sprite frame 1 or frame 2
|
|
||||||
uint8_t *_img4; // pointer to 4-bit sprite (uses color map)
|
|
||||||
uint8_t *_img8_1; // pointer to frame 1
|
|
||||||
uint8_t *_img8_2; // pointer to frame 2
|
|
||||||
|
|
||||||
uint16_t *_colorMap; // color map pointer: 16 entries, used with 4-bit color map.
|
|
||||||
|
|
||||||
int32_t _sinra; // Sine of rotation angle in fixed point
|
int32_t _sinra; // Sine of rotation angle in fixed point
|
||||||
int32_t _cosra; // Cosine of rotation angle in fixed point
|
int32_t _cosra; // Cosine of rotation angle in fixed point
|
||||||
@@ -533,8 +488,7 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
uint32_t _scolor;
|
uint32_t _scolor;
|
||||||
|
|
||||||
int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations)
|
int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations)
|
||||||
int32_t _dwidth, _dheight; // Real sprite width and height (for <8bpp Sprites)
|
int32_t _dwidth, _dheight; // Real sprite width and height
|
||||||
int32_t _bitwidth; // Sprite image bit width for drawPixel (for <8bpp Sprites, not swapped)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> static inline void transpose(T& a, T& b) { T t = a; a = b; b = t; }
|
template <typename T> static inline void transpose(T& a, T& b) { T t = a; a = b; b = t; }
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ bool Tuner_ReadBuffer(unsigned char *buf, uint16_t len) {
|
|||||||
static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
||||||
unsigned char buf[24 + 1];
|
unsigned char buf[24 + 1];
|
||||||
uint16_t i, len;
|
uint16_t i, len;
|
||||||
uint16_t r;
|
|
||||||
buf[0] = 0x1b;
|
buf[0] = 0x1b;
|
||||||
|
|
||||||
while (size) {
|
while (size) {
|
||||||
|
|||||||
@@ -945,10 +945,7 @@ void total_pc_control() {
|
|||||||
switch (data[0]) {
|
switch (data[0]) {
|
||||||
case 0: { // Set clock
|
case 0: { // Set clock
|
||||||
if(len < 5) break;
|
if(len < 5) break;
|
||||||
uint32_t clock = ((uint32_t)data[1] << 24) |
|
uint32_t clock = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]);
|
||||||
((uint32_t)data[2] << 16) |
|
|
||||||
((uint32_t)data[3] << 8) |
|
|
||||||
((uint32_t)data[4]);
|
|
||||||
Wire.setClock(clock);
|
Wire.setClock(clock);
|
||||||
Serial.write(1);
|
Serial.write(1);
|
||||||
Serial.write(0);
|
Serial.write(0);
|
||||||
@@ -973,9 +970,7 @@ void total_pc_control() {
|
|||||||
Wire.write(data + 3, len - 3);
|
Wire.write(data + 3, len - 3);
|
||||||
auto out = Wire.endTransmission(false);
|
auto out = Wire.endTransmission(false);
|
||||||
|
|
||||||
uint8_t recvlen_requested = data[3+datalen];
|
uint8_t recvlen = Wire.requestFrom(addr, data[3+datalen]);
|
||||||
uint8_t recvlen = Wire.requestFrom(addr, recvlen_requested);
|
|
||||||
|
|
||||||
Serial.write(recvlen+2);
|
Serial.write(recvlen+2);
|
||||||
Serial.write(2);
|
Serial.write(2);
|
||||||
Serial.write(out);
|
Serial.write(out);
|
||||||
@@ -992,13 +987,12 @@ void total_pc_control() {
|
|||||||
case 4: { // Version
|
case 4: { // Version
|
||||||
Serial.write(2);
|
Serial.write(2);
|
||||||
Serial.write(4);
|
Serial.write(4);
|
||||||
Serial.write(0);
|
Serial.write(1);
|
||||||
} break;
|
} break;
|
||||||
case 5: { // Reboot
|
case 5: { // Reboot
|
||||||
Serial.write(1);
|
Serial.write(1);
|
||||||
Serial.write(5);
|
Serial.write(5);
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
delay(5);
|
|
||||||
esp_restart();
|
esp_restart();
|
||||||
} break;
|
} break;
|
||||||
case 6: { // Change baud
|
case 6: { // Change baud
|
||||||
@@ -1009,9 +1003,14 @@ void total_pc_control() {
|
|||||||
((uint32_t)data[4]);
|
((uint32_t)data[4]);
|
||||||
Serial.write(1);
|
Serial.write(1);
|
||||||
Serial.write(6);
|
Serial.write(6);
|
||||||
Serial.flush(true);
|
Serial.flush();
|
||||||
Serial.updateBaudRate(clock);
|
Serial.updateBaudRate(clock);
|
||||||
} break;
|
} break;
|
||||||
|
case 0xff: { // Another wake command
|
||||||
|
Serial.write(1);
|
||||||
|
Serial.write(0xff);
|
||||||
|
Serial.flush(true);
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user