Register / Login  |  Desktop view  |  Jump to bottom of page

IoAbstraction & TaskManagerIO » 4W Serial Graphics display with PCF8574

Author: Maes2ro
08/08/2022 11:25:56
I am currently using a 128x64 graphics LCD that has a PCF8567 interface IC. my code is based on the excellent U8G2 library from Oli Kraus, and I'm operating in 4W Software serial mode. My controller is a Teensy 4.0.

Instead of connecting directly to the controller, I would instead like to use a PCF8574 IO expander.

To test the SW Serial, I am connecting the Teensy as Serial In (SDI) = 0, Serial clock (SCK) = 1, Data/Command (DC) = 2, Chip Select (CS) = 3, Reset (RS) = 4. That way I am definitely not using any of the hardware SPI. I am then passing those pin numbers to the libary constructor.

My thinking is that I could set up an expander with multiIoAddExpander(multiIo, ioFrom8574(0x20), 10); with the range starting at 100 as per your example. I then pass the abstracted pin numbers to the constructor SDI = 100, SCK = 101, DDC = 102, CS = 103, RS = 104.

This all seems logical, but the points where I am stuck are:
1. The multiIO example explicitly declares the data direction for the pins, but this is not exposed to me in the graphics library, so would the library be able to set up the data direction?
2. How do I get the Abstracted pins to update?

I'm thinking that you must have already solved these for your two line LCD, so might have some suggestions.

I'm not fixed on using the u8g2 library, and the adafruit GFX would be fine if that is more of a known quantity?

Author: davetcc
09/08/2022 06:39:51
Hi there, sounds like an interesting project

For pin direction, how does it work for normal SW pins. I’d maybe see how that works with U8G2 now. At the end of the day you could set that upfront.

For IO expander devices you need to call runLopp or use the helper functions ending with S. They sync with the device too. That’s done to improve performance

I’m writing from my phone so I’ll keep each reply short.

Author: davetcc
09/08/2022 06:42:57
U8G2 should be fine for this, I would imagine implementing the two callbacks for data and pin setup should be all that’s needed. I implement the data callback in tcMenu to prevent slow i2c from hampering menu performance.

See https://github.com/davetcc/tcMenu/blob/master/xmlPlugins/core-display/u8g2Driver/tcMenuU8g2.cpp#L30




Register / Login  |  Desktop view  |  Jump to top of page