96 lines
2.5 KiB
C
96 lines
2.5 KiB
C
#pragma once
|
|
|
|
// Display (ST7789, SPI)
|
|
// Source: https://www.lcdwiki.com/2.8inch_ESP32-32E-7789
|
|
// Driver: LovyanGFX with Panel_ST7789
|
|
|
|
#define PIN_TFT_MOSI 13
|
|
#define PIN_TFT_MISO 12
|
|
#define PIN_TFT_SCLK 14
|
|
#define PIN_TFT_CS 15
|
|
#define PIN_TFT_DC 2
|
|
#define PIN_TFT_RST -1
|
|
#define PIN_TFT_BL 21 // Backlight
|
|
|
|
#define PANEL_NATIVE_W 240
|
|
#define PANEL_NATIVE_H 320
|
|
|
|
// Dimensions after rotation, for sanity.
|
|
#define TFT_W 320
|
|
#define TFT_H 240
|
|
|
|
|
|
// Touchscreen (XPT2046, software SPI)
|
|
// unused for now, because shared pins with KB i2c.
|
|
#define PIN_BOOT_BTN 0
|
|
#define PIN_TOUCH_IRQ 36
|
|
#define PIN_TOUCH_MOSI 32
|
|
#define PIN_TOUCH_MISO 39
|
|
#define PIN_TOUCH_CLK 25
|
|
#define PIN_TOUCH_CS 33
|
|
// TODO: should calibrate if used.
|
|
#define TOUCH_X_MIN 200
|
|
#define TOUCH_X_MAX 3800
|
|
#define TOUCH_Y_MIN 200
|
|
#define TOUCH_Y_MAX 3800
|
|
|
|
|
|
// CardKB (M5Stack v1.1, I2C)
|
|
// SDA/GPIO21 is taken by the display backlight.
|
|
#define PIN_KB_SDA 23
|
|
#define PIN_KB_SCL 19
|
|
#define CARDKB_ADDR 0x5F
|
|
#define CARDKB_I2C_HZ 100000UL
|
|
// CardKB key byte values
|
|
#define KB_KEY_ENTER 0x0D
|
|
#define KB_KEY_BACKSPACE 0x08
|
|
#define KB_KEY_TAB 0x09
|
|
#define KB_KEY_ESC 0x1B
|
|
|
|
// Notes mode / BT dump
|
|
#define BT_DUMP_COUNTDOWN_S 3
|
|
#define NOTES_FILE "/notes.txt"
|
|
|
|
|
|
// ESP-NOW Chat
|
|
#define CHAT_PING_INTERVAL_MS 500
|
|
#define CHAT_PEER_TIMEOUT_MS 2000
|
|
#define CHAT_DEDUP_HISTORY 32
|
|
#define CHAT_MAX_MESSAGES 20
|
|
#define CHAT_MAX_MSG_LEN 100
|
|
#define CHAT_MAX_NICK_LEN 16
|
|
#define CHAT_MAX_PEERS 30
|
|
#define INPUT_MAX_LEN (CHAT_MAX_MSG_LEN - 1)
|
|
#define NICK_DEFAULT_PREFIX "user"
|
|
|
|
// UI layout constants
|
|
#define UI_HEADER_H 20 // top status bar height
|
|
#define UI_INPUT_H 20 // bottom input line height
|
|
#define UI_MSG_AREA_Y (UI_HEADER_H + 1)
|
|
#define UI_MSG_AREA_H (TFT_H - UI_HEADER_H - UI_INPUT_H - 2)
|
|
#define UI_INPUT_Y (TFT_H - UI_INPUT_H)
|
|
#define UI_LINE_H 18 // Approximate
|
|
#define UI_VISIBLE_LINES (UI_MSG_AREA_H / UI_LINE_H)
|
|
|
|
#define PIN_LED_RED 22
|
|
#define PIN_LED_GREEN 16
|
|
#define PIN_LED_BLUE 17
|
|
|
|
// SD card reader (unused)
|
|
// note: some same pins as cardKB!
|
|
#define PIN_SD_CS 5
|
|
#define PIN_SD_MOSI 23
|
|
#define PIN_SD_SCLK 18
|
|
#define PIN_SD_MISO 19
|
|
|
|
|
|
// Speaker
|
|
#define PIN_SPEAKER 26
|
|
#define PIN_SPEAKER_EN 4
|
|
|
|
// Misc
|
|
#define SERIAL_BAUD 115200
|
|
|
|
#define PIN_TOUCH7 27
|
|
#define TOUCH_THRESHOLD 200 /* Greater the value, more the sensitivity */
|