71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#include <Arduino.h>
|
|
#include "spore/Spore.h"
|
|
#include "spore/util/Logging.h"
|
|
#include "PixelStreamController.h"
|
|
#include "PixelStreamService.h"
|
|
#include <Adafruit_NeoPixel.h>
|
|
|
|
// Defaults are now loaded from config.json on LittleFS
|
|
// Can still be overridden with preprocessor defines if needed
|
|
#ifndef PIXEL_PIN
|
|
#define PIXEL_PIN 2
|
|
#endif
|
|
|
|
#ifndef PIXEL_COUNT
|
|
#define PIXEL_COUNT 16
|
|
#endif
|
|
|
|
#ifndef PIXEL_BRIGHTNESS
|
|
#define PIXEL_BRIGHTNESS 80
|
|
#endif
|
|
|
|
#ifndef PIXEL_MATRIX_WIDTH
|
|
#define PIXEL_MATRIX_WIDTH 16
|
|
#endif
|
|
|
|
#ifndef PIXEL_MATRIX_SERPENTINE
|
|
#define PIXEL_MATRIX_SERPENTINE 0
|
|
#endif
|
|
|
|
#ifndef PIXEL_TYPE
|
|
#define PIXEL_TYPE NEO_GRB + NEO_KHZ800
|
|
#endif
|
|
|
|
Spore spore({
|
|
{"app", "pixelstream"},
|
|
{"role", "led"},
|
|
{"pixels", String(PIXEL_COUNT)}
|
|
});
|
|
|
|
PixelStreamController* controller = nullptr;
|
|
PixelStreamService* service = nullptr;
|
|
|
|
void setup() {
|
|
spore.setup();
|
|
|
|
// Create service first (need it to load config)
|
|
service = new PixelStreamService(spore.getContext(), spore.getApiServer(), nullptr);
|
|
|
|
// Load pixelstream config from LittleFS (pixelstream.json) or use defaults
|
|
PixelStreamConfig config = service->loadConfig();
|
|
|
|
// Create controller with loaded config
|
|
controller = new PixelStreamController(spore.getContext(), config);
|
|
controller->begin();
|
|
|
|
// Update service with the actual controller
|
|
service->setController(controller);
|
|
|
|
// Register service
|
|
spore.registerService(service);
|
|
|
|
// Start the API server
|
|
spore.begin();
|
|
}
|
|
|
|
void loop() {
|
|
spore.loop();
|
|
}
|
|
|
|
|