🚩Colors aren't accurate. The arduino code works.
This commit is contained in:
parent
0c7668e04f
commit
47d4ab014b
@ -6,8 +6,9 @@
|
|||||||
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
|
#include <Arduino_JSON.h>
|
||||||
|
|
||||||
|
#define REFRESH 10 // Seconds until refresh
|
||||||
#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
|
#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
|
||||||
#define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module.
|
#define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module.
|
||||||
#define PANEL_CHAIN 1 // Total number of panels chained one to another
|
#define PANEL_CHAIN 1 // Total number of panels chained one to another
|
||||||
@ -15,13 +16,33 @@
|
|||||||
//MatrixPanel_I2S_DMA dma_display;
|
//MatrixPanel_I2S_DMA dma_display;
|
||||||
MatrixPanel_I2S_DMA *dma_display = nullptr;
|
MatrixPanel_I2S_DMA *dma_display = nullptr;
|
||||||
|
|
||||||
void putPixel(int16_t x, int16_t y, uint16_t color) {
|
|
||||||
|
|
||||||
|
int hexToRGB(String hex) {
|
||||||
|
|
||||||
|
// TODO: Fix the colors not being accurate
|
||||||
|
// Remove the '#' from the start
|
||||||
|
hex.remove(0, 1);
|
||||||
|
|
||||||
|
// Extract and convert the red, green, and blue components
|
||||||
|
uint8_t r = strtol(hex.substring(0, 2).c_str(), NULL, 16);
|
||||||
|
uint8_t g = strtol(hex.substring(2, 4).c_str(), NULL, 16);
|
||||||
|
uint8_t b = strtol(hex.substring(4, 6).c_str(), NULL, 16);
|
||||||
|
|
||||||
|
return dma_display->color565(r, g, b);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Pixel putting
|
||||||
|
void putPixel(int16_t x, int16_t y, int color) {
|
||||||
dma_display->drawPixel(x, y, color);
|
dma_display->drawPixel(x, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace with your network credentials
|
// Replace with your network credentials
|
||||||
const char* ssid = "ssid";
|
const char* ssid = "SSID";
|
||||||
const char* password = "password";
|
const char* password = "PASSWORD";
|
||||||
|
String serverName = "https://your-domain.com/board/json/";
|
||||||
|
|
||||||
void initWiFi() {
|
void initWiFi() {
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
@ -34,11 +55,11 @@ void initWiFi() {
|
|||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
}
|
}
|
||||||
|
|
||||||
String serverName = "https://changethis.com/board/json/";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
initWiFi();
|
initWiFi();
|
||||||
// Module configuration
|
// Module configuration
|
||||||
HUB75_I2S_CFG mxconfig(
|
HUB75_I2S_CFG mxconfig(
|
||||||
@ -72,6 +93,7 @@ void loop() {
|
|||||||
|
|
||||||
if ((millis() - lastTime) > timerDelay) {
|
if ((millis() - lastTime) > timerDelay) {
|
||||||
//Check WiFi connection status
|
//Check WiFi connection status
|
||||||
|
String payload = "null";
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
|
|
||||||
@ -89,8 +111,7 @@ void loop() {
|
|||||||
if (httpResponseCode > 0) {
|
if (httpResponseCode > 0) {
|
||||||
Serial.print("HTTP Response code: ");
|
Serial.print("HTTP Response code: ");
|
||||||
Serial.println(httpResponseCode);
|
Serial.println(httpResponseCode);
|
||||||
String payload = http.getString();
|
payload = http.getString();
|
||||||
Serial.println(payload);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.print("Error code: ");
|
Serial.print("Error code: ");
|
||||||
@ -104,13 +125,32 @@ void loop() {
|
|||||||
WiFi.reconnect();
|
WiFi.reconnect();
|
||||||
}
|
}
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
}
|
|
||||||
}
|
|
||||||
// animate by going through the colour wheel for the first two lines
|
|
||||||
drawText(wheelval);
|
|
||||||
wheelval +=1;
|
|
||||||
|
|
||||||
delay(20);
|
if (payload != "null") {
|
||||||
|
JSONVar board = JSON.parse(payload);
|
||||||
|
if (JSON.typeof(board) == "undefined") {
|
||||||
|
Serial.println("Parsing failed!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Parse JSON
|
||||||
|
for (int y = 0; y < PANEL_RES_Y; y++) {
|
||||||
|
for (int x = 0; x < PANEL_RES_X; x++) {
|
||||||
|
String color = board[String(y)][x];
|
||||||
|
|
||||||
|
int colorize;
|
||||||
|
if (color.length() < 1) {
|
||||||
|
colorize = dma_display->color444(0, 0, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
colorize = hexToRGB(color);
|
||||||
|
}
|
||||||
|
putPixel(x, y, colorize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay(REFRESH * 100);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user