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:
co-authored by
Claude Opus 4.7
parent
13cc4231a0
commit
65e51a0982
@@ -1,5 +1,6 @@
|
|||||||
#include "../../hal/display_hal.h"
|
#include "../../hal/display_hal.h"
|
||||||
#include "../../hal/imu_hal.h"
|
#include "../../hal/imu_hal.h"
|
||||||
|
#include "../../brightness.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Arduino_GFX_Library.h>
|
#include <Arduino_GFX_Library.h>
|
||||||
@@ -119,8 +120,11 @@ void display_hal_tick(void) {
|
|||||||
if (now - ramp_last < 25) return;
|
if (now - ramp_last < 25) return;
|
||||||
ramp_last = now;
|
ramp_last = now;
|
||||||
|
|
||||||
static const uint8_t levels[] = {60, 120, 170, 200};
|
// Ramp back to the user's chosen brightness (not a hardcoded level), so a
|
||||||
display_hal_set_brightness(levels[ramp_step - 1]);
|
// 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;
|
if (ramp_step >= 4) ramp_step = 0;
|
||||||
else ramp_step++;
|
else ramp_step++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user