Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
- { env: "lilygo-t-watch-s3" }
- { env: "lilygo-t-watch-ultra" }
- { env: "reaper" }
- { env: "renphone-accretion" }
- { env: "seeedstudio-reterminal-d1001" }
- { env: "seeedstudio-reterminal-e1001" }
- { env: "seeedstudio-reterminal-sticky" }
Expand Down
17 changes: 17 additions & 0 deletions boards/esp32s3-ili9341-xpt2046/connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ESP32-S3 ILI9341 XPT2046 Board Pin Connections

## Display (ILI9341 SPI - SPI2_HOST)
- **SCLK (SCK)**: GPIO 12
- **MOSI (SDI)**: GPIO 11
- **MISO (SDO)**: GPIO 13
- **DC (Data/Command)**: GPIO 2
- **CS (Chip Select)**: GPIO 10
- **RST (Reset)**: GPIO 14
- **BL (Backlight PWM)**: GPIO 21

## Touchscreen (XPT2046 SPI - SPI3_HOST / Soft SPI)
- **T_CLK (SCLK)**: GPIO 6
- **T_MOSI (DIN)**: GPIO 5
- **T_MISO (DO)**: GPIO 4
- **T_CS**: GPIO 9
- **T_IRQ (INT)**: Unconnected (-1)
138 changes: 138 additions & 0 deletions boards/esp32s3-ili9341-xpt2046/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#include "idf/launcher_platform.h"
#include "powerSave.h"
#include <Wire.h>
#include <interface.h>

#include "CYD28_TouchscreenR.h"
#ifndef CYD28_DISPLAY_HOR_RES_MAX
#define CYD28_DISPLAY_HOR_RES_MAX 240
#endif
#ifndef CYD28_DISPLAY_VER_RES_MAX
#define CYD28_DISPLAY_VER_RES_MAX 320
#endif

CYD28_TouchR touch(CYD28_DISPLAY_HOR_RES_MAX, CYD28_DISPLAY_VER_RES_MAX);

/***************************************************************************************
** Function name: _setup_gpio()
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/
void _setup_gpio() {
pinMode(CYD28_TouchR_CS, OUTPUT);
digitalWrite(CYD28_TouchR_CS, HIGH);
}

/***************************************************************************************
** Function name: _post_setup_gpio()
** Location: main.cpp
** Description: second stage gpio setup to make a few functions work
***************************************************************************************/
void _post_setup_gpio() {
// Brightness control setup
pinMode(TFT_BL, OUTPUT);
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
ledcWrite(TFT_BL, bright);

if (!touch.begin()) {
launcherConsolePrintf("%s\n", String("Touch IC not Started").c_str());
log_i("Touch IC not Started");
} else {
launcherConsolePrintf("%s\n", String("Touch IC Started").c_str());
}
}

/***************************************************************************************
** Function name: _late_setup_gpio()
** Location: main.cpp
** Description: third stage gpio, run before bootscreen animation
***************************************************************************************/
void _late_setup_gpio() {}

/***************************************************************************************
** Function name: getBattery()
** Location: display.cpp
** Description: Delivers the battery value from 1-100
***************************************************************************************/
int getBattery() { return 0; }

/*********************************************************************
** Function: setBrightness
** location: settings.cpp
** set brightness value
**********************************************************************/
void _setBrightness(uint8_t brightval) {
int dutyCycle;
if (brightval == 100) dutyCycle = 250;
else if (brightval == 75) dutyCycle = 130;
else if (brightval == 50) dutyCycle = 70;
else if (brightval == 25) dutyCycle = 20;
else if (brightval == 0) dutyCycle = 0;
else dutyCycle = ((brightval * 250) / 100);

log_i("dutyCycle for bright 0-255: %d", dutyCycle);
if (!ledcWrite(TFT_BL, dutyCycle)) {
launcherConsolePrintf("%s\n", String("Failed to set brightness").c_str());
ledcDetach(TFT_BL);
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
ledcWrite(TFT_BL, dutyCycle);
}
}

/*********************************************************************
** Function: InputHandler
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
checkPowerSaveTime();
PrevPress = false;
NextPress = false;
SelPress = false;
AnyKeyPress = false;
EscPress = false;

static long tm = launcherMillis();
if (launcherMillis() - tm > 200 || LongPress) {
if (touch.touched()) {
tm = launcherMillis();
auto t = touch.getPointScaled();

if (rotation == 3) {
t.y = (tftHeight + 20) - t.y;
t.x = tftWidth - t.x;
}
if (rotation == 0) {
int tmp = t.x;
t.x = tftWidth - t.y;
t.y = tmp;
}
if (rotation == 2) {
int tmp = t.x;
t.x = t.y;
t.y = (tftHeight + 20) - tmp;
}

if (!wakeUpScreen()) AnyKeyPress = true;
else return;

// Touch point global variable
touchPoint.x = t.x;
touchPoint.y = t.y;
touchPoint.pressed = true;
touchHeatMap(touchPoint);
}
}
}

/*********************************************************************
** Function: powerOff
** location: mykeyboard.cpp
** Turns off the device (or try to)
**********************************************************************/
void powerOff() { esp_deep_sleep_start(); }

/*********************************************************************
** Function: reboot
** Handles reboot process for devices
**********************************************************************/
void reboot() { ESP.restart(); }
74 changes: 74 additions & 0 deletions boards/esp32s3-ili9341-xpt2046/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32s3-ili9341-xpt2046]
board = esp32s3
board_build.partitions = support_files/custom_16Mb.csv
build_src_filter = ${env.build_src_filter} +<../boards/esp32s3-ili9341-xpt2046>
board_build.arduino.memory_type = qio_qspi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216

