summaryrefslogtreecommitdiff
path: root/src/DisplayApp/DisplayApp.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-03-15 18:03:11 +0100
committerJF <jf@codingfield.com>2020-03-15 18:03:11 +0100
commit2ed76ac55615a720dbcbf2ac828ad3060a252273 (patch)
treed51123b57241556303891ef4cb5b81c47c348a51 /src/DisplayApp/DisplayApp.cpp
parenteabb54f15df7df69951ce8f49a62d3bd702dd686 (diff)
Encapsulate brightness controll into the class BrightnessController.
Add a new app to configure the brightness.
Diffstat (limited to 'src/DisplayApp/DisplayApp.cpp')
-rw-r--r--src/DisplayApp/DisplayApp.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp
index 7464175e..3f58e4b3 100644
--- a/src/DisplayApp/DisplayApp.cpp
+++ b/src/DisplayApp/DisplayApp.cpp
@@ -13,6 +13,7 @@
#include <DisplayApp/Screens/Message.h>
#include <DisplayApp/Screens/Meter.h>
#include <DisplayApp/Screens/Gauge.h>
+#include <DisplayApp/Screens/Brightness.h>
#include "../SystemTask/SystemTask.h"
using namespace Pinetime::Applications;
@@ -57,12 +58,7 @@ void DisplayApp::Process(void *instance) {
}
void DisplayApp::InitHw() {
- nrf_gpio_cfg_output(pinLcdBacklight1);
- nrf_gpio_cfg_output(pinLcdBacklight2);
- nrf_gpio_cfg_output(pinLcdBacklight3);
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_clear(pinLcdBacklight3);
+ brightnessController.Init();
}
uint32_t acc = 0;
@@ -85,11 +81,11 @@ void DisplayApp::Refresh() {
if (xQueueReceive(msgQueue, &msg, queueTimeout)) {
switch (msg) {
case Messages::GoToSleep:
- nrf_gpio_pin_set(pinLcdBacklight3);
- vTaskDelay(100);
- nrf_gpio_pin_set(pinLcdBacklight2);
- vTaskDelay(100);
- nrf_gpio_pin_set(pinLcdBacklight1);
+ brightnessController.Backup();
+ while(brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
+ brightnessController.Lower();
+ vTaskDelay(100);
+ }
lcd.DisplayOff();
lcd.Sleep();
touchPanel.Sleep();
@@ -100,9 +96,7 @@ void DisplayApp::Refresh() {
touchPanel.Wakeup();
lcd.DisplayOn();
- nrf_gpio_pin_clear(pinLcdBacklight3);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_clear(pinLcdBacklight1);
+ brightnessController.Restore();
state = States::Running;
break;
case Messages::UpdateDateTime:
@@ -174,6 +168,7 @@ void DisplayApp::RunningState() {
case Apps::Test: currentScreen.reset(new Screens::Message(this)); break;
case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break;
case Apps::Gauge: currentScreen.reset(new Screens::Gauge(this)); break;
+ case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break;
}
nextApp = Apps::None;
}