Skip to content

Commit

Permalink
Two pins get set on Pico Board (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
elral authored Nov 23, 2023
1 parent 5f036f1 commit e7ee741
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/MF_Output/MFOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@

#include "MFOutput.h"

MFOutput::MFOutput(uint8_t pin)
MFOutput::MFOutput()
{
_pin = pin;
_value = false;
pinMode(_pin, OUTPUT); // set pin to input
}

void MFOutput::attach(uint8_t pin)
{
_pin = pin;
#if !defined(ARDUINO_ARCH_RP2040)
pinMode(_pin, OUTPUT);
set(_value);
#endif
}

void MFOutput::set(uint8_t value)
Expand Down
3 changes: 2 additions & 1 deletion src/MF_Output/MFOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
class MFOutput
{
public:
MFOutput(uint8_t pin = 1);
MFOutput();
void attach(uint8_t pin);
void set(uint8_t value);
void powerSavingMode(bool state);

Expand Down
7 changes: 6 additions & 1 deletion src/MF_Output/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ namespace Output
{
if (outputsRegistered == maxOutputs)
return;
outputs[outputsRegistered] = MFOutput(pin);
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 Down

0 comments on commit e7ee741

Please sign in to comment.