Skip to content

Commit

Permalink
Fix mapping from slider values to menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
garthk committed Jan 25, 2021
1 parent 52a3eb0 commit c70e1a3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/aiko/system_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c70e1a3

Please sign in to comment.