📜 ⬆️ ⬇️

How I made it much easier to work with the Raspberry Pi (“everything new is well forgotten old”)



-How to get started with Raspberry Pi?
-Fill the image on the SD-card, connect to the power supply and go to the store to buy everything that is missing.


Raspberry Pi in the standard package - not a gift. At least, if you are going to give Pi to someone for this New Year, make sure that the keyboard-monitor-mouse set, or at least a USB-UART adapter, will be available for the lucky 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 problems am I talking about?

Let's start with connecting to Pi. There are many ways, and each has its drawbacks.


USB-UART   USB-UART (   3.3V)      (FTDI,    ) (composite/HDMI)++      (    HDMI),     220    ,     -   ,   IP?       Ethernet    DHCP-    Pi   IP,     (   !)  Ethernet-   () WiFi  wpa_supplicant.conf  boot      IP (!)   (, WiFi   wlan2   ...) 

How to make an interface for your smart home / media center / robot?


 GUI    VNC  VNC       GUI       (Shutdown/Reboot/WiFi/IP/shell commands) SSH+CLI            WEB                Webmin/Ajenti/whatever 

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 a laptop with Linux to WiFi, and for the 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:



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?





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 the LCDProc was visible, which is more of 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 put it 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 those who might find it useful.


What is pyLCI?


pyLCI is a simple interface for configuring and managing Raspberry Pi functions using 2x16 screens, buttons and Python. It is simple, cheap and easy to use.
Installing pyLCI is easy - you install shield for $ 5 on Pi, download pyLCI on Pi and put it into autoload with the included script.


Examples of using


Under the spoilers - beautiful pyLCI gifs in work.


Getting IP

Shutdown / reboot

Connect to WiFi in McDonalds

Wifi password entry

Run your script

Unmounting flash drive

View USB devices

Restart fallen service

My application (Pomodoro timer)

Where can pyLCI be used?


  1. On a personal / home Raspberry Pi to more easily connect to it and perform some routine tasks.
  2. 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)
  3. When developing solutions on the Raspberry Pi (to raise the fallen escape room controller and restart the service without getting the computer is priceless)
  4. For your laptop on Pi (what's the use of Pi running 10 hours on battery if it can't be connected to WiFi)
  5. On your working Pi as an auxiliary interface (switch music / change volume while watching something on the Internet)

What hardware is needed for the interface?


The simple answer is to take such a shield from China:



It costs about 5 dollars, and it works flawlessly.


Do you want something of quality or urgently?

Then you can take a shield from Adafruit:



More expensive, but better made and wait for the delivery will not have to (shild from China - almost a complete copy of this).


I want to collect something from what is in place!

Displays


You need a simple display compatible with HD44780 commands, the minimum size is 16x2, displays of different sizes are supported. This type:



The display can be connected via GPIO (it takes 6 contacts on the Raspberry Pi) or I2C. Such displays often come across all sorts of Starter Kits, are available in every little bit respecting electronics store and market and cost $ 2 with free shipping from China.


Buttons / Keyboards


You need at least 5 buttons. They can be connected via GPIO, I2C-GPIO expanders, or use USB HID devices - such as such numpads:



Develop your 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 kind of RPC interface into it and write a pyLCI application that provides a UI and jerks RPC functions.


Hello World:


 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) 

What for what:



Documentation for various available UI elements is on ReadTheDocs , besides many examples of use can be seen in already written applications .


Adding features


Recently, I often add various features and fix bugs. A document with plans for the future is available here , but if you badly lack any function or application, please email me (crimier yandex ru) or issues on Github , I can help.


useful links




Developing a phone project on Pi Zero using pyLCI to change system settings without connecting via SSH


')

Source: https://habr.com/ru/post/400159/


All Articles