Files
spore/examples/neopixel/main.cpp
Patrick Balsiger bf17684dc6 feat: implement Spore framework class as main orchestration layer
- Add Spore class as unified interface for all core framework functionality
- Implement setup() and begin() methods for flexible initialization pattern
- Add service registration with addService() for both raw and smart pointers
- Provide accessor methods for core components (getTaskManager, getContext, etc.)
- Automatically include core services (Node, Network, Cluster, Task)
- Update all examples to use simplified Spore framework approach
- Fix circular dependency issues in include structure
- Remove setHostname and setApiPort configuration methods
- Add comprehensive documentation and usage examples

The Spore class encapsulates all core functionality from the base example
and provides a clean, unified API for the entire framework. Examples now
use just spore.setup() -> add services -> spore.begin() -> spore.loop().
2025-09-13 21:17:54 +02:00

45 lines
1002 B
C++

#include <Arduino.h>
#include "Spore.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();
Serial.println("[Main] NeoPixel service registered and ready!");
}
void loop() {
// Run the Spore framework loop
spore.loop();
}