LCD160CR with Pycom boards

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
gatorjon
Posts: 2
Joined: Fri Sep 20, 2019 4:11 am

LCD160CR with Pycom boards

Post by gatorjon » Sun Sep 22, 2019 12:50 am

Has anyone successfully used the LCD160CR with a Pycom WiPy or LoPy4?

User avatar
jimmo
Posts: 648
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: LCD160CR with Pycom boards

Post by jimmo » Sun Sep 22, 2019 2:30 pm

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 200 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)

gatorchu
Posts: 15
Joined: Sun Sep 22, 2019 3:50 pm

Re: LCD160CR with Pycom boards

Post by gatorchu » Sun Sep 22, 2019 4:01 pm

Looks great jimmo!! Thank you!
So the LCD160CR use both SPI and I2C interface for displaying and touching control!

User avatar
jimmo
Posts: 648
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: LCD160CR with Pycom boards

Post by jimmo » 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).

gatorchu
Posts: 15
Joined: Sun Sep 22, 2019 3:50 pm

Re: LCD160CR with Pycom boards

Post by gatorchu » Sun Sep 22, 2019 5:27 pm

Thank you for sharing!

chuckbook
Posts: 105
Joined: Fri Oct 30, 2015 11:55 pm

Re: LCD160CR with Pycom boards

Post by chuckbook » Mon Sep 23, 2019 8:21 am

LCD160CR uses SPI only for high speed bulk transfer of raw pixel data.

gatorjon
Posts: 2
Joined: Fri Sep 20, 2019 4:11 am

Re: LCD160CR with Pycom boards

Post by gatorjon » Fri Sep 27, 2019 3:10 am

Jimmo-
Thanks! The sleep_ms(10) to "def iflush" took care of the error we were receiving.

gatorchu
Posts: 15
Joined: Sun Sep 22, 2019 3:50 pm

Re: LCD160CR with Pycom boards

Post by gatorchu » Tue Oct 01, 2019 2:28 am

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?

User avatar
jimmo
Posts: 648
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: LCD160CR with Pycom boards

Post by jimmo » Tue Oct 01, 2019 4:14 am

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?

gatorchu
Posts: 15
Joined: Sun Sep 22, 2019 3:50 pm

Re: LCD160CR with Pycom boards

Post by gatorchu » Mon Oct 07, 2019 8:01 pm

That's smart, Jimmo. Thank you!

Post Reply