35 lines
1010 B
C++
35 lines
1010 B
C++
#pragma once
|
|
#include "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;
|
|
};
|