Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use raspberry source to drive 128x128 color screen SSD1351

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the raspberry source driver 128 color screen SSD1351, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

1 install Luma.Oide library

Sudo apt-get install python-dev python-pip libfreetype6-dev libjpeg-dev

Sudo-H pip install-- upgrade pip

Sudo apt-get purge python-pip

Sudo-H pip install-- upgrade luma.oled

Note: if you need to install the Luma.oled library of Python3, follow the corresponding Python3 version below to modify the above command to install.

Pip ⇒ pip3

Python ⇒ python3

Python-dev ⇒ python3-dev

Python-pip ⇒ python3-pip

If there is a scarlet letter error when installing the Luma.oled library, please continue to execute the command and try again because of network problems and failed to download a library called Pillow.

2 connect the display screen and Pi

Connect the port according to the following configuration. The port information of the raspberry source can be viewed at the following URL to view the https://pinout.xyz/pinout/spi

3 modify the code

Download the sample code https://github.com/rm-hull/luma.examples of luma

Let's take animated_gif.py as an example. The original code is as follows:

#! / usr/bin/env python#-*-coding: utf-8-*-# Copyright (c) 2017-18 Richard Hull and contributors# See LICENSE.rst for details.# PYTHON_ARGCOMPLETE_OK "" Displays an animated gif. "import os.pathfrom demo_opts import get_devicefrom PIL import Image, ImageSequencefrom luma.core.sprite_system import framerate_regulatordef main (): regulator = framerate_regulator (fps=10) img_path = os.path.abspath (os.path.join (os.path.dirname (_ _ file__)) 'images',' banana.gif')) banana = Image.open (img_path) size = [min (* device.size)] * 2 posn = ((device.width-size [0]) / / 2, device.height-size [1]) while True: for frame in ImageSequence.Iterator (banana): with regulator: background = Image.new ("RGB", device.size "white") background.paste (frame.resize (size, resample=Image.LANCZOS), posn) device.display (background.convert (device.mode)) if _ _ name__ = "_ _ main__": try: device = get_device () main () except KeyboardInterrupt: pass

The modified code is as follows:

#! / usr/bin/env python#-*-coding: utf-8-*-# Copyright (c) 2017-18 Richard Hull and contributors# See LICENSE.rst for details.# PYTHON_ARGCOMPLETE_OK "" Displays an animated gif. "" import timeimport os.pathfrom demo_opts import get_devicefrom PIL import Image, ImageSequencefrom luma.core.sprite_system import framerate_regulatorfrom luma.core.interface.serial import i2C, spifrom luma.oled.device import ssd1306, ssd1325, ssd1331, sh2106 Ssd1351def main (): regulator = framerate_regulator (fps=20) img_path = os.path.abspath (os.path.join (os.path.dirname (_ _ file__), 'images',' bq.gif')) banana = Image.open (img_path) # size = [min (* device.size)] * 2 # posn = ((device.width-size [0]) / / 2, device.height-size [1]) size = [128 Posn = (0,0) while True: for frame in ImageSequence.Iterator (banana): with regulator: background = Image.new ("RGB", device.size, "white") background.paste (frame.resize (size, resample=Image.LANCZOS) Posn) device.display (background.convert (device.mode)) time.sleep if _ _ name__ = = "_ _ main__": try: # serial = I2C (port=1,address=0x3c) serial = spi (device=0,port=0,bus_speed_hz=32000000) device= ssd1351 (serial) # device= ssd1306 (serial) main () except KeyboardInterrupt: pass

Mainly import ssd1351, and adjust device to ssd1351. The display effect is as follows:

The above is all the contents of the article "how to use a raspberry source to drive 128x128 color screen SSD1351". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report