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

⚡️ (lcd): Turn off backlight same time as lcd turn off command #741

Merged
merged 1 commit into from
May 5, 2022
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: 2 additions & 0 deletions drivers/CoreVideo/include/CoreLCDDriverOTM8009A.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class CoreLCDDriverOTM8009A : public interface::LCDDriver
private:
interface::DSIBase &_dsi;
mbed::PwmOut _backlight;

float _previous_brightness_value = {0.F};
ladislas marked this conversation as resolved.
Show resolved Hide resolved
};

namespace lcd::otm8009a {
Expand Down
6 changes: 6 additions & 0 deletions drivers/CoreVideo/source/CoreLCDDriverOTM8009A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ using namespace lcd::otm8009a;
void CoreLCDDriverOTM8009A::turnOn()
{
_dsi.write(display::turn_on::array, std::size(display::turn_on::array));
setBrightness(_previous_brightness_value);
}

void CoreLCDDriverOTM8009A::turnOff()
{
_dsi.write(display::turn_off::array, std::size(display::turn_off::array));
setBrightness(0.F);
}

void CoreLCDDriverOTM8009A::setBrightness(float value)
{
_backlight.write(value);

if (value != 0.F) {
_previous_brightness_value = value;
}
}

void CoreLCDDriverOTM8009A::initialize()
Expand Down
20 changes: 20 additions & 0 deletions drivers/CoreVideo/tests/CoreLCDDriverOTM8009A_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,23 @@ TEST_F(CoreOTM8009ATest, setBrightness)

ASSERT_EQ(spy_PwmOut_getValue(), 0.5);
}

TEST_F(CoreOTM8009ATest, setBrightnessTurnOffThenTurnOn)
{
auto initial_brightness_value = 0.4F;

otm.setBrightness(initial_brightness_value);

EXPECT_EQ(spy_PwmOut_getValue(), initial_brightness_value);

EXPECT_CALL(dsimock, write).Times(1);
otm.turnOff();

EXPECT_EQ(spy_PwmOut_getValue(), 0);
EXPECT_NE(spy_PwmOut_getValue(), initial_brightness_value);

EXPECT_CALL(dsimock, write).Times(1);
otm.turnOn();

EXPECT_EQ(spy_PwmOut_getValue(), initial_brightness_value);
}