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: