As mentioned before, I want this project to be as modular and reusable as possible.
Because of this I made a quick detour to get more out of this.
I made a simple navigation program that uses the LCD and the buttons on the LCD plate.
- Show the IP of the raspberry (no need for an external display,.. besides the LCD)
- A crude file explorer (only functions enter/exit folder and start another python script)
- Reboot system
- Shutdown system
- Exit program
All this was done with the help of a state machine and a python script code generator (lucky me,.. I work in a company that produces such software).
Here you see the domain model with all classes needed and the main state machine.
The state machine consists of two "main" states the first is the "show menu" and the second "show cmd output".
The "root menu" has the above listed functions hard coded. Every command (besides "exit") is a simple shell command that gets executed and the return value will be stored inside a "cmdOutput" list.
This Output list will then be show inside the "show cmd output", this enables the state machine to show me the Raspberries IP (hostname -I) or give me the ability to scroll across a file list (ls -p -a).
With the help of the "Navigate" node I then can enter/exit folders and execute python scripts.
The last thing needed to run the state machine is a bit of code (hand written):
from LCDMenu import * lcd = LCDMenu() lcd.runStateMachines()
And here you can see it in action (the putty output shows the trace information from the state machine and the activies)