From fe1c7ad9ede44bdd95ec50f9a04dc5f0cfbfad10 Mon Sep 17 00:00:00 2001
From: Philip Stewart <philip.d.stewart@gmail.com>
Date: Fri, 6 Nov 2020 12:46:46 +0000
Subject: [PATCH] feat(simple_menu): Make scroll buttons configurable

---
 Documentation/card10-cfg.rst        |  2 ++
 pycardium/modules/py/simple_menu.py | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/card10-cfg.rst b/Documentation/card10-cfg.rst
index 7a0173b3d..134014889 100644
--- a/Documentation/card10-cfg.rst
+++ b/Documentation/card10-cfg.rst
@@ -48,4 +48,6 @@ Option name        Type       Description
 ``ble_mac``        Boolean    MAC address used for BLE. Format: ``ca:4d:10:xx:xx:xx``.
 ------------------ ---------- -----------
 ``ble_log_enable`` Boolean    Activate HCI level logging of BLE data. Creates a new btsnoop compatible log file named ``ble.log`` in the ``logs`` folder after each boot if BLE is activated. Keeps the last 10 files.
+------------------ ---------- -----------
+``right_scroll``   Boolean    Use both right buttons to scroll up and down. Lower left button is SELECT.
 ================== ========== ===========
diff --git a/pycardium/modules/py/simple_menu.py b/pycardium/modules/py/simple_menu.py
index 5701d80b6..506c5f894 100644
--- a/pycardium/modules/py/simple_menu.py
+++ b/pycardium/modules/py/simple_menu.py
@@ -3,6 +3,7 @@ import color
 import display
 import sys
 import time
+import config
 
 TIMEOUT = 0x100
 """:py:func:`~simple_menu.button_events` timeout marker."""
@@ -193,11 +194,18 @@ class Menu:
         self.idx = 0
         self.select_time = time.time_ms()
         self.disp = display.open()
+        try:
+            right_scroll_str = config.get_string("right_scroll")
+            if right_scroll_str.lower() in ["true", "1"]:
+                right_buttons_scroll = True
+        except OSError:
+            right_buttons_scroll = self.right_buttons_scroll
+
         self.button_scroll_up = (
-            buttons.TOP_RIGHT if self.right_buttons_scroll else buttons.BOTTOM_LEFT
+            buttons.TOP_RIGHT if right_buttons_scroll else buttons.BOTTOM_LEFT
         )
         self.button_select = (
-            buttons.BOTTOM_LEFT if self.right_buttons_scroll else buttons.TOP_RIGHT
+            buttons.BOTTOM_LEFT if right_buttons_scroll else buttons.TOP_RIGHT
         )
 
     def entry2name(self, value):
-- 
GitLab