Initialize git
This commit is contained in:
106
hal/esp32/displays/generic.hpp
Normal file
106
hal/esp32/displays/generic.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define LGFX_USE_V1
|
||||
#include "Arduino.h"
|
||||
#include <LovyanGFX.hpp>
|
||||
|
||||
#include "pins.h"
|
||||
|
||||
|
||||
class LGFX : public lgfx::LGFX_Device
|
||||
{
|
||||
|
||||
lgfx::Panel_GC9A01 _panel_instance;
|
||||
lgfx::Light_PWM _light_instance;
|
||||
lgfx::Bus_SPI _bus_instance;
|
||||
lgfx::Touch_CST816S _touch_instance;
|
||||
|
||||
public:
|
||||
LGFX(void)
|
||||
{
|
||||
{
|
||||
auto cfg = _bus_instance.config();
|
||||
|
||||
// SPI bus settings
|
||||
cfg.spi_host = SPI; // Select the SPI to use ESP32-S2,C3 : SPI2_HOST or SPI3_HOST / ESP32 : VSPI_HOST or HSPI_HOST
|
||||
// * Due to the ESP-IDF version upgrade, VSPI_HOST, The HSPI_HOST specification is deprecated, so if you get an error, use SPI2_HOST or SPI3_HOST instead.
|
||||
cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3)
|
||||
cfg.freq_write = 80000000; // SPI time (up to 80MHz, four or five inputs divided by 80MHz to get an integer)
|
||||
cfg.freq_read = 20000000; // SPI time when connected cfg.spi_3wire = true; // Set true if receiving is done via MOSI pin
|
||||
cfg.use_lock = true; // Usage lock time setting true
|
||||
cfg.dma_channel = SPI_DMA_CH_AUTO; // Set the DMA channel to use (0=DMA not used / 1=1ch / 2=ch / SPI_DMA_CH_AUTO=automatic setting) // * Due to the ESP-IDF version upgrade, SPI_DMA_CH_AUTO (automatic setting) is now recommended for the DMA channel. Specifying 1ch or 2ch is no longer recommended.
|
||||
cfg.pin_sclk = SCLK; // Set the SPI SCLK pin number
|
||||
cfg.pin_mosi = MOSI; // Set the SPI CLK pin number
|
||||
cfg.pin_miso = MISO; // Set the SPI MISO pin number (-1 = disable)
|
||||
cfg.pin_dc = DC; // Set the SPI D/C pin number (-1 = disable)
|
||||
_bus_instance.config(cfg); // Reflect the setting value to the bus.
|
||||
_panel_instance.setBus(&_bus_instance); // Set the bus to the panel.
|
||||
}
|
||||
|
||||
{ // Set the display panel control.
|
||||
auto cfg = _panel_instance.config(); // Get the structure for display panel settings.
|
||||
|
||||
cfg.pin_cs = CS; // Pin number to which CS is connected (-1 = disable)
|
||||
cfg.pin_rst = RST; // Pin number to which RST is connected (-1 = disable)
|
||||
cfg.pin_busy = -1; // Pin number to which BUSY is connected (-1 = disable)
|
||||
|
||||
/* The following settings are set to general initial values for each panel, so try commenting out any items you are unsure of. */
|
||||
|
||||
cfg.memory_width = SCREEN_WIDTH; // Maximum width supported by driver IC
|
||||
cfg.memory_height = SCREEN_HEIGHT; // Maximum height supported by driver IC
|
||||
cfg.panel_width = SCREEN_WIDTH; // Actual displayable width
|
||||
cfg.panel_height = SCREEN_HEIGHT; // Actual displayable height
|
||||
cfg.offset_x = OFFSET_X; // Panel offset in X direction
|
||||
cfg.offset_y = OFFSET_Y; // Panel offset in Y direction
|
||||
cfg.offset_rotation = 0; // Value 0~7 in rotation direction (4~7 is inverted)
|
||||
cfg.dummy_read_pixel = 8; // Virtual number of positions read before reading image
|
||||
cfg.dummy_read_bits = 1; // The number of imaginary words other than the image element
|
||||
cfg.readable = false; // As long as the number of acquisitions is as high as possible, the setting is true
|
||||
cfg.invert = true; // As a result, the brightness and darkness of the face plate is reversed, and the setting is true
|
||||
cfg.rgb_order = RGB_ORDER; // As a result, the red color and the blue color are replaced on the face plate, and the setting is true
|
||||
cfg.dlen_16bit = false; // From 16th position to 16th position, the length of the number of transfers is set to true
|
||||
cfg.bus_shared = false; // How to use drawJpgFile (e.g. summary control)
|
||||
|
||||
_panel_instance.config(cfg);
|
||||
}
|
||||
|
||||
{ // Set backlight control. (delete if not necessary)
|
||||
|
||||
auto cfg = _light_instance.config(); // Get the structure for backlight configuration.
|
||||
|
||||
cfg.pin_bl = BL; // pin number to which the backlight is connected
|
||||
cfg.invert = false; // true to invert backlight brightness
|
||||
cfg.freq = 44100; // backlight PWM frequency
|
||||
cfg.pwm_channel = 1; // PWM channel number to use
|
||||
|
||||
_light_instance.config(cfg);
|
||||
_panel_instance.setLight(&_light_instance); // Sets the backlight to the panel.
|
||||
}
|
||||
|
||||
{ // Sets touchscreen control. (Delete if not needed)
|
||||
|
||||
auto cfg = _touch_instance.config();
|
||||
cfg.x_min = 0; // Minimum X value obtained from touch screen (raw value)
|
||||
cfg.x_max = SCREEN_WIDTH; // Maximum X value obtained from touch screen (raw value)
|
||||
cfg.y_min = 0; // Minimum Y value obtained from touch screen (raw value)
|
||||
cfg.y_max = SCREEN_HEIGHT; // Maximum Y value obtained from touch screen (raw value)
|
||||
cfg.pin_int = TP_INT; // Pin number to which INT is connected
|
||||
cfg.pin_rst = TP_RST;
|
||||
cfg.bus_shared = true; // Set true if using a common bus with the screen
|
||||
cfg.offset_rotation = 0; // Adjust if display and touch orientation do not match. Set to a value between 0 and 7
|
||||
|
||||
cfg.i2c_port = 0; // Select the I2C to use (0 or 1)
|
||||
cfg.i2c_addr = 0x15; // I2C device address number
|
||||
cfg.pin_sda = I2C_SDA; // Pin number to which SDA is connected
|
||||
cfg.pin_scl = I2C_SCL; // Pin number to which SCL is connected
|
||||
cfg.freq = 400000; // Set the I2C clock
|
||||
_touch_instance.config(cfg);
|
||||
_panel_instance.setTouch(&_touch_instance); // Set the touch screen to the panel.
|
||||
}
|
||||
|
||||
setPanel(&_panel_instance); // Set the panel to use.
|
||||
}
|
||||
};
|
||||
|
||||
LGFX tft;
|
||||
294
hal/esp32/displays/pins.h
Normal file
294
hal/esp32/displays/pins.h
Normal file
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Felix Biego
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
______________ _____
|
||||
___ __/___ /_ ___(_)_____ _______ _______
|
||||
__ /_ __ __ \__ / _ _ \__ __ `/_ __ \
|
||||
_ __/ _ /_/ /_ / / __/_ /_/ / / /_/ /
|
||||
/_/ /_.___/ /_/ \___/ _\__, / \____/
|
||||
/____/
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ELECROW_C3
|
||||
|
||||
// screen configs
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
#define OFFSET_X 0
|
||||
#define OFFSET_Y 0
|
||||
#define RGB_ORDER false
|
||||
|
||||
// touch
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 5
|
||||
#define TP_INT 0
|
||||
#define TP_RST -1
|
||||
|
||||
// display
|
||||
#define SPI SPI2_HOST
|
||||
|
||||
#define SCLK 6
|
||||
#define MOSI 7
|
||||
#define MISO -1
|
||||
#define DC 2
|
||||
#define CS 10
|
||||
#define RST -1
|
||||
|
||||
#define BL -1 // unused (connected on IO extender)
|
||||
#define VIBRATION_PIN 0 // dummy (connected on IO extender)
|
||||
|
||||
#define BUZZER_PIN 3
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif ESPC3
|
||||
|
||||
// screen configs
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
#define OFFSET_X 0
|
||||
#define OFFSET_Y 0
|
||||
#define RGB_ORDER false
|
||||
|
||||
// touch
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 5
|
||||
#define TP_INT 0
|
||||
#define TP_RST 1
|
||||
|
||||
// display
|
||||
#define SPI SPI2_HOST
|
||||
|
||||
#define SCLK 6
|
||||
#define MOSI 7
|
||||
#define MISO -1
|
||||
#define DC 2
|
||||
#define CS 10
|
||||
#define RST -1
|
||||
|
||||
#define BL 3
|
||||
|
||||
#define BUZZER_PIN -1
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif ESPS3_1_28
|
||||
|
||||
// screen configs
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
#define OFFSET_X 0
|
||||
#define OFFSET_Y 0
|
||||
#define RGB_ORDER false
|
||||
|
||||
// touch
|
||||
#define I2C_SDA 6
|
||||
#define I2C_SCL 7
|
||||
#define TP_INT 5
|
||||
#define TP_RST 13
|
||||
|
||||
// display
|
||||
#define SPI SPI2_HOST
|
||||
|
||||
#define SCLK 10
|
||||
#define MOSI 11
|
||||
#define MISO 12
|
||||
#define DC 8
|
||||
#define CS 9
|
||||
#define RST 14
|
||||
|
||||
#define BL 2
|
||||
|
||||
#define BUZZER_PIN -1
|
||||
|
||||
#define MAX_FILE_OPEN 50
|
||||
|
||||
#elif ESPS3_1_69
|
||||
|
||||
// screen configs
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 280
|
||||
#define OFFSET_X 0
|
||||
#define OFFSET_Y 20
|
||||
#define RGB_ORDER true
|
||||
|
||||
// touch
|
||||
#define I2C_SDA 11
|
||||
#define I2C_SCL 10
|
||||
#define TP_INT 14
|
||||
#define TP_RST 13
|
||||
|
||||
// display
|
||||
#define SPI SPI2_HOST
|
||||
|
||||
#define SCLK 6
|
||||
#define MOSI 7
|
||||
#define MISO -1
|
||||
#define DC 4
|
||||
#define CS 5
|
||||
#define RST 8
|
||||
|
||||
#define BL 15
|
||||
|
||||
#define BUZZER_PIN -1 //33
|
||||
|
||||
#define MAX_FILE_OPEN 20
|
||||
|
||||
#elif ESPS3_2_06
|
||||
|
||||
#define SCREEN_WIDTH 410
|
||||
#define SCREEN_HEIGHT 502
|
||||
|
||||
#define LCD_CS 12
|
||||
#define LCD_SCK 11
|
||||
#define LCD_SD0 4
|
||||
#define LCD_SD1 5
|
||||
#define LCD_SD2 6
|
||||
#define LCD_SD3 7
|
||||
#define LCD_RST 8
|
||||
|
||||
#define TOUCH_SDA 15
|
||||
#define TOUCH_SCL 14
|
||||
#define TOUCH_RST 9
|
||||
#define TOUCH_IRQ 38
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif M5_STACK_DIAL
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
||||
#define BUZZER_PIN 3
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif ESPS3_1_75
|
||||
|
||||
#define SCREEN_WIDTH 466
|
||||
#define SCREEN_HEIGHT 466
|
||||
|
||||
#define LCD_CS 12
|
||||
#define LCD_SCK 38
|
||||
#define LCD_SD0 4
|
||||
#define LCD_SD1 5
|
||||
#define LCD_SD2 6
|
||||
#define LCD_SD3 7
|
||||
#define LCD_RST 39
|
||||
|
||||
#define TOUCH_SDA 15
|
||||
#define TOUCH_SCL 14
|
||||
#define TOUCH_RST 40
|
||||
#define TOUCH_IRQ 11
|
||||
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
|
||||
#elif M5_STACK_DIAL
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
||||
#define BUZZER_PIN 3
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif VIEWE_SMARTRING
|
||||
#define SCREEN_WIDTH 466
|
||||
#define SCREEN_HEIGHT 466
|
||||
|
||||
#define LCD_CS 7
|
||||
#define LCD_SCK 13
|
||||
#define LCD_SD0 12
|
||||
#define LCD_SD1 8
|
||||
#define LCD_SD2 14
|
||||
#define LCD_SD3 9
|
||||
#define LCD_RST 11
|
||||
|
||||
#define TOUCH_SDA 41
|
||||
#define TOUCH_SCL 45
|
||||
#define TOUCH_RST 46
|
||||
#define TOUCH_IRQ 42
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#elif VIEWE_KNOB_15
|
||||
#define SCREEN_WIDTH 466
|
||||
#define SCREEN_HEIGHT 466
|
||||
|
||||
#define LCD_CS 12
|
||||
#define LCD_SCK 10
|
||||
#define LCD_SD0 13
|
||||
#define LCD_SD1 11
|
||||
#define LCD_SD2 14
|
||||
#define LCD_SD3 9
|
||||
#define LCD_RST 8
|
||||
#define LCD_EN 17
|
||||
|
||||
#define TOUCH_SDA 1
|
||||
#define TOUCH_SCL 3
|
||||
#define TOUCH_RST 2
|
||||
#define TOUCH_IRQ 4
|
||||
|
||||
#define ENCODER_A 6
|
||||
#define ENCODER_B 5
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// screen configs
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 240
|
||||
#define OFFSET_X 0
|
||||
#define OFFSET_Y 0
|
||||
#define RGB_ORDER false
|
||||
|
||||
// touch
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define TP_INT 14
|
||||
#define TP_RST 5
|
||||
|
||||
// display
|
||||
#define SPI VSPI_HOST
|
||||
|
||||
#define SCLK 18
|
||||
#define MOSI 23
|
||||
#define MISO -1
|
||||
#define DC 4
|
||||
#define CS 15
|
||||
#define RST 13
|
||||
|
||||
#define BL 2
|
||||
|
||||
#define BUZZER_PIN -1
|
||||
|
||||
#define MAX_FILE_OPEN 10
|
||||
|
||||
#endif
|
||||
123
hal/esp32/displays/viewe.hpp
Normal file
123
hal/esp32/displays/viewe.hpp
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Arduino_GFX_Library.h"
|
||||
#ifdef ESPS3_2_06
|
||||
#include "TouchDrvFT6X36.hpp"
|
||||
#else
|
||||
#include "TouchDrvCSTXXX.hpp"
|
||||
#endif
|
||||
#include "pins.h"
|
||||
|
||||
#define TFT_BLACK 0x00000
|
||||
|
||||
class DisplayWrapper
|
||||
{
|
||||
public:
|
||||
Arduino_GFX *gfx;
|
||||
|
||||
#ifdef ESPS3_2_06
|
||||
TouchDrvFT6X36 touch;
|
||||
#else
|
||||
TouchDrvCSTXXX touch;
|
||||
#endif
|
||||
|
||||
DisplayWrapper()
|
||||
{
|
||||
|
||||
static Arduino_DataBus *bus = new Arduino_ESP32QSPI(
|
||||
LCD_CS /* CS */, LCD_SCK /* SCK */, LCD_SD0 /* SDIO0 */, LCD_SD1 /* SDIO1 */,
|
||||
LCD_SD2 /* SDIO2 */, LCD_SD3 /* SDIO3 */);
|
||||
|
||||
gfx = new Arduino_CO5300(
|
||||
bus,
|
||||
LCD_RST /* RST */,
|
||||
0 /* rotation */,
|
||||
false /* IPS */,
|
||||
SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT,
|
||||
#ifdef ESPS3_2_06
|
||||
22 /* col_offset1 */,
|
||||
#else
|
||||
6 /* col_offset1 */,
|
||||
#endif
|
||||
0 /* row_offset1 */,
|
||||
0 /* col_offset2 */,
|
||||
0 /* row_offset2 */
|
||||
);
|
||||
}
|
||||
|
||||
bool init(void)
|
||||
{
|
||||
#ifdef LCD_EN
|
||||
pinMode(LCD_EN, OUTPUT);
|
||||
digitalWrite(LCD_EN, HIGH);
|
||||
#endif
|
||||
bool state = gfx->begin();
|
||||
touch.setPins(TOUCH_RST, TOUCH_IRQ);
|
||||
|
||||
#if defined(ESPS3_1_75)
|
||||
touch.begin(Wire, 0x5A, TOUCH_SDA, TOUCH_SCL);
|
||||
touch.setMaxCoordinates(466, 466);
|
||||
touch.setMirrorXY(true, true);
|
||||
#elif defined(ESPS3_2_06)
|
||||
touch.begin(Wire, 0x38, TOUCH_SDA, TOUCH_SCL);
|
||||
#else
|
||||
touch.begin(Wire, 0x15, TOUCH_SDA, TOUCH_SCL);
|
||||
#endif
|
||||
return state;
|
||||
}
|
||||
|
||||
void initDMA(void) {}
|
||||
|
||||
void fillScreen(uint16_t color)
|
||||
{
|
||||
gfx->fillScreen(color);
|
||||
}
|
||||
|
||||
void setRotation(uint8_t rotation)
|
||||
{
|
||||
// gfx->setRotation(rotation); // Not supported in CO5300
|
||||
}
|
||||
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data)
|
||||
{
|
||||
gfx->draw16bitBeRGBBitmap(x, y, data, w, h);
|
||||
}
|
||||
|
||||
void pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data)
|
||||
{
|
||||
gfx->draw16bitBeRGBBitmap(x, y, data, w, h);
|
||||
}
|
||||
|
||||
void startWrite(void) {}
|
||||
|
||||
uint32_t getStartCount(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void endWrite(void) {}
|
||||
|
||||
void setBrightness(uint8_t brightness)
|
||||
{
|
||||
((Arduino_CO5300 *)gfx)->setBrightness(brightness);
|
||||
}
|
||||
|
||||
void writePixel(int32_t x, int32_t y, const uint16_t color)
|
||||
{
|
||||
gfx->writePixel(x, y, color);
|
||||
}
|
||||
|
||||
bool getTouch(uint16_t *x, uint16_t *y)
|
||||
{
|
||||
int16_t x_arr[5], y_arr[5];
|
||||
uint8_t touched = touch.getPoint(x_arr, y_arr, touch.getSupportTouchPoint());
|
||||
*x = x_arr[0];
|
||||
*y = y_arr[0];
|
||||
return touched;
|
||||
}
|
||||
};
|
||||
|
||||
DisplayWrapper tft;
|
||||
Reference in New Issue
Block a user