diff options
| author | mrcodetastic <12006953+mrcodetastic@users.noreply.github.com> | 2024-09-19 22:24:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-19 22:24:16 +0100 |
| commit | bba1a47f01d079323f60982b0215810715d5095d (patch) | |
| tree | f61698a7ac83c2bf642d20679b7b1a63ccae8097 /examples | |
| parent | 7929b978505bfa29d89292b6c38f9a2dfffd105a (diff) | |
| parent | 268fd5ea4e22631cabe280217623d642dff52d7c (diff) | |
Merge pull request #676 from DevxMike/master
fixed nullptr dereference
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/1_SimpleTestShapes/1_SimpleTestShapes.ino | 16 | ||||
| -rw-r--r-- | examples/3_DoubleBuffer/3_DoubleBuffer.ino | 19 |
2 files changed, 22 insertions, 13 deletions
diff --git a/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino b/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino index 1d2ca75..64fb76c 100644 --- a/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino +++ b/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino @@ -13,13 +13,7 @@ //MatrixPanel_I2S_DMA dma_display; MatrixPanel_I2S_DMA *dma_display = nullptr; -uint16_t myBLACK = dma_display->color565(0, 0, 0); -uint16_t myWHITE = dma_display->color565(255, 255, 255); -uint16_t myRED = dma_display->color565(255, 0, 0); -uint16_t myGREEN = dma_display->color565(0, 255, 0); -uint16_t myBLUE = dma_display->color565(0, 0, 255); - - +uint16_t myBLACK, myWHITE, myRED, myGREEN, myBLUE; // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. @@ -109,6 +103,14 @@ void setup() { dma_display->begin(); dma_display->setBrightness8(90); //0-255 dma_display->clearScreen(); + + myBLACK = dma_display->color565(0, 0, 0); + myWHITE = dma_display->color565(255, 255, 255); + myRED = dma_display->color565(255, 0, 0); + myGREEN = dma_display->color565(0, 255, 0); + myBLUE = dma_display->color565(0, 0, 255); + + dma_display->fillScreen(myWHITE); // fix the screen with green diff --git a/examples/3_DoubleBuffer/3_DoubleBuffer.ino b/examples/3_DoubleBuffer/3_DoubleBuffer.ino index 5a41d67..c479941 100644 --- a/examples/3_DoubleBuffer/3_DoubleBuffer.ino +++ b/examples/3_DoubleBuffer/3_DoubleBuffer.ino @@ -5,16 +5,15 @@ // Double buffering is not always required in reality. #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h> +#include <array> MatrixPanel_I2S_DMA *display = nullptr; -uint16_t myDARK = display->color565(64, 64, 64); -uint16_t myWHITE = display->color565(192, 192, 192); -uint16_t myRED = display->color565(255, 0, 0); -uint16_t myGREEN = display->color565(0, 255, 0); -uint16_t myBLUE = display->color565(0, 0, 255); +constexpr std::size_t color_num = 5; +using colour_arr_t = std::array<uint16_t, color_num>; -uint16_t colours[5] = { myDARK, myWHITE, myRED, myGREEN, myBLUE }; +uint16_t myDARK, myWHITE, myRED, myGREEN, myBLUE; +colour_arr_t colours; struct Square { @@ -45,6 +44,14 @@ void setup() display = new MatrixPanel_I2S_DMA(mxconfig); display->begin(); // setup display with pins as pre-defined in the library + myDARK = display->color565(64, 64, 64); + myWHITE = display->color565(192, 192, 192); + myRED = display->color565(255, 0, 0); + myGREEN = display->color565(0, 255, 0); + myBLUE = display->color565(0, 0, 255); + + colours = {{ myDARK, myWHITE, myRED, myGREEN, myBLUE }}; + // Create some random squares for (int i = 0; i < numSquares; i++) { |
