diff --git a/platformio.ini b/platformio.ini
index f6c16d7..d076722 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -1,5 +1,5 @@
;[platformio]
-;env_default = Pot, Pot_esp32
+;env_default = analog
[common]
framework = arduino
@@ -15,25 +15,25 @@ lib_deps =
https://gitlab.com/wirelos/sprocket-lib.git#develop
-[env:pot]
+[env:analog]
platform = ${common.platform}
board = ${common.board}
framework = ${common.framework}
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
-src_filter = +<*> - + - +
+src_filter = +<*> - + - +
lib_deps = ${common.lib_deps}
lib_ignore =
Ai Esp32 Rotary Encoder
-[env:pot_esp32]
+[env:analog_esp32]
platform = espressif32
board = esp32dev
framework = ${common.framework}
build_flags = -std=c++14
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
-src_filter = +<*> - + - +
+src_filter = +<*> - + - +
lib_deps = ${common.lib_deps}
lib_ignore =
Ai Esp32 Rotary Encoder
@@ -56,6 +56,6 @@ framework = ${common.framework}
build_flags = -std=c++14
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
-src_filter = +<*> + + - +
+src_filter = +<*> + + - +
lib_deps = ${common.lib_deps}
Ai Esp32 Rotary Encoder
\ No newline at end of file
diff --git a/src/examples/pot/config.h b/src/examples/analog/config.h
similarity index 100%
rename from src/examples/pot/config.h
rename to src/examples/analog/config.h
diff --git a/src/examples/pot/main.cpp b/src/examples/analog/main.cpp
similarity index 82%
rename from src/examples/pot/main.cpp
rename to src/examples/analog/main.cpp
index fb5cb96..7c292a0 100644
--- a/src/examples/pot/main.cpp
+++ b/src/examples/analog/main.cpp
@@ -1,13 +1,13 @@
#include "config.h"
#include "Sprocket.h"
-#include "inputs/pot/PotPlugin.h"
+#include "inputs/analog/AnalogInputPlugin.h"
Sprocket *sprocket;
void registerPot(Sprocket* s, int pin, const char* topic)
{
s->addPlugin(
- new PotPlugin({pin, POT_THRESHOLD, POT_POLL_INTERVAL, topic}));
+ new AnalogInputPlugin({pin, POT_THRESHOLD, POT_POLL_INTERVAL, topic}));
s->subscribe(topic, bind([](String label, String val){
PRINT_MSG(Serial, label.c_str(), val.c_str());
}, topic, _1));
diff --git a/src/examples/combined/main.cpp b/src/examples/combined/main.cpp
index 58b2178..337dff7 100644
--- a/src/examples/combined/main.cpp
+++ b/src/examples/combined/main.cpp
@@ -1,11 +1,11 @@
#include "config.h"
#include "Sprocket.h"
#include "inputs/rotary/RotaryPlugin.h"
-#include "inputs/pot/PotPlugin.h"
+#include "inputs/analog/AnalogInputPlugin.h"
Sprocket *sprocket;
RotaryPlugin *r1;
-PotPlugin* p1;
+AnalogInputPlugin* p1;
void addRotary(Sprocket *s, Plugin *r, const char *topic)
{
@@ -15,13 +15,12 @@ void addRotary(Sprocket *s, Plugin *r, const char *topic)
s->addPlugin(r);
}
-void addPot(Sprocket* s, int pin, const char* topic)
+void addAnalogInput(Sprocket* s, int pin, const char* topic)
{
- s->addPlugin(
- new PotPlugin({pin, POT_THRESHOLD, POT_POLL_INTERVAL, topic}));
s->subscribe(topic, bind([](String label, String val){
PRINT_MSG(Serial, label.c_str(), val.c_str());
}, topic, _1));
+ s->addPlugin(new AnalogInputPlugin({pin, POT_THRESHOLD, POT_POLL_INTERVAL, topic}));
}
void setup()
@@ -30,10 +29,10 @@ void setup()
r1 = new RotaryPlugin({35, 34, 21, -1, 50, 0, 255, true, "rotary1"});
r1->rotaryEncoder->setup([] { r1->rotaryEncoder->readEncoder_ISR(); });
addRotary(sprocket, r1, "rotary1");
- addPot(sprocket, 36, "pot1");
- addPot(sprocket, 37, "pot2");
- addPot(sprocket, 38, "pot3");
- addPot(sprocket, 39, "pot4");
+ addAnalogInput(sprocket, 36, "pot1");
+ addAnalogInput(sprocket, 37, "pot2");
+ addAnalogInput(sprocket, 38, "pot3");
+ addAnalogInput(sprocket, 39, "pot4");
sprocket->activate();
}
diff --git a/src/inputs/pot/PotPlugin.cpp b/src/inputs/analog/AnalogInputPlugin.cpp
similarity index 55%
rename from src/inputs/pot/PotPlugin.cpp
rename to src/inputs/analog/AnalogInputPlugin.cpp
index 4c5f757..391c0b6 100644
--- a/src/inputs/pot/PotPlugin.cpp
+++ b/src/inputs/analog/AnalogInputPlugin.cpp
@@ -1,19 +1,18 @@
-#include "PotPlugin.h"
+#include "AnalogInputPlugin.h"
-PotPlugin::PotPlugin(GpioConfig cfg){
+AnalogInputPlugin::AnalogInputPlugin(GpioConfig cfg){
config = cfg;
}
-void PotPlugin::activate(Scheduler *userScheduler)
+void AnalogInputPlugin::activate(Scheduler *userScheduler)
{
- inputTask.set(TASK_MILLISECOND * config.updateInterval, TASK_FOREVER, std::bind(&PotPlugin::checkInput, this));
+ inputTask.set(TASK_MILLISECOND * config.updateInterval, TASK_FOREVER, std::bind(&AnalogInputPlugin::checkInput, this));
userScheduler->addTask(inputTask);
inputTask.enable();
- PRINT_MSG(Serial, "PLUGIN", "PotPlugin activated");
+ PRINT_MSG(Serial, "PLUGIN", "AnalogInputPlugin activated");
}
-void PotPlugin::checkInput()
+void AnalogInputPlugin::checkInput()
{
- // FIXME add range and threashold to config
int newVal = analogRead(config.pin);
if ((newVal >= currentVal + config.threshold || newVal <= currentVal - config.threshold))
{
diff --git a/src/inputs/pot/PotPlugin.h b/src/inputs/analog/AnalogInputPlugin.h
similarity index 75%
rename from src/inputs/pot/PotPlugin.h
rename to src/inputs/analog/AnalogInputPlugin.h
index 75cd403..25831ad 100644
--- a/src/inputs/pot/PotPlugin.h
+++ b/src/inputs/analog/AnalogInputPlugin.h
@@ -1,5 +1,5 @@
-#ifndef __POT_PLUGIN_H__
-#define __POT_PLUGIN_H__
+#ifndef __ANALOG_INPUT__PLUGIN_H__
+#define __ANALOG_INPUT__PLUGIN_H__
#define _TASK_SLEEP_ON_IDLE_RUN
#define _TASK_STD_FUNCTION
@@ -16,12 +16,12 @@
using namespace std;
using namespace std::placeholders;
-class PotPlugin : public Plugin {
+class AnalogInputPlugin : public Plugin {
public:
Task inputTask;
int currentVal = 0;
GpioConfig config;
- PotPlugin(GpioConfig cfg);
+ AnalogInputPlugin(GpioConfig cfg);
void activate(Scheduler* userScheduler);
void checkInput();
};