diff --git a/src/MF_CustomDevice/CustomDevice.cpp b/src/MF_CustomDevice/CustomDevice.cpp index 66ddbae6..fc80876c 100644 --- a/src/MF_CustomDevice/CustomDevice.cpp +++ b/src/MF_CustomDevice/CustomDevice.cpp @@ -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; @@ -84,4 +87,20 @@ namespace CustomDevice customDevice[device].set(messageID, output); // send the string to your custom device } -} // end of namespace \ No newline at end of file + /* ********************************************************************************** + 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 diff --git a/src/MF_CustomDevice/CustomDevice.h b/src/MF_CustomDevice/CustomDevice.h index 637b0e35..1fcb5fdf 100644 --- a/src/MF_CustomDevice/CustomDevice.h +++ b/src/MF_CustomDevice/CustomDevice.h @@ -7,4 +7,5 @@ namespace CustomDevice void Clear(); void update(); void OnSet(); + void PowerSave(bool state); } \ No newline at end of file diff --git a/src/mobiflight.cpp b/src/mobiflight.cpp index 158a9077..45ebae74 100644 --- a/src/mobiflight.cpp +++ b/src/mobiflight.cpp @@ -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)