Skip to content

Commit

Permalink
new messageID for setting outputs per deviceID
Browse files Browse the repository at this point in the history
  • Loading branch information
elral committed Dec 27, 2024
1 parent e55d65d commit b86c837
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CommandMessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void attachCommandCallbacks()
cmdMessenger.attach(kSetModuleSingleSegment, LedSegment::OnSetModuleSingleSegment);
#endif

cmdMessenger.attach(kSetPin_deprecated, Output::OnSet_deprecated);
cmdMessenger.attach(kSetPin, Output::OnSet);

#if MF_STEPPER_SUPPORT == 1
Expand Down
14 changes: 14 additions & 0 deletions src/MF_Output/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ namespace Output
outputs[output].set(state);
}

void OnSet_deprecated()
{
// Read led state argument, interpret string as boolean
int pin = cmdMessenger.readInt16Arg();
int state = cmdMessenger.readInt16Arg();

if (state == 0xFF)
digitalWrite(pin, MF_HIGH);
else if (state == 0x00)
digitalWrite(pin, MF_LOW);
else
analogWrite(pin, state);
}

void PowerSave(bool state)
{
for (uint8_t i = 0; i < outputsRegistered; ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/MF_Output/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Output
void Add(uint8_t pin = 1);
void Clear();
void OnSet();
void OnSet_deprecated();
void PowerSave(bool state);
}

Expand Down
3 changes: 2 additions & 1 deletion src/commandmessenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
enum {
kInitModule, // 0
kSetModule, // 1
kSetPin, // 2
kSetPin_deprecated, // 2
kSetStepper, // 3
kSetServo, // 4
kStatus, // 5, Command to report status
Expand Down Expand Up @@ -46,6 +46,7 @@ enum {
kSetStepperSpeedAccel, // 31
kSetCustomDevice, // 32
kSetModuleSingleSegment, // 33
kSetPin, // 34
kDebug = 0xFF // 255
};

Expand Down

0 comments on commit b86c837

Please sign in to comment.