diff --git a/partitions.csv b/partitions.csv index 67d77372..94f6c563 100644 --- a/partitions.csv +++ b/partitions.csv @@ -1,7 +1,7 @@ -# Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, 0x9000, 0x5000, -otadata, data, ota, 0xe000, 0x2000, -app0, app, ota_0, 0x10000, 0x640000, -app1, app, ota_1, 0x650000,0x640000, -spiffs, data, spiffs, 0xc90000,0x360000, -coredump, data, coredump,0xFF0000,0x10000, + +# Name, Type, SubType, Offset, Size +nvs, data, nvs, 0x9000, 0x5000 +otadata, data, ota, 0xe000, 0x2000 +app0, app, ota_0, 0x10000, 0x1E0000 +app1, app, ota_1, 0x1F0000,0x1E0000 +spiffs, data, spiffs, 0x3D0000,0x430000 diff --git a/platformio.ini b/platformio.ini index 0fd766a3..5abe0289 100644 --- a/platformio.ini +++ b/platformio.ini @@ -4,7 +4,7 @@ default_envs = default [base] platform = espressif32 @ 6.12.0 -board = esp32-c3-devkitm-1 +board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 upload_speed = 921600 @@ -12,8 +12,8 @@ check_tool = cppcheck check_flags = --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=unmatchedSuppression --suppress=*:*/.pio/* --inline-suppr check_skip_packages = yes -board_upload.flash_size = 16MB -board_upload.maximum_size = 16777216 +board_upload.flash_size = 8MB +board_upload.maximum_size = 8388608 board_upload.offset_address = 0x10000 build_flags = @@ -28,7 +28,9 @@ build_flags = ; Board configuration board_build.flash_mode = dio -board_build.flash_size = 16MB +board_build.flash_size = 8MB +board_build.psram_type = opi +board_build.arduino.memory_type = qio_opi board_build.partitions = partitions.csv extra_scripts = @@ -36,8 +38,9 @@ extra_scripts = ; Libraries lib_deps = - BatteryMonitor=symlink://open-x4-sdk/libs/hardware/BatteryMonitor - InputManager=symlink://open-x4-sdk/libs/hardware/InputManager + BatteryMonitor=symlink://open-x4-sdk/libs/hardware/BatteryMonitorMinRead + InputManager=symlink://open-x4-sdk/libs/hardware/InputManagerMinRead + SDCardManager=symlink://open-x4-sdk/libs/hardware/SDCardManagerMinRead EInkDisplay=symlink://open-x4-sdk/libs/display/EInkDisplay ArduinoJson @ 7.4.2 QRCode @ 0.0.1 @@ -47,6 +50,7 @@ extends = base build_flags = ${base.build_flags} -DCROSSPOINT_VERSION=\"${platformio.crosspoint_version}-dev\" + -DBOARD_HAS_PSRAM=1 [env:gh_release] extends = base diff --git a/src/Battery.h b/src/Battery.h index dcfcbf79..1e680e5d 100644 --- a/src/Battery.h +++ b/src/Battery.h @@ -1,6 +1,6 @@ #pragma once #include -#define BAT_GPIO0 0 // Battery voltage +#define BAT_GPIO0 1 // Battery voltage static BatteryMonitor battery(BAT_GPIO0); diff --git a/src/main.cpp b/src/main.cpp index 9b950f1f..f57cd9f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,22 +25,23 @@ #include "activities/util/FullScreenMessageActivity.h" #include "config.h" +#include +#include + #define SPI_FQ 40000000 -// Display SPI pins (custom pins for XteinkX4, not hardware SPI defaults) -#define EPD_SCLK 8 // SPI Clock -#define EPD_MOSI 10 // SPI MOSI (Master Out Slave In) -#define EPD_CS 21 // Chip Select -#define EPD_DC 4 // Data/Command -#define EPD_RST 5 // Reset -#define EPD_BUSY 6 // Busy +// Display SPI pins (custom pins for MinRead hardware) +#define EPD_SCLK 13 // SPI Clock +#define EPD_MOSI 14 // SPI MOSI (Master Out Slave In) +#define EPD_CS 12 // Chip Select +#define EPD_DC 11 // Data/Command +#define EPD_RST 10 // Reset +#define EPD_BUSY 9 // Busy #define UART0_RXD 20 // Used for USB connection detection -#define SD_SPI_CS 12 -#define SD_SPI_MISO 7 - EInkDisplay einkDisplay(EPD_SCLK, EPD_MOSI, EPD_CS, EPD_DC, EPD_RST, EPD_BUSY); InputManager inputManager; +SDCardManager sdCardManager; GfxRenderer renderer(einkDisplay); Activity* currentActivity; @@ -108,7 +109,10 @@ void verifyWakeupLongPress() { if (abort) { // Button released too early. Returning to sleep. // IMPORTANT: Re-arm the wakeup trigger before sleeping again - esp_deep_sleep_enable_gpio_wakeup(1ULL << InputManager::POWER_BUTTON_PIN, ESP_GPIO_WAKEUP_GPIO_LOW); + // Enable pull-up resistor for RTC GPIO + rtc_gpio_pullup_en((gpio_num_t)InputManager::PIN_CONFIRM); + // Configure wakeup on HIGH level (button released with pull-up) + esp_sleep_enable_ext1_wakeup(1ULL << InputManager::PIN_CONFIRM, ESP_EXT1_WAKEUP_ANY_HIGH); esp_deep_sleep_start(); } } @@ -129,9 +133,12 @@ void enterDeepSleep() { einkDisplay.deepSleep(); Serial.printf("[%lu] [ ] Power button press calibration value: %lu ms\n", millis(), t2 - t1); Serial.printf("[%lu] [ ] Entering deep sleep.\n", millis()); - esp_deep_sleep_enable_gpio_wakeup(1ULL << InputManager::POWER_BUTTON_PIN, ESP_GPIO_WAKEUP_GPIO_LOW); // Ensure that the power button has been released to avoid immediately turning back on if you're holding it waitForPowerRelease(); + // Enable pull-up resistor for RTC GPIO + rtc_gpio_pullup_en((gpio_num_t)InputManager::PIN_CONFIRM); + // Configure wakeup on HIGH level (button released with pull-up) + esp_sleep_enable_ext1_wakeup(1ULL << InputManager::PIN_CONFIRM, ESP_EXT1_WAKEUP_ANY_HIGH); // Enter Deep Sleep esp_deep_sleep_start(); } @@ -184,12 +191,11 @@ void setup() { // Initialize pins pinMode(BAT_GPIO0, INPUT); - // Initialize SPI with custom pins - SPI.begin(EPD_SCLK, SD_SPI_MISO, EPD_MOSI, EPD_CS); + // Initialize SPI for display (SD card now uses SDMMC, not SPI) + SPI.begin(EPD_SCLK, -1, EPD_MOSI, EPD_CS); // MISO not needed for display-only SPI - // SD Card Initialization - // We need 6 open files concurrently when parsing a new chapter - if (!SD.begin(SD_SPI_CS, SPI, SPI_FQ, "/sd", 6)) { + // SD Card Initialization using SDMMC + if (!sdCardManager.begin()) { Serial.printf("[%lu] [ ] SD card initialization failed\n", millis()); setupDisplayAndFonts(); exitActivity();