mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-18 15:57:24 +00:00
Merge branch 'master' into t-deck-pro
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#ifndef SLEEP_TIME
|
||||
#define SLEEP_TIME 30
|
||||
#endif
|
||||
#if EXCLUDE_POWER_FSM
|
||||
#if MESHTASTIC_EXCLUDE_POWER_FSM
|
||||
FakeFsm powerFSM;
|
||||
void PowerFSM_setup(){};
|
||||
#else
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep)
|
||||
#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen
|
||||
|
||||
#if EXCLUDE_POWER_FSM
|
||||
#if MESHTASTIC_EXCLUDE_POWER_FSM
|
||||
class FakeFsm
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -18,7 +18,7 @@ class PowerFSMThread : public OSThread
|
||||
protected:
|
||||
int32_t runOnce() override
|
||||
{
|
||||
#if !EXCLUDE_POWER_FSM
|
||||
#if !MESHTASTIC_EXCLUDE_POWER_FSM
|
||||
powerFSM.run_machine();
|
||||
|
||||
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
||||
|
||||
@@ -12,6 +12,7 @@ void TrackballInterruptBase::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLef
|
||||
this->_pinUp = pinUp;
|
||||
this->_pinLeft = pinLeft;
|
||||
this->_pinRight = pinRight;
|
||||
this->_pinPress = pinPress;
|
||||
this->_eventDown = eventDown;
|
||||
this->_eventUp = eventUp;
|
||||
this->_eventLeft = eventLeft;
|
||||
@@ -20,23 +21,23 @@ void TrackballInterruptBase::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLef
|
||||
|
||||
if (pinPress != 255) {
|
||||
pinMode(pinPress, INPUT_PULLUP);
|
||||
attachInterrupt(pinPress, onIntPress, RISING);
|
||||
attachInterrupt(pinPress, onIntPress, TB_DIRECTION);
|
||||
}
|
||||
if (this->_pinDown != 255) {
|
||||
pinMode(this->_pinDown, INPUT_PULLUP);
|
||||
attachInterrupt(this->_pinDown, onIntDown, RISING);
|
||||
attachInterrupt(this->_pinDown, onIntDown, TB_DIRECTION);
|
||||
}
|
||||
if (this->_pinUp != 255) {
|
||||
pinMode(this->_pinUp, INPUT_PULLUP);
|
||||
attachInterrupt(this->_pinUp, onIntUp, RISING);
|
||||
attachInterrupt(this->_pinUp, onIntUp, TB_DIRECTION);
|
||||
}
|
||||
if (this->_pinLeft != 255) {
|
||||
pinMode(this->_pinLeft, INPUT_PULLUP);
|
||||
attachInterrupt(this->_pinLeft, onIntLeft, RISING);
|
||||
attachInterrupt(this->_pinLeft, onIntLeft, TB_DIRECTION);
|
||||
}
|
||||
if (this->_pinRight != 255) {
|
||||
pinMode(this->_pinRight, INPUT_PULLUP);
|
||||
attachInterrupt(this->_pinRight, onIntRight, RISING);
|
||||
attachInterrupt(this->_pinRight, onIntRight, TB_DIRECTION);
|
||||
}
|
||||
|
||||
LOG_DEBUG("Trackball GPIO initialized (%d, %d, %d, %d, %d)", this->_pinUp, this->_pinDown, this->_pinLeft, this->_pinRight,
|
||||
@@ -67,19 +68,19 @@ int32_t TrackballInterruptBase::runOnce()
|
||||
e.inputEvent = this->_eventRight;
|
||||
}
|
||||
#else
|
||||
if (this->action == TB_ACTION_PRESSED) {
|
||||
if (this->action == TB_ACTION_PRESSED && !digitalRead(_pinPress)) {
|
||||
// LOG_DEBUG("Trackball event Press");
|
||||
e.inputEvent = this->_eventPressed;
|
||||
} else if (this->action == TB_ACTION_UP) {
|
||||
} else if (this->action == TB_ACTION_UP && !digitalRead(_pinUp)) {
|
||||
// LOG_DEBUG("Trackball event UP");
|
||||
e.inputEvent = this->_eventUp;
|
||||
} else if (this->action == TB_ACTION_DOWN) {
|
||||
} else if (this->action == TB_ACTION_DOWN && !digitalRead(_pinDown)) {
|
||||
// LOG_DEBUG("Trackball event DOWN");
|
||||
e.inputEvent = this->_eventDown;
|
||||
} else if (this->action == TB_ACTION_LEFT) {
|
||||
} else if (this->action == TB_ACTION_LEFT && !digitalRead(_pinLeft)) {
|
||||
// LOG_DEBUG("Trackball event LEFT");
|
||||
e.inputEvent = this->_eventLeft;
|
||||
} else if (this->action == TB_ACTION_RIGHT) {
|
||||
} else if (this->action == TB_ACTION_RIGHT && !digitalRead(_pinRight)) {
|
||||
// LOG_DEBUG("Trackball event RIGHT");
|
||||
e.inputEvent = this->_eventRight;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include "InputBroker.h"
|
||||
#include "mesh/NodeDB.h"
|
||||
|
||||
#ifndef TB_DIRECTION
|
||||
#define TB_DIRECTION RISING
|
||||
#endif
|
||||
|
||||
class TrackballInterruptBase : public Observable<const InputEvent *>, public concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
@@ -16,6 +20,7 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
void intUpHandler();
|
||||
void intLeftHandler();
|
||||
void intRightHandler();
|
||||
uint32_t lastTime = 0;
|
||||
|
||||
virtual int32_t runOnce() override;
|
||||
|
||||
@@ -28,14 +33,15 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
TB_ACTION_LEFT,
|
||||
TB_ACTION_RIGHT
|
||||
};
|
||||
|
||||
volatile TrackballInterruptBaseActionType action = TB_ACTION_NONE;
|
||||
|
||||
private:
|
||||
uint8_t _pinDown = 0;
|
||||
uint8_t _pinUp = 0;
|
||||
uint8_t _pinLeft = 0;
|
||||
uint8_t _pinRight = 0;
|
||||
uint8_t _pinPress = 0;
|
||||
|
||||
volatile TrackballInterruptBaseActionType action = TB_ACTION_NONE;
|
||||
|
||||
private:
|
||||
input_broker_event _eventDown = INPUT_BROKER_NONE;
|
||||
input_broker_event _eventUp = INPUT_BROKER_NONE;
|
||||
input_broker_event _eventLeft = INPUT_BROKER_NONE;
|
||||
|
||||
@@ -23,21 +23,41 @@ void TrackballInterruptImpl1::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLe
|
||||
|
||||
void TrackballInterruptImpl1::handleIntDown()
|
||||
{
|
||||
trackballInterruptImpl1->intDownHandler();
|
||||
if (TB_DIRECTION == RISING || millis() > trackballInterruptImpl1->lastTime + 10) {
|
||||
trackballInterruptImpl1->lastTime = millis();
|
||||
trackballInterruptImpl1->intDownHandler();
|
||||
trackballInterruptImpl1->setIntervalFromNow(20);
|
||||
}
|
||||
}
|
||||
void TrackballInterruptImpl1::handleIntUp()
|
||||
{
|
||||
trackballInterruptImpl1->intUpHandler();
|
||||
if (TB_DIRECTION == RISING || millis() > trackballInterruptImpl1->lastTime + 10) {
|
||||
trackballInterruptImpl1->lastTime = millis();
|
||||
trackballInterruptImpl1->intUpHandler();
|
||||
trackballInterruptImpl1->setIntervalFromNow(20);
|
||||
}
|
||||
}
|
||||
void TrackballInterruptImpl1::handleIntLeft()
|
||||
{
|
||||
trackballInterruptImpl1->intLeftHandler();
|
||||
if (TB_DIRECTION == RISING || millis() > trackballInterruptImpl1->lastTime + 10) {
|
||||
trackballInterruptImpl1->lastTime = millis();
|
||||
trackballInterruptImpl1->intLeftHandler();
|
||||
trackballInterruptImpl1->setIntervalFromNow(20);
|
||||
}
|
||||
}
|
||||
void TrackballInterruptImpl1::handleIntRight()
|
||||
{
|
||||
trackballInterruptImpl1->intRightHandler();
|
||||
if (TB_DIRECTION == RISING || millis() > trackballInterruptImpl1->lastTime + 10) {
|
||||
trackballInterruptImpl1->lastTime = millis();
|
||||
trackballInterruptImpl1->intRightHandler();
|
||||
trackballInterruptImpl1->setIntervalFromNow(20);
|
||||
}
|
||||
}
|
||||
void TrackballInterruptImpl1::handleIntPressed()
|
||||
{
|
||||
trackballInterruptImpl1->intPressHandler();
|
||||
if (TB_DIRECTION == RISING || millis() > trackballInterruptImpl1->lastTime + 10) {
|
||||
trackballInterruptImpl1->lastTime = millis();
|
||||
trackballInterruptImpl1->intPressHandler();
|
||||
trackballInterruptImpl1->setIntervalFromNow(20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,17 @@ class Default
|
||||
throttlingFactor = 0.04;
|
||||
else if (config.lora.use_preset && config.lora.modem_preset == meshtastic_Config_LoRaConfig_ModemPreset_MEDIUM_FAST)
|
||||
throttlingFactor = 0.02;
|
||||
else if (config.lora.use_preset && config.lora.modem_preset == meshtastic_Config_LoRaConfig_ModemPreset_SHORT_SLOW)
|
||||
throttlingFactor = 0.01;
|
||||
else if (config.lora.use_preset &&
|
||||
IS_ONE_OF(config.lora.modem_preset, meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST,
|
||||
meshtastic_Config_LoRaConfig_ModemPreset_SHORT_TURBO))
|
||||
return 1.0; // Don't bother throttling for highest bandwidth presets
|
||||
meshtastic_Config_LoRaConfig_ModemPreset_SHORT_TURBO,
|
||||
meshtastic_Config_LoRaConfig_ModemPreset_SHORT_SLOW))
|
||||
throttlingFactor = 0.01;
|
||||
|
||||
#if USERPREFS_EVENT_MODE
|
||||
// If we are in event mode, scale down the throttling factor
|
||||
throttlingFactor = 0.04;
|
||||
#endif
|
||||
|
||||
// Scaling up traffic based on number of nodes over 40
|
||||
int nodesOverForty = (numOnlineNodes - 40);
|
||||
return 1.0 + (nodesOverForty * throttlingFactor); // Each number of online node scales by 0.075 (default)
|
||||
|
||||
@@ -1137,7 +1137,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
|
||||
#endif
|
||||
#endif
|
||||
conn.has_serial = true; // No serial-less devices
|
||||
#if !EXCLUDE_POWER_FSM
|
||||
#if !MESHTASTIC_EXCLUDE_POWER_FSM
|
||||
conn.serial.is_connected = powerFSM.getState() == &stateSERIAL;
|
||||
#else
|
||||
conn.serial.is_connected = powerFSM.getState();
|
||||
|
||||
Reference in New Issue
Block a user