Welcome to CUBE Pi Case repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
OLED display
OLED display
OLED display1. Learning objectives2. Preparation before the experiment3. Install dependent librariesAdafruit_SSD1306 library4. OLED displays system information1. OLED display2. System information acquisition3. Run oled.py file5. Experimental phenomenon
1. Learning objectives
- Implement OLED display system information
Use OLED to display system information such as CPU usage, system time, and memory usage. This tutorial mainly learns how to run the oled.py file we wrote. The specific implementation principle and code are not analyzed.
2. Preparation before the experiment
Install the Raspberry Pi chassis according to the assembly video tutorial, and align the oled board with the 40pin pin of the Raspberry Pi.
3. Install dependent libraries
Adafruit_SSD1306 library
Note: If the Adafruit_SSD1306 library is installed in the "Install CubeNano driver library" tutorial, you can skip this step!
The Adafruit_SSD1306 library is a dependent library required in the oled.py file. Enter the following command in the terminal to install the Adafruit_SSD1306 library.
xxxxxxxxxxpip3 install Adafruit_SSD1306 --break-system-packages
The python Adafruit_SSD1306 library is used to control the data display of our OLED display.
Note: If the PIL library is missing in the OLED display tutorial, you can take the following solution. ** (generally not required to run)**
xxxxxxxxxxsudo apt-get install libjpeg-dev zlib1g-devpip3 install setuptools --break-system-packagespip3 install Pillow --break-system-packages
4. OLED displays system information
1. OLED display
| Function | Implementation function |
|---|---|
| OLED initialization | begin() |
| OLED clear display | clear() |
| OLED add characters | add_text(start_x, start_y, text, refresh) |
| OLED add lines | add_line(text, line, refresh) |
| OLED refresh display | refresh() |
2. System information acquisition
| Function | Implementation function |
|---|---|
| Read CPU usage | getCPULoadRate() |
| Read system time | getSystemTime() |
| Read memory usage and total memory | getUsagedRAM() |
| Read TF card space usage/TF card total space | getUsagedDisk() |
| Get local IP | getLocalIP() |
| Read free TF card space/TF card total space | getFreeDisk() |
3. Run oled.py file
Copy the oled.py file in the data to the Jetson motherboard system, open the terminal in the directory where the oled.py file is located, and use the following command to run the oled.py file.
xxxxxxxxxxpython3 oled.py

Note: You can press Ctrl + C twice in a row to terminate the operation
5. Experimental phenomenon
After running the oled.py file, you can see the display of system information related to the OLED display (to clear the OLED display, see the "Setting the boot-up auto-start" tutorial later and run the kill_oled.sh file).
