summaryrefslogtreecommitdiff
path: root/src/drivers/display.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-06-07 10:30:33 +1000
committerjacqueline <me@jacqueline.id.au>2023-06-07 10:30:33 +1000
commit2a568846bd8f1c9e23e86e7570557eed6f18cf9f (patch)
tree3c152311311233eda762bb8b441ad44b50800cb8 /src/drivers/display.cpp
parent610991455d335663de1dd6c0c6a3e0247ffd46df (diff)
downloadtangara-fw-2a568846bd8f1c9e23e86e7570557eed6f18cf9f.tar.gz
Cute brightness fade to avoid ugly startup :)
Diffstat (limited to 'src/drivers/display.cpp')
-rw-r--r--src/drivers/display.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index 7a49e02b..dd4cecb8 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -123,9 +123,11 @@ auto Display::Create(GpioExpander* expander,
.hpoint = 0};
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_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
+ ledc_fade_func_install(0);
+
// Next, init the SPI device
spi_device_interface_config_t spi_cfg = {
.command_bits = 0, // No command phase
@@ -180,9 +182,21 @@ auto Display::Create(GpioExpander* expander,
Display::Display(GpioExpander* gpio, spi_device_handle_t handle)
: gpio_(gpio),
handle_(handle),
- worker_task_(tasks::Worker::Start<tasks::Type::kUiFlush>()) {}
+ worker_task_(tasks::Worker::Start<tasks::Type::kUiFlush>()),
+ display_on_(false),
+ brightness_(4096) {}
+
+Display::~Display() {
+ ledc_fade_func_uninstall();
+}
-Display::~Display() {}
+auto Display::SetDisplayOn(bool enabled) -> void {
+ display_on_ = enabled;
+
+ int new_duty = display_on_ ? brightness_ : 0;
+ ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, new_duty, 250);
+ ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_NO_WAIT);
+}
void Display::SendInitialisationSequence(const uint8_t* data) {
// Hold onto the bus for the entire sequence so that we're not interrupted