add counter 0..2 for short pulses, high frequency, #2758

This commit is contained in:
MichaelDvP
2025-11-26 18:14:58 +01:00
parent 9edcf47073
commit 2bcd548747
7 changed files with 120 additions and 40 deletions

View File

@@ -132,7 +132,10 @@ class AnalogSensor {
PULSE = 12,
FREQ_0 = 13,
FREQ_1 = 14,
FREQ_2 = 15
FREQ_2 = 15,
CNT_0 = 16,
CNT_1 = 17,
CNT_2 = 18
};
void start(const bool factory_settings = false);
@@ -174,6 +177,9 @@ class AnalogSensor {
bool update(uint8_t gpio, std::string & name, double offset, double factor, uint8_t uom, int8_t type, bool deleted, bool is_system);
bool get_value_info(JsonObject output, const char * cmd, const int8_t id = -1);
void store_counters();
static std::vector<uint8_t> exclude_types() {
return exclude_types_;
}
private:
static constexpr double Beta = 4260;
@@ -185,7 +191,6 @@ class AnalogSensor {
static constexpr uint32_t MEASURE_ANALOG_INTERVAL = 500;
static uuid::log::Logger logger_;
void remove_ha_topic(const int8_t type, const uint8_t id) const;
bool command_setvalue(const char * value, const int8_t gpio);
void measure();
@@ -193,6 +198,7 @@ class AnalogSensor {
void get_value_json(JsonObject output, const Sensor & sensor);
std::vector<Sensor> sensors_; // our list of sensors
static std::vector<uint8_t> exclude_types_;
bool analog_enabled_;
bool changed_ = true; // this will force a publish of all sensors when initialising