Usermod class vars part1: add enabled and _name for imu and dallas
usermod_mpu6050_imu.h and usermod_temperature.h: - remove bool enabled = false/true (now default false) - remove static const char _name[] and _enabled[] - add constructor which calls superclass (temp?) - replace _enabled with "enabled" - remove const char PROGMEM init for _name[] and _enabled[] settings_um.htm: - Add usermod table with class properties (name and enabled) -> WIP as not all UM's now and enable will be checkbox ? (compare with info tab...?) fcn_declare.h - add _name and enabled to Usermod class and add name to constructor usermods_list.cpp - add Usermod name to constructor for mpu6050 and temperature) - to do add enabled is true to constructor
This commit is contained in:
@@ -45,13 +45,9 @@ class UsermodTemperature : public Usermod {
|
||||
// temperature if flashed to a board without a sensor attached
|
||||
byte sensorFound;
|
||||
|
||||
bool enabled = true;
|
||||
|
||||
bool HApublished = false;
|
||||
|
||||
// strings to reduce flash memory usage (used more than twice)
|
||||
static const char _name[];
|
||||
static const char _enabled[];
|
||||
static const char _readInterval[];
|
||||
static const char _parasite[];
|
||||
static const char _parasitePin[];
|
||||
@@ -163,6 +159,7 @@ class UsermodTemperature : public Usermod {
|
||||
#endif
|
||||
|
||||
public:
|
||||
UsermodTemperature(const char *name):Usermod(name) {} //WLEDMM: this shouldn't be necessary (passthrough of constructor), maybe because Usermod is an abstract class
|
||||
|
||||
void setup() {
|
||||
int retries = 10;
|
||||
@@ -327,7 +324,7 @@ class UsermodTemperature : public Usermod {
|
||||
void addToConfig(JsonObject &root) {
|
||||
// we add JSON object: {"Temperature": {"pin": 0, "degC": true}}
|
||||
JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname
|
||||
top[FPSTR(_enabled)] = enabled;
|
||||
top[FPSTR("enabled")] = enabled;
|
||||
top["pin"] = temperaturePin; // usermodparam
|
||||
top["degC"] = degC; // usermodparam
|
||||
top[FPSTR(_readInterval)] = readingInterval / 1000;
|
||||
@@ -352,7 +349,7 @@ class UsermodTemperature : public Usermod {
|
||||
return false;
|
||||
}
|
||||
|
||||
enabled = top[FPSTR(_enabled)] | enabled;
|
||||
enabled = top[FPSTR("enabled")] | enabled;
|
||||
newTemperaturePin = top["pin"] | newTemperaturePin;
|
||||
degC = top["degC"] | degC;
|
||||
readingInterval = top[FPSTR(_readInterval)] | readingInterval/1000;
|
||||
@@ -398,8 +395,6 @@ class UsermodTemperature : public Usermod {
|
||||
};
|
||||
|
||||
// strings to reduce flash memory usage (used more than twice)
|
||||
const char UsermodTemperature::_name[] PROGMEM = "Temperature";
|
||||
const char UsermodTemperature::_enabled[] PROGMEM = "enabled";
|
||||
const char UsermodTemperature::_readInterval[] PROGMEM = "read-interval-s";
|
||||
const char UsermodTemperature::_parasite[] PROGMEM = "parasite-pwr";
|
||||
const char UsermodTemperature::_parasitePin[] PROGMEM = "parasite-pwr-pin";
|
||||
|
||||
@@ -93,7 +93,6 @@ void IRAM_ATTR dmpDataReady() {
|
||||
class MPU6050Driver : public Usermod {
|
||||
private:
|
||||
MPU6050 mpu;
|
||||
bool enabled = true;
|
||||
bool initDone = false;
|
||||
unsigned long lastUMRun = millis();
|
||||
|
||||
@@ -105,11 +104,11 @@ class MPU6050Driver : public Usermod {
|
||||
uint8_t fifoBuffer[64]; // FIFO storage buffer
|
||||
|
||||
// strings to reduce flash memory usage (used more than twice)
|
||||
static const char _name[];
|
||||
static const char _enabled[];
|
||||
static const char _INT_pin[];
|
||||
|
||||
public:
|
||||
MPU6050Driver(const char *name):Usermod(name) {} //WLEDMM: this shouldn't be necessary (passthrough of constructor), maybe because Usermod is an abstract class
|
||||
|
||||
bool dmpReady = false; // set true if DMP init was successful // WLEDMM expose this info in public interface
|
||||
// orientation/motion vars
|
||||
Quaternion qat; // [w, x, y, z] quaternion container
|
||||
@@ -128,7 +127,7 @@ class MPU6050Driver : public Usermod {
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
// WLEDMM begin
|
||||
// WLEDMM begin
|
||||
if (!enabled) {
|
||||
dmpReady = false;
|
||||
return;
|
||||
@@ -358,7 +357,7 @@ class MPU6050Driver : public Usermod {
|
||||
void addToConfig(JsonObject& root)
|
||||
{
|
||||
JsonObject top = root.createNestedObject(FPSTR(_name));
|
||||
top[FPSTR(_enabled)] = enabled;
|
||||
top[FPSTR("enabled")] = enabled;
|
||||
//JsonObject interruptPin = top.createNestedObject(FPSTR(_INT_pin));
|
||||
//interruptPin["pin"] = INTERRUPT_PIN;
|
||||
DEBUG_PRINTLN(F("MPU6050 IMU config saved."));
|
||||
@@ -390,7 +389,7 @@ class MPU6050Driver : public Usermod {
|
||||
}
|
||||
|
||||
bool configComplete = !top.isNull();
|
||||
configComplete &= getJsonValue(top[FPSTR(_enabled)], enabled);
|
||||
configComplete &= getJsonValue(top[FPSTR("enabled")], enabled);
|
||||
//configComplete &= getJsonValue(top[FPSTR(_INT_pin)]["pin"], INTERRUPT_PIN);
|
||||
|
||||
DEBUG_PRINT(FPSTR(_name));
|
||||
@@ -416,6 +415,4 @@ class MPU6050Driver : public Usermod {
|
||||
};
|
||||
|
||||
// strings to reduce flash memory usage (used more than twice)
|
||||
const char MPU6050Driver::_name[] PROGMEM = "mpu6050-IMU";
|
||||
const char MPU6050Driver::_enabled[] PROGMEM = "enabled";
|
||||
const char MPU6050Driver::_INT_pin[] PROGMEM = "interrupt_pin";
|
||||
|
||||
Reference in New Issue
Block a user