diff --git a/examples/chain_counter.cpp b/examples/chain_counter.cpp index 66498e50c..b0f20c903 100644 --- a/examples/chain_counter.cpp +++ b/examples/chain_counter.cpp @@ -48,17 +48,17 @@ void setup() { counter_read_delay, counter_config_path); /** - * An IntegratorT called "accumulator" adds up all the counts it + * An Integrator called "accumulator" adds up all the counts it * receives (which are ints) and multiplies each count by gypsy_circum, which * is the amount of chain, in meters, that is moved by each revolution of the * windlass. (Since gypsy_circum is a float, the output of this transform must - * be a float, which is why we use IntegratorT). It can be + * be a float, which is why we use Integrator). It can be * configured in the Config UI at accum_config_path. */ float gypsy_circum = 0.32; String accum_config_path = "/accumulator/circum"; auto* accumulator = - new IntegratorT(gypsy_circum, 0.0, accum_config_path); + new Integrator(gypsy_circum, 0.0, accum_config_path); /** * There is no path for the amount of anchor rode deployed in the current diff --git a/src/sensesp/net/ws_client.h b/src/sensesp/net/ws_client.h index ca9638226..a75e31b4f 100644 --- a/src/sensesp/net/ws_client.h +++ b/src/sensesp/net/ws_client.h @@ -115,8 +115,8 @@ class WSClient : public Configurable, /// @brief Emits the number of deltas sent since last report TaskQueueProducer delta_tx_tick_producer_ = TaskQueueProducer(0, ReactESP::app, 5, 990); - IntegratorT delta_tx_count_producer_{1, 0, ""}; - IntegratorT delta_rx_count_producer_{1, 0, ""}; + Integrator delta_tx_count_producer_{1, 0, ""}; + Integrator delta_rx_count_producer_{1, 0, ""}; SemaphoreHandle_t received_updates_semaphore_ = xSemaphoreCreateRecursiveMutex(); diff --git a/src/sensesp/sensors/constant_sensor.h b/src/sensesp/sensors/constant_sensor.h index 967e51f1c..c0425eac2 100644 --- a/src/sensesp/sensors/constant_sensor.h +++ b/src/sensesp/sensors/constant_sensor.h @@ -51,10 +51,10 @@ static const char SCHEMA_CONSTANT_SENSOR[] PROGMEM = R"###({ * @brief Base class for constant value sensors. */ template -class ConstantSensor : public SensorT { +class ConstantSensor : public Sensor { public: ConstantSensor(T value, int send_interval = 30, String config_path = "") - : SensorT(config_path), value_{value}, send_interval_{send_interval} { + : Sensor(config_path), value_{value}, send_interval_{send_interval} { this->load_configuration(); ReactESP::app->onRepeat(send_interval_ * 1000, diff --git a/src/sensesp/sensors/digital_input.h b/src/sensesp/sensors/digital_input.h index e3f2686a1..7db74c624 100644 --- a/src/sensesp/sensors/digital_input.h +++ b/src/sensesp/sensors/digital_input.h @@ -45,12 +45,12 @@ class DigitalInput { * @param config_path The path to configuring read_delay in the Config UI. * * */ -class DigitalInputState : public DigitalInput, public SensorT { +class DigitalInputState : public DigitalInput, public Sensor { public: DigitalInputState(uint8_t pin, int pin_mode, int read_delay = 1000, String config_path = "") : DigitalInput{pin, pin_mode}, - SensorT(config_path), + Sensor(config_path), read_delay_{read_delay}, triggered_{false} { load_configuration(); @@ -84,7 +84,7 @@ class DigitalInputState : public DigitalInput, public SensorT { * @param config_path The path to configuring read_delay in the Config UI * * */ -class DigitalInputCounter : public DigitalInput, public SensorT { +class DigitalInputCounter : public DigitalInput, public Sensor { public: DigitalInputCounter(uint8_t pin, int pin_mode, int interrupt_type, unsigned int read_delay, String config_path = "") @@ -106,7 +106,7 @@ class DigitalInputCounter : public DigitalInput, public SensorT { unsigned int read_delay, String config_path, std::function interrupt_handler) : DigitalInput{pin, pin_mode}, - SensorT(config_path), + Sensor(config_path), interrupt_type_{interrupt_type}, interrupt_handler_{interrupt_handler}, read_delay_{read_delay} { @@ -185,12 +185,12 @@ class DigitalInputDebounceCounter : public DigitalInputCounter { * * @see Debounce * */ -class DigitalInputChange : public DigitalInput, public SensorT { +class DigitalInputChange : public DigitalInput, public Sensor { public: DigitalInputChange(uint8_t pin, int pin_mode, int interrupt_type, String config_path = "") : DigitalInput{pin, pin_mode}, - SensorT(config_path), + Sensor(config_path), interrupt_type_{interrupt_type}, triggered_{true} { load_configuration(); diff --git a/src/sensesp/sensors/sensor.cpp b/src/sensesp/sensors/sensor.cpp index c9752578b..4f05a23d4 100644 --- a/src/sensesp/sensors/sensor.cpp +++ b/src/sensesp/sensors/sensor.cpp @@ -2,9 +2,9 @@ namespace sensesp { -std::set Sensor::sensors_; +std::set SensorConfig::sensors_; -Sensor::Sensor(String config_path) : Configurable{config_path} { +SensorConfig::SensorConfig(String config_path) : Configurable{config_path} { sensors_.insert(this); } diff --git a/src/sensesp/sensors/sensor.h b/src/sensesp/sensors/sensor.h index 759055f43..2475cb05c 100644 --- a/src/sensesp/sensors/sensor.h +++ b/src/sensesp/sensors/sensor.h @@ -24,14 +24,14 @@ namespace sensesp { * variable to be configurable at run-time in your project, don't provide a * config_path when you construct the class. */ -class Sensor : virtual public Observable, public Configurable { +class SensorConfig : virtual public Observable, public Configurable { public: - Sensor(String config_path = ""); + SensorConfig(String config_path = ""); - static const std::set& get_sensors() { return sensors_; } + static const std::set& get_sensors() { return sensors_; } private: - static std::set sensors_; + static std::set sensors_; }; /** @@ -39,19 +39,19 @@ class Sensor : virtual public Observable, public Configurable { * **/ template -class SensorT : public Sensor, public ValueProducer { +class Sensor : public ValueProducer { public: - SensorT(String config_path = "") - : Sensor(config_path), ValueProducer() {} + Sensor(String config_path = "") + : SensorConfig(config_path), ValueProducer() {} }; -typedef SensorT FloatSensor; -typedef SensorT IntSensor; -typedef SensorT BoolSensor; -typedef SensorT StringSensor; +typedef Sensor FloatSensor; +typedef Sensor IntSensor; +typedef Sensor BoolSensor; +typedef Sensor StringSensor; template -class RepeatSensor : public SensorT { +class RepeatSensor : public Sensor { public: /** * @brief Construct a new RepeatSensor object. @@ -66,7 +66,7 @@ class RepeatSensor : public SensorT { * @tparam T The type of the value returned by the callback function. */ RepeatSensor(unsigned int repeat_interval_ms, std::function callback) - : SensorT(""), + : Sensor(""), repeat_interval_ms_(repeat_interval_ms), returning_callback_(callback) { ReactESP::app->onRepeat(repeat_interval_ms_, [this]() { @@ -89,7 +89,7 @@ class RepeatSensor : public SensorT { */ RepeatSensor(unsigned int repeat_interval_ms, std::function*)> callback) - : SensorT(""), + : Sensor(""), repeat_interval_ms_(repeat_interval_ms), emitting_callback_(callback) { ReactESP::app->onRepeat(repeat_interval_ms_, diff --git a/src/sensesp/sensors/system_info.h b/src/sensesp/sensors/system_info.h index 7bc7a942d..b153c705d 100644 --- a/src/sensesp/sensors/system_info.h +++ b/src/sensesp/sensors/system_info.h @@ -14,7 +14,7 @@ namespace sensesp { * @brief Connect a system information sensor to SKOutput **/ template -void connect_system_info_sensor(SensorT* sensor, String prefix, +void connect_system_info_sensor(Sensor* sensor, String prefix, String name) { auto hostname_obs = SensESPBaseApp::get()->get_hostname_observable(); String hostname = hostname_obs->get(); diff --git a/src/sensesp/transforms/debounce.h b/src/sensesp/transforms/debounce.h index 615516d6a..4b1fe447e 100644 --- a/src/sensesp/transforms/debounce.h +++ b/src/sensesp/transforms/debounce.h @@ -35,16 +35,14 @@ static const char DEBOUNCE_SCHEMA[] PROGMEM = R"###({ * @see DigitalInputChange */ template -class DebounceTemplate : public SymmetricTransform { +class Debounce : public SymmetricTransform { public: - DebounceTemplate(int ms_min_delay = 15, String config_path = "") - : SymmetricTransform(config_path), - ms_min_delay_{ms_min_delay} { + Debounce(int ms_min_delay = 15, String config_path = "") + : SymmetricTransform(config_path), ms_min_delay_{ms_min_delay} { this->load_configuration(); } virtual void set(T input, uint8_t input_channel = 0) override { - // Input has changed since the last emit, or this is the first // input since the program started to run. @@ -87,13 +85,11 @@ class DebounceTemplate : public SymmetricTransform { virtual String get_config_schema() override { return FPSTR(DEBOUNCE_SCHEMA); } }; -typedef DebounceTemplate DebounceBool; -typedef DebounceTemplate - Debounce; // for backward-compatibility with original class -typedef DebounceTemplate DebounceInt; -typedef DebounceTemplate - DebounceFloat; // not sure this works - test it if you use it +typedef Debounce DebounceBool; +typedef Debounce DebounceInt; +typedef Debounce + DebounceFloat; -} +} // namespace sensesp #endif diff --git a/src/sensesp/transforms/integrator.h b/src/sensesp/transforms/integrator.h index 0bf76b3d9..8539f830d 100644 --- a/src/sensesp/transforms/integrator.h +++ b/src/sensesp/transforms/integrator.h @@ -22,7 +22,7 @@ static const char INTEGRATOR_SCHEMA[] PROGMEM = R"({ * @tparam P Producer (output) data type */ template -class IntegratorT : public Transform { +class Integrator : public Transform { public: /** * @brief Construct a new Integrator T object @@ -31,7 +31,7 @@ class IntegratorT : public Transform { * @param value Initial value of the accumulator * @param config_path Configuration path */ - IntegratorT(P k = 1, P value = 0, String config_path = "") + Integrator(P k = 1, P value = 0, String config_path = "") : Transform(config_path), k{k}, value{value} { this->load_configuration(); this->emit(value); @@ -66,8 +66,8 @@ class IntegratorT : public Transform { P value = 0; }; -typedef IntegratorT Integrator; -typedef IntegratorT Accumulator; +typedef Integrator FloatIntegrator; +typedef Integrator Accumulator; } // namespace sensesp #endif diff --git a/src/sensesp_app_builder.h b/src/sensesp_app_builder.h index e6248aa51..2d290aef8 100644 --- a/src/sensesp_app_builder.h +++ b/src/sensesp_app_builder.h @@ -210,7 +210,7 @@ class SensESPAppBuilder : public SensESPBaseAppBuilder { const SensESPAppBuilder* enable_wifi_watchdog() { // create the wifi disconnect watchdog app_->system_status_controller_ - .connect_to(new DebounceTemplate( + .connect_to(new Debounce( 3 * 60 * 1000 // 180 s = 180000 ms = 3 minutes )) ->connect_to(new LambdaConsumer([](SystemStatus input) {