Skip to content

Commit

Permalink
Make system info sensors inherit from ValueProducer<T>
Browse files Browse the repository at this point in the history
They have no use for being FileSystemSaveable.
  • Loading branch information
mairas committed Oct 5, 2024
1 parent ae81b15 commit 91d4409
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/sensesp/sensors/system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void connect_system_info_sensor(Sensor<T>* sensor, String prefix, String name) {
* appears in your project's output. That is configured with
* SensESPAppBuilder.
**/
class SystemHz : public FloatSensor {
class SystemHz : public ValueProducer<float> {
public:
SystemHz() {
elapsed_millis_ = 0;
Expand All @@ -53,10 +53,9 @@ class SystemHz : public FloatSensor {
}
String get_value_name() { return "systemhz"; }

private:
protected:
uint32_t tick_count_ = 0;
elapsedMillis elapsed_millis_;
float system_hz_;
void tick();
void update();
};
Expand All @@ -68,15 +67,15 @@ class SystemHz : public FloatSensor {
* appears in your project's output. That is configured with
* SensESPAppBuilder.
**/
class FreeMem : public IntSensor {
class FreeMem : public ValueProducer<uint32_t> {
public:
FreeMem() {
SensESPBaseApp::get_event_loop()->onRepeat(1000,
[this]() { this->update(); });
}
String get_value_name() { return "freemem"; }

private:
protected:
void update();
};

Expand All @@ -88,15 +87,15 @@ class FreeMem : public IntSensor {
* appears in your project's output. That is configured with
* SensESPAppBuilder.
**/
class Uptime : public FloatSensor {
class Uptime : public ValueProducer<float> {
public:
Uptime() {
SensESPBaseApp::get_event_loop()->onRepeat(1000,
[this]() { this->update(); });
}
String get_value_name() { return "uptime"; }

private:
protected:
void update();
};

Expand All @@ -108,15 +107,15 @@ class Uptime : public FloatSensor {
* appears in your project's output. That is configured with
* SensESPAppBuilder.
**/
class IPAddrDev : public StringSensor {
class IPAddrDev : public ValueProducer<String> {
public:
IPAddrDev() {
SensESPBaseApp::get_event_loop()->onRepeat(10000,
[this]() { this->update(); });
}
String get_value_name() { return "ipaddr"; }

private:
protected:
void update();
};

Expand All @@ -128,15 +127,15 @@ class IPAddrDev : public StringSensor {
* appears in your project's output. That is configured with
* SensESPAppBuilder.
**/
class WiFiSignal : public FloatSensor {
class WiFiSignal : public ValueProducer<int> {
public:
WiFiSignal() {
SensESPBaseApp::get_event_loop()->onRepeat(3000,
[this]() { this->update(); });
}
String get_value_name() { return "wifisignal"; }

private:
protected:
void update();
};

Expand Down

0 comments on commit 91d4409

Please sign in to comment.