From 8b5adb6bc107e6315593595941f4d6084c1f6392 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:05:05 -0600 Subject: [PATCH] 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() --- firmware/common/portapack_persistent_memory.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index ea7cf175..37740bba 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -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;