mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 01:42:15 +00:00
Add more exclude options to save program ram/flash (#4408)
* Add PowerFSM Exclude option * Add TEXTMESSAGE module exclude option --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
92526fca23
commit
789e8f02bf
@ -22,7 +22,10 @@
|
|||||||
#ifndef SLEEP_TIME
|
#ifndef SLEEP_TIME
|
||||||
#define SLEEP_TIME 30
|
#define SLEEP_TIME 30
|
||||||
#endif
|
#endif
|
||||||
|
#if EXCLUDE_POWER_FSM
|
||||||
|
FakeFsm powerFSM;
|
||||||
|
void PowerFSM_setup(){};
|
||||||
|
#else
|
||||||
/// Should we behave as if we have AC power now?
|
/// Should we behave as if we have AC power now?
|
||||||
static bool isPowered()
|
static bool isPowered()
|
||||||
{
|
{
|
||||||
@ -395,4 +398,5 @@ void PowerFSM_setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
powerFSM.run_machine(); // run one iteration of the state machine, so we run our on enter tasks for the initial DARK state
|
powerFSM.run_machine(); // run one iteration of the state machine, so we run our on enter tasks for the initial DARK state
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Fsm.h>
|
#include "configuration.h"
|
||||||
|
|
||||||
// See sw-design.md for documentation
|
// See sw-design.md for documentation
|
||||||
|
|
||||||
@ -22,7 +22,30 @@
|
|||||||
#define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep)
|
#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
|
#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen
|
||||||
|
|
||||||
|
#if EXCLUDE_POWER_FSM
|
||||||
|
class FakeFsm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void trigger(int event)
|
||||||
|
{
|
||||||
|
if (event == EVENT_SERIAL_CONNECTED) {
|
||||||
|
serialConnected = true;
|
||||||
|
} else if (event == EVENT_SERIAL_DISCONNECTED) {
|
||||||
|
serialConnected = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bool getState() { return serialConnected; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool serialConnected = false;
|
||||||
|
};
|
||||||
|
extern FakeFsm powerFSM;
|
||||||
|
void PowerFSM_setup();
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <Fsm.h>
|
||||||
extern Fsm powerFSM;
|
extern Fsm powerFSM;
|
||||||
extern State stateON, statePOWER, stateSERIAL, stateDARK;
|
extern State stateON, statePOWER, stateSERIAL, stateDARK;
|
||||||
|
|
||||||
void PowerFSM_setup();
|
void PowerFSM_setup();
|
||||||
|
#endif
|
@ -18,6 +18,7 @@ class PowerFSMThread : public OSThread
|
|||||||
protected:
|
protected:
|
||||||
int32_t runOnce() override
|
int32_t runOnce() override
|
||||||
{
|
{
|
||||||
|
#if !EXCLUDE_POWER_FSM
|
||||||
powerFSM.run_machine();
|
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
|
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
||||||
@ -35,6 +36,9 @@ class PowerFSMThread : public OSThread
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 100;
|
return 100;
|
||||||
|
#else
|
||||||
|
return INT32_MAX;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -256,6 +256,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define MESHTASTIC_EXCLUDE_MQTT 1
|
#define MESHTASTIC_EXCLUDE_MQTT 1
|
||||||
#define MESHTASTIC_EXCLUDE_POWERMON 1
|
#define MESHTASTIC_EXCLUDE_POWERMON 1
|
||||||
#define MESHTASTIC_EXCLUDE_I2C 1
|
#define MESHTASTIC_EXCLUDE_I2C 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_POWER_FSM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Turn off all optional modules
|
// Turn off all optional modules
|
||||||
@ -269,6 +270,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define MESHTASTIC_EXCLUDE_RANGETEST 1
|
#define MESHTASTIC_EXCLUDE_RANGETEST 1
|
||||||
#define MESHTASTIC_EXCLUDE_REMOTEHARDWARE 1
|
#define MESHTASTIC_EXCLUDE_REMOTEHARDWARE 1
|
||||||
#define MESHTASTIC_EXCLUDE_STOREFORWARD 1
|
#define MESHTASTIC_EXCLUDE_STOREFORWARD 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_TEXTMESSAGE 1
|
||||||
#define MESHTASTIC_EXCLUDE_ATAK 1
|
#define MESHTASTIC_EXCLUDE_ATAK 1
|
||||||
#define MESHTASTIC_EXCLUDE_CANNEDMESSAGES 1
|
#define MESHTASTIC_EXCLUDE_CANNEDMESSAGES 1
|
||||||
#define MESHTASTIC_EXCLUDE_NEIGHBORINFO 1
|
#define MESHTASTIC_EXCLUDE_NEIGHBORINFO 1
|
||||||
|
@ -818,8 +818,11 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
conn.has_serial = true; // No serial-less devices
|
conn.has_serial = true; // No serial-less devices
|
||||||
|
#if !EXCLUDE_POWER_FSM
|
||||||
conn.serial.is_connected = powerFSM.getState() == &stateSERIAL;
|
conn.serial.is_connected = powerFSM.getState() == &stateSERIAL;
|
||||||
conn.serial.baud = SERIAL_BAUD;
|
#else
|
||||||
|
conn.serial.is_connected = powerFSM.getState();
|
||||||
|
#endif conn.serial.baud = SERIAL_BAUD;
|
||||||
|
|
||||||
r.get_device_connection_status_response = conn;
|
r.get_device_connection_status_response = conn;
|
||||||
r.which_payload_variant = meshtastic_AdminMessage_get_device_connection_status_response_tag;
|
r.which_payload_variant = meshtastic_AdminMessage_get_device_connection_status_response_tag;
|
||||||
|
@ -106,7 +106,9 @@ void setupModules()
|
|||||||
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
||||||
waypointModule = new WaypointModule();
|
waypointModule = new WaypointModule();
|
||||||
#endif
|
#endif
|
||||||
|
#if !MESHTASTIC_EXCLUDE_TEXTMESSAGE
|
||||||
textMessageModule = new TextMessageModule();
|
textMessageModule = new TextMessageModule();
|
||||||
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
||||||
traceRouteModule = new TraceRouteModule();
|
traceRouteModule = new TraceRouteModule();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user