refactor: harmonize method names

This commit is contained in:
2025-10-14 17:09:54 +02:00
parent 52f9098c1b
commit a45871625e
32 changed files with 274 additions and 79 deletions

View File

@@ -35,15 +35,14 @@ MultiMatrixService::MultiMatrixService(NodeContext& ctx, TaskManager& taskManage
} else {
LOG_ERROR("MultiMatrixService", "Failed to initialize DFPlayer");
}
registerTasks();
}
void MultiMatrixService::registerEndpoints(ApiServer& api) {
api.addEndpoint(API_STATUS_ENDPOINT, HTTP_GET,
api.registerEndpoint(API_STATUS_ENDPOINT, HTTP_GET,
[this](AsyncWebServerRequest* request) { handleStatusRequest(request); },
std::vector<ParamSpec>{});
api.addEndpoint(API_CONTROL_ENDPOINT, HTTP_POST,
api.registerEndpoint(API_CONTROL_ENDPOINT, HTTP_POST,
[this](AsyncWebServerRequest* request) { handleControlRequest(request); },
std::vector<ParamSpec>{
ParamSpec{String("action"), true, String("body"), String("string"),
@@ -144,8 +143,8 @@ void MultiMatrixService::setLoop(bool enabled) {
LOG_INFO("MultiMatrixService", String("Loop ") + (enabled ? "enabled" : "disabled"));
}
void MultiMatrixService::registerTasks() {
m_taskManager.registerTask("multimatrix_potentiometer", POTENTIOMETER_SAMPLE_INTERVAL_MS,
void MultiMatrixService::registerTasks(TaskManager& taskManager) {
taskManager.registerTask("multimatrix_potentiometer", POTENTIOMETER_SAMPLE_INTERVAL_MS,
[this]() { pollPotentiometer(); });
}

View File

@@ -14,6 +14,7 @@ class MultiMatrixService : public Service {
public:
MultiMatrixService(NodeContext& ctx, TaskManager& taskManager, uint8_t rxPin, uint8_t txPin, uint8_t potentiometerPin);
void registerEndpoints(ApiServer& api) override;
void registerTasks(TaskManager& taskManager) override;
const char* getName() const override { return "MultiMatrixAudio"; }
bool isReady() const;
@@ -34,7 +35,6 @@ private:
static constexpr uint8_t MAX_VOLUME = 30;
static constexpr uint8_t POT_VOLUME_EPSILON = 2;
void registerTasks();
void pollPotentiometer();
void handleStatusRequest(AsyncWebServerRequest* request);
void handleControlRequest(AsyncWebServerRequest* request);

View File

@@ -42,7 +42,7 @@ void setup() {
pixelController->begin();
audioService = std::make_shared<MultiMatrixService>(spore.getContext(), spore.getTaskManager(), MP3PLAYER_PIN_RX, MP3PLAYER_PIN_TX, POTENTIOMETER_PIN);
spore.addService(audioService);
spore.registerService(audioService);
spore.begin();