C++ array of pointers to objects

I was driving multiple TFT LCDs on the same microcontroller. Each LCD had its own instance and I needed an easy method of iterate through all of them.

The platform I used is a ST Nucleo F411RE board, the programming enviroment is mbed and the TFT LCDs are 2.2 inch ILI9341 display.

By using a single screen, the code could look like this:

On the other hand, by using multiple screens, the code could look like this:

The code is not elegant, but it gets the job done.
Note that the LCDs RST and CS pins need to be individually connected to the microcontroller.

Reference: www.java2s.com

No comments:

Post a Comment