Added implementation of previous_selection and next_selection handlers
This commit is contained in:
parent
a9dd13a1cc
commit
76cd7afa8b
20
__init__.py
20
__init__.py
@ -9,6 +9,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class lcdMenu:
|
class lcdMenu:
|
||||||
# lcd: I2C_LCD - an object of the I2C_LCD class (https://git.privacynerd.de/BlueFox/micropython-libraries/src/branch/main/PCF8574T)
|
# lcd: I2C_LCD - an object of the I2C_LCD class (https://git.privacynerd.de/BlueFox/micropython-libraries/src/branch/main/PCF8574T)
|
||||||
# buttons: dict - a dictionary with machine.Pin objects as items with following keys
|
# buttons: dict - a dictionary with machine.Pin objects as items with following keys
|
||||||
@ -49,10 +50,29 @@ class lcdMenu:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def previous_selection(self):
|
||||||
|
self.current_selection -= 1
|
||||||
|
if self.current_selection < 0: # after the last element:
|
||||||
|
if self.cycle: # if cycling is enabled, set it to the index of the last element
|
||||||
|
self.current_selection = len(self.menu_items)-1
|
||||||
|
else: # else, go to first element
|
||||||
|
self.current_selection = 0
|
||||||
|
|
||||||
|
|
||||||
|
def next_selection(self):
|
||||||
|
self.current_selection += 1
|
||||||
|
if self.current_selection >= len(self.menu_items): # after the last element:
|
||||||
|
if self.cycle: # if cycling is enabled, go to first element
|
||||||
|
self.current_selection = 0
|
||||||
|
else: # else, set it to the index of the last element
|
||||||
|
self.current_selection = len(self.menu_items)-1
|
||||||
|
|
||||||
|
|
||||||
def execute_selection(self):
|
def execute_selection(self):
|
||||||
self.menu_items[self.current_selection][1]()
|
self.menu_items[self.current_selection][1]()
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# TODO: add btn handlers and the actual process
|
# TODO: add btn handlers and the actual process
|
||||||
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user