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

Yann/feature/deepsleep corelcd #1382

Merged
merged 4 commits into from
Feb 4, 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
3 changes: 3 additions & 0 deletions drivers/CoreVideo/include/CoreLCD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CoreLCD : public interface::LCD

void setBrightness(float value) final;

void enableDeepSleep() final;
void disableDeepSleep() final;

private:
interface::LCDDriver &_driver;
};
Expand Down
3 changes: 3 additions & 0 deletions drivers/CoreVideo/include/CoreLCDDriverOTM8009A.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class CoreLCDDriverOTM8009A : public interface::LCDDriver

void setBrightness(float value) final;

void enableDeepSleep() final;
void disableDeepSleep() final;

private:
interface::DSIBase &_dsi;
interface::PwmOut &_backlight;
Expand Down
4 changes: 3 additions & 1 deletion drivers/CoreVideo/include/interface/LCDDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#pragma once

#include "interface/drivers/DeepSleepEnabled.h"

namespace leka::interface {

class LCDDriver
class LCDDriver : public interface::DeepSleepEnabled
{
public:
virtual ~LCDDriver() = default;
Expand Down
10 changes: 10 additions & 0 deletions drivers/CoreVideo/source/CoreLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ void CoreLCD::turnOff()
_driver.turnOff();
}

void CoreLCD::enableDeepSleep()
{
_driver.enableDeepSleep();
}

void CoreLCD::disableDeepSleep()
{
_driver.disableDeepSleep();
}

void CoreLCD::setBrightness(float value)
{
_driver.setBrightness(value);
Expand Down
10 changes: 10 additions & 0 deletions drivers/CoreVideo/source/CoreLCDDriverOTM8009A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ void CoreLCDDriverOTM8009A::turnOff()
setBrightness(0.F);
}

void CoreLCDDriverOTM8009A::enableDeepSleep()
{
_backlight.enableDeepSleep();
}

void CoreLCDDriverOTM8009A::disableDeepSleep()
{
_backlight.disableDeepSleep();
}

void CoreLCDDriverOTM8009A::setBrightness(float value)
{
_backlight.write(value);
Expand Down
14 changes: 14 additions & 0 deletions drivers/CoreVideo/tests/CoreLCDDriverOTM8009A_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ TEST_F(CoreOTM8009ATest, turnOff)
otm.turnOff();
}

TEST_F(CoreOTM8009ATest, enableDeepSleep)
{
EXPECT_CALL(backlightmock, enableDeepSleep);

otm.enableDeepSleep();
}

TEST_F(CoreOTM8009ATest, disableDeepSleep)
{
EXPECT_CALL(backlightmock, disableDeepSleep);

otm.disableDeepSleep();
}

TEST_F(CoreOTM8009ATest, setBrightness)
{
auto value = 0.5F;
Expand Down
14 changes: 14 additions & 0 deletions drivers/CoreVideo/tests/CoreLCD_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ TEST_F(CoreLCDTest, turnOff)
corelcd.turnOff();
}

TEST_F(CoreLCDTest, enableDeepSleep)
{
EXPECT_CALL(lcddrivermock, enableDeepSleep);

corelcd.enableDeepSleep();
}

TEST_F(CoreLCDTest, disableDeepSleep)
{
EXPECT_CALL(lcddrivermock, disableDeepSleep);

corelcd.disableDeepSleep();
}

TEST_F(CoreLCDTest, setBrightness)
{
EXPECT_CALL(lcddrivermock, setBrightness(An<float>())).Times(1);
Expand Down
4 changes: 3 additions & 1 deletion include/interface/drivers/LCD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#pragma once

#include "DeepSleepEnabled.h"

namespace leka::interface {

class LCD
class LCD : public interface::DeepSleepEnabled
{
public:
virtual ~LCD() = default;
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/mocks/mocks/leka/CoreLCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class CoreLCD : public interface::LCD
MOCK_METHOD(void, turnOn, (), (override));
MOCK_METHOD(void, turnOff, (), (override));
MOCK_METHOD(void, setBrightness, (float value), (override));

MOCK_METHOD(void, enableDeepSleep, (), (override));
MOCK_METHOD(void, disableDeepSleep, (), (override));
};

} // namespace leka::mock
3 changes: 3 additions & 0 deletions tests/unit/mocks/mocks/leka/CoreLCDDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class CoreLCDDriver : public interface::LCDDriver
MOCK_METHOD(void, turnOn, (), (override));
MOCK_METHOD(void, turnOff, (), (override));
MOCK_METHOD(void, setBrightness, (float value), (override));

MOCK_METHOD(void, enableDeepSleep, (), (override));
MOCK_METHOD(void, disableDeepSleep, (), (override));
};

} // namespace leka::mock