From 0cf12f3331cce94f2b676c45eb79b591868a4a73 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sat, 24 Feb 2024 20:51:45 -0600 Subject: [PATCH] Completed Pixel::setColorMap() --- src/src/extras/Pixel.h | 12 ++++----- src/src/extras/extras.ino | 56 ++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/src/extras/Pixel.h b/src/src/extras/Pixel.h index cd00e06..0a8ec75 100644 --- a/src/src/extras/Pixel.h +++ b/src/src/extras/Pixel.h @@ -39,12 +39,12 @@ namespace ColorMap { - static const uint8_t RGB[4]={32,24,16,8}; - static const uint8_t RBG[4]={32,16,24,8}; - static const uint8_t BRG[4]={24,16,32,8}; - static const uint8_t BGR[4]={16,24,32,8}; - static const uint8_t GBR[4]={16,32,24,8}; - static const uint8_t GRB[4]={24,32,16,8}; + static const uint8_t RGB[4]={31,23,15,7}; + static const uint8_t RBG[4]={31,15,23,7}; + static const uint8_t BRG[4]={23,15,31,7}; + static const uint8_t BGR[4]={15,23,31,7}; + static const uint8_t GBR[4]={15,31,23,7}; + static const uint8_t GRB[4]={23,31,15,7}; }; //////////////////////////////////////////// diff --git a/src/src/extras/extras.ino b/src/src/extras/extras.ino index a47cb35..9ac0d3f 100644 --- a/src/src/extras/extras.ino +++ b/src/src/extras/extras.ino @@ -27,30 +27,68 @@ #include "Pixel.h" -#define PIXEL_PIN 26 // set this to whatever pin you are using - note pin cannot be "input only" +#define PIXEL_PIN 32 // set this to whatever pin you are using - note pin cannot be "input only" +#define NPIXELS 60 // set to number of pixels in strand +#define COLORMAP ColorMap::GRB // sets the order in which color bytes are transmitted +#define RGBW true // set to true if RGBW, else false if just RGB -Pixel testPixel(PIXEL_PIN); +Pixel testPixel(PIXEL_PIN,RGBW); void setup() { Serial.begin(115200); delay(1000); - Serial.printf("Pixel Test on pin %d\n",PIXEL_PIN); + Serial.printf("\n\nPixel Test on pin %d with %d pixels\n\n",PIXEL_PIN,NPIXELS); + testPixel.setColorMap(COLORMAP); + } ////////////////////////////////////// void loop(){ - Serial.print("Red\n"); - testPixel.set(Pixel::RGB(100,0,0)); + + Serial.printf("Red..."); + for(int i=0;i<255;i++){ + testPixel.set(Pixel::RGB(i,0,0,0),NPIXELS); + delay(10); + } + for(int i=255;i>=0;i--){ + testPixel.set(Pixel::RGB(i,0,0,0),NPIXELS); + delay(10); + } delay(2000); - Serial.print("Green\n"); - testPixel.set(Pixel::RGB(0,100,0)); + Serial.printf("Green..."); + for(int i=0;i<255;i++){ + testPixel.set(Pixel::RGB(0,i,0,0),NPIXELS); + delay(10); + } + for(int i=255;i>=0;i--){ + testPixel.set(Pixel::RGB(0,i,0,0),NPIXELS); + delay(10); + } delay(2000); - Serial.print("Blue\n"); - testPixel.set(Pixel::RGB(0,0,100)); + Serial.printf("Blue..."); + for(int i=0;i<255;i++){ + testPixel.set(Pixel::RGB(0,0,i,0),NPIXELS); + delay(10); + } + for(int i=255;i>=0;i--){ + testPixel.set(Pixel::RGB(0,0,i,0),NPIXELS); + delay(10); + } + delay(2000); + + Serial.printf("White...\n"); + for(int i=0;i<255;i++){ + testPixel.set(Pixel::RGB(0,0,0,i),NPIXELS); + delay(10); + } + for(int i=255;i>=0;i--){ + testPixel.set(Pixel::RGB(0,0,0,i),NPIXELS); + delay(10); + } delay(2000); }