mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-01 07:30:33 +00:00
Merge remote-tracking branch 'upstream/master' into sh1106-support
This commit is contained in:
45
src/screen.h
45
src/screen.h
@@ -13,7 +13,10 @@
|
||||
#include "PeriodicTask.h"
|
||||
#include "TypedQueue.h"
|
||||
#include "lock.h"
|
||||
#include "power.h"
|
||||
#include "PowerStatus.h"
|
||||
#include "GPSStatus.h"
|
||||
#include "NodeStatus.h"
|
||||
#include "Observer.h"
|
||||
#include <string>
|
||||
|
||||
namespace meshtastic
|
||||
@@ -29,14 +32,6 @@ class DebugInfo
|
||||
DebugInfo(const DebugInfo &) = delete;
|
||||
DebugInfo &operator=(const DebugInfo &) = delete;
|
||||
|
||||
/// Sets user statistics.
|
||||
void setNodeNumbersStatus(int online, int total)
|
||||
{
|
||||
LockGuard guard(&lock);
|
||||
nodesOnline = online;
|
||||
nodesTotal = total;
|
||||
}
|
||||
|
||||
/// Sets the name of the channel.
|
||||
void setChannelNameStatus(const char *name)
|
||||
{
|
||||
@@ -44,25 +39,6 @@ class DebugInfo
|
||||
channelName = name;
|
||||
}
|
||||
|
||||
/// Sets battery/charging/etc status.
|
||||
//
|
||||
void setPowerStatus(const PowerStatus &status)
|
||||
{
|
||||
LockGuard guard(&lock);
|
||||
powerStatus = status;
|
||||
}
|
||||
|
||||
/// Sets GPS status.
|
||||
//
|
||||
// If this function never gets called, we assume GPS does not exist on this
|
||||
// device.
|
||||
// TODO(girts): figure out what the format should be.
|
||||
void setGPSStatus(const char *status)
|
||||
{
|
||||
LockGuard guard(&lock);
|
||||
gpsStatus = status;
|
||||
}
|
||||
|
||||
private:
|
||||
friend Screen;
|
||||
|
||||
@@ -71,15 +47,8 @@ class DebugInfo
|
||||
/// Renders the debug screen.
|
||||
void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||
|
||||
int nodesOnline = 0;
|
||||
int nodesTotal = 0;
|
||||
|
||||
PowerStatus powerStatus;
|
||||
|
||||
std::string channelName;
|
||||
|
||||
std::string gpsStatus;
|
||||
|
||||
/// Protects all of internal state.
|
||||
Lock lock;
|
||||
};
|
||||
@@ -93,6 +62,10 @@ class DebugInfo
|
||||
// simultaneously).
|
||||
class Screen : public PeriodicTask
|
||||
{
|
||||
CallbackObserver<Screen, const Status *> powerStatusObserver = CallbackObserver<Screen, const Status *>(this, &Screen::handleStatusUpdate);
|
||||
CallbackObserver<Screen, const Status *> gpsStatusObserver = CallbackObserver<Screen, const Status *>(this, &Screen::handleStatusUpdate);
|
||||
CallbackObserver<Screen, const Status *> nodeStatusObserver = CallbackObserver<Screen, const Status *>(this, &Screen::handleStatusUpdate);
|
||||
|
||||
public:
|
||||
Screen(uint8_t address, int sda = -1, int scl = -1);
|
||||
|
||||
@@ -189,6 +162,8 @@ class Screen : public PeriodicTask
|
||||
// Use this handle to set things like battery status, user count, GPS status, etc.
|
||||
DebugInfo *debug() { return &debugInfo; }
|
||||
|
||||
int handleStatusUpdate(const meshtastic::Status *arg);
|
||||
|
||||
protected:
|
||||
/// Updates the UI.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user