display: rotation flash ramps back to user brightness

The post-rotation brightness ramp targeted a hard-coded 200 (the old default),
which reset whatever the user had chosen via PWR-short-press after every IMU
rotation. Read brightness_get() instead and scale the 4-step ramp (30/60/85/100%)
toward that target.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Hermann Björgvin Haraldsson
2026-06-02 14:01:57 +00:00
co-authored by Claude Opus 4.7
parent 13cc4231a0
commit 65e51a0982
@@ -1,5 +1,6 @@
#include "../../hal/display_hal.h"
#include "../../hal/imu_hal.h"
#include "../../brightness.h"
#include "board.h"
#include <Arduino.h>
#include <Arduino_GFX_Library.h>
@@ -119,8 +120,11 @@ void display_hal_tick(void) {
if (now - ramp_last < 25) return;
ramp_last = now;
static const uint8_t levels[] = {60, 120, 170, 200};
display_hal_set_brightness(levels[ramp_step - 1]);
// Ramp back to the user's chosen brightness (not a hardcoded level), so a
// physical rotation doesn't reset what they set via PWR-short-press.
static const uint8_t pct[] = {30, 60, 85, 100};
uint8_t target = brightness_get();
display_hal_set_brightness((uint8_t)(((uint16_t)target * pct[ramp_step - 1]) / 100));
if (ramp_step >= 4) ramp_step = 0;
else ramp_step++;
}