diff options
| author | mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> | 2021-02-19 18:20:08 +0000 |
|---|---|---|
| committer | mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> | 2021-02-19 18:20:08 +0000 |
| commit | b1092495e9424dfc8a3eb97d0cf92fcc9b8caf5d (patch) | |
| tree | c291656443f1b7e195eadce587ddba1469899e3f /examples | |
| parent | 9a5bd38a1447b302447161fc5ac14180baa80a60 (diff) | |
Make SimpleTestShapes great again.
Long forgotten about.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/1_SimpleTestShapes/1_SimpleTestShapes.ino | 127 |
1 files changed, 65 insertions, 62 deletions
diff --git a/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino b/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino index 80f2236..3e384b5 100644 --- a/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino +++ b/examples/1_SimpleTestShapes/1_SimpleTestShapes.ino @@ -20,70 +20,49 @@ //P3RGB64x32MatrixPanel display; -void setup() { - - - Serial.begin(115200); - - Serial.println("*****************************************************"); - Serial.println(" HELLO !"); - Serial.println("*****************************************************"); - - dma_display.begin(); // use default pins - - // draw a pixel in solid white - dma_display.drawPixel(0, 0, dma_display.color444(15, 15, 15)); - delay(500); - - // fix the screen with green - dma_display.fillRect(0, 0, dma_display.width(), dma_display.height(), dma_display.color444(0, 15, 0)); - delay(500); - - // draw a box in yellow - dma_display.drawRect(0, 0, dma_display.width(), dma_display.height(), dma_display.color444(15, 15, 0)); - delay(500); - - // draw an 'X' in red - dma_display.drawLine(0, 0, dma_display.width()-1, dma_display.height()-1, dma_display.color444(15, 0, 0)); - dma_display.drawLine(dma_display.width()-1, 0, 0, dma_display.height()-1, dma_display.color444(15, 0, 0)); - delay(500); - - // draw a blue circle - dma_display.drawCircle(10, 10, 10, dma_display.color444(0, 0, 15)); - delay(500); - - // fill a violet circle - dma_display.fillCircle(40, 21, 10, dma_display.color444(15, 0, 15)); - delay(500); - - // fill the screen with 'black' - dma_display.fillScreen(dma_display.color444(0, 0, 0)); - +// Input a value 0 to 255 to get a color value. +// The colours are a transition r - g - b - back to r. +// From: https://gist.github.com/davidegironi/3144efdc6d67e5df55438cc3cba613c8 +uint16_t colorWheel(uint8_t pos) { + if(pos < 85) { + return dma_display.color565(pos * 3, 255 - pos * 3, 0); + } else if(pos < 170) { + pos -= 85; + return dma_display.color565(255 - pos * 3, 0, pos * 3); + } else { + pos -= 170; + return dma_display.color565(0, pos * 3, 255 - pos * 3); + } +} - // draw some text! +void drawText(int colorWheelOffset) +{ + + // draw text with a rotating colour dma_display.setTextSize(1); // size 1 == 8 pixels high dma_display.setTextWrap(false); // Don't wrap at end of line - will do ourselves dma_display.setCursor(5, 0); // start at top left, with 8 pixel of spacing uint8_t w = 0; - char *str = "ESP32 DMA"; - for (w=0; w<9; w++) { - dma_display.setTextColor(dma_display.color565(255, 0, 255)); + const char *str = "ESP32 DMA"; + for (w=0; w<strlen(str); w++) { + dma_display.setTextColor(colorWheel((w*32)+colorWheelOffset)); dma_display.print(str[w]); } dma_display.println(); + dma_display.print(" "); for (w=9; w<18; w++) { - dma_display.setTextColor(Wheel(w)); - dma_display.print(str[w]); + dma_display.setTextColor(colorWheel((w*32)+colorWheelOffset)); + dma_display.print("*"); } + dma_display.println(); - //dma_display.setTextColor(dma_display.Color333(4,4,4)); - //dma_display.println("Industries"); + dma_display.setTextColor(dma_display.color444(15,15,15)); dma_display.println("LED MATRIX!"); - // print each letter with a rainbow color + // print each letter with a fixed rainbow color dma_display.setTextColor(dma_display.color444(0,8,15)); dma_display.print('3'); dma_display.setTextColor(dma_display.color444(15,4,0)); @@ -110,21 +89,45 @@ void setup() { } -void loop() { - // do nothing + +void setup() { + + dma_display.begin(); // use default pins + + // fix the screen with green + dma_display.fillRect(0, 0, dma_display.width(), dma_display.height(), dma_display.color444(0, 15, 0)); + delay(500); + + // draw a box in yellow + dma_display.drawRect(0, 0, dma_display.width(), dma_display.height(), dma_display.color444(15, 15, 0)); + delay(500); + + // draw an 'X' in red + dma_display.drawLine(0, 0, dma_display.width()-1, dma_display.height()-1, dma_display.color444(15, 0, 0)); + dma_display.drawLine(dma_display.width()-1, 0, 0, dma_display.height()-1, dma_display.color444(15, 0, 0)); + delay(500); + + // draw a blue circle + dma_display.drawCircle(10, 10, 10, dma_display.color444(0, 0, 15)); + delay(500); + + // fill a violet circle + dma_display.fillCircle(40, 21, 10, dma_display.color444(15, 0, 15)); + delay(500); + + // fill the screen with 'black' + dma_display.fillScreen(dma_display.color444(0, 0, 0)); + + drawText(0); + } +uint8_t wheelval = 0; +void loop() { -// Input a value 0 to 24 to get a color value. -// The colours are a transition r - g - b - back to r. -uint16_t Wheel(byte WheelPos) { - if(WheelPos < 8) { - return dma_display.color444(15 - WheelPos*2, WheelPos*2, 0); - } else if(WheelPos < 16) { - WheelPos -= 8; - return dma_display.color444(0, 15-WheelPos*2, WheelPos*2); - } else { - WheelPos -= 16; - return dma_display.color444(0, WheelPos*2, 7 - WheelPos*2); - } + // animate by going through the colour wheel for the first two lines + drawText(wheelval); + wheelval +=1; + + delay(20); } |
