Add get brightness to the displayAbstract to allow
removal of backlight brightness stored in OmoteUI class "implement" new getter function in sim and esp32.
This commit is contained in:
parent
23fedd8052
commit
b45de68ebb
10 changed files with 20 additions and 13 deletions
|
@ -6,6 +6,7 @@ class DisplayAbstract
|
||||||
public:
|
public:
|
||||||
DisplayAbstract();
|
DisplayAbstract();
|
||||||
virtual void setBrightness(uint8_t brightness) = 0;
|
virtual void setBrightness(uint8_t brightness) = 0;
|
||||||
|
virtual uint8_t getBrightness() = 0;
|
||||||
virtual void turnOff() = 0;
|
virtual void turnOff() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -148,7 +148,7 @@ void HardwareRevX::activityDetection() {
|
||||||
void HardwareRevX::enterSleep() {
|
void HardwareRevX::enterSleep() {
|
||||||
// Save settings to internal flash memory
|
// Save settings to internal flash memory
|
||||||
preferences.putBool("wkpByIMU", wakeupByIMUEnabled);
|
preferences.putBool("wkpByIMU", wakeupByIMUEnabled);
|
||||||
preferences.putUChar("blBrightness", backlight_brightness);
|
preferences.putUChar("blBrightness", mDisplay->getBrightness());
|
||||||
preferences.putUChar("currentDevice", currentDevice);
|
preferences.putUChar("currentDevice", currentDevice);
|
||||||
if (!preferences.getBool("alreadySetUp"))
|
if (!preferences.getBool("alreadySetUp"))
|
||||||
preferences.putBool("alreadySetUp", true);
|
preferences.putBool("alreadySetUp", true);
|
||||||
|
@ -279,12 +279,14 @@ void HardwareRevX::setupBacklight() {
|
||||||
|
|
||||||
void HardwareRevX::restorePreferences() {
|
void HardwareRevX::restorePreferences() {
|
||||||
// Restore settings from internal flash memory
|
// Restore settings from internal flash memory
|
||||||
|
int backlight_brightness = 255;
|
||||||
preferences.begin("settings", false);
|
preferences.begin("settings", false);
|
||||||
if (preferences.getBool("alreadySetUp")) {
|
if (preferences.getBool("alreadySetUp")) {
|
||||||
wakeupByIMUEnabled = preferences.getBool("wkpByIMU");
|
wakeupByIMUEnabled = preferences.getBool("wkpByIMU");
|
||||||
backlight_brightness = preferences.getUChar("blBrightness");
|
backlight_brightness = preferences.getUChar("blBrightness");
|
||||||
currentDevice = preferences.getUChar("currentDevice");
|
currentDevice = preferences.getUChar("currentDevice");
|
||||||
}
|
}
|
||||||
|
mDisplay->setBrightness(backlight_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareRevX::setupIMU() {
|
void HardwareRevX::setupIMU() {
|
||||||
|
|
|
@ -69,7 +69,6 @@ private:
|
||||||
|
|
||||||
Preferences preferences;
|
Preferences preferences;
|
||||||
bool wakeupByIMUEnabled = true;
|
bool wakeupByIMUEnabled = true;
|
||||||
int backlight_brightness = 255;
|
|
||||||
byte currentDevice = 1; // Current Device to control (allows switching
|
byte currentDevice = 1; // Current Device to control (allows switching
|
||||||
// mappings between devices)
|
// mappings between devices)
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,10 @@ void Display::setBrightness(uint8_t brightness)
|
||||||
startFade();
|
startFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t Display::getBrightness(){
|
||||||
|
return mAwakeBrightness;
|
||||||
|
}
|
||||||
|
|
||||||
void Display::setCurrentBrightness(uint8_t brightness){
|
void Display::setCurrentBrightness(uint8_t brightness){
|
||||||
mBrightness = brightness;
|
mBrightness = brightness;
|
||||||
ledcWrite(LCD_BACKLIGHT_LEDC_CHANNEL, mBrightness);
|
ledcWrite(LCD_BACKLIGHT_LEDC_CHANNEL, mBrightness);
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Display: public DisplayAbstract
|
||||||
/// @brief Set brightness setting and fade to it
|
/// @brief Set brightness setting and fade to it
|
||||||
/// @param brightness
|
/// @param brightness
|
||||||
virtual void setBrightness(uint8_t brightness) override;
|
virtual void setBrightness(uint8_t brightness) override;
|
||||||
|
virtual uint8_t getBrightness() override;
|
||||||
virtual void turnOff() override;
|
virtual void turnOff() override;
|
||||||
|
|
||||||
void onTouch(Notification<TS_Point>::HandlerTy aTouchHandler);
|
void onTouch(Notification<TS_Point>::HandlerTy aTouchHandler);
|
||||||
|
|
|
@ -13,6 +13,10 @@ void SDLDisplay::setBrightness(uint8_t brightness){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t SDLDisplay::getBrightness(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SDLDisplay::turnOff(){
|
void SDLDisplay::turnOff(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@ class SDLDisplay : public DisplayAbstract{
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<SDLDisplay> getInstance();
|
static std::shared_ptr<SDLDisplay> getInstance();
|
||||||
|
|
||||||
void setBrightness(uint8_t brightness);
|
virtual void setBrightness(uint8_t brightness) override;
|
||||||
void turnOff();
|
virtual uint8_t getBrightness() override;
|
||||||
|
virtual void turnOff() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) override;
|
virtual void flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) override;
|
||||||
|
|
|
@ -29,7 +29,8 @@ void OmoteUI::tabview_device_event_cb(lv_event_t *e) {
|
||||||
// Slider Event handler
|
// Slider Event handler
|
||||||
void OmoteUI::bl_slider_event_cb(lv_event_t *e) {
|
void OmoteUI::bl_slider_event_cb(lv_event_t *e) {
|
||||||
lv_obj_t *slider = lv_event_get_target(e);
|
lv_obj_t *slider = lv_event_get_target(e);
|
||||||
backlight_brightness = std::clamp(lv_slider_get_value(slider), 60, 255);
|
auto newBrightness = std::clamp(lv_slider_get_value(slider), 60, 255);
|
||||||
|
mHardware->display()->setBrightness(newBrightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apple Key Event handler
|
// Apple Key Event handler
|
||||||
|
|
|
@ -229,12 +229,6 @@ void create_keyboard();
|
||||||
*/
|
*/
|
||||||
void update_wifi_selection_subpage(int page);
|
void update_wifi_selection_subpage(int page);
|
||||||
|
|
||||||
/************************************** Display settings menu ********************************************************/
|
|
||||||
/**
|
|
||||||
* Variable to store the current backlight brightness level
|
|
||||||
*/
|
|
||||||
unsigned int backlight_brightness;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Function to create the display settings page.
|
* @brief Function to create the display settings page.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,12 +18,12 @@ void OmoteUI::display_settings(lv_obj_t* parent)
|
||||||
lv_obj_set_style_bg_color(slider, lv_color_white(), LV_PART_KNOB);
|
lv_obj_set_style_bg_color(slider, lv_color_white(), LV_PART_KNOB);
|
||||||
lv_obj_set_style_bg_opa(slider, LV_OPA_COVER, LV_PART_MAIN);
|
lv_obj_set_style_bg_opa(slider, LV_OPA_COVER, LV_PART_MAIN);
|
||||||
lv_obj_set_style_bg_color(slider, lv_color_lighten(color_primary, 50), LV_PART_MAIN);
|
lv_obj_set_style_bg_color(slider, lv_color_lighten(color_primary, 50), LV_PART_MAIN);
|
||||||
lv_slider_set_value(slider, this->backlight_brightness, LV_ANIM_OFF);
|
lv_slider_set_value(slider, mHardware->display()->getBrightness() , LV_ANIM_OFF);
|
||||||
lv_obj_set_size(slider, lv_pct(66), 10);
|
lv_obj_set_size(slider, lv_pct(66), 10);
|
||||||
lv_obj_align(slider, LV_ALIGN_TOP_MID, 0, 3);
|
lv_obj_align(slider, LV_ALIGN_TOP_MID, 0, 3);
|
||||||
brightnessIcon = imgs.addHighBrightnessIcon(menuBox);
|
brightnessIcon = imgs.addHighBrightnessIcon(menuBox);
|
||||||
lv_obj_align(brightnessIcon, LV_ALIGN_TOP_RIGHT, 0, -1);
|
lv_obj_align(brightnessIcon, LV_ALIGN_TOP_RIGHT, 0, -1);
|
||||||
lv_obj_add_event_cb(slider, [] (lv_event_t* e) {mInstance->bl_slider_event_cb(e);}, LV_EVENT_VALUE_CHANGED, &this->backlight_brightness);
|
lv_obj_add_event_cb(slider, [] (lv_event_t* e) {mInstance->bl_slider_event_cb(e);}, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||||
|
|
||||||
menuLabel = lv_label_create(menuBox);
|
menuLabel = lv_label_create(menuBox);
|
||||||
lv_label_set_text(menuLabel, "Lift to Wake");
|
lv_label_set_text(menuLabel, "Lift to Wake");
|
||||||
|
|
Loading…
Add table
Reference in a new issue