Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmunro committed Jan 22, 2024
1 parent b539526 commit 3c1f8ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
33 changes: 27 additions & 6 deletions arduino/bitmapstream.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#define PIN_E 32
#define PANE_WIDTH PANEL_WIDTH * PANELS_NUMBER
#define PANE_HEIGHT PANEL_HEIGHT
#define useWifiManager 0

const char* wifiSsid = "moleman";
const char* wifiPass = "queenlaika";

const char* websockets_connection_string = "ws://rgb.mun.sh/sub"; //Enter server adress
using namespace websockets;
Expand All @@ -17,7 +21,6 @@ MatrixPanel_I2S_DMA* dma_display;
WebsocketsClient client;

void onMessageCallback(WebsocketsMessage message) {
Serial.print("Got Message");
uint16_t* uint16_data = (uint16_t *) message.c_str();
dma_display->drawRGBBitmap(0, 0, uint16_data, 128, 32);
}
Expand Down Expand Up @@ -54,27 +57,45 @@ void setup() {
mxconfig.mx_height = PANEL_HEIGHT; // we have 64 pix heigh panels
mxconfig.chain_length = PANELS_NUMBER; // we have 2 panels chained
mxconfig.gpio.e = PIN_E; // we MUST assign pin e to some free pin on a board to drive 64 pix height panels with 1/32 scan
// mxconfig.latch_blanking = 4;
// mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
mxconfig.clkphase = false;

dma_display = new MatrixPanel_I2S_DMA(mxconfig);

// let's adjust default brightness to about 75%
dma_display->setBrightness8(190); // range is 0-255, 0 - 0%, 255 - 100%

// Allocate memory and start DMA display
if (not dma_display->begin())
Serial.println("****** !KABOOM! I2S memory allocation failed ***********");

// let's adjust default brightness to about 75%
dma_display->setBrightness8(255); // range is 0-255, 0 - 0%, 255 - 100%

// Write some text
dma_display->fillScreenRGB888(0, 0, 255);
dma_display->setTextSize(1); // size 1 == 8 pixels high
dma_display->setTextWrap(true); // Don't wrap at end of line - will do ourselves
dma_display->print("Connecting...config wifi at SSID:TrainSignAP");
delay(1000);

WiFiManager wm;
bool connected;
connected = wm.autoConnect("TrainSignAP");

#if useWifiManager == 0
// Normal wifi
WiFi.mode(WIFI_STA);
WiFi.begin(wifiSsid, wifiPass);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}

connected = true;
#else
// WIFI MANAGER
WiFiManager wm;
connected = wm.autoConnect("TrainSignAP");
#endif


if(!connected) {
Serial.println("Failed to connect");
dma_display->fillScreenRGB888(255, 0, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ app.get('/api/train/:station', async (req, res) => {
};
};

if (!data?.services) {
res.json([]);
return;
}

// https://www.realtimetrains.co.uk/about/developer/pull/docs/locationlist/
let formatted = data.services.map((train: any) => ({
scheduled: formatDate(train.locationDetail.gbttBookedArrival),
Expand Down

0 comments on commit 3c1f8ca

Please sign in to comment.