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:
|
||||
DisplayAbstract();
|
||||
virtual void setBrightness(uint8_t brightness) = 0;
|
||||
virtual uint8_t getBrightness() = 0;
|
||||
virtual void turnOff() = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -148,7 +148,7 @@ void HardwareRevX::activityDetection() {
|
|||
void HardwareRevX::enterSleep() {
|
||||
// Save settings to internal flash memory
|
||||
preferences.putBool("wkpByIMU", wakeupByIMUEnabled);
|
||||
preferences.putUChar("blBrightness", backlight_brightness);
|
||||
preferences.putUChar("blBrightness", mDisplay->getBrightness());
|
||||
preferences.putUChar("currentDevice", currentDevice);
|
||||
if (!preferences.getBool("alreadySetUp"))
|
||||
preferences.putBool("alreadySetUp", true);
|
||||
|
@ -279,12 +279,14 @@ void HardwareRevX::setupBacklight() {
|
|||
|
||||
void HardwareRevX::restorePreferences() {
|
||||
// Restore settings from internal flash memory
|
||||
int backlight_brightness = 255;
|
||||
preferences.begin("settings", false);
|
||||
if (preferences.getBool("alreadySetUp")) {
|
||||
wakeupByIMUEnabled = preferences.getBool("wkpByIMU");
|
||||
backlight_brightness = preferences.getUChar("blBrightness");
|
||||
currentDevice = preferences.getUChar("currentDevice");
|
||||
}
|
||||
mDisplay->setBrightness(backlight_brightness);
|
||||
}
|
||||
|
||||
void HardwareRevX::setupIMU() {
|
||||
|
|
|
@ -69,7 +69,6 @@ private:
|
|||
|
||||
Preferences preferences;
|
||||
bool wakeupByIMUEnabled = true;
|
||||
int backlight_brightness = 255;
|
||||
byte currentDevice = 1; // Current Device to control (allows switching
|
||||
// mappings between devices)
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ void Display::setBrightness(uint8_t brightness)
|
|||
startFade();
|
||||
}
|
||||
|
||||
uint8_t Display::getBrightness(){
|
||||
return mAwakeBrightness;
|
||||
}
|
||||
|
||||
void Display::setCurrentBrightness(uint8_t brightness){
|
||||
mBrightness = brightness;
|
||||
ledcWrite(LCD_BACKLIGHT_LEDC_CHANNEL, mBrightness);
|
||||
|
|
|
@ -25,6 +25,7 @@ class Display: public DisplayAbstract
|
|||
/// @brief Set brightness setting and fade to it
|
||||
/// @param brightness
|
||||
virtual void setBrightness(uint8_t brightness) override;
|
||||
virtual uint8_t getBrightness() override;
|
||||
virtual void turnOff() override;
|
||||
|
||||
void onTouch(Notification<TS_Point>::HandlerTy aTouchHandler);
|
||||
|
|
|
@ -13,6 +13,10 @@ void SDLDisplay::setBrightness(uint8_t brightness){
|
|||
|
||||
}
|
||||
|
||||
uint8_t SDLDisplay::getBrightness(){
|
||||
|
||||
}
|
||||
|
||||
void SDLDisplay::turnOff(){
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,9 @@ class SDLDisplay : public DisplayAbstract{
|
|||
public:
|
||||
static std::shared_ptr<SDLDisplay> getInstance();
|
||||
|
||||
void setBrightness(uint8_t brightness);
|
||||
void turnOff();
|
||||
virtual void setBrightness(uint8_t brightness) override;
|
||||
virtual uint8_t getBrightness() override;
|
||||
virtual void turnOff() override;
|
||||
|
||||
protected:
|
||||
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
|
||||
void OmoteUI::bl_slider_event_cb(lv_event_t *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
|
||||
|
|
|
@ -229,12 +229,6 @@ void create_keyboard();
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -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_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_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_align(slider, LV_ALIGN_TOP_MID, 0, 3);
|
||||
brightnessIcon = imgs.addHighBrightnessIcon(menuBox);
|
||||
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);
|
||||
lv_label_set_text(menuLabel, "Lift to Wake");
|
||||
|
|
Loading…
Add table
Reference in a new issue