Gps toggle on 4 clicks
This commit is contained in:
@@ -50,9 +50,12 @@ void Button::update() {
|
|||||||
triggerEvent(SHORT_PRESS);
|
triggerEvent(SHORT_PRESS);
|
||||||
} else if (_clickCount == 2) {
|
} else if (_clickCount == 2) {
|
||||||
triggerEvent(DOUBLE_PRESS);
|
triggerEvent(DOUBLE_PRESS);
|
||||||
} else if (_clickCount >= 3) {
|
} else if (_clickCount == 3) {
|
||||||
triggerEvent(TRIPLE_PRESS);
|
triggerEvent(TRIPLE_PRESS);
|
||||||
|
} else if (_clickCount >= 4) {
|
||||||
|
triggerEvent(QUADRUPLE_PRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
_clickCount = 0;
|
_clickCount = 0;
|
||||||
_state = IDLE;
|
_state = IDLE;
|
||||||
}
|
}
|
||||||
@@ -116,6 +119,9 @@ void Button::triggerEvent(EventType event) {
|
|||||||
case TRIPLE_PRESS:
|
case TRIPLE_PRESS:
|
||||||
if (_onTriplePress) _onTriplePress();
|
if (_onTriplePress) _onTriplePress();
|
||||||
break;
|
break;
|
||||||
|
case QUADRUPLE_PRESS:
|
||||||
|
if (_onQuadruplePress) _onQuadruplePress();
|
||||||
|
break;
|
||||||
case LONG_PRESS:
|
case LONG_PRESS:
|
||||||
if (_onLongPress) _onLongPress();
|
if (_onLongPress) _onLongPress();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
SHORT_PRESS,
|
SHORT_PRESS,
|
||||||
DOUBLE_PRESS,
|
DOUBLE_PRESS,
|
||||||
TRIPLE_PRESS,
|
TRIPLE_PRESS,
|
||||||
|
QUADRUPLE_PRESS,
|
||||||
LONG_PRESS,
|
LONG_PRESS,
|
||||||
ANY_PRESS
|
ANY_PRESS
|
||||||
};
|
};
|
||||||
@@ -32,6 +33,7 @@ public:
|
|||||||
void onShortPress(EventCallback callback) { _onShortPress = callback; }
|
void onShortPress(EventCallback callback) { _onShortPress = callback; }
|
||||||
void onDoublePress(EventCallback callback) { _onDoublePress = callback; }
|
void onDoublePress(EventCallback callback) { _onDoublePress = callback; }
|
||||||
void onTriplePress(EventCallback callback) { _onTriplePress = callback; }
|
void onTriplePress(EventCallback callback) { _onTriplePress = callback; }
|
||||||
|
void onQuadruplePress(EventCallback callback) { _onQuadruplePress = callback; }
|
||||||
void onLongPress(EventCallback callback) { _onLongPress = callback; }
|
void onLongPress(EventCallback callback) { _onLongPress = callback; }
|
||||||
void onAnyPress(EventCallback callback) { _onAnyPress = callback; }
|
void onAnyPress(EventCallback callback) { _onAnyPress = callback; }
|
||||||
|
|
||||||
@@ -68,6 +70,7 @@ private:
|
|||||||
EventCallback _onShortPress = nullptr;
|
EventCallback _onShortPress = nullptr;
|
||||||
EventCallback _onDoublePress = nullptr;
|
EventCallback _onDoublePress = nullptr;
|
||||||
EventCallback _onTriplePress = nullptr;
|
EventCallback _onTriplePress = nullptr;
|
||||||
|
EventCallback _onQuadruplePress = nullptr;
|
||||||
EventCallback _onLongPress = nullptr;
|
EventCallback _onLongPress = nullptr;
|
||||||
EventCallback _onAnyPress = nullptr;
|
EventCallback _onAnyPress = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs) {
|
|||||||
_userButton->onShortPress([this]() { handleButtonShortPress(); });
|
_userButton->onShortPress([this]() { handleButtonShortPress(); });
|
||||||
_userButton->onDoublePress([this]() { handleButtonDoublePress(); });
|
_userButton->onDoublePress([this]() { handleButtonDoublePress(); });
|
||||||
_userButton->onTriplePress([this]() { handleButtonTriplePress(); });
|
_userButton->onTriplePress([this]() { handleButtonTriplePress(); });
|
||||||
|
_userButton->onQuadruplePress([this]() { handleButtonQuadruplePress(); });
|
||||||
_userButton->onLongPress([this]() { handleButtonLongPress(); });
|
_userButton->onLongPress([this]() { handleButtonLongPress(); });
|
||||||
_userButton->onAnyPress([this]() { handleButtonAnyPress(); });
|
_userButton->onAnyPress([this]() { handleButtonAnyPress(); });
|
||||||
#endif
|
#endif
|
||||||
@@ -383,6 +384,12 @@ void UITask::handleButtonTriplePress() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UITask::handleButtonQuadruplePress() {
|
||||||
|
MESH_DEBUG_PRINTLN("UITask: quad press triggered");
|
||||||
|
_board->toggleGps();
|
||||||
|
_need_refresh = true;
|
||||||
|
}
|
||||||
|
|
||||||
void UITask::handleButtonLongPress() {
|
void UITask::handleButtonLongPress() {
|
||||||
MESH_DEBUG_PRINTLN("UITask: long press triggered");
|
MESH_DEBUG_PRINTLN("UITask: long press triggered");
|
||||||
if (millis() - ui_started_at < 8000) { // long press in first 8 seconds since startup -> CLI/rescue
|
if (millis() - ui_started_at < 8000) { // long press in first 8 seconds since startup -> CLI/rescue
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class UITask {
|
|||||||
void handleButtonShortPress();
|
void handleButtonShortPress();
|
||||||
void handleButtonDoublePress();
|
void handleButtonDoublePress();
|
||||||
void handleButtonTriplePress();
|
void handleButtonTriplePress();
|
||||||
|
void handleButtonQuadruplePress();
|
||||||
void handleButtonLongPress();
|
void handleButtonLongPress();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
virtual void onAfterTransmit() { }
|
virtual void onAfterTransmit() { }
|
||||||
virtual void reboot() = 0;
|
virtual void reboot() = 0;
|
||||||
virtual void powerOff() { /* no op */ }
|
virtual void powerOff() { /* no op */ }
|
||||||
|
virtual bool toggleGps() { return false; } // could be a board_toggle depending on the board features ...
|
||||||
virtual uint8_t getStartupReason() const = 0;
|
virtual uint8_t getStartupReason() const = 0;
|
||||||
virtual bool startOTAUpdate(const char* id, char reply[]) { return false; } // not supported
|
virtual bool startOTAUpdate(const char* id, char reply[]) { return false; } // not supported
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "T1000eBoard.h"
|
#include "T1000eBoard.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
#include <bluefruit.h>
|
#include <bluefruit.h>
|
||||||
|
|
||||||
@@ -26,6 +27,10 @@ void T1000eBoard::begin() {
|
|||||||
delay(10); // give sx1262 some time to power up
|
delay(10); // give sx1262 some time to power up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool T1000eBoard::toggleGps() {
|
||||||
|
return sensors.toggle_gps();
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static BLEDfu bledfu;
|
static BLEDfu bledfu;
|
||||||
|
|
||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool toggleGps() override;
|
||||||
|
|
||||||
void powerOff() override {
|
void powerOff() override {
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
digitalWrite(GPS_VRTC_EN, LOW);
|
digitalWrite(GPS_VRTC_EN, LOW);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#define RADIOLIB_STATIC_ONLY 1
|
#define RADIOLIB_STATIC_ONLY 1
|
||||||
#include <RadioLib.h>
|
#include <RadioLib.h>
|
||||||
#include <helpers/RadioLibWrappers.h>
|
#include <helpers/RadioLibWrappers.h>
|
||||||
#include <helpers/nrf52/T1000eBoard.h>
|
#include "T1000eBoard.h"
|
||||||
#include <helpers/CustomLR1110Wrapper.h>
|
#include <helpers/CustomLR1110Wrapper.h>
|
||||||
#include <helpers/ArduinoHelpers.h>
|
#include <helpers/ArduinoHelpers.h>
|
||||||
#include <helpers/SensorManager.h>
|
#include <helpers/SensorManager.h>
|
||||||
@@ -28,6 +28,7 @@ public:
|
|||||||
const char* getSettingName(int i) const override;
|
const char* getSettingName(int i) const override;
|
||||||
const char* getSettingValue(int i) const override;
|
const char* getSettingValue(int i) const override;
|
||||||
bool setSettingValue(const char* name, const char* value) override;
|
bool setSettingValue(const char* name, const char* value) override;
|
||||||
|
bool toggle_gps() { gps_active ? stop_gps() : start_gps(); return gps_active;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
Reference in New Issue
Block a user