fix review comments (don't let commands queue up if we are missing a display)

This commit is contained in:
geeksville 2020-03-29 11:13:53 -07:00
parent 11d57e721a
commit 81734f75c8
2 changed files with 9 additions and 8 deletions

View File

@ -401,10 +401,7 @@ void _screen_header()
} }
#endif #endif
Screen::Screen(uint8_t address, uint8_t sda, uint8_t scl) Screen::Screen(uint8_t address, uint8_t sda, uint8_t scl) : cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) {}
: cmdQueue(32), useDisplay(false), dispdev(address, sda, scl), ui(&dispdev)
{
}
void Screen::handleSetOn(bool on) void Screen::handleSetOn(bool on)
{ {

View File

@ -40,7 +40,7 @@ class DebugInfo
/// Sets battery/charging/etc status. /// Sets battery/charging/etc status.
// //
void setPowerStatus(const PowerStatus& status) void setPowerStatus(const PowerStatus &status)
{ {
LockGuard guard(&lock); LockGuard guard(&lock);
powerStatus = status; powerStatus = status;
@ -169,9 +169,13 @@ class Screen : public PeriodicTask
/// Enques given command item to be processed by main loop(). /// Enques given command item to be processed by main loop().
bool enqueueCmd(const CmdItem &cmd) bool enqueueCmd(const CmdItem &cmd)
{ {
bool success = cmdQueue.enqueue(cmd, 0); if (!useDisplay)
setPeriod(1); // handle ASAP return true; // claim success if our display is not in use
return success; else {
bool success = cmdQueue.enqueue(cmd, 0);
setPeriod(1); // handle ASAP
return success;
}
} }
// Implementations of various commands, called from doTask(). // Implementations of various commands, called from doTask().