[修改] 编码优化
This commit is contained in:
@ -5,7 +5,7 @@ import RPi.GPIO as GPIO
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
class LED(object):
|
class LED(object):
|
||||||
"""class for SSD1306 128*64 0.96inch OLED displays."""
|
"""class for LED."""
|
||||||
|
|
||||||
def __init__(self, led):
|
def __init__(self, led):
|
||||||
LED = led
|
LED = led
|
||||||
@ -25,3 +25,11 @@ class LED(object):
|
|||||||
GPIO.output(LED,GPIO.HIGH)
|
GPIO.output(LED,GPIO.HIGH)
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
|
||||||
|
LED_GPIO_RED = 26
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# 128x64 display with hardware SPI:
|
||||||
|
led = LED.LED(LED_GPIO_RED)
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
main()
|
||||||
|
|||||||
@ -1,14 +1,22 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import spidev as SPI
|
import spidev as SPI
|
||||||
import SSD1306
|
import SSD1306
|
||||||
import time
|
|
||||||
|
|
||||||
from PIL import Image,ImageDraw,ImageFont
|
from PIL import Image,ImageDraw,ImageFont
|
||||||
|
|
||||||
|
# Raspberry Pi pin configuration:
|
||||||
|
OLED_GPIO_RST = 19
|
||||||
|
OLED_GPIO_DC = 16
|
||||||
|
OLED_SPI_BUS = 0
|
||||||
|
OLED_SPI_CS = 0
|
||||||
|
|
||||||
# Raspberry Pi pin configuration:
|
# Raspberry Pi pin configuration:
|
||||||
GPIO_RST = 19
|
GPIO_RST = 19
|
||||||
GPIO_DC = 16
|
GPIO_DC = 16
|
||||||
SPI_BUS = 0
|
SPI_BUS = 0
|
||||||
SPI_CS = 0
|
SPI_CS = 0
|
||||||
|
|
||||||
# 128x64 display with hardware SPI:
|
# 128x64 display with hardware SPI:
|
||||||
disp = SSD1306.SSD1306(GPIO_RST, GPIO_DC, SPI.SpiDev(SPI_BUS, SPI_CS))
|
disp = SSD1306.SSD1306(GPIO_RST, GPIO_DC, SPI.SpiDev(SPI_BUS, SPI_CS))
|
||||||
|
|||||||
21
main.py
21
main.py
@ -1,31 +1,28 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import spidev as SPI
|
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 Pioneer600.Led.LED as LED
|
import Pioneer600.Led.LED as LED
|
||||||
import Pioneer600.Oled.SSD1306 as SSD1306
|
import Pioneer600.Oled.SSD1306 as SSD1306
|
||||||
|
|
||||||
from PIL import Image,ImageDraw,ImageFont
|
from PIL import Image,ImageDraw,ImageFont
|
||||||
|
|
||||||
# Raspberry Pi pin configuration:
|
# Raspberry Pi pin configuration:
|
||||||
|
LED_GPIO_RED = 26
|
||||||
|
|
||||||
OLED_GPIO_RST = 19
|
OLED_GPIO_RST = 19
|
||||||
OLED_GPIO_DC = 16
|
OLED_GPIO_DC = 16
|
||||||
OLED_SPI_BUS = 0
|
OLED_SPI_BUS = 0
|
||||||
OLED_SPI_CS = 0
|
OLED_SPI_CS = 0
|
||||||
|
|
||||||
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():
|
def main():
|
||||||
|
|
||||||
|
# 128x64 display with hardware SPI:
|
||||||
|
led = LED.LED(LED_GPIO_RED)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -34,5 +31,3 @@ def main():
|
|||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user