big update:

- display update
- timer changed to ms
- allow connections just when connected
This commit is contained in:
Peter Buchegger 2021-03-27 22:02:43 +01:00
parent c96a0310ae
commit 2c78a002ab
19 changed files with 332 additions and 351 deletions

View file

@ -22,3 +22,11 @@ TaskManager &System::getTaskManager() {
Display &System::getDisplay() {
return _display;
}
bool System::isWifiEthConnected() const {
return _isWifiEthConnected;
}
void System::connectedViaWifiEth(bool status) {
_isWifiEthConnected = status;
}

View file

@ -17,12 +17,15 @@ public:
std::shared_ptr<Configuration> getUserConfig() const;
TaskManager & getTaskManager();
Display & getDisplay();
bool isWifiEthConnected() const;
void connectedViaWifiEth(bool status);
private:
std::shared_ptr<BoardConfig> _boardConfig;
std::shared_ptr<Configuration> _userConfig;
TaskManager _taskManager;
Display _display;
bool _isWifiEthConnected;
};
#endif

View file

@ -75,9 +75,3 @@ void StatusFrame::drawStatusPage(Bitmap &bitmap) {
y += getSystemFont()->heightInPixel;
}
}
bool StatusFrame::isPrio() const {
return std::any_of(_tasks.begin(), _tasks.end(), [](std::shared_ptr<Task> task) {
return task->getState() != Okay;
});
}

View file

@ -81,8 +81,6 @@ public:
}
void drawStatusPage(Bitmap &bitmap) override;
bool isPrio() const;
private:
std::list<std::shared_ptr<Task>> _tasks;
};

View file

@ -1,28 +1,28 @@
#include "Timer.h"
Timer::Timer() : _timeout_sec(0), _timeout(0) {
Timer::Timer() : _timeout_ms(0), _nextTimeout(0) {
}
void Timer::setTimeout(const time_t timeout_sec) {
_timeout_sec = timeout_sec;
void Timer::setTimeout(const uint32_t timeout_ms) {
_timeout_ms = timeout_ms;
}
time_t Timer::getTriggerTime() const {
return _timeout;
time_t Timer::getTriggerTimeInSec() const {
return (_nextTimeout - millis()) / 1000;
}
bool Timer::isActive() const {
return _timeout != 0;
return _nextTimeout != 0;
}
void Timer::reset() {
_timeout = 0;
_nextTimeout = 0;
}
bool Timer::check() {
return now() > _timeout;
return millis() > _nextTimeout;
}
void Timer::start() {
_timeout = now() + _timeout_sec;
_nextTimeout = millis() + _timeout_ms;
}

View file

@ -7,8 +7,8 @@ class Timer {
public:
Timer();
void setTimeout(const time_t timeout_sec);
time_t getTriggerTime() const;
void setTimeout(const uint32_t timeout_ms);
time_t getTriggerTimeInSec() const;
bool isActive() const;
@ -18,8 +18,8 @@ public:
void start();
private:
time_t _timeout_sec;
time_t _timeout;
uint32_t _timeout_ms;
uint32_t _nextTimeout;
};
#endif