LCD160CR with Pycom boards
LCD160CR with Pycom boards
Has anyone successfully used the LCD160CR with a Pycom WiPy or LoPy4?
Re: LCD160CR with Pycom boards
Yup, LoPy4, using both the Pycom firmware (Pycom MicroPython 1.20.0.rc13 [v1.9.4-94bb382] on 2019-08-22; LoPy4 with ESP32) and main MicroPython (built from head).
On regular MicroPython it was pretty straightforward -- construct the pwr, i2c and spi objects manually based on the pin selection.
On the PyCom firmware, I had to add a sleep_ms(10) to "def iflush", on the line before the i2c.readfrom_into. The following code worked to initialise it (with my fairly arbitrary pin selection):
Code: Select all
import machine
import time
import lcd160cr
pwr = machine.Pin('P22', machine.Pin.OUT)
pwr.value(1)
time.sleep_ms(10)
i2c = machine.I2C(0, pins=('P9','P10',))
spi = machine.SPI(0, pins=('P11','P12','P13',))
lcd = lcd160cr.LCD160CR(spi=spi,i2c=i2c,pwr=pwr)
Re: LCD160CR with Pycom boards
Looks great jimmo!! Thank you!
So the LCD160CR use both SPI and I2C interface for displaying and touching control!
So the LCD160CR use both SPI and I2C interface for displaying and touching control!
Re: LCD160CR with Pycom boards
Yes both i2c and spi are required. I haven't looked in detail but it would appear that all the commands happen via i2c and pixel data by spi.
There's an interrupt line that the driver doesn't appear to use, but I imagine it lets you get notified on touch events. (The driver just lets you query the current touch state). I will confirm, and maybe see about getting that added to the driver.
(It probably goes without saying but I'm using the driver in drivers/display/lcd160cr.py, which is included by default in the pyboard firmware, but works just fine on other ports too).
There's an interrupt line that the driver doesn't appear to use, but I imagine it lets you get notified on touch events. (The driver just lets you query the current touch state). I will confirm, and maybe see about getting that added to the driver.
(It probably goes without saying but I'm using the driver in drivers/display/lcd160cr.py, which is included by default in the pyboard firmware, but works just fine on other ports too).
Re: LCD160CR with Pycom boards
Thank you for sharing!
Re: LCD160CR with Pycom boards
LCD160CR uses SPI only for high speed bulk transfer of raw pixel data.
Re: LCD160CR with Pycom boards
Jimmo-
Thanks! The sleep_ms(10) to "def iflush" took care of the error we were receiving.
Thanks! The sleep_ms(10) to "def iflush" took care of the error we were receiving.
Re: LCD160CR with Pycom boards
Hi Jimmo,jimmo wrote: ↑Sun Sep 22, 2019 4:59 pmYes both i2c and spi are required. I haven't looked in detail but it would appear that all the commands happen via i2c and pixel data by spi.
There's an interrupt line that the driver doesn't appear to use, but I imagine it lets you get notified on touch events. (The driver just lets you query the current touch state). I will confirm, and maybe see about getting that added to the driver.
(It probably goes without saying but I'm using the driver in drivers/display/lcd160cr.py, which is included by default in the pyboard firmware, but works just fine on other ports too).
May I ask you how you find the position to add the sleep_ms(10)? Do you have a specific method or clues to locate the position?
Re: LCD160CR with Pycom boards
I was getting an I2C error when running the firmware, looking at the traceback I could see which operation was failing. When I tried to send the same commands manually from the REPL I didn't see any error, so I assumed that it was some sort of timing problem. 10ms was the shortest sleep that seemed to solve the issue.
I don't know why I don't see the same error in the main MicroPython firmware... maybe a bug in the Pycom I2C driver?
Re: LCD160CR with Pycom boards
That's smart, Jimmo. Thank you!