mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-02 11:55:56 +00:00
Last second fixes (#7156)
* Ditch the 30 second delay for button presses * Only order strictly weakly * Too many comments! * Only sort the populated meshNodes
This commit is contained in:
parent
705515ace2
commit
2bcf608654
@ -58,15 +58,15 @@ bool ButtonThread::initButton(const ButtonConfig &config)
|
|||||||
userButton.attachLongPressStart(
|
userButton.attachLongPressStart(
|
||||||
[](void *callerThread) -> void {
|
[](void *callerThread) -> void {
|
||||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||||
if (millis() > 30000) // hold off 30s after boot
|
// if (millis() > 30000) // hold off 30s after boot
|
||||||
thread->btnEvent = BUTTON_EVENT_LONG_PRESSED;
|
thread->btnEvent = BUTTON_EVENT_LONG_PRESSED;
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
userButton.attachLongPressStop(
|
userButton.attachLongPressStop(
|
||||||
[](void *callerThread) -> void {
|
[](void *callerThread) -> void {
|
||||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||||
if (millis() > 30000) // hold off 30s after boot
|
// if (millis() > 30000) // hold off 30s after boot
|
||||||
thread->btnEvent = BUTTON_EVENT_LONG_RELEASED;
|
thread->btnEvent = BUTTON_EVENT_LONG_RELEASED;
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
@ -254,7 +254,8 @@ int32_t ButtonThread::runOnce()
|
|||||||
case BUTTON_EVENT_LONG_RELEASED: {
|
case BUTTON_EVENT_LONG_RELEASED: {
|
||||||
|
|
||||||
LOG_INFO("LONG PRESS RELEASE");
|
LOG_INFO("LONG PRESS RELEASE");
|
||||||
if (_longLongPress != INPUT_BROKER_NONE && (millis() - buttonPressStartTime) >= _longLongPressTime) {
|
if (millis() > 30000 && _longLongPress != INPUT_BROKER_NONE &&
|
||||||
|
(millis() - buttonPressStartTime) >= _longLongPressTime) {
|
||||||
evt.inputEvent = _longLongPress;
|
evt.inputEvent = _longLongPress;
|
||||||
this->notifyObservers(&evt);
|
this->notifyObservers(&evt);
|
||||||
}
|
}
|
||||||
|
@ -1694,23 +1694,22 @@ void NodeDB::sortMeshDB()
|
|||||||
{
|
{
|
||||||
if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) {
|
if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) {
|
||||||
lastSort = millis();
|
lastSort = millis();
|
||||||
std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
|
std::sort(meshNodes->begin(), meshNodes->begin() + numMeshNodes,
|
||||||
if (a.num == myNodeInfo.my_node_num) {
|
[](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
|
||||||
return true;
|
if (a.num == myNodeInfo.my_node_num) {
|
||||||
}
|
return true;
|
||||||
if (b.num == myNodeInfo.my_node_num) {
|
}
|
||||||
return false;
|
if (b.num == myNodeInfo.my_node_num) {
|
||||||
}
|
return false;
|
||||||
bool aFav = a.is_favorite;
|
}
|
||||||
bool bFav = b.is_favorite;
|
bool aFav = a.is_favorite;
|
||||||
if (aFav != bFav)
|
bool bFav = b.is_favorite;
|
||||||
return aFav;
|
if (aFav != bFav)
|
||||||
if (a.last_heard == 0 || a.last_heard == UINT32_MAX)
|
return aFav;
|
||||||
return false;
|
if (a.last_heard != b.last_heard)
|
||||||
if (b.last_heard == 0 || b.last_heard == UINT32_MAX)
|
return a.last_heard > b.last_heard;
|
||||||
return true;
|
return a.num > b.num;
|
||||||
return a.last_heard > b.last_heard;
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user