Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power saving lcd #340

Merged
merged 3 commits into from
Oct 27, 2024
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
7 changes: 7 additions & 0 deletions src/MF_LCDDisplay/LCDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ namespace LCDDisplay
cmdMessenger.unescape(output);
lcd_I2C[address].display(output);
}

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

// LCDDisplay.cpp
1 change: 1 addition & 0 deletions src/MF_LCDDisplay/LCDDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace LCDDisplay
void Add(uint8_t address = 0x24, uint8_t cols = 16, uint8_t lines = 2);
void Clear();
void OnSet();
void PowerSave(bool state);
}

// LCDDisplay.h
8 changes: 6 additions & 2 deletions src/MF_LCDDisplay/MFLCDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ void MFLCDDisplay::detach()

void MFLCDDisplay::powerSavingMode(bool state)
{
if (state)
if (state) {
_lcdDisplay.noBacklight();
else
_lcdDisplay.noDisplay();
}
else {
_lcdDisplay.backlight();
_lcdDisplay.display();
}
}

void MFLCDDisplay::test()
Expand Down
6 changes: 6 additions & 0 deletions src/mobiflight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#if MF_SERVO_SUPPORT == 1
#include "Servos.h"
#endif
#if MF_LCD_SUPPORT == 1
#include "LCDDisplay.h"
#endif
#if MF_OUTPUT_SHIFTER_SUPPORT == 1
#include "OutputShifter.h"
#endif
Expand Down Expand Up @@ -126,6 +129,9 @@ void SetPowerSavingMode(bool state)
#if MF_OUTPUT_SHIFTER_SUPPORT == 1
OutputShifter::PowerSave(state);
#endif
#if MF_LCD_SUPPORT == 1
LCDDisplay::PowerSave(state);
#endif

#ifdef DEBUG2CMDMESSENGER
if (state)
Expand Down
Loading