Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power saving mode #306

Merged
merged 9 commits into from
Jan 10, 2024
21 changes: 20 additions & 1 deletion src/MF_CustomDevice/CustomDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
Normally nothing has to be changed in this file
It handles one or multiple custom devices
********************************************************************************** */

#define MESSAGEID_POWERSAVINGMODE -2

namespace CustomDevice
{
MFCustomDevice *customDevice;
Expand Down Expand Up @@ -84,4 +87,20 @@ namespace CustomDevice
customDevice[device].set(messageID, output); // send the string to your custom device
}

} // end of namespace
/* **********************************************************************************
This function is called if the status of the PowerSavingMode changes.
'state' is true if PowerSaving is enabled
'state' is false if PowerSaving is disabled
MessageID '-2' for the custom device for PowerSavingMode
********************************************************************************** */
void PowerSave(bool state)
{
for (uint8_t i = 0; i < customDeviceRegistered; ++i) {
if (state)
customDevice[i].set(MESSAGEID_POWERSAVINGMODE, "1");
else
customDevice[i].set(MESSAGEID_POWERSAVINGMODE, "0");
}
}

} // end of namespace
1 change: 1 addition & 0 deletions src/MF_CustomDevice/CustomDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ namespace CustomDevice
void Clear();
void update();
void OnSet();
void PowerSave(bool state);
}
3 changes: 3 additions & 0 deletions src/mobiflight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ void SetPowerSavingMode(bool state)
#if MF_STEPPER_SUPPORT == 1
Stepper::PowerSave(state);
#endif
#if MF_CUSTOMDEVICE_SUPPORT == 1
CustomDevice::PowerSave(state);
#endif

#ifdef DEBUG2CMDMESSENGER
if (state)
Expand Down
Loading