build_flags =
${env.build_flags}
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1

-D DEVICE_NAME='"ESP32-S3 ILI9341 XPT2046"'
-D OTA_TAG='"esp32s3_ili9341_xpt2046"'

-D ROTATION=0
-D HAS_TOUCH=1
-D HAS_RESISTIVE_TOUCH=1

# LovyanGFX Driver Configuration
-D USE_LOVYANGFX=1
-D LOVYAN_PANEL=Panel_ILI9341
-D LOVYAN_BUS=Bus_SPI

# Display Pins and Settings
-D TFT_WIDTH=240
-D TFT_HEIGHT=320
-D TFT_MEM_WIDTH=240
-D TFT_MEM_HEIGHT=320
-D TFT_OFFSET_X=0
-D TFT_OFFSET_Y=0
-D TFT_SCLK=12
-D TFT_MOSI=11
-D TFT_MISO=13
-D TFT_DC=2
-D TFT_CS=10
-D TFT_RST=14
-D TFT_BUSY=-1
-D TFT_BL=21
-D TFT_SPI_HOST=2
-D TFT_SPI_MODE=0
-D TFT_WRITE_FREQ=40000000
-D TFT_READ_FREQ=16000000
-D TFT_SPI_3WIRE=false
-D TFT_USE_LOCK=true
-D TFT_BUS_SHARED=false
-D TFT_INVERTION=0
-D TFT_RGB_ORDER=0

# Touch Pins (XPT2046)
-D CYD28_TouchR_CLK=6
-D CYD28_TouchR_MOSI=5
-D CYD28_TouchR_MISO=4
-D CYD28_TouchR_CS=9
-D CYD28_TouchR_IRQ=-1

lib_deps =
${env.lib_deps}
lovyan03/LovyanGFX@^1.2.0

lib_ignore =
SensorLib
XPowersLib
81 changes: 81 additions & 0 deletions boards/renphone-accretion/connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Accretion Phone — DIY ESP32-S3 phone

Home-made phone: ESP32-S3 module with 16MB flash and 8MB OPI PSRAM (N16R8),
2.8" ILI9341 240x320 SPI display, XPT2046 resistive touch, SD card on SDIO.
Display and touch use the same pinout as the generic
`esp32s3-ili9341-xpt2046` env; this env adds the SD card, battery sense and
the keep-off pins below.

## Display — ILI9341, 240x320, SPI (SPI2_HOST)

| Signal | GPIO |
| ------ | ---- |
| SCLK | 12 |
| MOSI | 11 |
| MISO | 13 |
| DC | 2 |
| CS | 10 |
| RST | 14 |
| BL | 21 (PWM) |

Not IPS, no inversion, RGB order default (`TFT_IPS=0`).

## Touch — XPT2046, bit-banged on its own pins

| Signal | GPIO |
| ------ | ---- |
| CLK | 6 |
| MOSI | 5 |
| MISO | 4 |
| CS | 9 |
| IRQ | not wired (-1), the driver polls |

These are **not** on the display SPI bus (`xpt_shared_spi = false` in
`hal_touch_init`). Touch orientation follows the generic 2.8" module table
(`CYD-2432S028`); if the corners come out swapped or mirrored on real
hardware, tune `CYD28_TouchR_ROT` (bit0 = swap X/Y, bit1 = invert X,
bit2 = invert Y) in `platformio.ini`, then run Settings > Calibrate Touch.

## SD card — native SDIO, 1-bit mode (not SPI)

| Signal | GPIO |
| ------ | ---- |
| CLK | 39 |
| CMD | 38 |
| D0 | 40 |

D1–D3 are not wired. `sd_functions.cpp` mounts it in 1-bit mode when
`SD_MMC_4BIT` is not set.

## Battery

- Single-cell Li-ion, 10k + 10k voltage divider (read value x2) on
**GPIO 8** (`ANALOG_BAT_PIN`, ADC1_CH7 — safe to read with WiFi on).
- No PMIC or fuel gauge, the percentage is estimated from voltage by the
shared `getBattery()`.
- GPIO 4 must **not** be used for the divider: it is the touch MISO line.

## Device specific initialization

- Vibration motor on GPIO 18 (`VIB_PIN`), driven LOW in `_setup_gpio()` so it
stays off while the pin would otherwise float.
- WS2812 LED on GPIO 48 (`RGB_LED_PIN`), turned off in `_setup_gpio()` with the
core's `neopixelWrite()`.
- TFT CS (10) and touch CS (9) are set HIGH before anything else starts.
- The launcher does not use audio, IMU or mic; the pins are recorded below
so the next person does not reuse them.

## Pins used by the phone firmware, unused by the Launcher

| Function | GPIO |
| --------------------- | ----------------------------- |
| I2S amp (MAX98357A) | BCLK 42, LRC 41, DOUT 17 |
| I2S mic (INMP441) | SCK 47, WS 46, SD 45 |
| MPU6050 (I2C 0x68) | SDA 15, SCL 7 |
| USB female (native) | D- 19, D+ 20 |

## Notes

- The module uses octal PSRAM, so GPIO 35–37 are reserved by the module and
must stay unused (none of the pins above are in that range).
- Power off is a plain deep sleep; wake it with the EN/reset button.
Loading