feat: rewrite NeoPattern example
This commit is contained in:
@@ -2,25 +2,31 @@
|
||||
#include "spore/Spore.h"
|
||||
#include "spore/util/Logging.h"
|
||||
#include "NeoPatternService.h"
|
||||
#include "NeoPixelConfig.h"
|
||||
|
||||
#ifndef LED_STRIP_PIN
|
||||
#define LED_STRIP_PIN 2
|
||||
// Configuration constants
|
||||
#ifndef NEOPIXEL_PIN
|
||||
#define NEOPIXEL_PIN 2
|
||||
#endif
|
||||
|
||||
#ifndef LED_STRIP_LENGTH
|
||||
#define LED_STRIP_LENGTH 8
|
||||
#ifndef NEOPIXEL_LENGTH
|
||||
#define NEOPIXEL_LENGTH 8
|
||||
#endif
|
||||
|
||||
#ifndef LED_STRIP_TYPE
|
||||
#define LED_STRIP_TYPE (NEO_GRB + NEO_KHZ800)
|
||||
#ifndef NEOPIXEL_BRIGHTNESS
|
||||
#define NEOPIXEL_BRIGHTNESS 100
|
||||
#endif
|
||||
|
||||
#ifndef NEOPIXEL_UPDATE_INTERVAL
|
||||
#define NEOPIXEL_UPDATE_INTERVAL 100
|
||||
#endif
|
||||
|
||||
// Create Spore instance with custom labels
|
||||
Spore spore({
|
||||
{"app", "neopattern"},
|
||||
{"device", "light"},
|
||||
{"pixels", String(LED_STRIP_LENGTH)},
|
||||
{"pin", String(LED_STRIP_PIN)}
|
||||
{"device", "led_strip"},
|
||||
{"pixels", String(NEOPIXEL_LENGTH)},
|
||||
{"pin", String(NEOPIXEL_PIN)}
|
||||
});
|
||||
|
||||
// Create custom service
|
||||
@@ -30,17 +36,25 @@ void setup() {
|
||||
// Initialize the Spore framework
|
||||
spore.setup();
|
||||
|
||||
// Create configuration
|
||||
NeoPixelConfig config(
|
||||
NEOPIXEL_PIN,
|
||||
NEOPIXEL_LENGTH,
|
||||
NEOPIXEL_BRIGHTNESS,
|
||||
NEOPIXEL_UPDATE_INTERVAL
|
||||
);
|
||||
|
||||
// Create and add custom service
|
||||
neoPatternService = new NeoPatternService(spore.getTaskManager(), LED_STRIP_LENGTH, LED_STRIP_PIN, LED_STRIP_TYPE);
|
||||
neoPatternService = new NeoPatternService(spore.getTaskManager(), config);
|
||||
spore.addService(neoPatternService);
|
||||
|
||||
// Start the API server and complete initialization
|
||||
spore.begin();
|
||||
|
||||
LOG_INFO( "Main", "NeoPattern service registered and ready!");
|
||||
LOG_INFO("Main", "NeoPattern service registered and ready!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Run the Spore framework loop
|
||||
spore.loop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user