diff --git a/boards/_boards_json/lilygo-t-deck-pro-epaper.json b/boards/_boards_json/lilygo-t-deck-pro-epaper.json new file mode 100644 index 000000000..a2c4962e5 --- /dev/null +++ b/boards/_boards_json/lilygo-t-deck-pro-epaper.json @@ -0,0 +1,56 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DT_DECK_PRO_EPAPER", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "lilygo-t-deck-pro-epaper" + }, + "connectivity": [ + "wifi", + "bluetooth", + "lora", + "cellular" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo T-Deck Pro E-Paper (16M Flash 8M PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.lilygo.cc", + "vendor": "LilyGo" +} diff --git a/boards/lilygo-t-deck-pro-epaper/README.md b/boards/lilygo-t-deck-pro-epaper/README.md new file mode 100644 index 000000000..e81aefed1 --- /dev/null +++ b/boards/lilygo-t-deck-pro-epaper/README.md @@ -0,0 +1,207 @@ +# LilyGo T-Deck Pro E-Paper - Bruce Firmware + +⚠️ **EXPERIMENTAL SUPPORT** ⚠️ + +This board configuration is experimental and has significant limitations due to the E-Paper display. + +## Hardware Specifications + +- **MCU**: ESP32-S3FN16R8 (16MB Flash, 8MB PSRAM) +- **Display**: GDEQ031T10 (3.1" E-Paper, 320x240, UC8253 controller) +- **Touch**: CST328 capacitive touch controller (I2C 0x1A) +- **Keyboard**: TCA8418 QWERTY keyboard controller (I2C 0x34) +- **LoRa**: SX1262 (915/868 MHz) +- **GPS**: MIA-M10Q (UART) +- **4G Modem**: A7682E LTE Cat 1 (optional) +- **Battery**: 1400mAh LiPo with BQ25896 charger and BQ27220 fuel gauge +- **Gyroscope**: BHI260AP (I2C 0x28) +- **SD Card**: MicroSD slot (SPI) + +## Pin Configuration + +### Display (E-Paper) +- **MOSI**: GPIO 33 +- **SCK**: GPIO 36 +- **CS**: GPIO 34 +- **DC**: GPIO 35 +- **BUSY**: GPIO 37 +- **RST**: Not connected (-1) + +### Touch (CST328) +- **SDA**: GPIO 13 +- **SCL**: GPIO 14 +- **INT**: GPIO 12 +- **RST**: GPIO 45 + +### Keyboard (TCA8418) +- **SDA**: GPIO 13 +- **SCL**: GPIO 14 +- **INT**: GPIO 15 +- **LED**: GPIO 42 + +### LoRa (SX1262) +- **MOSI**: GPIO 33 +- **MISO**: Not used +- **SCK**: GPIO 36 +- **CS**: GPIO 3 +- **RST**: GPIO 4 +- **DIO1**: GPIO 5 +- **BUSY**: GPIO 6 + +### SD Card +- **MOSI**: GPIO 33 +- **SCK**: GPIO 36 +- **CS**: GPIO 48 + +### GPS (MIA-M10Q) +- **TX**: GPIO 16 +- **RX**: GPIO 17 +- **Baud Rate**: 9600 + +### Power +- **Power Control**: GPIO 10 +- **Battery ADC**: GPIO 4 + +## Keyboard Layout + +The T-Deck Pro features a 40-key QWERTY keyboard (4 rows × 10 columns) with three layers: + +### Normal Layer (Default) +``` +Row 0: q w e r t y u i o p +Row 1: a s d f g h j k l ↵ +Row 2: Fn z x c v b n m ⇧ ⌫ +Row 3: [ Space Bar ] , . / +``` + +### Shift Layer (Hold Shift) +``` +Row 0: Q W E R T Y U I O P +Row 1: A S D F G H J K L ↵ +Row 2: Fn Z X C V B N M ⇧ ⌫ +Row 3: [ Space Bar ] < > ? +``` + +### Fn Layer (Hold Fn) +``` +Row 0: 1 2 3 4 5 6 7 8 9 0 +Row 1: ! @ # $ % ^ & * ( ) +Row 2: Fn - _ = + [ ] ; ⇪ ⌫ +Row 3: [ Space Bar ] , . / +``` + +**Special Key Combinations:** +- **Fn + Shift** = Toggle Caps Lock (⇪) +- **Caps Lock** affects letter keys only (numbers/symbols unaffected) +- **Keyboard LED** provides visual feedback on key presses + +## Known Limitations + +### E-Paper Display Limitations + +1. **Slow Refresh Rate**: E-Paper displays take 1-2 seconds to fully refresh + - Bruce's UI expects fast TFT refresh rates + - Menus and animations will be very slow and choppy + - Not suitable for real-time operations + +2. **Ghosting**: E-Paper displays show ghosting effects + - Previous images may remain faintly visible + - Full screen refreshes needed periodically + +3. **Monochrome Only**: E-Paper is black and white + - No color support (Bruce UI uses colors extensively) + - Reduced visual feedback + +4. **No Backlight**: E-Paper has no backlight + - Needs external light to be readable + - Brightness controls do nothing + +### Current Implementation Status + +✅ **Working:** +- Touch input (CST328 capacitive touchscreen) +- **Keyboard input (TCA8418 QWERTY keyboard) - NEW!** + - Full QWERTY layout with 40 keys + - Fn, Shift, and Caps Lock support + - Key event handling with LED feedback + - Debouncing and proper key press/release detection +- Basic GPIO setup +- Power management +- SD Card support +- LoRa module support (SX1262) + +⚠️ **Partially Working:** +- Display output (using TFT_eSPI with ST7789 driver as placeholder) + - **CRITICAL**: E-Paper requires GxEPD2 library, not TFT_eSPI + - Current config will NOT work correctly with E-Paper + - This is a temporary workaround for compilation +- Battery monitoring (basic ADC reading, needs BQ27220 integration) + +❌ **Not Implemented:** +- 4G Modem (A7682E not supported in Bruce) +- Gyroscope (BHI260AP not used in Bruce) +- Battery fuel gauge (BQ27220 precise reading) +- Charger status (BQ25896 reading) + +## Required Changes for Full E-Paper Support + +To properly support the E-Paper display, the following major changes are needed: + +1. **Replace TFT_eSPI with GxEPD2** + - Add `zinggjm/GxEPD2` library dependency + - Create wrapper layer to adapt GxEPD2 API to Bruce's display API + - Implement partial refresh strategies to improve performance + +2. **Optimize UI for E-Paper** + - Reduce refresh frequency + - Simplify animations + - Use partial refreshes where possible + - Convert color schemes to high-contrast B&W + +3. **Add Battery Management** ✅ **Keyboard Driver Complete!** + - Implement BQ27220 fuel gauge reading + - Implement BQ25896 charger status + - Proper battery percentage calculation + +## Building + +```bash +pio run -e lilygo-t-deck-pro-epaper +``` + +## Flashing + +```bash +pio run -e lilygo-t-deck-pro-epaper -t upload +``` + +## Recommendations + +**For Production Use:** +- Consider using the regular T-Deck or T-Deck Plus with TFT display +- Bruce is optimized for fast TFT displays, not E-Paper +- E-Paper support would require significant UI redesign + +**For Testing:** +- This configuration can be used to test non-display features +- Keyboard, LoRa, GPS, and other peripherals should work +- Display will be slow but functional for basic menu navigation + +## References + +- [LilyGo T-Deck Pro GitHub](https://github.com/Xinyuan-LilyGO/T-Deck-Pro) +- [LilyGo T-Deck Pro Wiki](https://wiki.lilygo.cc/get_started/en/Wearable/T-Deck-Pro/T-Deck-Pro.html) +- [GxEPD2 Library](https://github.com/ZinggJM/GxEPD2) +- [Bruce Firmware](https://github.com/pr3y/Bruce) + +## Contributing + +If you want to improve E-Paper support: +1. Implement GxEPD2 wrapper layer +2. Add TCA8418 keyboard library +3. Optimize UI for E-Paper refresh rates +4. Test and submit pull request + +--- + +**Note**: This is an experimental configuration. Use at your own risk. diff --git a/boards/lilygo-t-deck-pro-epaper/interface.cpp b/boards/lilygo-t-deck-pro-epaper/interface.cpp new file mode 100644 index 000000000..36c4c932e --- /dev/null +++ b/boards/lilygo-t-deck-pro-epaper/interface.cpp @@ -0,0 +1,420 @@ +#include "core/powerSave.h" +#include "core/utils.h" +#include +#include + +// Touch controller CST328 +#define TOUCH_MODULES_CST_SELF +#include +TouchDrvCSTXXX touch; + +// Keyboard controller TCA8418 +#include +Adafruit_TCA8418 *keyboard; + +// Pin definitions for T-Deck Pro E-Paper +#define BOARD_I2C_SDA 13 +#define BOARD_I2C_SCL 14 +#define BOARD_TOUCH_INT 12 +#define BOARD_TOUCH_RST 45 +#define BOARD_KEYBOARD_INT 15 +#define BOARD_KEYBOARD_LED 42 +#define PIN_POWER_ON 10 +#define SEL_BTN 0 // Placeholder for function key + +// I2C addresses +#define CST328_SLAVE_ADDRESS 0x1A +#define TCA8418_KEYBOARD_ADDRESS 0x34 +#define BQ25896_CHARGER_ADDRESS 0x6B +#define BQ27220_FUEL_GAUGE_ADDRESS 0x55 + +// E-Paper display pins +#define EPD_BUSY 37 +#define EPD_DC 35 +#define EPD_CS 34 + +struct TouchPoint { + int16_t x = 0; + int16_t y = 0; +}; + +// Keyboard state variables +bool fn_key_pressed = false; +bool shift_key_pressed = false; +bool caps_lock = false; + +// T-Deck Pro keyboard matrix: 4 rows x 10 columns (40 keys) +// Based on standard QWERTY layout similar to T-LoRa Pager +#define KB_ROWS 4 +#define KB_COLS 10 + +struct KeyValue_t { + const char value_first; // Normal key + const char value_second; // Shift key + const char value_third; // Fn key +}; + +// T-Deck Pro QWERTY Keymap +// Row 0: Q W E R T Y U I O P +// Row 1: A S D F G H J K L Enter +// Row 2: Fn Z X C V B N M Shift Backspace +// Row 3: Space (spanning multiple columns) +const KeyValue_t _key_value_map[KB_ROWS][KB_COLS] = { + // Row 0: Top row - QWERTYUIOP + {{'q', 'Q', '1'}, + {'w', 'W', '2'}, + {'e', 'E', '3'}, + {'r', 'R', '4'}, + {'t', 'T', '5'}, + {'y', 'Y', '6'}, + {'u', 'U', '7'}, + {'i', 'I', '8'}, + {'o', 'O', '9'}, + {'p', 'P', '0'}}, + + // Row 1: Middle row - ASDFGHJKL + Enter + {{'a', 'A', '!'}, + {'s', 'S', '@'}, + {'d', 'D', '#'}, + {'f', 'F', '$'}, + {'g', 'G', '%'}, + {'h', 'H', '^'}, + {'j', 'J', '&'}, + {'k', 'K', '*'}, + {'l', 'L', '('}, + {KEY_ENTER, KEY_ENTER, ')'}}, + + // Row 2: Bottom letter row - Fn + ZXCVBNM + Shift + Backspace + {{KEY_FN, KEY_FN, KEY_FN}, + {'z', 'Z', '-'}, + {'x', 'X', '_'}, + {'c', 'C', '='}, + {'v', 'V', '+'}, + {'b', 'B', '['}, + {'n', 'N', ']'}, + {'m', 'M', ';'}, + {KEY_SHIFT, KEY_SHIFT, CAPS_LOCK}, + {KEY_BACKSPACE, KEY_BACKSPACE, KEY_BACKSPACE}}, + + // Row 3: Space bar + {{' ', ' ', ' '}, + {' ', ' ', ' '}, + {' ', ' ', ' '}, + {' ', ' ', ' '}, + {' ', ' ', ' '}, + {' ', ' ', ' '}, + {' ', ' ', ' '}, + {',', '<', ','}, + {'.', '>', '.'}, + {'/', '?', '/'}} +}; + +/*************************************************************************************** +** Function name: getKeyChar +** Description: Get character based on modifier keys +***************************************************************************************/ +char getKeyChar(uint8_t k) { + if (k >= KB_ROWS * KB_COLS) return '\0'; + + char keyVal; + uint8_t row = k / KB_COLS; + uint8_t col = k % KB_COLS; + + if (fn_key_pressed) { + keyVal = _key_value_map[row][col].value_third; + } else if (shift_key_pressed ^ caps_lock) { + keyVal = _key_value_map[row][col].value_second; + } else { + keyVal = _key_value_map[row][col].value_first; + } + return keyVal; +} + +/*************************************************************************************** +** Function name: handleSpecialKeys +** Description: Handle Fn, Shift, and Caps Lock keys +** Returns: 1 if special key handled, 0 otherwise +***************************************************************************************/ +int handleSpecialKeys(uint8_t k, bool pressed) { + if (k >= KB_ROWS * KB_COLS) return 0; + + char keyVal = _key_value_map[k / KB_COLS][k % KB_COLS].value_first; + + switch (keyVal) { + case KEY_FN: + fn_key_pressed = pressed; + return 1; + + case KEY_SHIFT: + shift_key_pressed = pressed; + // Fn + Shift = Caps Lock toggle + if (fn_key_pressed && shift_key_pressed) { + caps_lock = !caps_lock; + } + return 1; + + default: + break; + } + return 0; +} + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: Initial setup for the T-Deck Pro E-Paper +***************************************************************************************/ +void _setup_gpio() { + // Power control + pinMode(PIN_POWER_ON, OUTPUT); + digitalWrite(PIN_POWER_ON, HIGH); + + // Initialize I2C bus + Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); + delay(100); + + // Initialize Touch Controller CST328 + pinMode(BOARD_TOUCH_INT, INPUT); + pinMode(BOARD_TOUCH_RST, OUTPUT); + digitalWrite(BOARD_TOUCH_RST, LOW); + delay(100); + digitalWrite(BOARD_TOUCH_RST, HIGH); + delay(200); + + touch.setPins(BOARD_TOUCH_RST, BOARD_TOUCH_INT); + if (touch.begin(Wire, CST328_SLAVE_ADDRESS, BOARD_I2C_SDA, BOARD_I2C_SCL)) { + Serial.println("CST328 Touch initialized"); + // Set coordinates for 320x240 E-Paper in landscape (rotation 1) + touch.setMaxCoordinates(320, 240); + touch.setSwapXY(false); + touch.setMirrorXY(false, false); + } else { + Serial.println("Failed to initialize CST328 Touch"); + } + + // Initialize TCA8418 Keyboard + pinMode(BOARD_KEYBOARD_INT, INPUT_PULLUP); + pinMode(BOARD_KEYBOARD_LED, OUTPUT); + digitalWrite(BOARD_KEYBOARD_LED, LOW); + + keyboard = new Adafruit_TCA8418(); + if (!keyboard->begin(TCA8418_KEYBOARD_ADDRESS, &Wire)) { + Serial.println("Failed to find TCA8418 Keyboard"); + } else { + Serial.println("TCA8418 Keyboard initialized successfully"); + // Configure keyboard matrix: 4 rows, 10 columns + keyboard->matrix(KB_ROWS, KB_COLS); + // Clear any pending events + keyboard->flush(); + } + + // Initialize placeholder button + pinMode(SEL_BTN, INPUT_PULLUP); + + // Set LoRa CS pin HIGH (disable LoRa on shared SPI) + pinMode(3, OUTPUT); + digitalWrite(3, HIGH); + + // Set SD Card CS pin HIGH (disable SD on shared SPI) + pinMode(48, OUTPUT); + digitalWrite(48, HIGH); + + // E-Paper BUSY pin input + pinMode(EPD_BUSY, INPUT); + + // GPS setup + bruceConfigPins.gpsBaudrate = 9600; // MIA-M10Q default baud rate + + Serial.println("T-Deck Pro E-Paper GPIO setup complete"); +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: Second stage gpio setup +***************************************************************************************/ +void _post_setup_gpio() { + // E-Paper has no backlight, so no PWM setup needed + // Turn on keyboard LED for status indication + digitalWrite(BOARD_KEYBOARD_LED, HIGH); + delay(500); + digitalWrite(BOARD_KEYBOARD_LED, LOW); +} + +/*************************************************************************************** +** Function name: _setBrightness +** Location: settings.cpp +** Description: Set brightness (controls keyboard LED for E-Paper) +***************************************************************************************/ +void _setBrightness(uint8_t brightval) { + // E-Paper displays have no backlight + // Use keyboard LED to indicate brightness setting + if (brightval > 0) { + analogWrite(BOARD_KEYBOARD_LED, map(brightval, 0, 100, 0, 255)); + } else { + digitalWrite(BOARD_KEYBOARD_LED, LOW); + } +} + +/*************************************************************************************** +** Function name: getBattery +** Location: display.cpp +** Description: Get battery percentage from ADC +***************************************************************************************/ +int getBattery() { + // TODO: Implement BQ27220 fuel gauge reading for accurate percentage + // For now, use simple ADC reading from battery pin + int adcValue = analogRead(4); // ANALOG_BAT_PIN + + // Simple voltage divider calculation + // Adjust multiplier based on actual voltage divider ratio + float voltage = (adcValue / 4095.0) * 3.3 * 2.0; + + // LiPo voltage range: 3.3V (0%) to 4.2V (100%) + int percent = ((voltage - 3.3) / (4.2 - 3.3)) * 100; + + return (percent < 0) ? 1 : (percent > 100) ? 100 : percent; +} + +/*************************************************************************************** +** Function name: isCharging +** Location: interface.h +** Description: Check if device is charging +***************************************************************************************/ +bool isCharging() { + // TODO: Implement BQ25896 charger status reading + // For now, return false + return false; +} + +/*************************************************************************************** +** Function name: InputHandler +** Description: Handle input from touch screen and keyboard +***************************************************************************************/ +void InputHandler(void) { + static unsigned long lastInputTime = millis(); + static unsigned long lastKeyTime = millis(); + TouchPoint t; + uint8_t touched = 0; + + // Check keyboard input first (higher priority) + if (keyboard->available() > 0) { + int keyEvent = keyboard->getEvent(); + bool pressed = keyEvent & 0x80; // Bit 7: 1=pressed, 0=released + uint8_t keyValue = keyEvent & 0x7F; // Bits 0-6: key position + keyValue--; // Adjust for 0-based indexing + + if (keyValue < KB_ROWS * KB_COLS) { + // Handle special keys (Fn, Shift, Caps Lock) + if (handleSpecialKeys(keyValue, pressed) > 0) { + lastKeyTime = millis(); + return; + } + + // Get character for this key + char keyChar = getKeyChar(keyValue); + + if (pressed && keyChar != '\0') { + if (!wakeUpScreen()) { + AnyKeyPress = true; + KeyStroke.Clear(); + KeyStroke.hid_keys.push_back(keyChar); + + // Handle special characters + if (keyChar == KEY_BACKSPACE) { + KeyStroke.del = true; + EscPress = true; + } + if (keyChar == KEY_ENTER) { + KeyStroke.enter = true; + SelPress = true; + } + if (keyChar == KEY_FN) { + KeyStroke.fn = true; + } + + KeyStroke.word.push_back(keyChar); + KeyStroke.pressed = true; + + Serial.printf("Key: '%c' (0x%02X) at pos %d\n", keyChar, keyChar, keyValue); + + // Brief LED blink for feedback + digitalWrite(BOARD_KEYBOARD_LED, HIGH); + delay(20); + digitalWrite(BOARD_KEYBOARD_LED, LOW); + } + lastKeyTime = millis(); + return; + } + } + } else { + // Clear keystroke if no keys in buffer + if (millis() - lastKeyTime > 100) { + KeyStroke.pressed = false; + } + } + + // Check touch input (lower priority, only if no keyboard input) + if (millis() - lastInputTime > 100) { // Debounce 100ms + if (touch.isPressed()) { + touched = touch.getPoint(&t.x, &t.y); + + if (touched) { + lastInputTime = millis(); + + if (!wakeUpScreen()) { + AnyKeyPress = true; + touchPoint.x = t.x; + touchPoint.y = t.y; + touchPoint.pressed = true; + touchHeatMap(touchPoint); + + Serial.printf("Touch: x=%d, y=%d\n", t.x, t.y); + } else { + return; // Screen was asleep, just wake it + } + } + } + } + + // Check function button (if available) + if (digitalRead(SEL_BTN) == LOW) { + if (millis() - lastInputTime > 200) { + lastInputTime = millis(); + if (!wakeUpScreen()) { + AnyKeyPress = true; + SelPress = true; + Serial.println("Function button pressed"); + } else { + return; + } + } + } +} + +/*************************************************************************************** +** Function name: powerOff +** Location: mykeyboard.cpp +** Description: Power off the device +***************************************************************************************/ +void powerOff() { + // Turn off keyboard LED + digitalWrite(BOARD_KEYBOARD_LED, LOW); + + // Set power pin low to turn off + digitalWrite(PIN_POWER_ON, LOW); + delay(1000); + + // If still running, enter deep sleep + esp_deep_sleep_start(); +} + +/*************************************************************************************** +** Function name: checkReboot +** Location: mykeyboard.cpp +** Description: Check for reboot condition +***************************************************************************************/ +void checkReboot() { + // Could implement long-press detection here for reboot/reset + // For now, no-op +} diff --git a/boards/lilygo-t-deck-pro-epaper/lilygo-t-deck-pro-epaper.ini b/boards/lilygo-t-deck-pro-epaper/lilygo-t-deck-pro-epaper.ini new file mode 100644 index 000000000..895464377 --- /dev/null +++ b/boards/lilygo-t-deck-pro-epaper/lilygo-t-deck-pro-epaper.ini @@ -0,0 +1,177 @@ +; 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:lilygo-t-deck-pro-epaper] +board = esp32-s3-devkitc-1 +board_build.partitions = custom_16Mb.csv +build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-deck-pro-epaper> +build_flags = + ${env.build_flags} + -Iboards/lilygo-t-deck-pro-epaper + -mfix-esp32-psram-cache-issue + -mfix-esp32-psram-cache-strategy=memw + -Os + -DCORE_DEBUG_LEVEL=1 + -DBOARD_HAS_PSRAM + -DARDUINO_ESP32S3_DEV + + ;Features Enabled + # T-Deck Pro specific + -DT_DECK_PRO_EPAPER=1 + + ;FM Radio + -DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 + -DFM_RSTPIN=-1 + + ;Microphone - T-Deck Pro may have optional audio module + ;-DMIC_SPM1423=1 ;uncomment to enable Applicable for SPM1423 device + -DPIN_CLK=-1 + -DI2S_SCLK_PIN=-1 + -DI2S_DATA_PIN=-1 + -DPIN_DATA=-1 + + ; SERIAL (GPS) dedicated pins - MIA-M10Q GPS + -DSERIAL_TX=16 + -DSERIAL_RX=17 + -DGPS_SERIAL_TX=16 + -DGPS_SERIAL_RX=17 + + ;RGB LED - not available on T-Deck Pro + -DRGB_LED=-1 + + ;Have RTC Chip - not available on T-Deck Pro + ;-DHAS_RTC=1 + + ;Speaker - optional on some T-Deck Pro variants (PCM512A) + ;-DHAS_NS4168_SPKR=1 ;uncomment to enable + -DBCLK=7 + -DWCLK=9 + -DDOUT=8 + -DMCLK=-1 + + ;Can run USB as HID + -DUSB_as_HID=1 + -DBAD_TX=GROVE_SDA + -DBAD_RX=GROVE_SCL + + ;Battery ADC read pin + -DANALOG_BAT_PIN=4 + + ;Buttons configuration - T-Deck Pro uses keyboard and trackball + -DHAS_BTN=1 + -DBTN_ALIAS='"Keyboard"' + -DBTN_PIN=15 ; Keyboard interrupt pin + -DBTN_ACT=LOW + + ;Infrared - not available by default on T-Deck Pro + -DIR_TX_PINS='{{"Unavailable", -1}}' + -DIR_RX_PINS='{{"Unavailable", -1}}' + -DLED=-1 + -DLED_ON=HIGH + -DLED_OFF=LOW + + ;Radio Frequency (one pin modules) - not available by default + -DRF_TX_PINS='{{"Unavailable", -1}}' + -DRF_RX_PINS='{{"Unavailable", -1}}' + + ;CC1101 SPI connection pins - can be added externally + ;-DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=-1 + -DCC1101_SS_PIN=-1 + -DCC1101_MOSI_PIN=-1 + -DCC1101_SCK_PIN=-1 + -DCC1101_MISO_PIN=-1 + + ;NRF24 SPI connection pins - can be added externally + ;-DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=-1 + -DNRF24_SS_PIN=-1 + -DNRF24_MOSI_PIN=-1 + -DNRF24_SCK_PIN=-1 + -DNRF24_MISO_PIN=-1 + + ;W5500 Ethernet - not available on T-Deck Pro + ;-DUSE_W5500_VIA_SPI + -DW5500_SS_PIN=-1 + -DW5500_MOSI_PIN=-1 + -DW5500_SCK_PIN=-1 + -DW5500_MISO_PIN=-1 + -DW5500_INT_PIN=-1 + + ;LoRa setup pins - SX1262 on T-Deck Pro + -DUSE_SX1262=1 + -DLORA_SCK=SPI_SCK_PIN + -DLORA_MISO=SPI_MISO_PIN + -DLORA_MOSI=SPI_MOSI_PIN + -DLORA_CS=3 + -DLORA_RST=4 + -DLORA_DIO0=5 + -DLORA_DIO1=5 + -DLORA_BUSY=6 + + ;Font sizes, depending on device + -DFP=1 + -DFM=2 + -DFG=3 + + ;Screen Setup - E-Paper Display GDEQ031T10 + -DHAS_SCREEN=1 + -DHAS_TOUCH=1 + -DUSE_EPAPER=1 + -DROTATION=1 + -DBACKLIGHT=-1 ; E-Paper has no backlight + -DMINBRIGHT=0 + + ;TFT_eSPI display - Using EPD driver mode + -DUSER_SETUP_LOADED=1 + ;-DEPD_DRIVER=1 ; E-Paper driver mode + ; Using custom SPI configuration for GDEQ031T10 + -DST7789_DRIVER=1 ; Temporary - will need custom EPD driver + -DTFT_WIDTH=320 + -DTFT_HEIGHT=240 + -DTFT_RGB_ORDER=TFT_RGB + -DTFT_BL=-1 + -DTFT_MISO=-1 + -DTFT_MOSI=33 + -DTFT_SCLK=36 + -DTFT_CS=34 + -DTFT_DC=35 + -DTFT_RST=-1 + -DEPD_BUSY=37 ; E-Paper BUSY pin + -DTOUCH_CS=-1 + -DTFT_BACKLIGHT_ON=0 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=10000000 ; E-Paper needs slower SPI + -DSPI_READ_FREQUENCY=10000000 + -DSPI_TOUCH_FREQUENCY=400000 + + ;SD Card Setup pins - shares SPI with E-Paper + -DSDCARD_CS=48 + -DSDCARD_SCK=36 + -DSDCARD_MISO=-1 + -DSDCARD_MOSI=33 + + ;Default I2C port - Touch and Keyboard + -DGROVE_SDA=13 + -DGROVE_SCL=14 + + ;SPI pins (shared by E-Paper, LoRa, SD Card) + -DSPI_SCK_PIN=36 + -DSPI_MOSI_PIN=33 + -DSPI_MISO_PIN=-1 + -DSPI_SS_PIN=-1 + + -DDEVICE_NAME='"Lilygo T-Deck Pro E-Paper"' + +lib_deps = + ${env.lib_deps} + lewisxhe/SensorLib + adafruit/Adafruit TCA8418 @ ^1.0.2 ; Keyboard controller + ;zinggjm/GxEPD2@^1.5.9 ; E-Paper display library - for future use diff --git a/boards/lilygo-t-deck-pro-epaper/pins_arduino.h b/boards/lilygo-t-deck-pro-epaper/pins_arduino.h new file mode 100644 index 000000000..da610597e --- /dev/null +++ b/boards/lilygo-t-deck-pro-epaper/pins_arduino.h @@ -0,0 +1,77 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// T-Deck Pro does not have NeoPixel LED +#define PIN_NEOPIXEL -1 +#define LED_BUILTIN -1 +#define BUILTIN_LED -1 +#define RGB_BUILTIN -1 +#define RGB_BRIGHTNESS 0 + +#define HAS_KEYBOARD // Has TCA8418 keyboard controller +#define HAS_KEYBOARD_HID // Has keyboard HID support +#define KB_HID_EXIT_MSG "Fn + Esc to exit" + +// UART pins - GPS MIA-M10Q +static const uint8_t TX = 16; +static const uint8_t RX = 17; + +// I2C pins - Touch CST328 & Keyboard TCA8418 +static const uint8_t SDA = 13; +static const uint8_t SCL = 14; + +// SPI pins - E-Paper display, SD Card, LoRa +static const uint8_t SS = 34; // E-Paper CS +static const uint8_t MOSI = 33; +static const uint8_t MISO = -1; // No MISO needed for E-Paper +static const uint8_t SCK = 36; + +// ADC pins +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; // Battery ADC +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +// Touch capacitive pins (ESP32-S3 has touch support) +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +// Deepsleep - Keyboard interrupt can wake +#define DEEPSLEEP_WAKEUP_PIN 15 // Keyboard INT pin +#define DEEPSLEEP_PIN_ACT LOW + +#endif /* Pins_Arduino_h */