Skip to content

Commit

Permalink
Merge pull request #4 from hs3city/switch-to-mhet-live-mini32
Browse files Browse the repository at this point in the history
Switch to MH-ET Live Mini32
  • Loading branch information
DoomHammer authored Jun 6, 2024
2 parents 3a21663 + 460c537 commit 0958d2b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 51 deletions.
24 changes: 5 additions & 19 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -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
[env:mhetesp32minikit]
board = mhetesp32minikit
45 changes: 15 additions & 30 deletions src/odessa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,33 +36,16 @@ std::vector<std::tuple<std::string, std::string, std::string>> 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
Expand Down Expand Up @@ -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);
Expand All @@ -123,7 +109,8 @@ void onConnectionEstablished()
Serial.print("Time: ");
Serial.println(time.c_str());
dma_display->clearScreen();
} });
}
});
}

void setup()
Expand Down Expand Up @@ -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);
}
}
6 changes: 4 additions & 2 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 0958d2b

Please sign in to comment.