Fix up screen brightness and transitions
This commit is contained in:
+15
-3
@@ -104,15 +104,27 @@ auto Display::Create(GpioExpander* expander,
|
||||
.freq_hz = 5000,
|
||||
.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,
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.channel = LEDC_CHANNEL_0,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
.duty = 4095,
|
||||
.duty = 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
|
||||
spi_device_interface_config_t spi_cfg = {
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace ui {
|
||||
class UiState : public tinyfsm::Fsm<UiState> {
|
||||
public:
|
||||
static auto Init(drivers::GpioExpander* gpio_expander,
|
||||
std::weak_ptr<drivers::RelativeWheel> touchwheel,
|
||||
std::weak_ptr<drivers::Display> display) -> void;
|
||||
const std::weak_ptr<drivers::RelativeWheel> &touchwheel,
|
||||
const std::weak_ptr<drivers::Display> &display) -> void;
|
||||
|
||||
virtual ~UiState() {}
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ void LvglMain(std::weak_ptr<drivers::RelativeWheel> weak_touch_wheel,
|
||||
|
||||
std::shared_ptr<Screen> screen = UiState::current_screen();
|
||||
if (screen != current_screen && screen != nullptr) {
|
||||
current_screen = screen;
|
||||
// TODO(jacqueline): animate this sometimes
|
||||
lv_scr_load(screen->root());
|
||||
current_screen = screen;
|
||||
}
|
||||
|
||||
lv_task_handler();
|
||||
|
||||
+7
-4
@@ -23,12 +23,16 @@ std::weak_ptr<drivers::Display> UiState::sDisplay;
|
||||
std::shared_ptr<Screen> UiState::sCurrentScreen;
|
||||
|
||||
auto UiState::Init(drivers::GpioExpander* gpio_expander,
|
||||
std::weak_ptr<drivers::RelativeWheel> touchwheel,
|
||||
std::weak_ptr<drivers::Display> display) -> void {
|
||||
const std::weak_ptr<drivers::RelativeWheel>& touchwheel,
|
||||
const std::weak_ptr<drivers::Display>& display) -> void {
|
||||
assert(!touchwheel.expired());
|
||||
assert(!display.expired());
|
||||
sGpioExpander = gpio_expander;
|
||||
sTouchWheel = touchwheel;
|
||||
sDisplay = display;
|
||||
|
||||
sCurrentScreen.reset(new screens::Splash());
|
||||
|
||||
StartLvgl(sTouchWheel, sDisplay);
|
||||
}
|
||||
|
||||
@@ -39,7 +43,6 @@ void PreBoot::react(const system_fsm::DisplayReady& ev) {
|
||||
}
|
||||
|
||||
void Splash::entry() {
|
||||
sCurrentScreen.reset(new screens::Splash());
|
||||
}
|
||||
|
||||
void Splash::react(const system_fsm::BootComplete& ev) {
|
||||
@@ -47,7 +50,7 @@ void Splash::react(const system_fsm::BootComplete& ev) {
|
||||
}
|
||||
|
||||
void Interactive::entry() {
|
||||
// sCurrentScreen.reset(new screens::Menu());
|
||||
sCurrentScreen.reset(new screens::Menu());
|
||||
}
|
||||
|
||||
} // namespace states
|
||||
|
||||
Reference in New Issue
Block a user