added text mask
Fork of NeoStrip by
Revision 1:3ffc314e9849, committed 2014-04-25
- Comitter:
- rhodes42
- Date:
- Fri Apr 25 14:39:53 2014 +0000
- Parent:
- 0:9f237b11f0a8
- Commit message:
- gpio_init --> gpio_init_out;
Changed in this revision
diff -r 9f237b11f0a8 -r 3ffc314e9849 NeoStrip.cpp --- a/NeoStrip.cpp Wed Mar 12 18:36:58 2014 +0000 +++ b/NeoStrip.cpp Fri Apr 25 14:39:53 2014 +0000 @@ -33,7 +33,7 @@ N = 0; } - gpio_init(&gpio, pin, PIN_OUTPUT); // initialize GPIO registers + gpio_init_out(&gpio, pin);//, PIN_OUTPUT); // initialize GPIO registers neo_fio_reg = (uint32_t)gpio.reg_dir; // set registers and bitmask for neo_bitmask = 1 << ((int)pin & 0x1F); // the assembly to use }
diff -r 9f237b11f0a8 -r 3ffc314e9849 NeoStrip.h --- a/NeoStrip.h Wed Mar 12 18:36:58 2014 +0000 +++ b/NeoStrip.h Fri Apr 25 14:39:53 2014 +0000 @@ -7,6 +7,9 @@ * Library for the control of Adafruit NeoPixel addressable RGB LEDs. */ +#include "mbed.h" +#include <stdint.h> + #ifndef NEOSTRIP_H #define NEOSTRIP_H @@ -69,6 +72,12 @@ * values in separate arguments. */ void setPixel(int p, uint8_t red, uint8_t green, uint8_t blue); + + /** + * Multiply a pixel value by mask so that you can turn colored pixels on/off + * for displaying text + */ + /** * Set n pixels starting at pixel p. @@ -93,6 +102,9 @@ * at the end. */ void write(); + + + protected: NeoColor *strip; // pixel data buffer modified by setPixel() and used by neo_out()
diff -r 9f237b11f0a8 -r 3ffc314e9849 TextMask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextMask.cpp Fri Apr 25 14:39:53 2014 +0000 @@ -0,0 +1,266 @@ +#include "TextMask.h" + + +int maskA[20] = { 0, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 1, 1, 0, + 1, 0, 1, 0}; + +int maskB[20] = { 0, 1, 0, 0, + 1, 0, 1, 0, + 1, 1, 0, 0, + 1, 0, 1, 0, + 1, 1, 0, 0}; + +int maskC[20] = { 0, 1, 1, 0, + 1, 0, 0, 0, + 1, 0, 0, 0, + 1, 0, 0, 0, + 0, 1, 1, 0}; + +int maskD[20] = { 1, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 1, 0, 0}; + +int maskE[20] = { 1, 1, 1, 0, + 1, 0, 0, 0, + 1, 1, 1, 0, + 1, 0, 0, 0, + 1, 1, 1, 0}; + +int maskF[20] = { 1, 1, 1, 0, + 1, 0, 0, 0, + 1, 1, 1, 0, + 1, 0, 0, 0, + 1, 0, 0, 0}; + +int maskG[20] = { 0, 1, 1, 0, + 1, 0, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 1, 0}; + +int maskH[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 1, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0}; + +int maskI[20] = { 1, 1, 1, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 1, 1, 1, 0}; + +int maskJ[20] = { 1, 1, 1, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 1, 1, 0, 0}; + +int maskK[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0}; + +int maskL[20] = { 1, 0, 0, 0, + 1, 0, 0, 0, + 1, 0, 0, 0, + 1, 0, 0, 0, + 1, 1, 1, 0}; + +int maskM[20] = { 1, 0, 0, 1, + 1, 1, 1, 1, + 1, 1, 1, 1, + 1, 0, 0, 1, + 1, 0, 0, 1}; + +int maskN[20] = { 1, 0, 0, 1, + 1, 1, 0, 1, + 1, 1, 1, 1, + 1, 0, 1, 1, + 1, 0, 0, 1}; + +int maskO[20] = { 0, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 0, 0}; + +int maskP[20] = { 1, 1, 1, 0, + 1, 0, 1, 0, + 1, 1, 1, 0, + 1, 0, 0, 0, + 1, 0, 0, 0}; + +int maskQ[20] = { 0, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 0, 1}; + +int maskR[20] = { 1, 1, 0, 0, + 1, 0, 1, 0, + 1, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0}; + +int maskS[20] = { 0, 1, 1, 0, + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 1, 0, 0}; + +int maskT[20] = { 1, 1, 1, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 0, 1, 0, 0, + 0, 1, 0, 0}; + +int maskU[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 1, 0}; + +int maskV[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 1, 1, 0, + 0, 1, 0, 0}; + +int maskW[20] = { 1, 0, 0, 1, + 1, 0, 0, 1, + 1, 0, 0, 1, + 1, 1, 1, 1, + 1, 0, 0, 1}; + +int maskX[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 0, 0, + 1, 0, 1, 0, + 1, 0, 1, 0}; + +int maskY[20] = { 1, 0, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 0, 0, + 0, 1, 0, 0}; + +int maskZ[20] = { 1, 1, 1, 0, + 0, 0, 1, 0, + 0, 1, 0, 0, + 1, 0, 0, 0, + 1, 1, 1, 0}; + +int * getCharMask(char inChar) +{ + + switch(inChar) + { + case 'A': + return maskA; + break; + case 'B': + return maskB; + break; + case 'C': + return maskC; + break; + case 'D': + return maskD; + break; + case 'E': + return maskE; + break; + case 'F': + return maskF; + break; + case 'G': + return maskG; + break; + case 'H': + return maskH; + break; + case 'I': + return maskI; + break; + case 'J': + return maskJ; + break; + case 'K': + return maskK; + break; + case 'L': + return maskL; + break; + case 'M': + return maskM; + break; + case 'N': + return maskN; + break; + case 'O': + return maskO; + break; + case 'P': + return maskP; + break; + case 'Q': + return maskQ; + break; + case 'R': + return maskR; + break; + case 'S': + return maskS; + break; + case 'T': + return maskT; + break; + case 'U': + return maskU; + break; + case 'V': + return maskV; + break; + case 'W': + return maskW; + break; + case 'X': + return maskX; + break; + case 'Y': + return maskY; + break; + case 'Z': + return maskZ; + break; + } +} + +void maskChar(NeoStrip strip, int xPos, int yPos, int xDim, int yDim, char inChar) +{ + if (inChar > 90 || inChar < 65) + return; + + int * mask = getCharMask(inChar); + + for (int i = 0; i < 5; i++) + { + for (int j = 0; j < 4; j++) + { + int pos = (i+yPos)*xDim + xPos + j; + if (!mask[i*4+j]) + strip.setPixel(pos, 0, 0, 0); + //strip.maskPixel(pos, mask[i*4+j]; + } + } + + +} +
diff -r 9f237b11f0a8 -r 3ffc314e9849 TextMask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextMask.h Fri Apr 25 14:39:53 2014 +0000 @@ -0,0 +1,8 @@ + +#include "NeoStrip.h" + + + +void maskChar(NeoStrip strip, int xPos, int yPos, int xDim, int yDim, char inChar); + +