Treat encoder rate multiplier value of 0 in pmem the same as 1 (#1898)

* Double-check encoder rate multiplier is not 0

* Eliminated redundant check in pmem init()
This commit is contained in:
Mark Thompson 2024-02-15 00:05:05 -06:00 committed by GitHub
parent c3add0ce84
commit 8b5adb6bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -229,7 +229,9 @@ struct data_t {
uint16_t fake_brightness_level : 4;
// Encoder rotation rate multiplier for larger increments when rotated rapidly
uint16_t encoder_rate_multiplier : 8;
uint16_t encoder_rate_multiplier : 4;
uint16_t UNUSED : 4;
// Headphone volume in centibels.
int16_t headphone_volume_cb;
@ -296,6 +298,8 @@ struct data_t {
encoder_dial_sensitivity(DIAL_SENSITIVITY_NORMAL),
fake_brightness_level(BRIGHTNESS_50),
encoder_rate_multiplier(1),
UNUSED(0),
headphone_volume_cb(-600),
misc_config(),
ui_config2(),
@ -457,7 +461,6 @@ void init() {
// Firmware upgrade handling - adjust newly defined fields where 0 is an invalid default
if (fake_brightness_level() == 0) set_fake_brightness_level(BRIGHTNESS_50);
if (encoder_rate_multiplier() == 0) set_encoder_rate_multiplier(1);
}
void persist() {
@ -989,7 +992,9 @@ void set_encoder_dial_sensitivity(uint8_t v) {
data->encoder_dial_sensitivity = v;
}
uint8_t encoder_rate_multiplier() {
return data->encoder_rate_multiplier;
uint8_t v = data->encoder_rate_multiplier;
if (v == 0) v = 1; // minimum value is 1; treat 0 the same as 1
return v;
}
void set_encoder_rate_multiplier(uint8_t v) {
data->encoder_rate_multiplier = v;