From 460c53782c8293eeb5f9eb027e01d08c0a87aa67 Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Thu, 19 Oct 2023 16:53:39 +0200 Subject: [PATCH] Switch to MH-ET Live Mini32 --- platformio.ini | 24 +++++------------------- src/odessa.cpp | 45 +++++++++++++++------------------------------ src/settings.h | 6 ++++-- 3 files changed, 24 insertions(+), 51 deletions(-) diff --git a/platformio.ini b/platformio.ini index 2a630a4..5d49f31 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,29 +1,15 @@ -; Common configuration [env] platform = espressif32@^5 framework = arduino -board = esp32dev monitor_speed = 115200 -monitor_filter = esp32_exception_decoder lib_deps = https://github.com/plapointe6/EspMQTTClient @ ^1.13.2 bblanchon/ArduinoJson @ ^6.19.4 - adafruit/Adafruit GFX Library @ ^1.11.5 https://github.com/DoomHammer/Adafruit-GFX-Library#enable-utf-8 - https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA @ ^3.0.2 -build_flags = - -D ARDUINO_LOOP_STACK_SIZE=2048 - -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG - -Wno-nonnull-compare + https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA @ ^3.0.9 -; Production environment -[env:release] -build_flags = - ${env.build_flags} - -D PRODUCTION=1 +[env:esp32] +board = esp32dev -; Development environment -[env:develop] -build_type = debug -debug_extra_cmds = - set remote hardware-watchpoint-limit 2 \ No newline at end of file +[env:mhetesp32minikit] +board = mhetesp32minikit \ No newline at end of file diff --git a/src/odessa.cpp b/src/odessa.cpp index 449e91e..68e78c3 100644 --- a/src/odessa.cpp +++ b/src/odessa.cpp @@ -14,7 +14,11 @@ #define PANEL_RES_Y 64 // Number of pixels tall of each INDIVIDUAL panel module. #define PANEL_CHAIN 1 // Total number of panels chained one to another +#ifdef ARDUINO_MH_ET_LIVE_ESP32MINIKIT +#define E_PIN 18 +#else #define E_PIN 32 +#endif // MatrixPanel_I2S_DMA dma_display; MatrixPanel_I2S_DMA *dma_display = nullptr; @@ -32,33 +36,16 @@ std::vector> transport_times; EspMQTTClient client( ssid, password, - BROKER, // MQTT Broker server ip - "", // Can be omitted if not needed - "", // Can be omitted if not needed - "RGBMatrixClient" // Client name that uniquely identify your device + MQTT_BROKER, + MQTT_USER, + MQTT_PASSWORD, + "Odessa", + MQTT_BROKER_PORT ); DynamicJsonDocument doc(MAX_PAYLOAD); -uint16_t colorWheel(uint8_t pos) -{ - if (pos < 85) - { - return dma_display->color565(pos * 3, 255 - pos * 3, 0); - } - else if (pos < 170) - { - pos -= 85; - return dma_display->color565(255 - pos * 3, 0, pos * 3); - } - else - { - pos -= 170; - return dma_display->color565(0, pos * 3, 255 - pos * 3); - } -} - -void drawText(int colorWheelOffset) +void drawText() { dma_display->setTextSize(1); // size 1 == 8 pixels high dma_display->setTextWrap(false); // Don't wrap at end of line - will do ourselves @@ -98,11 +85,10 @@ void drawText(int colorWheelOffset) void onConnectionEstablished() { - Serial.println("Connection established"); client.subscribe(topic, [](const String &payload) - { + { Serial.println(payload); deserializeJson(doc, payload); @@ -123,7 +109,8 @@ void onConnectionEstablished() Serial.print("Time: "); Serial.println(time.c_str()); dma_display->clearScreen(); - } }); + } + }); } void setup() @@ -167,14 +154,12 @@ void setup() dma_display->fillScreen(dma_display->color444(0, 0, 0)); } -uint8_t wheelval = 0; void loop() { client.loop(); // animate by going through the colour wheel for the first two lines - drawText(wheelval); - wheelval += 1; + drawText(); delay(20); -} \ No newline at end of file +} diff --git a/src/settings.h b/src/settings.h index 2d2c7b1..559555c 100644 --- a/src/settings.h +++ b/src/settings.h @@ -2,7 +2,9 @@ const char *ssid = "Your SSID goes here"; const char *password = "AVerySafePassw0rd"; -const char* BROKER = "X.Y.Z.W"; -const uint16_t BROKER_PORT = 1883; +const char* MQTT_BROKER = "X.Y.Z.W"; +const uint16_t MQTT_BROKER_PORT = 1883; +const char* MQTT_USER = "username"; +const char* MQTT_PASSWORD = "password"; const String topic="feed/public_transport";