From c70e1a3e7101d6e05ec586fe6780318cc5ed80a6 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Mon, 25 Jan 2021 16:46:07 +1100 Subject: [PATCH] Fix mapping from slider values to menu items. --- lib/aiko/system_ui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/aiko/system_ui.py b/lib/aiko/system_ui.py index 597c964..212e06c 100644 --- a/lib/aiko/system_ui.py +++ b/lib/aiko/system_ui.py @@ -50,8 +50,11 @@ def button_handler(number, state): def slider_handler(number, state, value): if value: - menu_item = menu_items - int(map_value(value, 0, 100, 0, menu_items-1)) - 1 - menu_item_select(menu_item) + menu_item_select(slider_zone(value, menu_items)) + +def slider_zone(value, zones): + # return zone integer in range(0, zones - 1) given value integer in range (0, 100) + return zones - min(int(map_value(value, 0, 100, 0, zones)), zones - 1) - 1 def system_features_menu(): oled.oleds_system_use(True)