SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
system_info.cpp
Go to the documentation of this file.
1#include "sensesp.h"
2
3#include "system_info.h"
4
5#include <WiFi.h>
6
7#include "Arduino.h"
8
9namespace sensesp {
10
12 // getting sporadic divide by 0 exceptions, no harm in skipping a loop.
13 if (elapsed_millis_ == 0) {
14 return;
15 }
16
17 uint32_t current_tick_count_ = event_loop()->getTickCount();
18 output_ =
19 (current_tick_count_ - last_tick_count_) / (elapsed_millis_ / 1000.);
20
21 last_tick_count_ = current_tick_count_;
23
24 this->notify();
25}
26
27void FreeMem::update() { this->emit(ESP.getFreeHeap()); }
28
29void Uptime::update() { this->emit(static_cast<double>(millis()) / 1000.); }
30
31void IPAddrDev::update() { this->emit(WiFi.localIP().toString()); }
32
33void WiFiSignal::update() { this->emit(WiFi.RSSI()); }
34
35} // namespace sensesp
uint32_t last_tick_count_
Definition system_info.h:56
elapsedMillis elapsed_millis_
Definition system_info.h:57
void emit(const uint32_t &new_value)
std::shared_ptr< reactesp::EventLoop > event_loop()
Definition sensesp.cpp:9