[修改] 增加包 Pioneer600
This commit is contained in:
30
Led/led.py
30
Led/led.py
@ -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()
|
||||
27
Pioneer600/Led/LED.py
Normal file
27
Pioneer600/Led/LED.py
Normal file
@ -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()
|
||||
|
||||
0
Pioneer600/Led/__init__.py
Normal file
0
Pioneer600/Led/__init__.py
Normal file
0
Pioneer600/Oled/__init__.py
Normal file
0
Pioneer600/Oled/__init__.py
Normal file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
Pioneer600/__init__.py
Normal file
0
Pioneer600/__init__.py
Normal file
7
main.py
7
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:
|
||||
|
||||
Reference in New Issue
Block a user