A micropython library, which supports vertical and horizontal scrolling through menu items on both 2x16 and 4x20 LCDs
Go to file
2024-11-13 21:59:07 +01:00
images Added a first attempt for documentation 2024-11-13 21:59:07 +01:00
__init__.py Updated the error message changed previously 2024-11-13 20:33:24 +01:00
example_quittable.py Added quitting a menu functionality (actually quitting the run()'s infinite internal loop) 2024-11-12 22:15:15 +01:00
example_simple.py Added quitting a menu functionality (actually quitting the run()'s infinite internal loop) 2024-11-12 22:15:15 +01:00
example_submenu.py Added quitting a menu functionality (actually quitting the run()'s infinite internal loop) 2024-11-12 22:15:15 +01:00
LICENSE Initial commit 2024-10-30 19:41:28 +00:00
README.md Added a first attempt for documentation 2024-11-13 21:59:07 +01:00
tests.py Update tests.py 2024-11-01 21:13:06 +00:00

lcdMenu

A micropython library, which supports vertical and horizontal scrolling through menu items on both 2x16 and 4x20 liquid crystal displays

This project is the completely rewritten successor of my old (and now archived) ProgramChooser library.

It is now production-ready (tested on 2x16 displays only at the moment.) ToDo: Make the README.md also seem production ready!

Roadmap

  • forward, backward and select button
  • support for horizontal and vertical scrolling
  • support for both 2x16 and 4x20 LCDs
  • a reliable order of the menu items
  • good documentation for all of this (maybe through examples)
  • show an exit screen when a specific exit code is returned by a callback function
  • make the menu itself exitable (to enable stuff like submenus, etc.)
  • make the project a valid python package

Here are some of examples of how a lcdMenu will look, and to get those, simply append the Code column's contents to the following (considering you have the library "installed" as explained before. All the examples below use a 2x16 display.

from lcdMenu import lcdMenu
from machine import Pin, I2C
from PCF8574T import I2C_LCD

prev_btn = Pin(13, Pin.IN, Pin.PULL_DOWN)  # input of the first btn
next_btn = Pin(14, Pin.IN, Pin.PULL_DOWN)  # input of the second btn
ok_btn   = Pin(15, Pin.IN, Pin.PULL_DOWN)  # input of switch

LCD = I2C_LCD(I2C(0, sda=Pin(8), scl=Pin(9), freq=400000),0x27,2, 16)

def first():
    print("first() called! 1")
def second():
    print("second() called! 2")
def third():
    print("third() called! 3")
    return True


menuItems = [("first item", first),
             ("second item", second),
             ("third item", third)]
button_mappings = {"prev_btn":prev_btn, "next_btn": next_btn, "ok_btn": ok_btn}
Result Code
No title, first item & cycling on -> up & down, vertical scrolling ```python
menu = lcdMenu(LCD, button_mappings, scroll_direction=False, cycle=True, hide_menu_name=True, name="Fullscreen!")
menu.setup(menuItems)
menu.run()
| ![No title, first item & no cycling -> only down, vertical scrolling](images/2x16-no-title-vertical-only-down.jpg)    |  |
| ![No title, middle item -> up & down, vertical scrolling](images/2x16-no-title-vertical-up-down.jpg)                  |  |
| ![No title, last item & no cycling -> only up, vertical scrolling](images/2x16-no-title-vertical-only-up.jpg)         |  |
| ![With title, only one option, vertical scrolling](images/2x16-title-vertical-no-options.jpg)                         |  |
| ![With title, first item & no cycling -> only down, vertical scrolling](images/2x16-title-vertical-only-down.jpg)     |  |
| ![With title, middle item -> up & down, vertical scrolling](images/2x16-title-vertical-up-down.jpg)                   |  | 
| ![With title, last item & no cycling -> only up, vertical scrolling](images/2x16-title-vertical-only-up.jpg)          |  |
| ![With title, middle item -> forward and backward, horizontal scrolling](images/2x16-title-horizontal.jpg)            |  |


## License

This project is licensed under the GPL-v3-or-later. A copy can be found [here](LICENSE).