mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 19:02:00 +00:00
ui: opt-out for discover screen
This commit is contained in:
@@ -407,6 +407,7 @@ int MyMesh::getRecentlyHeard(AdvertPath dest[], int max_num) {
|
|||||||
return max_num;
|
return max_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DISPLAY_CLASS) && !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
int MyMesh::getDiscoveredNodes(DiscoveredNode nodes[], int max_num) {
|
int MyMesh::getDiscoveredNodes(DiscoveredNode nodes[], int max_num) {
|
||||||
if (max_num > DISCOVERED_NODES_TABLE_SIZE) max_num = DISCOVERED_NODES_TABLE_SIZE;
|
if (max_num > DISCOVERED_NODES_TABLE_SIZE) max_num = DISCOVERED_NODES_TABLE_SIZE;
|
||||||
if (max_num > disc_nodes_count) max_num = disc_nodes_count;
|
if (max_num > disc_nodes_count) max_num = disc_nodes_count;
|
||||||
@@ -451,6 +452,7 @@ void MyMesh::checkControlDataForPendingDiscovery(uint8_t payload[], size_t p_len
|
|||||||
}
|
}
|
||||||
disc_nodes_count ++;
|
disc_nodes_count ++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MyMesh::onContactPathUpdated(const ContactInfo &contact) {
|
void MyMesh::onContactPathUpdated(const ContactInfo &contact) {
|
||||||
out_frame[0] = PUSH_CODE_PATH_UPDATED;
|
out_frame[0] = PUSH_CODE_PATH_UPDATED;
|
||||||
@@ -832,7 +834,9 @@ void MyMesh::onControlDataRecv(mesh::Packet *packet) {
|
|||||||
MESH_DEBUG_PRINTLN("onControlDataRecv(), payload_len too long: %d", packet->payload_len);
|
MESH_DEBUG_PRINTLN("onControlDataRecv(), payload_len too long: %d", packet->payload_len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if defined(DISPLAY_CLASS) && !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
checkControlDataForPendingDiscovery(packet->payload, packet->payload_len);
|
checkControlDataForPendingDiscovery(packet->payload, packet->payload_len);
|
||||||
|
#endif
|
||||||
int i = 0;
|
int i = 0;
|
||||||
out_frame[i++] = PUSH_CODE_CONTROL_DATA;
|
out_frame[i++] = PUSH_CODE_CONTROL_DATA;
|
||||||
out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4);
|
out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ struct AdvertPath {
|
|||||||
uint8_t path[MAX_PATH_SIZE];
|
uint8_t path[MAX_PATH_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(DISPLAY_CLASS) && !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
struct DiscoveredNode {
|
struct DiscoveredNode {
|
||||||
uint8_t pubkey_prefix[9];
|
uint8_t pubkey_prefix[9];
|
||||||
float snr_in;
|
float snr_in;
|
||||||
@@ -91,6 +92,7 @@ struct DiscoveredNode {
|
|||||||
char name[32];
|
char name[32];
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class MyMesh : public BaseChatMesh, public DataStoreHost {
|
class MyMesh : public BaseChatMesh, public DataStoreHost {
|
||||||
public:
|
public:
|
||||||
@@ -110,8 +112,10 @@ public:
|
|||||||
|
|
||||||
int getRecentlyHeard(AdvertPath dest[], int max_num);
|
int getRecentlyHeard(AdvertPath dest[], int max_num);
|
||||||
|
|
||||||
|
#if defined(DISPLAY_CLASS) && !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
bool requestRepeatersDiscovery();
|
bool requestRepeatersDiscovery();
|
||||||
int getDiscoveredNodes(DiscoveredNode nodes[], int max_num);
|
int getDiscoveredNodes(DiscoveredNode nodes[], int max_num);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float getAirtimeBudgetFactor() const override;
|
float getAirtimeBudgetFactor() const override;
|
||||||
@@ -268,12 +272,18 @@ private:
|
|||||||
#define ADVERT_PATH_TABLE_SIZE 16
|
#define ADVERT_PATH_TABLE_SIZE 16
|
||||||
AdvertPath advert_paths[ADVERT_PATH_TABLE_SIZE]; // circular table
|
AdvertPath advert_paths[ADVERT_PATH_TABLE_SIZE]; // circular table
|
||||||
|
|
||||||
#define DISCOVERED_NODES_TABLE_SIZE 10
|
#if defined(DISPLAY_CLASS) && !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
|
#ifdef UI_RECENT_LIST_SIZE
|
||||||
|
#define DISCOVERED_NODES_TABLE_SIZE UI_RECENT_LIST_SIZE
|
||||||
|
#else
|
||||||
|
#define DISCOVERED_NODES_TABLE_SIZE 4
|
||||||
|
#endif
|
||||||
DiscoveredNode discovered_nodes[DISCOVERED_NODES_TABLE_SIZE]; // not circular, latest discovered nodes are not kept
|
DiscoveredNode discovered_nodes[DISCOVERED_NODES_TABLE_SIZE]; // not circular, latest discovered nodes are not kept
|
||||||
uint32_t disc_node_req_tag = 0;
|
uint32_t disc_node_req_tag = 0;
|
||||||
uint32_t disc_nodes_count = 0;
|
uint32_t disc_nodes_count = 0;
|
||||||
|
|
||||||
void checkControlDataForPendingDiscovery(uint8_t payload[], size_t p_len);
|
void checkControlDataForPendingDiscovery(uint8_t payload[], size_t p_len);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MyMesh the_mesh;
|
extern MyMesh the_mesh;
|
||||||
|
|||||||
@@ -103,7 +103,9 @@ class HomeScreen : public UIScreen {
|
|||||||
#if UI_SENSORS_PAGE == 1
|
#if UI_SENSORS_PAGE == 1
|
||||||
SENSORS,
|
SENSORS,
|
||||||
#endif
|
#endif
|
||||||
|
#if !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
DISCOVERY,
|
DISCOVERY,
|
||||||
|
#endif
|
||||||
SHUTDOWN,
|
SHUTDOWN,
|
||||||
Count // keep as last
|
Count // keep as last
|
||||||
};
|
};
|
||||||
@@ -115,9 +117,11 @@ class HomeScreen : public UIScreen {
|
|||||||
uint8_t _page;
|
uint8_t _page;
|
||||||
bool _shutdown_init;
|
bool _shutdown_init;
|
||||||
AdvertPath recent[UI_RECENT_LIST_SIZE];
|
AdvertPath recent[UI_RECENT_LIST_SIZE];
|
||||||
|
#if !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
DiscoveredNode discovered[UI_RECENT_LIST_SIZE];
|
DiscoveredNode discovered[UI_RECENT_LIST_SIZE];
|
||||||
uint32_t discovery_req_time = 0;
|
uint32_t discovery_req_time = 0;
|
||||||
bool discovery_disp_names = true; // by default desplay names if available (removes SNR_O)
|
bool discovery_disp_names = true; // by default desplay names if available (removes SNR_O)
|
||||||
|
#endif
|
||||||
|
|
||||||
void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) {
|
void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) {
|
||||||
// Convert millivolts to percentage
|
// Convert millivolts to percentage
|
||||||
@@ -463,6 +467,7 @@ public:
|
|||||||
if (sensors_scroll) sensors_scroll_offset = (sensors_scroll_offset+1)%sensors_nb;
|
if (sensors_scroll) sensors_scroll_offset = (sensors_scroll_offset+1)%sensors_nb;
|
||||||
else sensors_scroll_offset = 0;
|
else sensors_scroll_offset = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#if !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
} else if (_page == HomePage::DISCOVERY) {
|
} else if (_page == HomePage::DISCOVERY) {
|
||||||
int count = the_mesh.getDiscoveredNodes(discovered, UI_RECENT_LIST_SIZE);
|
int count = the_mesh.getDiscoveredNodes(discovered, UI_RECENT_LIST_SIZE);
|
||||||
display.setColor(UIColor::primary_txt);
|
display.setColor(UIColor::primary_txt);
|
||||||
@@ -495,7 +500,7 @@ public:
|
|||||||
y = 10 + 11 * UI_RECENT_LIST_SIZE;
|
y = 10 + 11 * UI_RECENT_LIST_SIZE;
|
||||||
display.drawTextCentered(display.width() / 2, y, "discover: " PRESS_LABEL);
|
display.drawTextCentered(display.width() / 2, y, "discover: " PRESS_LABEL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (_page == HomePage::SHUTDOWN) {
|
} else if (_page == HomePage::SHUTDOWN) {
|
||||||
display.setColor(UIColor::corp_blue);
|
display.setColor(UIColor::corp_blue);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@@ -521,9 +526,11 @@ public:
|
|||||||
if (_page == HomePage::RECENT) {
|
if (_page == HomePage::RECENT) {
|
||||||
_task->showAlert("Recent adverts", 800);
|
_task->showAlert("Recent adverts", 800);
|
||||||
}
|
}
|
||||||
|
#if !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
if (_page == HomePage::DISCOVERY) {
|
if (_page == HomePage::DISCOVERY) {
|
||||||
_task->showAlert("Repeater disc", 800);
|
_task->showAlert("Repeater disc", 800);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (c == KEY_ENTER && _page == HomePage::BLUETOOTH) {
|
if (c == KEY_ENTER && _page == HomePage::BLUETOOTH) {
|
||||||
@@ -556,6 +563,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if !(defined(UI_NO_DISCOVER_SCREEN) && (UI_NO_DISCOVER_SCREEN + 0 != 0))
|
||||||
if (c == KEY_ENTER && _page == HomePage::DISCOVERY) {
|
if (c == KEY_ENTER && _page == HomePage::DISCOVERY) {
|
||||||
if (millis() > discovery_req_time + 5000) { // rate limiter
|
if (millis() > discovery_req_time + 5000) { // rate limiter
|
||||||
the_mesh.requestRepeatersDiscovery();
|
the_mesh.requestRepeatersDiscovery();
|
||||||
@@ -567,6 +575,7 @@ public:
|
|||||||
discovery_disp_names = !discovery_disp_names;
|
discovery_disp_names = !discovery_disp_names;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (c == KEY_ENTER && _page == HomePage::SHUTDOWN) {
|
if (c == KEY_ENTER && _page == HomePage::SHUTDOWN) {
|
||||||
_shutdown_init = true; // need to wait for button to be released
|
_shutdown_init = true; // need to wait for button to be released
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user