From 7ee6c9cfa1d29fb9faf2786376123a633f81224b Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Wed, 10 Jan 2024 13:13:05 +0100 Subject: [PATCH 1/3] Power saving mode (#306) * add power saving maode for custom devices * add PowerSavingMode * fixed wrong function to enter PowerSavingMode * send Message for PowerSavingMode in correct format * MessageID is '-2' for PowerSavingMode * use a define instead of fixed value for set() command --- src/MF_CustomDevice/CustomDevice.cpp | 21 ++++++++++++++++++++- src/MF_CustomDevice/CustomDevice.h | 1 + src/mobiflight.cpp | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) 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) From f971fba97c3f65be6189e1fd32275808717b7bb2 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Wed, 10 Jan 2024 13:13:29 +0100 Subject: [PATCH 2/3] Fix reversed logic for output shifter (#308) * add reversed output logic * missed reversed output logic for clear() * using MF_LOW and MF_HIGH like for the outputs * fic reversed logic for output shifter --- src/MF_OutputShifter/MFOutputShifter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MF_OutputShifter/MFOutputShifter.h b/src/MF_OutputShifter/MFOutputShifter.h index 5deeb656..b69f601d 100644 --- a/src/MF_OutputShifter/MFOutputShifter.h +++ b/src/MF_OutputShifter/MFOutputShifter.h @@ -8,7 +8,7 @@ #include -#ifdef REVERSED_OUTPUT_OUTPUT +#ifdef REVERSED_OUTPUT_OUTPUTSHIFTER #define MF_HIGH LOW #define MF_LOW HIGH #else From f883fe95140908a02cb00a3234b426e3d9ad5147 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Wed, 10 Jan 2024 13:13:57 +0100 Subject: [PATCH 3/3] Add core version (#309) * add core version in OnGetInfo * for Core FW both versions are always the same --- get_version.py | 10 ++++++++-- src/Config.cpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/get_version.py b/get_version.py index a1f94183..4a443427 100644 --- a/get_version.py +++ b/get_version.py @@ -15,11 +15,17 @@ firmware_version = firmware_version.lstrip("v") firmware_version = firmware_version.strip(".") +# The community devices have a slightly different version where the +# core firmware version is defined within there .ini file +# For the core FW both versions are always the same +core_firmware_version = firmware_version + print(f'Using version {firmware_version} for the build') +print(f'Using version {core_firmware_version} as core version') -# Append the version to the build defines so it gets baked into the firmware +# Append the version and core version to the build defines so it gets baked into the firmware env.Append(CPPDEFINES=[ - f'BUILD_VERSION={firmware_version}' + f'BUILD_VERSION={firmware_version}', f'CORE_BUILD_VERSION={core_firmware_version}' ]) # Set the output filename to the name of the board and the version diff --git a/src/Config.cpp b/src/Config.cpp index 51315bfb..69ca9e7a 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -48,6 +48,7 @@ #define STRINGIZER(arg) #arg #define STR_VALUE(arg) STRINGIZER(arg) #define VERSION STR_VALUE(BUILD_VERSION) +#define CORE_VERSION STR_VALUE(CORE_BUILD_VERSION) MFEEPROM MFeeprom; @@ -554,6 +555,7 @@ void OnGetInfo() cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(serial); cmdMessenger.sendCmdArg(VERSION); + cmdMessenger.sendCmdArg(CORE_VERSION); cmdMessenger.sendCmdEnd(); }