46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
#include <Arduino.h>
|
|
#include "spore/Spore.h"
|
|
#include "spore/services/LoggingService.h"
|
|
#include "NeoPixelService.h"
|
|
|
|
#ifndef NEOPIXEL_PIN
|
|
#define NEOPIXEL_PIN 2
|
|
#endif
|
|
|
|
#ifndef NEOPIXEL_COUNT
|
|
#define NEOPIXEL_COUNT 16
|
|
#endif
|
|
|
|
#ifndef NEOPIXEL_TYPE
|
|
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800)
|
|
#endif
|
|
|
|
// Create Spore instance with custom labels
|
|
Spore spore({
|
|
{"app", "neopixel"},
|
|
{"device", "light"},
|
|
{"pixels", String(NEOPIXEL_COUNT)},
|
|
{"pin", String(NEOPIXEL_PIN)}
|
|
});
|
|
|
|
// Create custom service
|
|
NeoPixelService* neoPixelService = nullptr;
|
|
|
|
void setup() {
|
|
// Initialize the Spore framework
|
|
spore.setup();
|
|
|
|
// Create and add custom service
|
|
neoPixelService = new NeoPixelService(spore.getTaskManager(), NEOPIXEL_COUNT, NEOPIXEL_PIN, NEOPIXEL_TYPE);
|
|
spore.addService(neoPixelService);
|
|
|
|
// Start the API server and complete initialization
|
|
spore.begin();
|
|
|
|
LOG_INFO(spore.getContext(), "Main", "NeoPixel service registered and ready!");
|
|
}
|
|
|
|
void loop() {
|
|
// Run the Spore framework loop
|
|
spore.loop();
|
|
} |