7 #include <Adafruit_NeoPixel.h>
10 #define SWIPE_DELAY 1000
78 leds.updateLength(num_leds[psi_size]);
79 leds.updateType(NEO_GRB + NEO_KHZ800);
83 memcpy(LEDmap, LEDmap8,
sizeof(LEDmap8));
86 for(
int x = 0; x < psi_size ; x++ ){
87 memcpy(LEDmap[x], LEDmap7[x],
sizeof(LEDmap7[x]));
91 for(
int x = 0; x < psi_size ; x++ ){
92 memcpy(LEDmap[x], LEDmap5[x],
sizeof(LEDmap5[x]));
98 leds.setBrightness(brightness);
119 if (*cmd++ ==
'P' && *cmd++ ==
'S')
121 long int cmdvalue = 0;
123 while (*c >=
'0' && *c <=
'9')
125 cmdvalue = cmdvalue * 10 + (*c++ -
'0');
136 selectEffect((
long int)seq * 10000L + (
long int)speedScale * 100 + numSeconds);
140 unsigned long currentMillis = millis();
141 if (currentMillis >= fSwipeSpeed)
143 swipe_main(swipe_position);
144 if (swipe_direction == 0) {
145 if (swipe_position >= grid_size-1) {
147 fSwipeSpeed = currentMillis + random(sdelay, sdelay*4);
149 fSwipeSpeed = currentMillis + sspeed;
153 if (swipe_position <= 0) {
155 fSwipeSpeed = currentMillis + random(sdelay, sdelay*4);
157 fSwipeSpeed = currentMillis + sspeed;
161 if (swipe_position ==
int((grid_size/2)+0.5)) {
162 if (random(0,100) < stickiness) {
163 fSwipeSpeed = currentMillis + random(sdelay, sdelay*4);
179 leds.setBrightness(brightness);
193 color_one =
leds.Color(r,g,b);
195 color_two =
leds.Color(r,g,b);
234 int swipe_direction = 0;
235 int swipe_position = 0;
241 int num_leds[9] = {0, 0, 0, 0, 0, 21, 0, 37, 52};
242 uint32_t color_one =
leds.Color(255,0,0);
243 uint32_t color_two =
leds.Color(0,0, 255);
244 unsigned long fSwipeSpeed;
245 unsigned long fSwipeMillis;
248 const int LEDmap5[5][5] PROGMEM = {
252 {13, 14, 15, 16, 17},
253 {99, 18, 19, 20, 99},
256 const int LEDmap7[7][7] PROGMEM = {
257 {99, 99, 2, 1, 0, 99, 99},
258 {99, 7, 6, 5, 4, 3, 99},
259 {14, 13, 12, 11, 10, 9, 8},
260 {21, 20, 19, 18, 17, 16, 15},
261 {28, 27, 26, 25, 24, 23, 22},
262 {99, 33, 32, 31, 30, 29, 99 },
263 {99, 99, 36, 35, 34, 99, 99}
266 const int LEDmap8[8][8] PROGMEM = {
267 {99,99,3,2,1,0,99,99},
269 {17,16,15,14,13,12,11,10},
270 {25,24,23,22,21,20,19,18},
271 {33,32,31,30,29,28,27,26},
272 {41,40,39,38,37,36,35,34},
273 {99,47,46,45,44,43,42,99},
274 {99,99,51,50,49,48,99,99}
277 void swipe_main(uint8_t pos)
280 for(
int row = 0; row <= grid_size-1 ; row++) {
281 if(swipe_direction == 0)
285 int led = LEDmap[pos][row];
287 leds.setPixelColor(led, color);
#define SWIPE_DELAY
Definition: NeoPixelPSI.h:10
#define STICKINESS
Definition: NeoPixelPSI.h:11
#define SWIPE_SPEED
Definition: NeoPixelPSI.h:9
#define BRIGHTNESS
Definition: NeoPixelPSI.h:12
Base class for all animated devices.
Definition: AnimatedEvent.h:19
Base class for all command enabled devices.
Definition: CommandEvent.h:18
NeoPixelPSI by Darren Poulson daz@r2djp.co.uk
Definition: NeoPixelPSI.h:42
virtual void handleCommand(const char *cmd) override
Command Prefix: PS.
Definition: NeoPixelPSI.h:117
void setSequence(Sequence seq=kNormal, uint8_t speedScale=0, uint8_t numSeconds=0)
Select the specified effect sequence.
Definition: NeoPixelPSI.h:134
void set_brightness(int bright)
Set the brightness of the PSI.
Definition: NeoPixelPSI.h:177
virtual void animate()
Subclasses must implement this function to run through a single frame of animation/activity.
Definition: NeoPixelPSI.h:139
void set_stickiness(int s)
Set the 'stickiness'.
Definition: NeoPixelPSI.h:227
NeoPixelPSI(int psi_pin, int psi_size=5)
Constructor.
Definition: NeoPixelPSI.h:76
EffectValue
Definition: NeoPixelPSI.h:47
@ kNormalVal
Definition: NeoPixelPSI.h:48
PSIID
Definition: NeoPixelPSI.h:60
@ kRearPSI
Rear PSI ID.
Definition: NeoPixelPSI.h:64
@ kFrontPSI
Front PSI ID.
Definition: NeoPixelPSI.h:62
virtual void set_color(int c, int r, int g, int b)
set the colors of the PSI
Definition: NeoPixelPSI.h:191
Sequence
Definition: NeoPixelPSI.h:52
@ kHeart
Definition: NeoPixelPSI.h:55
@ kNormal
Definition: NeoPixelPSI.h:53
@ kSolid
Definition: NeoPixelPSI.h:54
@ kMalf
Definition: NeoPixelPSI.h:56
Adafruit_NeoPixel leds
Definition: NeoPixelPSI.h:44
void selectEffect(long inputNum)
Select the specified effect using a 32-bit integer.
Definition: NeoPixelPSI.h:109
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: NeoPixelPSI.h:67
void set_delay(int d)
Set the delay between swipes.
Definition: NeoPixelPSI.h:214
void set_speed(int s)
Set the speed the swipe effect moves at.
Definition: NeoPixelPSI.h:205
Utility class to control a VMusic2 module.
Definition: SetupEvent.h:16