From 4e5114a01b3aa2e24e9be842b69cc7a81b54da5c Mon Sep 17 00:00:00 2001 From: fvanroie Date: Sun, 23 Jul 2023 16:20:39 +0200 Subject: [PATCH] Add SenseCAP Indicator D1 --- .../Arduino_RGB_Display_mod.h | 136 +++++++++ .../Arduino_PCA9535SWSPI.cpp | 269 ++++++++++++++++++ .../Arduino_PCA9535SWSPI.h | 57 ++++ src/drv/tft/tft_defines.h | 4 + src/drv/tft/tft_driver_arduinogfx.cpp | 20 +- src/drv/touch/touch_driver_ft6336u.h | 26 +- user_setups/esp32s3/sensecap-indicator.ini | 92 ++++++ 7 files changed, 600 insertions(+), 4 deletions(-) create mode 100644 src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.cpp create mode 100644 src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.h create mode 100644 user_setups/esp32s3/sensecap-indicator.ini diff --git a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h index 7aa1e8e0..f0cea72f 100644 --- a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h +++ b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h @@ -11,6 +11,142 @@ #include "Arduino_GFX.h" #include "Arduino_RGBPanel_mod.h" + +static const uint8_t st7701_sensecap_indicator_init_operations[] = { + BEGIN_WRITE, + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10, + + WRITE_C8_D16, 0xC0, 0x3B, 0x00, + WRITE_C8_D16, 0xC1, 0x0D, 0x02, + WRITE_C8_D16, 0xC2, 0x31, 0x05, + WRITE_C8_D8, 0xC7, 0x04, + WRITE_C8_D8, 0xCD, 0x08, + + WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x11, 0x18, 0x0E, + 0x11, 0x06, 0x07, 0x08, + 0x07, 0x22, 0x04, 0x12, + 0x0F, 0xAA, 0x31, 0x18, + + END_WRITE, + BEGIN_WRITE, + + WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x11, 0x19, 0x0E, + 0x12, 0x07, 0x08, 0x08, + 0x08, 0x22, 0x04, 0x11, + 0x11, 0xA9, 0x32, 0x18, + + // PAGE1 + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11, + + WRITE_C8_D8, 0xB0, 0x60, // Vop=4.7375v + WRITE_C8_D8, 0xB1, 0x32, // VCOM=32 + WRITE_C8_D8, 0xB2, 0x07, // VGH=15v + WRITE_C8_D8, 0xB3, 0x80, + WRITE_C8_D8, 0xB5, 0x49, // VGL=-10.17v + WRITE_C8_D8, 0xB7, 0x85, + WRITE_C8_D8, 0xB8, 0x21, // AVDD=6.6 & AVCL=-4.6 + WRITE_C8_D8, 0xC1, 0x78, + WRITE_C8_D8, 0xC2, 0x78, + + END_WRITE, + DELAY, 20, + BEGIN_WRITE, + + WRITE_COMMAND_8, 0xE0, + WRITE_BYTES, 3, 0x00, 0x1B, 0x02, + + WRITE_COMMAND_8, 0xE1, + WRITE_BYTES, 11, + 0x08, 0xA0, 0x00, 0x00, + 0x07, 0xA0, 0x00, 0x00, + 0x00, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE2, + WRITE_BYTES, 12, + 0x11, 0x11, 0x44, 0x44, + 0xED, 0xA0, 0x00, 0x00, + 0xEC, 0xA0, 0x00, 0x00, + + END_WRITE, + BEGIN_WRITE, + + WRITE_COMMAND_8, 0xE3, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE4, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE5, + WRITE_BYTES, 16, + 0x0A, 0xE9, 0xD8, 0xA0, + 0x0C, 0xEB, 0xD8, 0xA0, + 0x0E, 0xED, 0xD8, 0xA0, + 0x10, 0xEF, 0xD8, 0xA0, + + WRITE_COMMAND_8, 0xE6, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE7, 0x44, 0x44, + + END_WRITE, + BEGIN_WRITE, + + WRITE_COMMAND_8, 0xE8, + WRITE_BYTES, 16, + 0x09, 0xE8, 0xD8, 0xA0, + 0x0B, 0xEA, 0xD8, 0xA0, + 0x0D, 0xEC, 0xD8, 0xA0, + 0x0F, 0xEE, 0xD8, 0xA0, + + WRITE_COMMAND_8, 0xEB, + WRITE_BYTES, 7, + 0x02, 0x00, 0xE4, 0xE4, + 0x88, 0x00, 0x40, + + WRITE_C8_D16, 0xEC, 0x3C, 0x00, + + WRITE_COMMAND_8, 0xED, + WRITE_BYTES, 16, + 0xAB, 0x89, 0x76, 0x54, + 0x02, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x20, + 0x45, 0x67, 0x98, 0xBA, + + WRITE_C8_D8, 0x36, 0x10, + + END_WRITE, + BEGIN_WRITE, + + //-----------VAP & VAN--------------- + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13, + + WRITE_C8_D8, 0xE5, 0xE4, + + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00, + + WRITE_COMMAND_8, 0x21, // 0x20 normal, 0x21 IPS + WRITE_C8_D8, 0x3A, 0x60, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565 + + WRITE_COMMAND_8, 0x11, // Sleep Out + END_WRITE, + + DELAY, 120, + + BEGIN_WRITE, + WRITE_COMMAND_8, 0x29, // Display On + END_WRITE, + + DELAY, 120, +}; + + class Arduino_RGB_Display_Mod : public Arduino_GFX{ public: Arduino_RGB_Display_Mod( diff --git a/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.cpp b/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.cpp new file mode 100644 index 00000000..28463861 --- /dev/null +++ b/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.cpp @@ -0,0 +1,269 @@ +#include "Arduino_PCA9535SWSPI.h" +#include "driver/gpio.h" +#include "hasplib.h" + +Arduino_PCA9535SWSPI::Arduino_PCA9535SWSPI(int8_t sda, int8_t scl, int8_t pwd, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire) + : _sda(sda), _scl(scl), _pwd(pwd), _cs(cs), _sck(sck), _mosi(mosi), _wire(wire) +{ +} + +bool Arduino_PCA9535SWSPI::begin(int32_t speed, int8_t dataMode) +{ + UNUSED(speed); + UNUSED(dataMode); + + _address = PCA9535_IIC_ADDRESS; + _wire->beginTransmission(_address); + if (!_wire->endTransmission()) + { + LOG_INFO(TAG_DRVR, "Found xl9535"); + is_found = true; + // this->pinMode8(0, 0xFF, OUTPUT); + if (_pwd != GFX_NOT_DEFINED) + { + this->pinMode(_pwd, OUTPUT); + this->digitalWrite(_pwd, 1); + } + this->pinMode(_cs, OUTPUT); + this->digitalWrite(_cs, 1); + this->pinMode(_sck, OUTPUT); + this->digitalWrite(_sck, 1); + this->pinMode(_mosi, OUTPUT); + this->digitalWrite(_mosi, 1); + } + else + { + LOG_INFO(TAG_DRVR, "xl9535 not found"); + is_found = false; + } + + return is_found; +} + +void Arduino_PCA9535SWSPI::beginWrite() +{ + this->digitalWrite(_cs, 0); +} + +void Arduino_PCA9535SWSPI::endWrite() +{ + this->digitalWrite(_cs, 1); +} + +void Arduino_PCA9535SWSPI::writeCommand(uint8_t c) +{ + // D/C bit, command + this->digitalWrite(_mosi, 0); + this->digitalWrite(_sck, 0); + this->digitalWrite(_sck, 1); + + uint8_t bit = 0x80; + while (bit) + { + if (c & bit) + { + this->digitalWrite(_mosi, 1); + } + else + { + this->digitalWrite(_mosi, 0); + } + this->digitalWrite(_sck, 0); + bit >>= 1; + this->digitalWrite(_sck, 1); + } +} + +void Arduino_PCA9535SWSPI::writeCommand16(uint16_t) +{ +} + +void Arduino_PCA9535SWSPI::write(uint8_t d) +{ + // D/C bit, data + this->digitalWrite(_mosi, 1); + this->digitalWrite(_sck, 0); + this->digitalWrite(_sck, 1); + + uint8_t bit = 0x80; + while (bit) + { + if (d & bit) + { + this->digitalWrite(_mosi, 1); + } + else + { + this->digitalWrite(_mosi, 0); + } + this->digitalWrite(_sck, 0); + bit >>= 1; + this->digitalWrite(_sck, 1); + } +} + +void Arduino_PCA9535SWSPI::write16(uint16_t) +{ + // not implemented +} + +void Arduino_PCA9535SWSPI::writeRepeat(uint16_t p, uint32_t len) +{ + // not implemented +} + +void Arduino_PCA9535SWSPI::writePixels(uint16_t *data, uint32_t len) +{ + // not implemented +} + +#if !defined(LITTLE_FOOT_PRINT) +void Arduino_PCA9535SWSPI::writeBytes(uint8_t *data, uint32_t len) +{ + // not implemented +} +#endif // !defined(LITTLE_FOOT_PRINT) + +void Arduino_PCA9535SWSPI::writeRegister(uint8_t reg, uint8_t *data, size_t len) +{ + _wire->beginTransmission(_address); + _wire->write(reg); + for (size_t i = 0; i < len; i++) + { + _wire->write(data[i]); + } + _wire->endTransmission(); +} + +uint8_t Arduino_PCA9535SWSPI::readRegister(uint8_t reg, uint8_t *data, size_t len) +{ + _wire->beginTransmission(_address); + _wire->write(reg); + _wire->endTransmission(); + _wire->requestFrom(_address, len); + size_t index = 0; + while (index < len) + data[index++] = _wire->read(); + return 0; +} + +void Arduino_PCA9535SWSPI::pinMode(uint8_t pin, uint8_t mode) +{ + if (is_found) + { + uint8_t port = 0; + if (pin > 15) + { + gpio_set_direction((gpio_num_t)pin, mode == OUTPUT ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT); + } + else if (pin > 7) + { + this->readRegister(PCA9535_CONFIG_PORT_1_REG, &port, 1); + if (mode == OUTPUT) + { + port = port & (~(1 << (pin - 10))); + } + else + { + port = port | (1 << (pin - 10)); + } + this->writeRegister(PCA9535_CONFIG_PORT_1_REG, &port, 1); + } + else + { + this->readRegister(PCA9535_CONFIG_PORT_0_REG, &port, 1); + if (mode == OUTPUT) + { + port = port & (~(1 << pin)); + } + else + { + port = port | (1 << pin); + } + this->writeRegister(PCA9535_CONFIG_PORT_0_REG, &port, 1); + } + } + else + { + LOG_INFO(TAG_DRVR, "xl9535 not found"); + } +} +void Arduino_PCA9535SWSPI::pinMode8(uint8_t port, uint8_t pin, uint8_t mode) +{ + if (is_found) + { + uint8_t _pin = (mode != OUTPUT) ? pin : ~pin; + if (port) + { + this->writeRegister(PCA9535_CONFIG_PORT_1_REG, &_pin, 1); + } + else + { + this->writeRegister(PCA9535_CONFIG_PORT_0_REG, &_pin, 1); + } + } + else + { + LOG_INFO(TAG_DRVR, "xl9535 not found"); + } +} + +void Arduino_PCA9535SWSPI::digitalWrite(uint8_t pin, uint8_t val) +{ + if (is_found) + { + uint8_t port = 0; + uint8_t reg_data = 0; + if (pin > 15) + { + gpio_set_level((gpio_num_t)pin, val); + } + else if (pin > 7) + { + this->readRegister(PCA9535_OUTPUT_PORT_1_REG, ®_data, 1); + reg_data = reg_data & (~(1 << (pin - 10))); + port = reg_data | val << (pin - 10); + this->writeRegister(PCA9535_OUTPUT_PORT_1_REG, &port, 1); + } + else + { + this->readRegister(PCA9535_OUTPUT_PORT_0_REG, ®_data, 1); + reg_data = reg_data & (~(1 << pin)); + port = reg_data | val << pin; + this->writeRegister(PCA9535_OUTPUT_PORT_0_REG, &port, 1); + } + } + else + { + LOG_INFO(TAG_DRVR, "xl9535 not found"); + } +} + +int Arduino_PCA9535SWSPI::digitalRead(uint8_t pin) +{ + if (is_found) + { + int state = 0; + uint8_t port = 0; + if (pin > 15) + { + state = gpio_get_level((gpio_num_t)pin); + } + else if (pin > 7) + { + this->readRegister(PCA9535_INPUT_PORT_1_REG, &port, 1); + state = port & (pin - 10) ? 1 : 0; + } + else + { + this->readRegister(PCA9535_INPUT_PORT_0_REG, &port, 1); + state = port & pin ? 1 : 0; + } + return state; + } + else + { + LOG_INFO(TAG_DRVR, "xl9535 not found"); + } + return 0; +} diff --git a/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.h b/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.h new file mode 100644 index 00000000..1a60a076 --- /dev/null +++ b/src/drv/tft/Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.h @@ -0,0 +1,57 @@ +#ifndef _Arduino_PCA9535SWSPI_H_ +#define _Arduino_PCA9535SWSPI_H_ + +#include + +#include "Arduino_DataBus.h" + +#define PCA9535_IIC_ADDRESS 0X20 + +#define PCA9535_INPUT_PORT_0_REG 0X00 +#define PCA9535_INPUT_PORT_1_REG 0X01 +#define PCA9535_OUTPUT_PORT_0_REG 0X02 +#define PCA9535_OUTPUT_PORT_1_REG 0X03 +#define PCA9535_INVERSION_PORT_0_REG 0X04 +#define PCA9535_INVERSION_PORT_1_REG 0X05 +#define PCA9535_CONFIG_PORT_0_REG 0X06 +#define PCA9535_CONFIG_PORT_1_REG 0X07 + +class Arduino_PCA9535SWSPI : public Arduino_DataBus +{ +public: + Arduino_PCA9535SWSPI(int8_t sda, int8_t scl, int8_t pwd, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire = &Wire); + + bool begin(int32_t speed = GFX_NOT_DEFINED, int8_t dataMode = GFX_NOT_DEFINED) override; + void beginWrite() override; + void endWrite() override; + void writeCommand(uint8_t) override; + void writeCommand16(uint16_t) override; + void write(uint8_t) override; + void write16(uint16_t) override; + void writeRepeat(uint16_t p, uint32_t len) override; + void writePixels(uint16_t *data, uint32_t len) override; + +#if !defined(LITTLE_FOOT_PRINT) + void writeBytes(uint8_t *data, uint32_t len) override; +#endif // !defined(LITTLE_FOOT_PRINT) + + void pinMode(uint8_t pin, uint8_t mode); + void pinMode8(uint8_t port, uint8_t pin, uint8_t mode); + + void digitalWrite(uint8_t pin, uint8_t val); + int digitalRead(uint8_t pin); + +protected: + void writeRegister(uint8_t reg, uint8_t *data, size_t len); + uint8_t readRegister(uint8_t reg, uint8_t *data, size_t len); + + uint8_t _address; + bool is_found; + + int8_t _sda, _scl, _pwd, _cs, _sck, _mosi; + TwoWire *_wire; + +private: +}; + +#endif // _Arduino_PCA9535SWSPI_H_ diff --git a/src/drv/tft/tft_defines.h b/src/drv/tft/tft_defines.h index cb589eb1..b886f8f9 100644 --- a/src/drv/tft/tft_defines.h +++ b/src/drv/tft/tft_defines.h @@ -14,6 +14,10 @@ #define TOUCH_IRQ -1 #endif +#ifndef TOUCH_RST +#define TOUCH_RST -1 +#endif + #ifndef TFT_DMA_CHANNEL #define TFT_DMA_CHANNEL 0 #endif diff --git a/src/drv/tft/tft_driver_arduinogfx.cpp b/src/drv/tft/tft_driver_arduinogfx.cpp index fc596422..1d0ad7d7 100644 --- a/src/drv/tft/tft_driver_arduinogfx.cpp +++ b/src/drv/tft/tft_driver_arduinogfx.cpp @@ -1,4 +1,4 @@ -/* MIT License - Copyright (c) 2019-2022 Francis Van Roie +/* MIT License - Copyright (c) 2019-2023 Francis Van Roie For full license information read the LICENSE file in the project folder */ #if defined(ARDUINO) && defined(HASP_USE_ARDUINOGFX) @@ -7,6 +7,7 @@ #include "Arduino_RGBPanel_mod.h" #include "Arduino_RGB_Display_mod.h" +#include "Arduino_PCA9535SWSPI/Arduino_PCA9535SWSPI.h" namespace dev { @@ -34,9 +35,24 @@ void ArduinoGfx::init(int w, int h) 6 /* B1 */, 5 /* B2 */, 3 /* B3 */, 2 /* B4 */, 1 /* hsync_polarity */, 50 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 30 /* hsync_back_porch */, 1 /* vsync_polarity */, 20 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 30 /* vsync_back_porch */, 1 /* pclk_active_neg */); - tft = new Arduino_RGB_Display(w, h, rgbpanel, 0 /* rotation */, TFT_AUTO_FLUSH, bus, TFT_RST, + tft = new Arduino_RGB_Display(w, h, rgbpanel, 0 /* rotation */, TFT_AUTO_FLUSH, bus, TFT_RST, st7701_type4_init_operations, sizeof(st7701_type4_init_operations)); +#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(SENSECAP_INDICATOR_D1) + Wire.begin(TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_FREQUENCY); + pinMode(TFT_SCLK, OUTPUT); + pinMode(TFT_MOSI, OUTPUT); + pinMode(TFT_MISO, OUTPUT); + Arduino_DataBus* bus = new Arduino_PCA9535SWSPI(TOUCH_SDA, TOUCH_SCL, 5 /* XL PWD */, 4 /* XL CS */, + TFT_SCLK /* XL SCK */, TFT_MOSI /* XL MOSI */, &Wire); + Arduino_ESP32RGBPanel* rgbpanel = new Arduino_ESP32RGBPanel( + TFT_DE, TFT_VSYNC, TFT_HSYNC, TFT_PCLK, TFT_R0, TFT_R1, TFT_R2, TFT_R3, TFT_R4, TFT_G0, TFT_G1, TFT_G2, TFT_G3, + TFT_G4, TFT_G5, TFT_B0, TFT_B1, TFT_B2, TFT_B3, TFT_B4, TFT_HSYNC_POLARITY, TFT_HSYNC_FRONT_PORCH, + TFT_HSYNC_PULSE_WIDTH, TFT_HSYNC_BACK_PORCH, TFT_VSYNC_POLARITY, TFT_VSYNC_FRONT_PORCH, TFT_VSYNC_PULSE_WIDTH, + TFT_VSYNC_BACK_PORCH); + tft = new Arduino_RGB_Display(w, h, rgbpanel, 0 /* rotation */, TFT_AUTO_FLUSH, bus, TFT_RST, + st7701_sensecap_indicator_init_operations, sizeof(st7701_sensecap_indicator_init_operations)); + #elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(GC9503V_DRIVER) Arduino_DataBus* bus = new Arduino_SWSPI(TFT_DC, TFT_CS, TFT_SCLK, TFT_MOSI, TFT_MISO); Arduino_ESP32RGBPanel* rgbpanel = new Arduino_ESP32RGBPanel( diff --git a/src/drv/touch/touch_driver_ft6336u.h b/src/drv/touch/touch_driver_ft6336u.h index 0935781b..efc419cf 100644 --- a/src/drv/touch/touch_driver_ft6336u.h +++ b/src/drv/touch/touch_driver_ft6336u.h @@ -12,8 +12,8 @@ #include #include "FT6336U.h" -#include "touch_driver.h" // base class -#include "touch_helper.h" // i2c scanner +#include "touch_driver.h" // base class +#include "touch_helper.h" // i2c scanner #include "../../hasp/hasp.h" // for hasp_sleep_state extern uint8_t hasp_sleep_state; @@ -67,6 +67,21 @@ class TouchFt6336u : public BaseTouch { data->state = LV_INDEV_STATE_PR; hasp_set_sleep_offset(0); // Reset the offset +#if defined(TOUCH_SWAP_XY) && (TOUCH_SWAP_XY) + data->point.x = ft6336u_touch->read_touch1_y(); + data->point.y = ft6336u_touch->read_touch1_x(); +#else + data->point.x = ft6336u_touch->read_touch1_x(); + data->point.y = ft6336u_touch->read_touch1_y(); +#endif + +#if defined(TOUCH_INVERSE_X) && (TOUCH_INVERSE_X) + data->point.x = _width_max - data->point.x; +#endif +#if defined(TOUCH_INVERSE_Y) && (TOUCH_INVERSE_Y) + data->point.y = _height_max - data->point.y; +#endif + } else { data->state = LV_INDEV_STATE_REL; } @@ -77,6 +92,9 @@ class TouchFt6336u : public BaseTouch { void init(int w, int h) { + _height_max = h - 1; + _width_max = w - 1; + LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA); LOG_INFO(TAG_DRVR, F("Touch SCL : %d"), TOUCH_SCL); LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), I2C_TOUCH_FREQUENCY); @@ -110,6 +128,10 @@ class TouchFt6336u : public BaseTouch { LOG_ERROR(TAG_DRVR, F("FT6336U touch driver failed to start")); } } + + private: + uint16_t _width_max; + uint16_t _height_max; }; } // namespace dev diff --git a/user_setups/esp32s3/sensecap-indicator.ini b/user_setups/esp32s3/sensecap-indicator.ini new file mode 100644 index 00000000..a2a5b03d --- /dev/null +++ b/user_setups/esp32s3/sensecap-indicator.ini @@ -0,0 +1,92 @@ +;***************************************************; +; SenseCAP Indicator D1, 4-Inch Touch Screen ; +; - Custom esp32-s3 board ; +; - st7701s TFT ; +; - ft6336u touch controller ; +;***************************************************; + +[sensecap-indicator-d1] +extends = arduino_esp32s3_v2 +board = esp32-s3-devkitc-1 +board_build.arduino.memory_type = qio_opi + +build_flags = + -D HASP_MODEL="SenseCAP Indicator D1" + ${arduino_esp32s3_v2.build_flags} + ${esp32s3.ps_ram} + -DSENSECAP_INDICATOR_D1 + ;-DARDUINO_USB_CDC_ON_BOOT + ;-DUSE_USB_CDC_CONSOLE + +;region -- ArduinoGFX build options ------------------------ + -D HASP_USE_ARDUINOGFX=1 + -D HASP_LV_USE_SW_ROTATE=1 + -D ST7701_DRIVER=1 + -D TFT_WIDTH=480 + -D TFT_HEIGHT=480 + ; Bus Settings + -D TFT_HSYNC=16 + -D TFT_VSYNC=17 + -D TFT_DE=18 + -D TFT_PCLK=21 + -D TFT_R0=4 + -D TFT_R1=3 + -D TFT_R2=2 + -D TFT_R3=1 + -D TFT_R4=0 + -D TFT_G0=10 + -D TFT_G1=9 + -D TFT_G2=8 + -D TFT_G3=7 + -D TFT_G4=6 + -D TFT_G5=5 + -D TFT_B0=15 + -D TFT_B1=14 + -D TFT_B2=13 + -D TFT_B3=12 + -D TFT_B4=11 + -D TFT_DC=-1 + -D TFT_CS=-1 + -D TFT_SCLK=41 + -D TFT_MOSI=48 + -D TFT_MISO=47 + -D TFT_RST=-1 + -D TFT_BUSY=-1 + -D TFT_BCKL=45 + ; Panel Settings + -D TFT_HSYNC_POLARITY=1 + -D TFT_HSYNC_FRONT_PORCH=10 + -D TFT_HSYNC_PULSE_WIDTH=8 + -D TFT_HSYNC_BACK_PORCH=50 + -D TFT_VSYNC_POLARITY=1 + -D TFT_VSYNC_FRONT_PORCH=10 + -D TFT_VSYNC_PULSE_WIDTH=8 + -D TFT_VSYNC_BACK_PORCH=20 + -D TFT_PCLK_ACTIVE_NEG=1 ; 0 + -D TFT_PREFER_SPEED=18000000 + -D TFT_AUTO_FLUSH=1 + ; Touch Settings + -D TOUCH_DRIVER=0x6336 + -D TOUCH_WIDTH=480 + -D TOUCH_HEIGHT=480 + -D TOUCH_SWAP_XY=0 + -D TOUCH_INVERSE_X=1 + -D TOUCH_INVERSE_Y=1 + -D TOUCH_SDA=39 + -D TOUCH_SCL=40 + -D TOUCH_RST=-1 + -D TOUCH_IRQ=-1 + -D I2C_TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_ADDRESS=0x48 + -D I2C_TOUCH_PORT=1 +;endregion + +lib_deps = + ${arduino_esp32s3_v2.lib_deps} + ${arduinogfx.lib_deps} + ; ${ft6336.lib_deps} + git+https://github.com/RobTillaart/TCA9555.git + + +[env:sensecap-indicator-d1_8MB] +extends = sensecap-indicator-d1, flash_8mb