Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CustomDevices
Submodule CustomDevices updated from d7e3f3 to 6a2b28
13 changes: 10 additions & 3 deletions src/MF_Output/MFOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@ MFOutput::MFOutput()
void MFOutput::attach(uint8_t pin)
{
_pin = pin;
#if !defined(ARDUINO_ARCH_RP2040)
#if defined(ARDUINO_ARCH_RP2040)
pinMode(_pin, OUTPUT_12MA);
#else
pinMode(_pin, OUTPUT);
set(_value);
#endif
set(LOW);
}

void MFOutput::set(uint8_t value)
{
_value = value;
analogWrite(_pin, _value);
if (_value == 0xFF)
digitalWrite(_pin, HIGH);
else if (_value == 0x00)
digitalWrite(_pin, LOW);
else
analogWrite(_pin, _value);
}

void MFOutput::powerSavingMode(bool state)
Expand Down
13 changes: 7 additions & 6 deletions src/MF_Output/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ namespace Output
return;
outputs[outputsRegistered] = MFOutput();
outputs[outputsRegistered].attach(pin);
#if defined(ARDUINO_ARCH_RP2040)
pinMode(pin, OUTPUT_12MA);
analogWrite(pin, false);
#endif
outputsRegistered++;
#ifdef DEBUG2CMDMESSENGER
cmdMessenger.sendCmd(kDebug, F("Added output"));
Expand All @@ -52,9 +48,14 @@ namespace Output
// Read led state argument, interpret string as boolean
int pin = cmdMessenger.readInt16Arg();
int state = cmdMessenger.readInt16Arg();

// Set led
analogWrite(pin, state); // why does the UI sends the pin number and not the x.th output number like other devices?
// output[pin].set(state); // once this is changed uncomment this
if (state == 0xFF)
digitalWrite(pin, HIGH);
else if (state == 0x00)
digitalWrite(pin, LOW);
else
analogWrite(pin, state);
}

void PowerSave(bool state)
Expand Down