Buttons
Rows
The same rows as connected together for the display also share inputs for the buttons.
ESP | Rows |
---|---|
GPIO39 | 1 & 7 |
GPIO36 | 2 & 8 |
GPIO35 | 3 & 9 |
GPIO34 | 4 & 10 |
GPIO33 | 5 & 11 |
GPIO32 | 6 & 12 |
Detecting Button Presses
- Detect button presses by checking for high values on the input pins. This indicates whether one or more buttons are being pressed in that row group.
- Once you have a row group, cycle through each pixel in the row. Use the same logic & data format as the display to set this pixel to red. However, instead of drawing to the display as normal, instead send the data after setting A0, A1 & A2 low.
For reference, send
[0xFF] * 9
and set the relevant red component to 0 as you scan. - Read the same row group input pin again. If the current pixel is pressed, the value should now be low.
- Continue 2 and 3 until a button has been found.
- You may wish to redraw to the display as normal after this to reduce artifacts shown.