From b656f348f8eebb19e1eaa0378e342577dd2296d0 Mon Sep 17 00:00:00 2001 From: gaoyang3513 Date: Thu, 29 Jun 2023 23:54:51 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=94=B9]=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8C=85=20Pioneer600?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Led/led.py | 30 ------------------------ Pioneer600/Led/LED.py | 27 +++++++++++++++++++++ Pioneer600/Led/__init__.py | 0 {Oled => Pioneer600/Oled}/SSD1306.py | 0 Pioneer600/Oled/__init__.py | 0 {Oled => Pioneer600/Oled}/animate.py | 0 {Oled => Pioneer600/Oled}/dispchar.py | 0 {Oled => Pioneer600/Oled}/happycat.ppm | Bin {Oled => Pioneer600/Oled}/image.py | 0 {Oled => Pioneer600/Oled}/oled.py | 0 {Oled => Pioneer600/Oled}/waveshare.bmp | Bin {Oled => Pioneer600/Oled}/waveshare.py | 0 Pioneer600/__init__.py | 0 main.py | 7 +++++- 14 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 Led/led.py create mode 100644 Pioneer600/Led/LED.py create mode 100644 Pioneer600/Led/__init__.py rename {Oled => Pioneer600/Oled}/SSD1306.py (100%) create mode 100644 Pioneer600/Oled/__init__.py rename {Oled => Pioneer600/Oled}/animate.py (100%) rename {Oled => Pioneer600/Oled}/dispchar.py (100%) rename {Oled => Pioneer600/Oled}/happycat.ppm (100%) rename {Oled => Pioneer600/Oled}/image.py (100%) rename {Oled => Pioneer600/Oled}/oled.py (100%) rename {Oled => Pioneer600/Oled}/waveshare.bmp (100%) rename {Oled => Pioneer600/Oled}/waveshare.py (100%) create mode 100644 Pioneer600/__init__.py diff --git a/Led/led.py b/Led/led.py deleted file mode 100644 index b976b3a..0000000 --- a/Led/led.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -import RPi.GPIO as GPIO -import time -import spidev - -def main(): - LED = 26 - - GPIO.setwarnings(False) - - GPIO.setmode(GPIO.BCM) - GPIO.setup(LED,GPIO.OUT) - - spi = spidev.SpiDev() - - try: - while True: - GPIO.output(LED,GPIO.HIGH) - time.sleep(1) - GPIO.output(LED,GPIO.LOW) - time.sleep(1) - except: - print("except") - GPIO.output(LED,GPIO.HIGH) - GPIO.cleanup() - -if __name__=='__main__': - main() diff --git a/Pioneer600/Led/LED.py b/Pioneer600/Led/LED.py new file mode 100644 index 0000000..d868f31 --- /dev/null +++ b/Pioneer600/Led/LED.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +import RPi.GPIO as GPIO +import time + +class LED(object): + """class for SSD1306 128*64 0.96inch OLED displays.""" + + def __init__(self, led): + LED = led + + GPIO.setwarnings(False) + GPIO.setmode(GPIO.BCM) + GPIO.setup(LED,GPIO.OUT) + + try: + while True: + GPIO.output(LED,GPIO.HIGH) + time.sleep(1) + GPIO.output(LED,GPIO.LOW) + time.sleep(1) + except: + print("except") + GPIO.output(LED,GPIO.HIGH) + GPIO.cleanup() + diff --git a/Pioneer600/Led/__init__.py b/Pioneer600/Led/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Oled/SSD1306.py b/Pioneer600/Oled/SSD1306.py similarity index 100% rename from Oled/SSD1306.py rename to Pioneer600/Oled/SSD1306.py diff --git a/Pioneer600/Oled/__init__.py b/Pioneer600/Oled/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Oled/animate.py b/Pioneer600/Oled/animate.py similarity index 100% rename from Oled/animate.py rename to Pioneer600/Oled/animate.py diff --git a/Oled/dispchar.py b/Pioneer600/Oled/dispchar.py similarity index 100% rename from Oled/dispchar.py rename to Pioneer600/Oled/dispchar.py diff --git a/Oled/happycat.ppm b/Pioneer600/Oled/happycat.ppm similarity index 100% rename from Oled/happycat.ppm rename to Pioneer600/Oled/happycat.ppm diff --git a/Oled/image.py b/Pioneer600/Oled/image.py similarity index 100% rename from Oled/image.py rename to Pioneer600/Oled/image.py diff --git a/Oled/oled.py b/Pioneer600/Oled/oled.py similarity index 100% rename from Oled/oled.py rename to Pioneer600/Oled/oled.py diff --git a/Oled/waveshare.bmp b/Pioneer600/Oled/waveshare.bmp similarity index 100% rename from Oled/waveshare.bmp rename to Pioneer600/Oled/waveshare.bmp diff --git a/Oled/waveshare.py b/Pioneer600/Oled/waveshare.py similarity index 100% rename from Oled/waveshare.py rename to Pioneer600/Oled/waveshare.py diff --git a/Pioneer600/__init__.py b/Pioneer600/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py index 06e6051..3f2790d 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,10 @@ import sys import time import RPi.GPIO as GPIO import spidev as SPI +sys.path.append(os.path.join(os.path.dirname(__file__),'Led')) sys.path.append(os.path.join(os.path.dirname(__file__),'Oled')) -import SSD1306 +import Pioneer600.Led.LED as LED +import Pioneer600.Oled.SSD1306 as SSD1306 from PIL import Image,ImageDraw,ImageFont @@ -19,6 +21,9 @@ LED_GPIO_RED = 26 # 128x64 display with hardware SPI: disp = SSD1306.SSD1306(OLED_GPIO_RST, OLED_GPIO_DC, SPI.SpiDev(OLED_SPI_BUS, OLED_SPI_CS)) +# 128x64 display with hardware SPI: +led = LED.LED(LED_GPIO_RED) + def main(): try: