Page 1 of 1

LCD160CR with Pycom boards

Posted: Sun Sep 22, 2019 12:50 am
by gatorjon
Has anyone successfully used the LCD160CR with a Pycom WiPy or LoPy4?

Re: LCD160CR with Pycom boards

Posted: Sun Sep 22, 2019 2:30 pm
by jimmo
gatorjon wrote:
Sun Sep 22, 2019 12:50 am
Has anyone successfully used the LCD160CR with a Pycom WiPy or LoPy4?
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).
IMG_20190922_232624_resize.jpg
IMG_20190922_232624_resize.jpg (301.18 KiB) Viewed 5855 times
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

Posted: Sun Sep 22, 2019 4:01 pm
by gatorchu
Looks great jimmo!! Thank you!
So the LCD160CR use both SPI and I2C interface for displaying and touching control!

Re: LCD160CR with Pycom boards

Posted: Sun Sep 22, 2019 4:59 pm
by jimmo
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).

Re: LCD160CR with Pycom boards

Posted: Sun Sep 22, 2019 5:27 pm
by gatorchu
Thank you for sharing!

Re: LCD160CR with Pycom boards

Posted: Mon Sep 23, 2019 8:21 am
by chuckbook
LCD160CR uses SPI only for high speed bulk transfer of raw pixel data.

Re: LCD160CR with Pycom boards

Posted: Fri Sep 27, 2019 3:10 am
by gatorjon
Jimmo-
Thanks! The sleep_ms(10) to "def iflush" took care of the error we were receiving.

Re: LCD160CR with Pycom boards

Posted: Tue Oct 01, 2019 2:28 am
by gatorchu
jimmo wrote:
Sun Sep 22, 2019 4:59 pm
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).
Hi Jimmo,

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

Posted: Tue Oct 01, 2019 4:14 am
by jimmo
gatorchu wrote:
Tue Oct 01, 2019 2:28 am
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?
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

Posted: Mon Oct 07, 2019 8:01 pm
by gatorchu
That's smart, Jimmo. Thank you!