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:
Jonathan Bennett 2024-08-06 18:48:55 -05:00 committed by GitHub
parent 92526fca23
commit 789e8f02bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 4 deletions

View File

@ -22,7 +22,10 @@
#ifndef SLEEP_TIME
#define SLEEP_TIME 30
#endif
#if EXCLUDE_POWER_FSM
FakeFsm powerFSM;
void PowerFSM_setup(){};
#else
/// Should we behave as if we have AC power now?
static bool isPowered()
{
@ -395,4 +398,5 @@ void PowerFSM_setup()
#endif
powerFSM.run_machine(); // run one iteration of the state machine, so we run our on enter tasks for the initial DARK state
}
}
#endif

View File

@ -1,6 +1,6 @@
#pragma once
#include <Fsm.h>
#include "configuration.h"
// See sw-design.md for documentation
@ -22,7 +22,30 @@
#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
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 State stateON, statePOWER, stateSERIAL, stateDARK;
void PowerFSM_setup();
#endif

View File

@ -18,6 +18,7 @@ class PowerFSMThread : public OSThread
protected:
int32_t runOnce() override
{
#if !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
@ -35,6 +36,9 @@ class PowerFSMThread : public OSThread
}
return 100;
#else
return INT32_MAX;
#endif
}
};

View File

@ -256,6 +256,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MESHTASTIC_EXCLUDE_MQTT 1
#define MESHTASTIC_EXCLUDE_POWERMON 1
#define MESHTASTIC_EXCLUDE_I2C 1
#define MESHTASTIC_EXCLUDE_POWER_FSM 1
#endif
// 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_REMOTEHARDWARE 1
#define MESHTASTIC_EXCLUDE_STOREFORWARD 1
#define MESHTASTIC_EXCLUDE_TEXTMESSAGE 1
#define MESHTASTIC_EXCLUDE_ATAK 1
#define MESHTASTIC_EXCLUDE_CANNEDMESSAGES 1
#define MESHTASTIC_EXCLUDE_NEIGHBORINFO 1

View File

@ -818,8 +818,11 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
#endif
#endif
conn.has_serial = true; // No serial-less devices
#if !EXCLUDE_POWER_FSM
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.which_payload_variant = meshtastic_AdminMessage_get_device_connection_status_response_tag;

View File

@ -106,7 +106,9 @@ void setupModules()
#if !MESHTASTIC_EXCLUDE_WAYPOINT
waypointModule = new WaypointModule();
#endif
#if !MESHTASTIC_EXCLUDE_TEXTMESSAGE
textMessageModule = new TextMessageModule();
#endif
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
traceRouteModule = new TraceRouteModule();
#endif