Fix up screen brightness and transitions

custom
jacqueline 2 years ago
parent 8a2a2d2265
commit d2e5d2ab3c
  1. 18
      src/drivers/display.cpp
  2. 4
      src/ui/include/ui_fsm.hpp
  3. 2
      src/ui/lvgl_task.cpp
  4. 11
      src/ui/ui_fsm.cpp

@ -104,15 +104,27 @@ auto Display::Create(GpioExpander* expander,
.freq_hz = 5000, .freq_hz = 5000,
.clk_cfg = LEDC_AUTO_CLK, .clk_cfg = LEDC_AUTO_CLK,
}; };
ledc_timer_config(&led_config); ESP_ERROR_CHECK(ledc_timer_config(&led_config));
gpio_config_t led_pin_config{
.pin_bit_mask = 1ULL << kDisplayLedEn,
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE,
};
gpio_config(&led_pin_config);
ledc_channel_config_t led_channel{.gpio_num = kDisplayLedEn, ledc_channel_config_t led_channel{.gpio_num = kDisplayLedEn,
.speed_mode = LEDC_LOW_SPEED_MODE, .speed_mode = LEDC_LOW_SPEED_MODE,
.channel = LEDC_CHANNEL_0, .channel = LEDC_CHANNEL_0,
.timer_sel = LEDC_TIMER_0, .timer_sel = LEDC_TIMER_0,
.duty = 4095, .duty = 0,
.hpoint = 0}; .hpoint = 0};
ledc_channel_config(&led_channel); ESP_ERROR_CHECK(ledc_channel_config(&led_channel));
ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 4096));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
// Next, init the SPI device // Next, init the SPI device
spi_device_interface_config_t spi_cfg = { spi_device_interface_config_t spi_cfg = {

@ -22,8 +22,8 @@ namespace ui {
class UiState : public tinyfsm::Fsm<UiState> { class UiState : public tinyfsm::Fsm<UiState> {
public: public:
static auto Init(drivers::GpioExpander* gpio_expander, static auto Init(drivers::GpioExpander* gpio_expander,
std::weak_ptr<drivers::RelativeWheel> touchwheel, const std::weak_ptr<drivers::RelativeWheel> &touchwheel,
std::weak_ptr<drivers::Display> display) -> void; const std::weak_ptr<drivers::Display> &display) -> void;
virtual ~UiState() {} virtual ~UiState() {}

@ -66,9 +66,9 @@ void LvglMain(std::weak_ptr<drivers::RelativeWheel> weak_touch_wheel,
std::shared_ptr<Screen> screen = UiState::current_screen(); std::shared_ptr<Screen> screen = UiState::current_screen();
if (screen != current_screen && screen != nullptr) { if (screen != current_screen && screen != nullptr) {
current_screen = screen;
// TODO(jacqueline): animate this sometimes // TODO(jacqueline): animate this sometimes
lv_scr_load(screen->root()); lv_scr_load(screen->root());
current_screen = screen;
} }
lv_task_handler(); lv_task_handler();

@ -23,12 +23,16 @@ std::weak_ptr<drivers::Display> UiState::sDisplay;
std::shared_ptr<Screen> UiState::sCurrentScreen; std::shared_ptr<Screen> UiState::sCurrentScreen;
auto UiState::Init(drivers::GpioExpander* gpio_expander, auto UiState::Init(drivers::GpioExpander* gpio_expander,
std::weak_ptr<drivers::RelativeWheel> touchwheel, const std::weak_ptr<drivers::RelativeWheel>& touchwheel,
std::weak_ptr<drivers::Display> display) -> void { const std::weak_ptr<drivers::Display>& display) -> void {
assert(!touchwheel.expired());
assert(!display.expired());
sGpioExpander = gpio_expander; sGpioExpander = gpio_expander;
sTouchWheel = touchwheel; sTouchWheel = touchwheel;
sDisplay = display; sDisplay = display;
sCurrentScreen.reset(new screens::Splash());
StartLvgl(sTouchWheel, sDisplay); StartLvgl(sTouchWheel, sDisplay);
} }
@ -39,7 +43,6 @@ void PreBoot::react(const system_fsm::DisplayReady& ev) {
} }
void Splash::entry() { void Splash::entry() {
sCurrentScreen.reset(new screens::Splash());
} }
void Splash::react(const system_fsm::BootComplete& ev) { void Splash::react(const system_fsm::BootComplete& ev) {
@ -47,7 +50,7 @@ void Splash::react(const system_fsm::BootComplete& ev) {
} }
void Interactive::entry() { void Interactive::entry() {
// sCurrentScreen.reset(new screens::Menu()); sCurrentScreen.reset(new screens::Menu());
} }
} // namespace states } // namespace states

Loading…
Cancel
Save