Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions boards/esp32-s3-devkitc-1-4MB.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"build": {
"arduino":{
"ldscript": "esp32s3_out.ld",
"partitions": "elecrow_4MB.csv",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_ESP32S3_DEV",
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"psram_type": "opi",
"hwids": [
[
"0x303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": [
"esp-builtin"
],
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "ESP32-S3 DevKitC-1 4MB Elecrow",
"upload": {
"flash_size": "4MB",
"maximum_size": 4194304,
"maximum_ram_size": 327680,
"require_upload_port": true,
"speed": 921600
},
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
"vendor": "Espressif"
}
6 changes: 6 additions & 0 deletions elecrow_4MB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size
nvs, data, nvs, 0x9000, 0x5000
otadata, data, ota, 0xE000, 0x2000
app0, app, ota_0, 0x10000, 0x2E5000
spiffs, data, spiffs, 0x2F5000, 0x030000
coredump, data, coredump,0x325000, 0x008000
44 changes: 43 additions & 1 deletion include/hal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
* @brief ELECROW ESP32 Terminal BOARD pin definition
*
*/
#ifdef ELECROW_ESP32
#ifdef ELECROW_ESP32_35
// Official specs: https://www.elecrow.com/wiki/esp32-display-352727-intelligent-touch-screen-wi-fi26ble-320480-hmi-display.html
#define I2C_SDA_PIN GPIO_NUM_38
#define I2C_SCL_PIN GPIO_NUM_39

Expand All @@ -74,6 +75,47 @@
extern const uint8_t SD_CLK = GPIO_NUM_42;
#endif

#ifdef ELECROW_ESP32_50
// Official specs: https://www.elecrow.com/wiki/esp32-display-502727-intelligent-touch-screen-wi-fi26ble-800480-hmi-display.html
// LCD Backlight IO2
#define I2C_SDA_PIN GPIO_NUM_19
#define I2C_SCL_PIN GPIO_NUM_20

// Use GPIO_D port for GPS
uint8_t GPS_TX = GPIO_NUM_NC;
uint8_t GPS_RX = GPIO_NUM_38;

extern const uint8_t BOARD_BOOT_PIN = GPIO_NUM_0;

extern const uint8_t SD_CS = GPIO_NUM_10;
extern const uint8_t SD_MISO = GPIO_NUM_13;
extern const uint8_t SD_MOSI = GPIO_NUM_11;
extern const uint8_t SD_CLK = GPIO_NUM_12;
// Alternative
// extern const uint8_t SD_CS = GPIO_NUM_7;
// extern const uint8_t SD_MISO = GPIO_NUM_4;
// extern const uint8_t SD_MOSI = GPIO_NUM_6;
// extern const uint8_t SD_CLK = GPIO_NUM_5;
#endif

#ifdef ELECROW_ESP32_70
// Official specs: https://www.elecrow.com/wiki/esp32-display-702727-intelligent-touch-screen-wi-fi26ble-800480-hmi-display.html
// LCD Backlight IO2
#define I2C_SDA_PIN GPIO_NUM_19
#define I2C_SCL_PIN GPIO_NUM_20

// Use GPIO_D port for GPS
uint8_t GPS_TX = GPIO_NUM_NC;
uint8_t GPS_RX = GPIO_NUM_38;

extern const uint8_t BOARD_BOOT_PIN = GPIO_NUM_0;

extern const uint8_t SD_CS = GPIO_NUM_10;
extern const uint8_t SD_MISO = GPIO_NUM_13;
extern const uint8_t SD_MOSI = GPIO_NUM_11;
extern const uint8_t SD_CLK = GPIO_NUM_12;
#endif

/**
* @brief MAKERFABS ESP32S3 BOARD pin definition
*
Expand Down
220 changes: 220 additions & 0 deletions include/touch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*******************************************************************************
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround.. I think LovyanGFX has support for GT911 touch

* Touch libraries:
* FT6X36: https://github.com/strange-v/FT6X36.git
* GT911: https://github.com/TAMCTec/gt911-arduino.git
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
******************************************************************************/

/* uncomment for FT6X36 */
// #define TOUCH_FT6X36
// #define TOUCH_FT6X36_SCL 38//19
// #define TOUCH_FT6X36_SDA 37//18
// #define TOUCH_FT6X36_INT 4//39
// #define TOUCH_SWAP_XY
// #define TOUCH_MAP_X1 800
// #define TOUCH_MAP_X2 0
// #define TOUCH_MAP_Y1 0
// #define TOUCH_MAP_Y2 480

/* uncomment for GT911 */
#define TOUCH_GT911
#define TOUCH_GT911_SCL 20//20
#define TOUCH_GT911_SDA 19//19
#define TOUCH_GT911_INT -1//-1
#define TOUCH_GT911_RST -1//38
#define TOUCH_GT911_ROTATION ROTATION_NORMAL
#define TOUCH_MAP_X1 800//480
#define TOUCH_MAP_X2 0
#define TOUCH_MAP_Y1 480//272
#define TOUCH_MAP_Y2 0

/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 38
// #define TOUCH_XPT2046_INT 36
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_MAP_X1 4000
// #define TOUCH_MAP_X2 100
// #define TOUCH_MAP_Y1 100
// #define TOUCH_MAP_Y2 4000

LGFX lcd;

int touch_last_x = 0, touch_last_y = 0;

#if defined(TOUCH_FT6X36)
#include <Wire.h>
#include <FT6X36.h>
FT6X36 ts(&Wire, TOUCH_FT6X36_INT);
bool touch_touched_flag = true, touch_released_flag = true;

#elif defined(TOUCH_GT911)
#include <Wire.h>
#include <TAMC_GT911.h>
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, max(TOUCH_MAP_X1, TOUCH_MAP_X2), max(TOUCH_MAP_Y1, TOUCH_MAP_Y2));

#elif defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);

#endif

#if defined(TOUCH_FT6X36)
void touch(TPoint p, TEvent e)
{
if (e != TEvent::Tap && e != TEvent::DragStart && e != TEvent::DragMove && e != TEvent::DragEnd)
{
return;
}
// translation logic depends on screen rotation
#if defined(TOUCH_SWAP_XY)
touch_last_x = map(p.y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width());
touch_last_y = map(p.x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height());
#else
touch_last_x = map(p.x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width());
touch_last_y = map(p.y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height());
#endif
switch (e)
{
case TEvent::Tap:
Serial.println("Tap");
touch_touched_flag = true;
touch_released_flag = true;
break;
case TEvent::DragStart:
Serial.println("DragStart");
touch_touched_flag = true;
break;
case TEvent::DragMove:
Serial.println("DragMove");
touch_touched_flag = true;
break;
case TEvent::DragEnd:
Serial.println("DragEnd");
touch_released_flag = true;
break;
default:
Serial.println("UNKNOWN");
break;
}
}
#endif

void touch_init()
{
#if defined(TOUCH_FT6X36)
Wire.begin(TOUCH_FT6X36_SDA, TOUCH_FT6X36_SCL);
ts.begin();
ts.registerTouchHandler(touch);

#elif defined(TOUCH_GT911)
Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
ts.begin();
ts.setRotation(TOUCH_GT911_ROTATION);

#elif defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);

#endif
}

bool touch_has_signal()
{
#if defined(TOUCH_FT6X36)
ts.loop();
return touch_touched_flag || touch_released_flag;

#elif defined(TOUCH_GT911)
return true;

#elif defined(TOUCH_XPT2046)
return ts.tirqTouched();

#else
return false;
#endif
}

bool touch_touched()
{
#if defined(TOUCH_FT6X36)
if (touch_touched_flag)
{
touch_touched_flag = false;
return true;
}
else
{
return false;
}

#elif defined(TOUCH_GT911)
ts.read();
if (ts.isTouched)
{
#if defined(TOUCH_SWAP_XY)
touch_last_x = map(ts.points[0].y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width() - 1);
touch_last_y = map(ts.points[0].x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height() - 1);
#else
touch_last_x = map(ts.points[0].x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width() - 1);
touch_last_y = map(ts.points[0].y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height() - 1);
#endif
return true;
}
else
{
return false;
}

#elif defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
#if defined(TOUCH_SWAP_XY)
touch_last_x = map(p.y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width() - 1);
touch_last_y = map(p.x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height() - 1);
#else
touch_last_x = map(p.x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, lcd.width() - 1);
touch_last_y = map(p.y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, lcd.height() - 1);
#endif
return true;
}
else
{
return false;
}

#else
return false;
#endif
}

bool touch_released()
{
#if defined(TOUCH_FT6X36)
if (touch_released_flag)
{
touch_released_flag = false;
return true;
}
else
{
return false;
}

#elif defined(TOUCH_GT911)
return true;

#elif defined(TOUCH_XPT2046)
return true;

#else
return false;
#endif
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file ELECROW_ESP32.hpp
* @file ELECROW_ESP32_35.hpp
* @author Jordi Gauchía (jgauchia@jgauchia.com)
* @brief LOVYANGFX TFT driver for ELECROW ESP32 3.5 Terminal
* @version 0.2.3
Expand Down
Loading