Files
spore/examples/neopattern/main.cpp
2025-10-14 18:01:37 +02:00

61 lines
1.3 KiB
C++

#include <Arduino.h>
#include "spore/Spore.h"
#include "spore/util/Logging.h"
#include "NeoPatternService.h"
#include "NeoPixelConfig.h"
// Configuration constants
#ifndef NEOPIXEL_PIN
#define NEOPIXEL_PIN 2
#endif
#ifndef NEOPIXEL_LENGTH
#define NEOPIXEL_LENGTH 16
#endif
#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"},
{"role", "led"},
{"pixels", String(NEOPIXEL_LENGTH)},
{"pin", String(NEOPIXEL_PIN)}
});
// Create custom service
NeoPatternService* neoPatternService = nullptr;
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.getContext(), spore.getTaskManager(), config);
spore.registerService(neoPatternService);
// Start the API server and complete initialization
spore.begin();
LOG_INFO("Main", "NeoPattern service registered and ready!");
}
void loop() {
// Run the Spore framework loop
spore.loop();
}