How did I extensively simplify the interaction with Raspberry Pi?
-How to get started along with Raspberry Pi?
-Fill the particular image on the Facts, hook up to the strong supply and go in order to the store to purchase anything that is missing.
Raspberry Pi in the regular package – not the gift. At least, if you are planning to give Pi in order to someone for this New Year, ensure that the keyboard-monitor-mouse set, or at least a USB-UART adapter, will be available to the happy recipient.
What to do if you want to do your project, but there is only a fee and it is problematic to connect at least something to it? I suffered with this kind of problems for 3 years until I developed pyLCI. About how to start using pyLCI and what it gives, I will tell you today.
What issues am I talking about?
In the three years that I have been working with Raspberry Pi, I learned Linux, programming in Python and using all of this to create various interesting devices. All this time I ran across the same problems, the root of which is that the Raspberry Pi does not have simple built-in methods for interacting with the OS – for example, the built-in monitor / keyboard. As a result, it is easy to connect any laptop with Linux to WiFi, and for Raspberry Pi you need to use additional hardware, dig with commands or carry monitors. This, as for me, has not yet been avoided, but it can be solved with a minimal amount of effort.
The more I developed different projects, the more different solutions I tried. During this time I used:
UART via Bluetooth (HC-05)
Buttons on GPIO
Display that shows IP
It’s not that. The resulting solutions at some point clearly showed their limitations, and with all the iron that I used, one could achieve much more. What did my requirements ultimately form?
The interface should be cheap. Buying additional hardware is always problematic, so the lower the price, the easier it is to equip the project with the interface.
The interface should be universal. The cheapest iron is that which has already been purchased or can be dropped from somewhere.
The interface should be simple. The simpler it is to use, the more you can achieve.
As a result, last year (2015), I started a project that uses cheap displays and buttons and gives me the opportunity to use the basic functions of the Raspberry Pi. It would seem that the idea is very simple – such interfaces have been popular for a long time in various devices – but when searching for ready-made solutions for Linux, only LCDProc was visible, which is more than a status monitor. Most of the people who wanted to use such an interface, collective farms or something on Python with ready libs for displays and somehow working navigation code, sometimes not even rendered into classes for reuse.
In April of this year, a bunch of projects and a lot of mistakes later, I finished the project to version 1.0, called pyLCI and laid it out on GT for everyone to see. Since then, much has changed – pyLCI was used in each of my Raspberry Pi-projects, features were added, bugs disappeared, and occasionally I received letters with questions about some of the nuances of pyLCI. Now my goal is to tell about this project to all who it may be useful.
What exactly is pyLCI?
pyLCI is a simple interface for configuring and managing Raspberry Pi functions using 2×16 screens, buttons and Python. It is simple, cheap and easy to use.
It is easy to install pyLCI – you put a shield for $ 5 on Pi, download pyLCI on Pi and put it into autoload with the included script.
Where you can use pyLCI?
On the personal / home Raspberry Pi for easier connection to it and perform some routine tasks.
When using the Raspberry Pi for training (for example, by significantly reducing the budget to the periphery and time to “connect to the Raspberry Pi” at the beginning of the lesson)
When developing solutions on the Raspberry Pi (to raise the fallen escape room controller and restart the service without getting the computer is priceless)
For your laptop computer on Pi (what’s the use of Pi, working 10 hours from the battery, if it can not be connected to WiFi)
On your working Pi as an auxiliary interface (switch music / change volume while watching something on the Internet)
What hardware is required for the interface?
The answer is simple: take this one:
The price is approximately USD 5 and it is humming along smoothly.
Developing your own applications
pyLCI is a UI framework that provides various UI elements to speed development and even allows you to fully integrate your application into pyLCI. For complex applications that need to be run separately, there is a proven approach – to implement some RPC interface in it and write a pyLCI application that provides a UI and jerks RPC functions.
menu_name = "Hello world" from ui import Printer #Callback global for pyLCI callback = None #Some globals for us i = None o = None def init_app(input, output): global callback, i, o i = input; o = output callback = lambda: Printer("Hello world!", i, o)
Let’s define the main elements:
menu_name – the name of the application in the main menu
i – input device, catches button presses and calls callbacks set on them.
o – output device, operates the display.
printer is a simple display function. Uses i and o, has various useful parameters and ways to call.
init_app is an application function called when pyLCI starts. It transfers i and o to the application, it usually creates the main UI elements of the application.
callback is a function called when an application is activated. Usually activates the main menu of the application, in our case simply calls Printer with our message.
Documentation on the various available UI elements is on ReadTheDocs, besides many examples of use can be seen in already written applications.
Recently, I often add various features and fix bugs. A document with plans for the future is available here.
Developing a phone project on Pi Zero using pyLCI to change system settings without connecting via SSH.