[新增] Oled显示

This commit is contained in:
2023-07-02 13:11:51 +08:00
parent 20dcf41bf4
commit 0ecf68a4e4
4 changed files with 984 additions and 49 deletions

18
main.py
View File

@ -6,8 +6,8 @@ import sys
import time
import RPi.GPIO as GPIO
import spidev as SPI
import Pioneer600.Led.LED as LED
import Pioneer600.Oled.SSD1306 as SSD1306
import Pioneer600.Led.led as LED
import Pioneer600.Oled.oled as OLED
from PIL import Image,ImageDraw,ImageFont
import threading
@ -22,27 +22,31 @@ OLED_SPI_CS = 0
# 新线程执行的代码:
def blink_loop(*args, **kwargs):
try:
delay_ms = 500
while True:
GPIO.output(args, GPIO.HIGH)
time.sleep(1)
time.sleep(delay_ms/1000)
GPIO.output(args, GPIO.LOW)
time.sleep(1)
time.sleep(delay_ms/1000)
except:
print("except")
GPIO.output(args, GPIO.HIGH)
GPIO.cleanup()
def main():
# 128x64 display with hardware SPI:
led = LED.LED(LED_GPIO_RED)
led = LED.LED(LED_GPIO_RED)
oled = OLED.OLED(OLED_GPIO_RST, OLED_GPIO_DC, OLED_SPI_BUS, OLED_SPI_CS)
try:
led_blink = threading.Thread(target=blink_loop, name='led_blink', args=(LED_GPIO_RED,))
led_blink.start()
oled.draw_text(0, 0, 16, 'Hello, workld')
while True:
time.sleep(1)
except:
print("Except")
led_blink.join()