pin versions

This commit is contained in:
2025-08-14 21:21:39 +02:00
parent 1aa90acee4
commit afd867d393
79 changed files with 20 additions and 7833 deletions

View File

@@ -1,38 +0,0 @@
#include "RotaryPlugin.h"
RotaryPlugin::RotaryPlugin(RotaryConfig cfg)
{
config = cfg;
rotaryEncoder = new AiEsp32RotaryEncoder(config.pinA, config.pinB, config.pinButton, config.pinVcc);
rotaryEncoder->begin();
rotaryEncoder->setBoundaries(config.lowerBound, config.upperBound, config.circulateValues);
}
void RotaryPlugin::activate(Scheduler *userScheduler)
{
// add update task
inputTask.set(TASK_MILLISECOND * config.updateInterval, TASK_FOREVER, std::bind(&RotaryPlugin::checkInput, this));
userScheduler->addTask(inputTask);
inputTask.enable();
// add dummy subscription
subscribe(config.topic, [](String msg){});
subscribe(String(config.topic) + "/btn", [](String msg){});
PRINT_MSG(Serial, "PLUGIN", "RotaryPlugin activated");
}
void RotaryPlugin::checkInput()
{
rotaryEncoder->enable();
if (rotaryEncoder->encoderChanged())
{
int encReading = rotaryEncoder->readEncoder();
publish(config.topic, String(encReading));
}
ButtonState newBtnState = rotaryEncoder->currentButtonState();
if(newBtnState != btnState){
btnState = newBtnState;
publish(String(config.topic) + String("/btn"), String(btnState));
}
}

View File

@@ -1,45 +0,0 @@
#ifndef __ROTARY_PLUGIN_H__
#define __ROTARY_PLUGIN_H__
#define _TASK_SLEEP_ON_IDLE_RUN
#define _TASK_STD_FUNCTION
#include <functional>
#include <vector>
#include <FS.h>
#include <TaskSchedulerDeclarations.h>
#include <Plugin.h>
#include <utils/print.h>
#include <utils/misc.h>
#include "AiEsp32RotaryEncoder.h"
using namespace std;
using namespace std::placeholders;
struct RotaryConfig
{
int pinA;
int pinB;
int pinButton;
int pinVcc;
int updateInterval;
int lowerBound;
int upperBound;
bool circulateValues;
const char* topic;
//const char* topicButton;
};
class RotaryPlugin : public Plugin {
public:
Task inputTask;
int currentVal = 0;
ButtonState btnState = BUT_RELEASED;
AiEsp32RotaryEncoder* rotaryEncoder;
RotaryConfig config;
RotaryPlugin(RotaryConfig cfg);
void activate(Scheduler* userScheduler);
void checkInput();
};
#endif