airlcd.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. local airLCD = {}
  2. function airLCD.lcd_init(sn)
  3. if sn == "AirLCD_1000" then
  4. width = 320
  5. height = 480
  6. lcd_ic = "st7796"
  7. elseif sn == "AirLCD_1001" then
  8. width = 320
  9. height = 480
  10. lcd_ic = "st7796"
  11. elseif sn == "AirLCD_1002" then
  12. width = 480
  13. height = 480
  14. lcd_ic = "R395435T01"
  15. else
  16. log.info("lcd", "没有找到合适的LCD")
  17. end
  18. lcd_param = {
  19. port = lcd.HWID_0, -- 使用的spi id 号
  20. pin_dc = 0xff, -- 命令选择硬件,不设置
  21. pin_rst = 2, -- 屏幕reset 管脚
  22. direction = 0, -- 屏幕方向
  23. -- direction0 = 0x00,
  24. w = width, -- 屏幕宽度
  25. h = height, -- 屏幕高度
  26. xoffset = 0, -- X轴偏移像素
  27. yoffset = 0, -- Y轴偏移像素
  28. sleepcmd = 0x10, -- LCD睡眠命令
  29. wakecmd = 0x11, -- LCD唤醒命令
  30. }
  31. gpio.setup(164, 1, gpio.PULLUP)
  32. gpio.setup(141, 1, gpio.PULLUP)
  33. sys.wait(1000)
  34. lcd.init(lcd_ic,lcd_param)
  35. lcd.setupBuff(nil, true) -- 设置缓冲区大小,使用系统内存
  36. lcd.autoFlush(false) -- 自动刷新LCD
  37. if sn == "AirLCD_1001" then
  38. log.info("tp", "tp init")
  39. local function tp_callBack(tp_device,tp_data)
  40. sys.publish("TP",tp_device,tp_data)
  41. end
  42. local i2c_id = 0
  43. i2c.setup(i2c_id, i2c.SLOW)
  44. tp_device = tp.init("gt911",{port=i2c_id, pin_rst = 20,pin_int = gpio.WAKEUP0,},tp_callBack)
  45. end
  46. end
  47. return airLCD