This project shows how to drive two screens with one ESP32 board. We intend to show how the hardward working with the Object Oriented Programming. The two screens are two screen objects in the software area.
1. Creating Data Bus Objects:
* Two `Arduino_DataBus` objects are created, each representing the data transmission channel for one display. The code uses the `Arduino_ESP32SPI` class to define the data bus and specifies the pin connections for each display:
* The `bus` object uses ESP32 pins 11 (DC), 10 (CS), 12 (SCK), and 13 (MOSI) to connect to the first display.
* The `bus2` object uses pins 41 (DC), 42 (CS), 39 (SCK), and 0 (MOSI) to connect to the second display.
* `GFX_NOT_DEFINED` signifies that the MISO pin is not used.
2. Creating Display Objects:
* Two `Arduino_GFX` objects are then created, representing the two displays. The display type and configuration information are specified:
* The `gfx` object represents the first display, using the `Arduino_GC9A01` class to define the display type. It also specifies the display's RST pin, rotation orientation, IPS type, width, height, and border offset values.
* The `gfx2` object represents the second display, also using the `Arduino_GC9A01` class. However, it omits the RST pin, rotation, width, and height information, as these parameters can be set using other methods.
3. Initialization and Usage:
* Initialize both display objects, for example:
```cpp
gfx->begin();
gfx2->begin();
```
* Use the `gfx` and `gfx2` objects to call functions provided by the GFX For Arduino library to control each display, for example:
```cpp
gfx->fillScreen(BLACK); // Set the background color of the first display to black
gfx2->fillRect(10, 10, 50, 50, RED); // Draw a red rectangle on the second display
```
Summary:
Using this approach, you can use the GFX For Arduino library to easily drive two different displays and control their display content separately. Remember that the pin connections and display type need to be set according to your specific setup.
Comments
Please log in or sign up to comment.