Skip to content

Commit 268fd5e

Browse files
committed
fixed nullptr dereference in example 3
1 parent 4b3404a commit 268fd5e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

examples/1_SimpleTestShapes/1_SimpleTestShapes.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void setup() {
108108
myWHITE = dma_display->color565(255, 255, 255);
109109
myRED = dma_display->color565(255, 0, 0);
110110
myGREEN = dma_display->color565(0, 255, 0);
111-
myBLUE = dma_disdisplay->color565(0, 0, 255);
111+
myBLUE = dma_display->color565(0, 0, 255);
112112

113113

114114
dma_display->fillScreen(myWHITE);

examples/3_DoubleBuffer/3_DoubleBuffer.ino

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
// Double buffering is not always required in reality.
66

77
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
8+
#include <array>
89

910
MatrixPanel_I2S_DMA *display = nullptr;
1011

11-
uint16_t myDARK = display->color565(64, 64, 64);
12-
uint16_t myWHITE = display->color565(192, 192, 192);
13-
uint16_t myRED = display->color565(255, 0, 0);
14-
uint16_t myGREEN = display->color565(0, 255, 0);
15-
uint16_t myBLUE = display->color565(0, 0, 255);
12+
constexpr std::size_t color_num = 5;
13+
using colour_arr_t = std::array<uint16_t, color_num>;
1614

17-
uint16_t colours[5] = { myDARK, myWHITE, myRED, myGREEN, myBLUE };
15+
uint16_t myDARK, myWHITE, myRED, myGREEN, myBLUE;
16+
colour_arr_t colours;
1817

1918
struct Square
2019
{
@@ -45,6 +44,14 @@ void setup()
4544
display = new MatrixPanel_I2S_DMA(mxconfig);
4645
display->begin(); // setup display with pins as pre-defined in the library
4746

47+
myDARK = display->color565(64, 64, 64);
48+
myWHITE = display->color565(192, 192, 192);
49+
myRED = display->color565(255, 0, 0);
50+
myGREEN = display->color565(0, 255, 0);
51+
myBLUE = display->color565(0, 0, 255);
52+
53+
colours = {{ myDARK, myWHITE, myRED, myGREEN, myBLUE }};
54+
4855
// Create some random squares
4956
for (int i = 0; i < numSquares; i++)
5057
{

0 commit comments

Comments
 (0)