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
13 changes: 13 additions & 0 deletions src/MF_OutputShifter/MFOutputShifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,17 @@ void MFOutputShifter::update()
digitalWrite(_latchPin, HIGH);
}

void MFOutputShifter::powerSavingMode(bool state)
{
if (state) {
digitalWrite(_latchPin, LOW);
for (uint8_t i = _moduleCount; i > 0; i--) {
shiftOut(_dataPin, _clockPin, MSBFIRST, 0xFF * MF_LOW);
}
digitalWrite(_latchPin, HIGH);
} else {
update();
}
}

// MFOutputShifter.cpp
1 change: 1 addition & 0 deletions src/MF_OutputShifter/MFOutputShifter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MFOutputShifter
void detach();
void clear();
void update();
void powerSavingMode(bool state);

private:
uint8_t _latchPin; // Latch pin
Expand Down
7 changes: 7 additions & 0 deletions src/MF_OutputShifter/OutputShifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ namespace OutputShifter
int value = cmdMessenger.readInt16Arg();
outputShifter[module].setPins(pins, value);
}

void PowerSave(bool state)
{
for (uint8_t i = 0; i < outputShifterRegistered; ++i) {
outputShifter[i].powerSavingMode(state);
}
}
} // namespace

// OutputShifter.cpp
1 change: 1 addition & 0 deletions src/MF_OutputShifter/OutputShifter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace OutputShifter
void Add(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules);
void Clear();
void OnSet();
void PowerSave(bool state);
}

// OutputShifter.h
3 changes: 3 additions & 0 deletions src/mobiflight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void SetPowerSavingMode(bool state)
#if MF_CUSTOMDEVICE_SUPPORT == 1
CustomDevice::PowerSave(state);
#endif
#if MF_OUTPUT_SHIFTER_SUPPORT == 1
OutputShifter::PowerSave(state);
#endif

#ifdef DEBUG2CMDMESSENGER
if (state)
Expand Down