Abstracted statuses, made display event-driven

This commit is contained in:
Professr
2020-06-27 21:19:49 -07:00
parent 5ea59a1c4d
commit 542b8b26ce
16 changed files with 565 additions and 266 deletions

View File

@@ -2,9 +2,11 @@
#include <Arduino.h>
#include <assert.h>
#include "Observer.h"
#include "MeshTypes.h"
#include "mesh-pb-constants.h"
#include "NodeStatus.h"
extern DeviceState devicestate;
extern MyNodeInfo &myNodeInfo;
@@ -32,6 +34,7 @@ class NodeDB
bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled
NodeInfo *updateGUIforNode = NULL; // if currently showing this node, we think you should update the GUI
bool updateTextMessage = false; // if true, the GUI should show a new text message
Observable<const meshtastic::NodeStatus> newStatus;
/// don't do mesh based algoritm for node id assignment (initially)
/// instead just store in flash - possibly even in the initial alpha release do this hack
@@ -91,6 +94,15 @@ class NodeDB
/// Find a node in our DB, create an empty NodeInfo if missing
NodeInfo *getOrCreateNode(NodeNum n);
/// Notify observers of changes to the DB
void notifyObservers() {
// Notify observers of the current node state
meshtastic::NodeStatus status;
status.numOnline = getNumOnlineNodes();
status.numTotal = getNumNodes();
newStatus.notifyObservers(status);
}
/// read our db from flash
void loadFromDisk();