From 4b0a31a2ed5bb7051f38cf6d7a5d9d902a774887 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sun, 17 Mar 2024 22:27:10 +0100 Subject: [PATCH] Add support for OrangeClock PCB, add README --- .github/workflows/tagging.yml | 5 +++ README.md | 13 ++++++++ boards/orangeclock.json | 62 +++++++++++++++++++++++++++++++++++ platformio.ini | 15 +++++++-- src/config.cpp | 2 ++ src/epd.cpp | 2 +- src/main.cpp | 29 ++++++++++++++++ 7 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 README.md create mode 100644 boards/orangeclock.json diff --git a/.github/workflows/tagging.yml b/.github/workflows/tagging.yml index 29b4b62..07e8ba4 100644 --- a/.github/workflows/tagging.yml +++ b/.github/workflows/tagging.yml @@ -37,6 +37,11 @@ jobs: version: esp32s2 - name: lolin_s3_mini version: esp32s3 + - name: orangeclock + version: esp32s3 + exclude: + - chip: orangeclock + epd_variant: 213epd runs-on: ubuntu-latest permissions: contents: write diff --git a/README.md b/README.md new file mode 100644 index 0000000..1fb871f --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# OrangeBTClock (working title) + +[![BTClock CI](https://github.com/btclock/OrangeBTClock/actions/workflows/tagging.yml/badge.svg)](https://github.com/btclock/OrangeBTClock/actions/workflows/tagging.yml) + +Firmware for cheap ESP32-S2/S3 hardware combined with a eInk display + +See releases for prebuilt binaries, ready to flash (e.g. with the [esphome web flasher](https://web.esphome.io/)) + +## Development + +- [PlatformIO](https://platformio.org/platformio-ide). +- [Node.js](https://nodejs.org/en) and [yarn](https://yarnpkg.com/). + diff --git a/boards/orangeclock.json b/boards/orangeclock.json new file mode 100644 index 0000000..c852a39 --- /dev/null +++ b/boards/orangeclock.json @@ -0,0 +1,62 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_ORANGECLOCK", + "-DARDUINO_ESP32S3_DEV", + "-DIS_ORANGECLOCK", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "psram_type": "opi", + "espidf": { + "sdkconfig_path": "boards" + }, + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "OrangeClock", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "http://github.com/btclock", + "vendor": "BTClock" +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index d86dcf0..613f146 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ [platformio] data_dir = data/build_gz -default_envs = lolin_s2_mini_213epd, lolin_s2_mini_29epd, lolin_s3_mini_213epd, lolin_s3_mini_29epd +default_envs = lolin_s2_mini_213epd, lolin_s2_mini_29epd, lolin_s3_mini_213epd, lolin_s3_mini_29epd, orangeclock_29epd [btclock_base] platform = espressif32 @@ -29,7 +29,7 @@ lib_deps = bblanchon/ArduinoJson@^7.0.3 mathieucarbou/ESP Async WebServer gilmaimon/ArduinoWebsockets@^0.5.3 - + fastled/FastLED@^3.6.0 [env:lolin_s2_mini] extends = btclock_base board = lolin_s2_mini @@ -60,4 +60,13 @@ build_flags = extends = env:lolin_s3_mini build_flags = ${btclock_base.build_flags} - -D VERSION_EPD_2_9 \ No newline at end of file + -D VERSION_EPD_2_9 + + +[env:orangeclock_29epd] +extends = btclock_base +board = orangeclock +build_flags = + ${btclock_base.build_flags} + -D VERSION_EPD_2_9 + -D IS_ORANGECLOCK \ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index 5144416..d676389 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -92,6 +92,7 @@ void setupWifi() WiFiManager wm; + #ifndef ARDUINO_ORANGECLOCK // Touch pin 14 to reset if (touchRead(14) > 9000) { @@ -108,6 +109,7 @@ void setupWifi() wm.resetSettings(); } } + #endif String softAP_SSID = String("OrangeBTClock"); diff --git a/src/epd.cpp b/src/epd.cpp index 10ad8d0..04b4e9f 100644 --- a/src/epd.cpp +++ b/src/epd.cpp @@ -51,7 +51,7 @@ void setupDisplay() // display.fillRect(0, row1, display.width(), 54, GxEPD_BLACK); display.displayWindow(0, row1, display.width(), row2); - display.display(true); + display.display(false); // display.fillRect(0, row2, display.width(), 54, GxEPD_BLACK); // display.displayWindow(0, row2, display.width(), 54); diff --git a/src/main.cpp b/src/main.cpp index bb44a0a..3537df6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include "config.hpp" #include "webserver.hpp" #include +#include #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ #define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */ @@ -21,6 +22,10 @@ GxEPD2_BW display = EPD_CLASS(4, 2, 3, 1); GxEPD2_BW display = EPD_CLASS(5, 3, 2, 1); #endif +#ifdef ARDUINO_ORANGECLOCK +GxEPD2_BW display = EPD_CLASS(5, 3, 1, 2); +#endif + typedef void (*MethodPtr)(String, char); MethodPtr methods[] = {nullptr, updateRow1, updateRow2, updateRow3}; @@ -30,14 +35,25 @@ uint currentPrice = 0; String currentBlock = ""; String currentFees = ""; +#define NUM_LEDS 2 +CRGB leds[NUM_LEDS]; + void setup() { // setCpuFrequencyMhz(40); Serial.begin(115200); + #ifndef IS_ORANGECLOCK pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); + #else + FastLED.addLeds(leds, NUM_LEDS); + leds[0] = CRGB::DarkOrange; + leds[1] = CRGB::OrangeRed; + + FastLED.show(); + #endif setupPreferences(); setupDisplay(); @@ -52,7 +68,20 @@ void setup() } client.setInsecure(); + #ifndef IS_ORANGECLOCK digitalWrite(LED_BUILTIN, LOW); + #else + leds[0] = CRGB::Black; + leds[1] = CRGB::Black; + + FastLED.show(); + delay(100); + + display.setFullWindow(); + display.clearScreen(GxEPD_WHITE); + display.display(true); + + #endif } void loop()