raspberry pi lcd display tutorial made in china
Connecting an LCD to your Raspberry Pi will spice up almost any project, but what if your pins are tied up with connections to other modules? No problem, just connect your LCD with I2C, it only uses two pins (well, four if you count the ground and power).
In this tutorial, I’ll show you everything you need to set up an LCD using I2C, but if you want to learn more about I2C and the details of how it works, check out our article Basics of the I2C Communication Protocol.
BONUS: I made a quick start guide for this tutorial that you can download and go back to later if you can’t set this up right now. It covers all of the steps, diagrams, and code you need to get started.
There are a couple ways to use I2C to connect an LCD to the Raspberry Pi. The simplest is to get an LCD with an I2C backpack. But the hardcore DIY way is to use a standard HD44780 LCD and connect it to the Pi via a chip called the PCF8574.
The PCF8574 converts the I2C signal sent from the Pi into a parallel signal that can be used by the LCD. Most I2C LCDs use the PCF8574 anyway. I’ll explain how to connect it both ways in a minute.
I’ll also show you how to program the LCD using Python, and provide examples for how to print and position the text, clear the screen, scroll text, print data from a sensor, print the date and time, and print the IP address of your Pi.
Connecting an LCD with an I2C backpack is pretty self-explanatory. Connect the SDA pin on the Pi to the SDA pin on the LCD, and the SCL pin on the Pi to the SCL pin on the LCD. The ground and Vcc pins will also need to be connected. Most LCDs can operate with 3.3V, but they’re meant to be run on 5V, so connect it to the 5V pin of the Pi if possible.
If you have an LCD without I2C and have a PCF8574 chip lying around, you can use it to connect your LCD with a little extra wiring. The PCF8574 is an 8 bit I/O expander which converts a parallel signal into I2C and vice-versa. The Raspberry Pi sends data to the PCF8574 via I2C. The PCF8574 then converts the I2C signal into a 4 bit parallel signal, which is relayed to the LCD.
Before we get into the programming, we need to make sure the I2C module is enabled on the Pi and install a couple tools that will make it easier to use I2C.
Now we need to install a program called I2C-tools, which will tell us the I2C address of the LCD when it’s connected to the Pi. So at the command prompt, enter sudo apt-get install i2c-tools.
Next we need to install SMBUS, which gives the Python library we’re going to use access to the I2C bus on the Pi. At the command prompt, enter sudo apt-get install python-smbus.
Now reboot the Pi and log in again. With your LCD connected, enter i2cdetect -y 1 at the command prompt. This will show you a table of addresses for each I2C device connected to your Pi:
We’ll be using Python to program the LCD, so if this is your first time writing/running a Python program, you may want to check out How to Write and Run a Python Program on the Raspberry Pi before proceeding.
There are a couple things you may need to change in the code above, depending on your set up. On line 19 there is a function that defines the port for the I2C bus (I2CBUS = 0). Older Raspberry Pi’s used port 0, but newer models use port 1. So depending on which RPi model you have, you might need to change this from 0 to 1.
The function mylcd.lcd_display_string() prints text to the screen and also lets you chose where to position it. The function is used as mylcd.lcd_display_string("TEXT TO PRINT", ROW, COLUMN). For example, the following code prints “Hello World!” to row 2, column 3:
On a 16×2 LCD, the rows are numbered 1 – 2, while the columns are numbered 0 – 15. So to print “Hello World!” at the first column of the top row, you would use mylcd.lcd_display_string("Hello World!", 1, 0).
You can create any pattern you want and print it to the display as a custom character. Each character is an array of 5 x 8 pixels. Up to 8 custom characters can be defined and stored in the LCD’s memory. This custom character generator will help you create the bit array needed to define the characters in the LCD memory.
The code below will display data from a DHT11 temperature and humidity sensor. Follow this tutorial for instructions on how to set up the DHT11 on the Raspberry Pi. The DHT11 signal pin is connected to BCM pin 4 (physical pin 7 of the RPi).
By inserting the variable from your sensor into the mylcd.lcd_display_string() function (line 22 in the code above) you can print the sensor data just like any other text string.
These programs are just basic examples of ways you can control text on your LCD. Try changing things around and combining the code to get some interesting effects. For example, you can make some fun animations by scrolling with custom characters. Don’t have enough screen space to output all of your sensor data? Just print and clear each reading for a couple seconds in a loop.
That’s right! In today’s tutorial I show you how to wire up and program your very own mini LCD display to your Raspberry Pi! By the end the of this video you will be printing your own messages to your very own screen module and will understand all of the Python code behind it. A good, cheap and enjoyable little project for Raspberry Pi – with plenty of scope for your own further developments!
We"re glad you could join us for another lesson in our comprehensive Raspberry Pi programming guide. The previous tutorial taught us how to install and connect the RFID card chip to your Raspberry Pi through step-by-step instructions. We also learnt how to install the libraries for the RFID card and build a simple authentication system. However, in this guide, I"ll show you how to install a 16-by-2-inch LCD screen on your Raspberry Pi.
This screen is a neat solution for displaying data from a Raspberry Pi without breaking the bank or getting too technical. A 162 display is better employed for presenting concise data or messages than a touchscreen or standard LCD panel.
A liquid crystal display, or LCD, the screen is a versatile electronic display module. The 16x2 LCD module is popular in many electronic gadgets and circuits. Because there are two lines, the LCD can show 16 characters across each. This LCD uses a 5x7 pixel matrix to show each character. The 224 distinct characters and symbols can be shown on the 16x2 programmable alphanumeric dot matrix display. The Command register and Data register are the two types in this LCD.
LCDs can function thanks to the principle of light transmission from one layer to the next via modules. These units will vibrate and align themselves such that the polarized sheet is at an angle of 90 degrees, allowing light to pass through. In other words, these molecules inspect the information on every pixel. Every single pixel uses the light-absorption technique to display the numeral. It is necessary to adjust the molecular orientation to the incident light angle to show the numerical value.
LCDs are everywhere, from CD and DVD players and digital watches to computers and televisions. LCDs have supplanted CRTs (Catalyst Ray Tubes) in the screen manufacturing industry because CRTs are bulkier, heavier, and consume more energy than LCDs. LCD screens are more slender than their CRT counterparts. Since LCDs are based on a light-blocking rather than a light-dissipating technology, they require less electricity than LED panels.
LCDs employ two distinct registers—the data register and the command register. You can use the RS pins to alter the register. It is a data register if we set it to 1 and a command register if we set it to 0.
The display"s command register keeps track of the user"s input. Pre-display data is saved in a data register. In order to manipulate the display, one must first load the instruction register with commands and then load the data registers with the image data. If you"re working on a Raspberry Pi project and want to avoid learning low-level commands, you can use the Liquid Crystal Library instead. If a potentiometer is connected across the VEE pin, changing its value can alter the display"s contrast.
The pins on a standard 16x2 LCD are not always used. Since we"re only going to be using this Circuit in 4-bit mode, we"ll only need to use 4 of the available data bus lines.
Due to the absence of soldering, header pins will need to be added before they can be used. With them, it"s easier to maintain eye contact with the display. In the hands of a seasoned solderer, soldering is a simple task that may be completed in a matter of minutes.
The 16x2 LCD screen is easily connected to the Raspberry Pi. There will be a lot of cables to connect, but nothing too complicated. Before you go in and start soldering components together for the Circuit, there"s one thing you need to know. Pi"s GPIO pins are only rated for 3v3; thus, connecting the read/write input of the LCD to the ground is necessary to prevent 5v from re-entering the Pi. Brackets denote the logical/physical PINs used in the following instructions; otherwise, GPIO PINs are used.
Follow these steps, or check out the schematic below, beginning with gpio 1 of the liquid crystal display screen. The first screen pin is the one that is equidistant from those two sides.
Having done so, the screen should power up and establish a connection with the RPi without any further effort on your part. You can use the following circuit schematic to help you hook up the screen.
The newest Raspbian release has all the necessary packages loaded out of the box to allow for GPIO device communication. Python should also be available without further installation. More information on configuring the Pi for GPIO use may be helpful if you are using a previous version of Raspbian. While familiarity with Python would make this course more useful, readers with no background in the language should still be able to follow along.
Here I will demonstrate how to use the Adafruit library. It was made with Adafruit LCD boards in mind, but it can also be used with boards from other manufacturers. If the controller on your display board is an HD44780, you shouldn"t have any problems.
After the installation, you can use the Adafruit library from any Python program on the Pi. Just paste this line into the beginning of your Python file to make use of the library. The board can then be activated after being initialized.
The Adafruit LCD 16x2 library makes it simple to exchange data with your Raspberry Pi. Python scripts for adjusting and configuring the display can be written relatively easily.
The package we just downloaded may find several working examples of utilizing the LCD library. Before running any of these examples, make sure the pin parameters at the top of the program reflect your setup. My Circuit should yield the following results.
Change the values in this section to match the ones described above for the pin configuration. To leave when you"re done, hit CTRL+X+Y on your keyboard. To execute this code, open a terminal and type python followed by the name of the file (including the extension).
In this session, I"ll go over the fundamental Python methods for interacting with the screen. To initialize the pins, it is necessary to invoke the following class. Before calling the class, make sure all the parameters have been defined.
While you could always use one of the other options, it"s improbable that you"ll ever need to. The Ardafruit CharLCD.py file in the Adafruit CharLCD folder of the Adafruit Python CharLCD folder will list all the accessible methods.
If your Python script isn"t producing any output on the screen, it"s probably due to incorrectly configured pins. Verify both of them, as well as the breadboard"s connections.
This guide walked you through connecting the Pi 4 to a 16x2 LCD. You can accomplish so much more with this sleek screen. You may set up a script to run at boot time and show useful information like the IP address, time, temperature, and more.
Please let me know how successful you were in putting up a Pi 4 LCD 162 display with the help of this tutorial. The following tutorial teaches how to interface a soil moisture sensor with raspberry pi 4.
Looking good! That"s nice to combine with this housing: https://www.sossolutions.nl/raspberry-p ... dinrail-2b (DIN-rail) so you can fit it into your meter cabinet.
HW: HP dc7900 USD running ESXi, RaspberryPi (few of it), AEON S2 USB stick, Fibaro modules (Dimmers, switches), 1-wire (DS18B20, DS2423), DSC Alarm with Envisalink ethernet module, MySensors, RFLink
Check the number in the table, this is your address. If there are more devices on your I2c bus, there will be several addresses visible. To be sure, unplug all other devices and the address left will be the LCD (or try them all)
HW: HP dc7900 USD running ESXi, RaspberryPi (few of it), AEON S2 USB stick, Fibaro modules (Dimmers, switches), 1-wire (DS18B20, DS2423), DSC Alarm with Envisalink ethernet module, MySensors, RFLink
LCD screens are useful and found in many parts of our life. At the train station, parking meter, vending machines communicating brief messages on how we interact with the machine they are connected to. LCD screens are a fun way to communicate information in Raspberry Pi Pico projects and other Raspberry Pi Projects. They have a big bright screen which can display text, numbers and characters across a 16 x 2 screen. The 16 refers to 16 characters across the screen, and the 2 represents the number of rows we have. We can get LCD screens with 20x2, 20x4 and many other configurations, but 16x2 is the most common.
In this tutorial, we will learn how to connect an LCD screen, an HD44780, to a Raspberry Pi Pico via the I2C interface using the attached I2C backpack, then we will install a MicroPython library via the Thonny editor and learn how to use it to write text to the display, control the cursor and the backlight.
2. Import four librariesof pre-written code. The first two are from the Machine library and they enable us to use I2C and GPIO pins. Next we import the sleep function from Time enabling us to pause the code. Finally we import the I2C library to interact with the LCD screen.from machine import I2C, Pin
3. Create an objecti2c to communicate with the LCD screen over the I2C protocol. Here we are using I2C channel 0, which maps SDA to GP0 and SCL to GP1.i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
5. Create an objectlcdto set up the I2C connection for the library. It tells the library what I2C pins we are using, set via the i2c object, the address of our screen, set via I2C_ADDRand finally it sets that we have a screen with two rows and 16 columns.lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
6. Create a loopto continually run the code, the first line in the loop will print the I2C address of our display to Thonny’s Python Shell.while True:
8. Write two lines of textto the screen. The first will print “I2C Address:” followed by the address stored inside the I2C_ADDR object. Then insert a new line character “\n” and then write another line saying “Tom’s Hardware" (or whatever you want it to say). Pause for two seconds to allow time to read the text.lcd.putstr("I2C Address:"+str(I2C_ADDR)+"\n")
9. Clear the screenbefore repeating the previous section of code, but this time we display the I2C address of the LCD display using its hex value. The PCF8574T chip used in the I2C backpack has two address, 0x20 and 0x27 and it is useful to know which it is using, especially if we are using multiple I2C devices as they may cause a clash on the bus.lcd.clear()
12. Turn the backlight back onand then hide the cursor. Sometimes, a flashing cursor can detract from the information we are trying to communicate.lcd.backlight_on()
13. Create a for loopthat will print the number 0 to 19 on the LCD screen. Note that there is a 0.4 second delay before we delete the value and replace it with the next. We have to delete the text as overwriting the text will make it look garbled.for i in range(20):
Save and runyour code. As with any Python script in Thonny, Click on File >> Saveand save the file to your Raspberry Pi Pico. We recommend calling it i2c_lcd_test.py. When ready, click on the Green play buttonto start the code and watch as the test runs on the screen.
Computer monitors are great for office work, gaming, and browsing, but these displays can be large and power consuming. One display found in both the commercial and hobby world is the HD44780 16 x 2 display, which can display two lines of alphanumeric characters. In this tutorial, we will learn how to connect one to a Raspberry Pi and code it using the Python programming language!
The HD44780 has a number of registers and commands that are used to control the display, but getting the display to work can be somewhat tricky, especially for inexperienced users. This is why most coders will turn to libraries. They include prewritten code that has been proven to work. In this tutorial, we will be relying on two libraries to control the LCD: RPLCD and RPi.GPIO. Before we can continue, we need to install the RPLCD library by using the following command in a terminal window:
First, we need to import the RPi.GPIO library as GPIO. This will allow us to use the GPIO library and refer to it as “GPIO”, which is easier than RPi.GPIO. The next library that we need to include is the RPLCD library, which allows us to use the LCD. Therefore, the first two lines of code in our Python program will be:
CharLCD is a Python library that lets users access Adafruit character LCDs from a Raspberry Pi. Next, we need to tell the RPLCD library what pins we have connected the LCD to. In the Scheme-It schematic above, we connected the LCD pins to the following GPIO (using the BOARD numbering scheme). The Pi has two numbering schemes; BOARD and BCM. The BOARD numbering scheme refers to the I/O header whereas the BCM scheme refers to the GPIO numbers from the Broadcom IC. It is often easier to use BOARD scheme as you can count the pins to determine which one you need to use whereas the BCM scheme requires you to first choose a GPIO and then determine its pin number (BOARD).
Now that we have configured the LCD, it’s time to do a few tasks with it! The first function that we should learn to use is “write_string()”, which is used to write text to the LCD. Try the following command:
Writing predefined strings is not entirely helpful, and displaying variables can be very beneficial. Luckily for us, Python allows typecasting, where one variable can be converted into another variable. The example below shows how we can display a counter, which displays an integer on the LCD, along with a simple “Count” message.
Next, we’ll learn how to clear the display. Displays like those based around the HD44780 are static, and they remember what you tell them to display. However, this also means that when you want to write new data, you may need to clear the entire display. Therefore, you can use this clear function to clear the display:
Sometimes printing text on the top left of the display may not be desirable. In this case, you will need to change the cursor’s position. To do this, we can set the cursor_pos variable to a specific value. The example below sets the cursor position to row 2 (x) and column 0 (y).
At the end of your program, you should include the function “lcd.close()”, as this will free up the GPIO for other programs that may need to use them.
Computer monitors are great for office work, gaming, and browsing, but these displays can be large and power consuming. One display found in both the commercial and hobby world is the HD44780 16 x 2 display, which can display two lines of alphanumeric characters. In this tutorial, we will learn how to connect one to a Raspberry Pi and code it using the Python programming language!
The HD44780 has a number of registers and commands that are used to control the display, but getting the display to work can be somewhat tricky, especially for inexperienced users. This is why most coders will turn to libraries. They include prewritten code that has been proven to work. In this tutorial, we will be relying on two libraries to control the LCD: RPLCD and RPi.GPIO. Before we can continue, we need to install the RPLCD library by using the following command in a terminal window:
First, we need to import the RPi.GPIO library as GPIO. This will allow us to use the GPIO library and refer to it as “GPIO”, which is easier than RPi.GPIO. The next library that we need to include is the RPLCD library, which allows us to use the LCD. Therefore, the first two lines of code in our Python program will be:
CharLCD is a Python library that lets users access Adafruit character LCDs from a Raspberry Pi. Next, we need to tell the RPLCD library what pins we have connected the LCD to. In the Scheme-It schematic above, we connected the LCD pins to the following GPIO (using the BOARD numbering scheme). The Pi has two numbering schemes; BOARD and BCM. The BOARD numbering scheme refers to the I/O header whereas the BCM scheme refers to the GPIO numbers from the Broadcom IC. It is often easier to use BOARD scheme as you can count the pins to determine which one you need to use whereas the BCM scheme requires you to first choose a GPIO and then determine its pin number (BOARD).
Now that we have configured the LCD, it’s time to do a few tasks with it! The first function that we should learn to use is “write_string()”, which is used to write text to the LCD. Try the following command:
Writing predefined strings is not entirely helpful, and displaying variables can be very beneficial. Luckily for us, Python allows typecasting, where one variable can be converted into another variable. The example below shows how we can display a counter, which displays an integer on the LCD, along with a simple “Count” message.
Next, we’ll learn how to clear the display. Displays like those based around the HD44780 are static, and they remember what you tell them to display. However, this also means that when you want to write new data, you may need to clear the entire display. Therefore, you can use this clear function to clear the display:
Sometimes printing text on the top left of the display may not be desirable. In this case, you will need to change the cursor’s position. To do this, we can set the cursor_pos variable to a specific value. The example below sets the cursor position to row 2 (x) and column 0 (y).
At the end of your program, you should include the function “lcd.close()”, as this will free up the GPIO for other programs that may need to use them.
In previous tutorials, I showed you how to use MicroPython on the Raspberry Pi Pico. While MicroPython is straightforward to use, it has some processing overhead. C offers faster and more efficient computation in the Pico. In this tutorial, I’ll show you how to set up VS Code and blink an LED with C code.
At the time of writing, there is no simple, cross-platform IDE that comes pre-loaded with the Pico SDK, so we have to install things manually. I highly recommend reading Chapter 1 (for Linux) or Chapter 9 (macOS and Windows) of the Getting Started with Raspberry Pi Pico guide, as they walk you through the steps needed for installing the various build tools for the RP2040 (and Pico).
If you’re using a Raspberry Pi, Raspbian, or some other form of Debian, this process has been made easy with a simple script that you can run with a few commands:
In VS Code, I recommend installing a few extensions to make development for the Pico easier. Click the Extensions button on the left side and search for cmake. Install CMake Tools, which will also install the CMake extension.
Scroll down to find Cmake: Build Environment. If you do not have PICO_SDK_PATH set in your environment variables, I recommend adding an item here with PICO_SDK_PATH as the key and the value set to the location of the pico-sdk folder (e.g. C:\VSARM\sdk\pico\pico-sdk).
In VS Code, select File > Open Folder. Create a folder somewhere on your filesystem, preferably wherever you like to keep your Pico projects (for example, I’ll create a folder named “blink” in “Documents/Raspberry Pi Pico”). Select this new folder and click Select Folder.
In this example, we are blinking the onboard LED by toggling pin 25. We also print "Blinking!" out over the serial port with printf. We can choose which serial port to use (USB or UART) in the CMakeLists.txt file, as you will see next. You can read more about the various SDK functions in this online documentation as well as in the Pico C/C++ SDK guide.
CMake is a meta-build system that will automatically generate the files necessary for other build systems. We will use CMake to create files for the Make build system and then call “make” to compile and link our code.
Note that the CMake script we created uses some functions found in the pico_sdk_import.cmake file, which is part of the Pico SDK. One reason we set PICO_SDK_PATH as an environment variable is so that this script knows where to find that .cmake file.
Note that the bottom two functions (pico_enable_stdio_usb and pico_enable_stdio_uart) allow us to enable or disable a particular port for printf(). By enabling the USB port and disabling the UART port, we can send and receive serial data over USB.
Click No active kit to bring up a drop-down menu at the top of VS Code. Click [Scan for kits]. When this is done, click No active kit again. You should see your installed GNU Toolchain compiler available as an option. Click it (GCC for arm-none-eabi) to set the compiler for your build process.
The build directory will contain the automatically generated files (from CMake) necessary for building (compiling and linking) your source code. If you want to run CMake again in VS Code, you just need to click the same CMake button again. Note that you can also delete the build directory if you want to start clean.
Click the Build button in the status bar (at the bottom of the window). This will call make to build your project. You should see new, compiled binaries appear in the build folder.
We will use the .uf2 binary to program our Pico. Note that the .elf, .bin, and .hex are also compiled binaries of the same program. The .elf file contains extra debugging information that will allow us to do step-through debugging, which we will explore in the next tutorial.
Make sure the USB cable is not plugged into your Pico. Press the BOOTSEL button and hold it down while plugging the USB cable into the Pico. Once the USB cable is attached, release the BOOTSEL button.
Navigate into your build folder. Copy blink.uf2 (unfortunately, copying files from within VS Code does not work--you will have to do it from a file explorer window). Paste the file into the top level of your RPI-RP2 drive.
Open a serial terminal program and connect it to the serial port of your Pico (e.g. COM9 in Windows) with a baud rate of 115200. You should see “Blinking!” appear every 2 seconds.
I hope this tutorial has helped you get started creating C programs for your Raspberry Pi Pico! If you would like to dive deeper into the Pico C/C++ SDK, I recommend checking out the following documentation:
So I don"t know how much help I can be as I don"t know recalBOX and have a 3.5" LCD coming from China. As I understand, the fbcp program moves the screen data from framebuffer 0, HDMI, to framebuffer 1, LCD. This allows you to display your desktop on the LCD but has a performance hit so you can"t achieve a full 60fps.
Your second link does include a link to the fbcp Git hub, https://github.com/ian57/rpi-fbcp. At that link there are precompiled bins that should work, just copy into /usr/bin You shouldn"t need to compile unless you are making changes to fbcp.
Compatible with and can be directly connected to any version of Raspberry Pi. (If you are using a Raspberry Pi Zero / Zero 2 W, an additional HDMI cable is required.)
Raspberry Pi leads out 40 GPIO pins, while the screen leads out 26 pins. When connecting, pay attention to the corresponding pins and Raspberry Pi pins.
5) Insert the TF card into the Raspberry Pi, power on the Raspberry Pi, and wait for more than 10 seconds to display normally. But the touch is abnormal at that time, and the touch needs to be calibrated as the following steps.
You can perform touch calibration by clicking the Raspberry Pi icon on the taskbar, selecting Preferences -> Calibrate Touchscreen, and following the displayed prompts.
4. After calibration, the following data will be displayed. If you want to save these touch values, you can replace the data in the red circle with the data in the corresponding position in 99-calibration.conf.
Since the ads7846.dtbo provided by Raspberry Pi by default has no de-jitter parameters, you can increase the de-jitter parameters by modifying and replacing ads7846.dtbo
As a 2.4inch TFT display module with a resolution of 240 * 320, it uses the SPI interface for communication. LCD has an internal controller with basic functions, which can be used to draw points, lines, circles, and rectangles, and can display English, Chinese as well as pictures.
The 2.4inch LCD uses the PH2.0 8PIN interface, which can be connected to the Raspberry Pi according to the above table: (Please connect according to the pin definition table. The color of the wiring in the picture is for reference only, and the actual color shall prevail.)
The example we provide is based on STM32F103RBT6, and the connection method provided is also the corresponding pin of STM32F103RBT6. If you need to transplant the program, please connect according to the actual pin.
The LCD supports 12-bit, 16-bit, and 18-bit input color formats per pixel, namely RGB444, RGB565, and RGB666 three color formats, this demo uses RGB565 color format, which is also a commonly used RGB format.
For most LCD controllers, the communication mode of the controller can be configured, usually with an 8080 parallel interface, three-wire SPI, four-wire SPI, and other communication methods. This LCD uses a four-wire SPI communication interface, which can greatly save the GPIO port, and the communication speed will be faster.
Note: Different from the traditional SPI protocol, the data line from the slave to the master is hidden since the device only has a display requirement.
Framebuffer uses a video output device to drive a video display device from a memory buffer containing complete frame data. Simply put, a memory area is used to store the display content, and the display content can be changed by changing the data in the memory.
2.We use Dev libraries by default. If you need to change to BCM2835 or WiringPi libraries ,please open RaspberryPi\c\Makefile and modify lines 13-15 as follows:
If you need to draw pictures, or display Chinese and English characters, we provide some basic functions here about some graphics processing in the directory RaspberryPi\c\lib\GUI\GUI_Paint.c(.h).
Set points of the display position and color in the buffer: here is the core GUI function, processing points display position and color in the buffer.
The fill color of a certain window in the image buffer: the image buffer part of the window filled with a certain color, usually used to fresh the screen into blank, often used for time display, fresh the last second of the screen.
Display time: in the image buffer,use (Xstart Ystart) as the left vertex, display time,you can choose Ascii visual character font, font foreground color, font background color.;
2. The module_init() function is automatically called in the INIT () initializer on the LCD, but the module_exit() function needs to be called by itself
Python has an image library PIL official library link, it do not need to write code from the logical layer like C, can directly call to the image library for image processing. The following will take 1.54inch LCD as an example, we provide a brief description for the demo.
Note: Each character library contains different characters; If some characters cannot be displayed, it is recommended that you can refer to the encoding set ro used.
We write 1"s where we want a pixel lit up, and 0 where we want it dark. If you stand far away from your monitor, you may be able to make out the pictures embedded in the binary strings!
I re-organized the README.txt extracted from LCD_show.tar.tz that I extracted from the rpi_35_v1_B_B+_PI2 to make this a little easier to follow, plus added a couple missing steps. I am sure there are other ways to accomplish this, but this worked for me.
In previous posts I’ve covered using HD44780 16×2 and 20×4 LCD screens with the Raspberry Pi using Python. These are relatively easy to use but require a number of connections to be made to the Pi’s GPIO header. This setup can be simplified with the use of an I2C enabled LCD screen.
This requires a high level voltage (5V) and a low level voltage (3.3V) which the device uses as a reference. The HV pins can be connected to the screen and two of the LV pins to the Pi’s I2C interface.Level ShifterPiI2C Backpack
While experimenting I found that it worked fine without the level shifting but I couldn’t be certain this wasn’t going to damage the Pi at some point. So it’s probably best to play it safe!
The example script will allow you to send text to the screen via I2C. It is very similar to my scripts for the normal 16×2 screen. To download the script directly to your Pi you can use :wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/lcd_i2c.py
In order to use I2C devices you must enable the interface on your Raspberry Pi. This can be done by following my “Enabling The I2C Interface On The Raspberry Pi” tutorial. By default the I2C backpack will show up on address 0x27.