Skip to content

Commit

Permalink
Merge branch 'MobiFlight:main' into wo_NameBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
elral authored Oct 22, 2024
2 parents 5c87b39 + 7992af8 commit fed89d1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
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

0 comments on commit fed89d1

Please sign in to comment.