sohotcall

micropython esp8266 5110 lcd font

Jun 1st, 2018 (edited)
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #====Pinout:=====
  2. #   RST--RST
  3. # 2(D4)--CS(CE)
  4. #15(D8)--DC
  5. #13(D7)--MOSI(DIN)
  6. #14(D5)--SCK(CLK)
  7. #   3V3--VCC
  8. #   GND--LED
  9. #   GND--GND
  10. #
  11. #TEXT: 8 row x 21 col = 168 chars
  12.  
  13. import ubinascii,time
  14. from machine import Pin,SoftSPI
  15. nce=Pin(2,Pin.OUT,value=1)
  16. ndc=Pin(15,Pin.OUT)
  17. spi=SoftSPI(baudrate=100000,sck=Pin(14),mosi=Pin(13),miso=Pin(12))
  18. time.sleep_ms(500)
  19. def ntxt(x):
  20.  nce.off()
  21.  ndc.off()
  22.  spi.write(b'!\x14\xB2 \x0C@\x80')
  23.  f=ubinascii.a2b_base64('IEwfTAhMRFQfNAgfYR5eTF5MHhBkDg4eEhJaZGBxDFUAYANfSBkqYEBRVUQQBAAYLnI5MQ43LiEqIkBQREpRIS4+Py4/Pz8uH3EIHx9fHi4/Lj8yYR8PHxsDOWADcSIQEPRFlP2mL3bBh2yig/HgZGLyEVWj9HTyk3WFjgYmMaoABRj6LpnlAIsDqyMCIQQZdYeVVfpNRR9VdQICilIiFbTyVYx0jQns+Y982YT4eXQRttFND/x8+tkfnY/BBxCE')
  24.  ndc.on()
  25.  for i in range(0,126):
  26.   t,p=i//21%3*4,i+i//63*21
  27.   p,q=ord(x[p])%96,ord(x[p+21])%96
  28.   p,q,r,s=f[p],f[p+96],f[q],f[q+96]
  29.   y=p&31|r<<6&192,p>>5|q<<2&28|r<<1&192,q>>3|s<<3&192,0,p>>2&7|r<<4&240,q&7|r>>1&48|s<<6&192,q>>5&7|s<<1&240,0,p>>4&1|r<<2&124,q>>2&1|r>>3&12|s<<4&112,q>>7&1|s>>1&124,0
  30.   spi.write(bytes(y[t:t+4]))
  31.  nce.on()
  32. ntxt((13*'Halo, dunia! ')[0:168])
  33.  
RAW Paste Data