feat: services (#2)
This commit is contained in:
34
examples/neopattern/NeoPatternService.h
Normal file
34
examples/neopattern/NeoPatternService.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "services/Service.h"
|
||||
#include "TaskManager.h"
|
||||
#include "NeoPattern.cpp"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class NeoPatternService : public Service {
|
||||
public:
|
||||
NeoPatternService(TaskManager& taskMgr, uint16_t numPixels, uint8_t pin, uint8_t type);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
const char* getName() const override { return "NeoPattern"; }
|
||||
|
||||
void setBrightness(uint8_t b);
|
||||
void setPatternByName(const String& name);
|
||||
|
||||
private:
|
||||
void registerTasks();
|
||||
void registerPatterns();
|
||||
std::vector<String> patternNamesVector();
|
||||
String currentPatternName();
|
||||
void update();
|
||||
|
||||
// Handlers
|
||||
void handleStatusRequest(AsyncWebServerRequest* request);
|
||||
void handlePatternsRequest(AsyncWebServerRequest* request);
|
||||
void handleControlRequest(AsyncWebServerRequest* request);
|
||||
|
||||
TaskManager& taskManager;
|
||||
NeoPattern pixels;
|
||||
unsigned long updateIntervalMs;
|
||||
uint8_t brightness;
|
||||
std::map<String, std::function<void()>> patternSetters;
|
||||
};
|
||||
Reference in New Issue
Block a user