def main(): SPI = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock RST = pyb.Pin('PE9') CE = pyb.Pin('PE8') DC = pyb.Pin('PE7') LIGHT = pyb.Pin('PE6') lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) # for i in range(83): # lcd_5110.lcd_write_draw(i,0,1) # for i in range(83): # lcd_5110.lcd_write_draw(i,5,0x80) # for i in range(6): # lcd_5110.lcd_write_draw(0,i,0xff) # for i in range(6): # lcd_5110.lcd_write_draw(83,i,0xff) while True: a = 0 b = 32 for i in range(8): lcd_5110.lcd_write_pictuer(0, 0, a, b) a += 32 b += 32 pyb.delay(150)
def main(): SPI = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock RST = pyb.Pin('Y10') CE = pyb.Pin('Y11') DC = pyb.Pin('Y9') LIGHT = pyb.Pin('Y12') lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110.lcd_write_draw_x(0, 0, 20, 50) lcd_5110.lcd_write_draw_x(40, 0, 36, 10) lcd_5110.lcd_write_draw_x(20, 0, 36, 60) lcd_5110.lcd_write_draw_x(30, 10, 0, 80) lcd_5110.lcd_read_hc()
def main(): SPI = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock RST = pyb.Pin('Y10') CE = pyb.Pin('Y11') DC = pyb.Pin('Y9') LIGHT = pyb.Pin('Y12') lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110.lcd_write_string('Hello Python!', 0, 0) lcd_5110.lcd_write_string('Micropython', 6, 1) lcd_5110.lcd_write_string('TPYBoard', 12, 2) lcd_5110.lcd_write_string('v102', 60, 3) lcd_5110.lcd_write_string('This is a test of LCD5110', 0, 4)
def main(): SPI = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock RST = pyb.Pin('X1') CE = pyb.Pin('X2') DC = pyb.Pin('X3') LIGHT = pyb.Pin('X4') lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110.lcd_write_string('Hello EveryOne', 0, 0) lcd_5110.lcd_write_string('It', 6, 1) lcd_5110.lcd_write_string('Is', 12, 2) lcd_5110.lcd_write_string('Turnip', 60, 3) lcd_5110.lcd_write_string('Smart', 0, 4)
from dht11 import DHT11 def main(lcd_5110, dht, uart6): data_ = dht.read_data() lcd_5110.lcd_write_string(' ', 0, 1) #添加一个分隔行 lcd_5110.lcd_write_string('Temp:' + data_[0], 2, 2) lcd_5110.lcd_write_string(' ', 0, 3) lcd_5110.lcd_write_string(' Hum:' + data_[1], 2, 4) uart6.write(data_[0] + ',' + data_[1]) #通过串口将数据发送给v202 if __name__ == '__main__': #init UART u6 = pyb.UART(6, 115200) #init DHT11 dht = DHT11('X12') #init LCD5110 SPI = pyb.SPI(1) RST = pyb.Pin('Y11') CE = pyb.Pin('Y10') DC = pyb.Pin('Y9') LIGHT = pyb.Pin('X4') #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd_5110.lcd_write_string('TPYBoard v102', 1, 0) while True: main(lcd_5110, dht, u6) pyb.delay(2000)
# main.py -- put your code here! from machine import SPI, Pin # WiPy (on Exp board, SD and User-LED jumper have to be removed!) SPI = machine.SPI(0) # GP14 (CLK) + GP16 (MOSI->DIN), User-LED jumper removed! RST = machine.Pin('GP24') CE = machine.Pin('GP12') DC = machine.Pin('GP22') LIGHT = machine.Pin('GP23') # PWR = directly from 3V3 pin of the WiPy import upcd8544 lcd = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) lcd.data([0xff]) lcd.data([0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa])
* D5 (GPIO14) 4 Clk Output from ESP SPI clock * 3V3 5 Vcc 3.3V from ESP to display * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM * G 7 Gnd Ground """ from machine import Pin, SPI from time import sleep, ticks_ms import upcd8544 spi = SPI(1, baudrate=80000000, polarity=0, phase=0) RST = Pin(4) CE = Pin(5) DC = Pin(12) BL = Pin(16) lcd = upcd8544.PCD8544(spi, RST, CE, DC, BL) #lcd.light_on() #lcd.light_off() # Use a framebuffer to store the 4032 pixels (84x48): import framebuf width = 84 height = 48 pages = height // 8 buffer = bytearray(pages * width) framebuf = framebuf.FrameBuffer1(buffer, width, height) # Print Hello, World! using the 8x8 font:
import upcd8544 from machine import SPI, Pin from pyb import UART from ubinascii import hexlify from ubinascii import * #以上内容为声明所使用的类库 leds = [pyb.LED(i) for i in range(1, 5)] P, L, SHUCHU = 0, 0, 0 SPI = pyb.SPI(1) #DIN=>X8-MOSI/CLK=>X6-SCK #DIN =>SPI(1).MOSI 'X8' data flow (Master out, Slave in) #CLK =>SPI(1).SCK 'X6' SPI clock RST = pyb.Pin('X20') CE = pyb.Pin('X19') DC = pyb.Pin('X18') LIGHT = pyb.Pin('X17') lcd_5110 = upcd8544.PCD8544(SPI, RST, CE, DC, LIGHT) #以上内容为声明并初始化显示屏 count_ = 0 N2 = Pin('Y3', Pin.OUT_PP) #定义“Y3”为输出模式,这个引脚是控制蜂鸣器的,来电话了需要响铃的 N1 = Pin('Y6', Pin.OUT_PP) #定义“Y6”位输出模式,“Y6”引脚是板载通信系统的开关控制引脚 N1.low() pyb.delay(2000) N1.high() pyb.delay(10000) #通过拉低拉高开光控制引脚,启动通信系统 u2 = UART(4, 115200) #设置串口4,并设置串口波特率为115200 i = '0' w = 0 d = 0 q = 0 G = 0 j = 0 while 0 < 1:
import upcd8544 gc.collect() import framebuf import math gc.collect() #spi = HSPI(baudrate=80000000, polarity=0, phase=0) spi = SPI(-1, baudrate=200000, polarity=0, phase=0, sck=Pin(0), mosi=Pin(1), miso=Pin(4)) RST = Pin(3) #CE = Pin(5) DC = Pin(2) #BL = Pin(16) lcd = upcd8544.PCD8544(spi, RST, DC) width = 84 height = 48 pages = height // 8 buffer = bytearray(pages * width) framebuf1 = framebuf.FrameBuffer1(buffer, width, height) gc.collect()