From 9f1ee25a7b81104f2f92a3d26ce87f6df0b3b7dd Mon Sep 17 00:00:00 2001
From: DTTerastar
Date: Sat, 27 Mar 2021 10:58:54 -0400
Subject: [PATCH] Whoops, that was a brain eraser
---
.github/workflows/main.yml | 4 ++--
platformio.ini | 4 ++--
src/Settings.h | 14 ++++++++++----
src/main.cpp | 29 ++++++++++-------------------
4 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 5809a7d..ec5020d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -29,13 +29,13 @@ jobs:
run: echo "PLATFORMIO_BUILD_FLAGS=-DVERSION='\"${GITHUB_REF#refs/*/}\"'" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Run PlatformIO
- run: pio run -e esp32 -e m5stickc -e m5stickc-plus -e m5stack-atom
+ run: pio run -e esp32 -e m5stickc -e m5stickc-plus -e m5atom-matrix
- name: Rename firmware
run: |
cp .pio/build/esp32/firmware.bin esp32.bin
cp .pio/build/m5stickc/firmware.bin m5stickc.bin
cp .pio/build/m5stickc-plus/firmware.bin m5stickc-plus.bin
- cp .pio/build/m5stack-atom/firmware.bin m5stack-atom.bin
+ cp .pio/build/m5atom-matrix/firmware.bin m5atom-matrix.bin
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
diff --git a/platformio.ini b/platformio.ini
index e0f4b90..1b3c839 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -69,7 +69,7 @@ build_flags =
-D PLUS
-D FIRMWARE='"m5stickc-plus"'
-[env:m5stack-atom]
+[env:m5atom-matrix]
platform = espressif32
platform_packages = framework-arduinoespressif32 @ https://github.com/DTTerastar/arduino-esp32.git#follow-redirects-http-update
framework = arduino
@@ -87,7 +87,7 @@ monitor_speed = 115200
build_flags =
-D M5ATOM
-D MATRIX
- -D FIRMWARE='"m5stack-atom"'
+ -D FIRMWARE='"m5atom-matrix"'
[env:verbose]
platform = espressif32
diff --git a/src/Settings.h b/src/Settings.h
index b51f892..5fc3803 100644
--- a/src/Settings.h
+++ b/src/Settings.h
@@ -29,7 +29,6 @@
//Replace with the room name where the node will be placed
#define DEFAULT_ROOM "living-room"
-//Specify the LED pin. For most dev boards, this is GPIO2
#ifdef M5STICK
#define LED_BUILTIN 10
@@ -38,14 +37,21 @@
#define BUTTON 39
#define BUTTON_PRESSED 0
+#else
+#if M5ATOM
+
+#define LED_BUILTIN 10
+#define LED_BUILTIN_ON 0
+
+#define BUTTON 39
+#define BUTTON_PRESSED 0
+
#else // Huzzah32
#define LED_BUILTIN 13
#define LED_BUILTIN_ON 1
-#define BUTTON 39
-#define BUTTON_PRESSED 1
-
+#endif
#endif
#ifdef M5STICK
diff --git a/src/main.cpp b/src/main.cpp
index e7253b5..5d108e9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -475,21 +475,9 @@ void firmwareUpdate(void)
WiFiClientSecure client;
client.setInsecure();
- httpUpdate.setLedPin(LED_BUILTIN, LOW);
+ httpUpdate.setLedPin(LED_BUILTIN, LED_BUILTIN_ON);
httpUpdate.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
-#ifdef M5STICK
-#ifdef PLUS
- String firmwareUrl = String("https://github.com/DTTerastar/ESP32-mqtt-room/releases/latest/download/m5stickc-plus.bin");
-#else
- String firmwareUrl = String("https://github.com/DTTerastar/ESP32-mqtt-room/releases/latest/download/m5stickc.bin");
-#endif
-#else
-#ifdef M5ATOM
- String firmwareUrl = String("https://github.com/DTTerastar/ESP32-mqtt-room/releases/latest/download/m5stack-atom.bin");
-#else
- String firmwareUrl = String("https://github.com/DTTerastar/ESP32-mqtt-room/releases/latest/download/esp32.bin");
-#endif
-#endif
+ String firmwareUrl = Sprintf("https://github.com/DTTerastar/ESP32-mqtt-room/releases/latest/download/%s.bin", FIRMWARE);
HTTPClient http;
if (!http.begin(client, firmwareUrl))
@@ -530,12 +518,14 @@ void firmwareUpdate(void)
void spiffsInit()
{
int ledState = HIGH;
- int flashes = 0;
-
- unsigned long debounceDelay = 250;
-
digitalWrite(LED_BUILTIN, ledState);
+#ifdef BUTTON
+
+ pinMode(BUTTON, INPUT);
+ int flashes = 0;
+ unsigned long debounceDelay = 250;
+
long lastDebounceTime = millis();
while (digitalRead(BUTTON) == BUTTON_PRESSED)
{
@@ -559,12 +549,13 @@ void spiffsInit()
}
}
+#endif
+
SPIFFS.begin(true);
}
void setup()
{
- pinMode(BUTTON, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);