Sample code for TI_NEOPIXEL_SPI

Dependencies:   TI_NEOPIXEL_SPI

Committer:
tichise
Date:
Sat Jan 04 02:53:47 2020 +0000
Revision:
5:dc96362ec4d5
Parent:
2:e91690a04f44
switched back to PixelArray

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tichise 0:601717e4c63e 1 #include "mbed.h"
tichise 0:601717e4c63e 2 #include "TI_NEOPIXEL_SPI.h"
tichise 0:601717e4c63e 3
tichise 0:601717e4c63e 4 TI_NEOPIXEL_SPI pixelArray(p11);
tichise 0:601717e4c63e 5
tichise 2:e91690a04f44 6 int totalNumOfRingLED = 8+16+24+35; // 8+16+24+35
tichise 2:e91690a04f44 7 int startNumOfRingLED = 35+24;
tichise 2:e91690a04f44 8 int endNumOfRingLED = 35+24+16;
tichise 0:601717e4c63e 9
tichise 0:601717e4c63e 10 int main()
tichise 0:601717e4c63e 11 {
tichise 0:601717e4c63e 12 bool isRed = false;
tichise 0:601717e4c63e 13
tichise 0:601717e4c63e 14 while(1) {
tichise 0:601717e4c63e 15 if (isRed) {
tichise 0:601717e4c63e 16 // pixelArray.switchLightOff(pixelCount);
tichise 2:e91690a04f44 17 // pixelArray.changeColor(totalNumOfRingLED, startNumOfRingLED, endNumOfRingLED, (rgbColor) {50, 10, 170});
tichise 5:dc96362ec4d5 18
tichise 5:dc96362ec4d5 19 int buffer = 4;
tichise 5:dc96362ec4d5 20 pixelArray.chaseRainbow(totalNumOfRingLED, buffer);
tichise 0:601717e4c63e 21
tichise 0:601717e4c63e 22 } else {
tichise 2:e91690a04f44 23 // rgbColor topColor = (rgbColor) {255, 0, 0};
tichise 2:e91690a04f44 24 // rgbColor bottomColor = (rgbColor) {0, 32, 255};
tichise 0:601717e4c63e 25
tichise 0:601717e4c63e 26 rgbColor circleColor = (rgbColor){50, 10, 170};
tichise 2:e91690a04f44 27 pixelArray.circle(totalNumOfRingLED, startNumOfRingLED, endNumOfRingLED, circleColor);
tichise 0:601717e4c63e 28
tichise 2:e91690a04f44 29 // pixelArray.switchLightOn(totalNumOfRingLED, startNumOfRingLED, endNumOfRingLED, pixelCount);
tichise 2:e91690a04f44 30 // pixelArray.changeColor(totalNumOfRingLED, startNumOfRingLED, endNumOfRingLED, (rgbColor) {255, 255, 255});
tichise 0:601717e4c63e 31 }
tichise 0:601717e4c63e 32 isRed = !isRed;
tichise 0:601717e4c63e 33
tichise 0:601717e4c63e 34 wait(2);
tichise 0:601717e4c63e 35 }
tichise 0:601717e4c63e 36 }