89 fID(ledControl.addDevice()),
115 fDisplayEffectVal = inputNum;
116 fPreviousEffectVal = ~fDisplayEffectVal;
124 selectEffect((
long int)seq * 10000L + (
long int)speedScale * 100 + numSeconds);
132 fLC.clearDisplay(fID);
133 fLC.setIntensity(fID, 15);
134 fLC.setPower(fID,
true);
142 unsigned long now = millis();
143 if (fDisplayEffectVal != fPreviousEffectVal)
145 fLC.setIntensity(fID, 15);
146 fLC.clearDisplay(fID);
150 fEffectStartMillis = millis();
151 fPreviousEffectVal = fDisplayEffectVal;
155 fLastTimeBottom = now;
160 else if (now < fNextStepTimeMS)
165 int selectSequence = (fDisplayEffectVal % 1000000) / 10000;
166 int selectSpeed = (fDisplayEffectVal % 1000) / 100;
167 int selectLength = (fDisplayEffectVal % 100);
170 switch (selectSequence)
175 fLC.setIntensity(fID, random(15));
178 if (fLastTimeBar + BARGRAPHSPEED < now)
180 byte chance = random(100);
183 if (displayValue == fBarValue && chance < 10)
185 fBarDirection = -fBarDirection;
188 if (displayValue == fBarValue && chance < 40)
190 fBarValue = min(max(0, fBarValue + fBarDirection), 6);
194 else if (chance < 90 && fBarValue > 0)
196 displayValue = (displayValue == fBarValue) ? displayValue - 1 : fBarValue;
201 if (fLastTimeBlue + BLUELEDSPEED < now)
206 if (fLastTimeRed + REDLEDSPEED < now)
212 if (fLastTimeBottom + BOTTOMLEDSPEED < now)
215 fLastTimeBottom = now;
217 if (fLastTimeTop + TOPBLOCKSPEED < now)
221 fLastTimeTop = TOPBLOCKSPEED;
223 fDelayTime = min(TOPBLOCKSPEED, min(BOTTOMLEDSPEED, min(REDLEDSPEED, min(BLUELEDSPEED, BARGRAPHSPEED))));
229 fNextStepTimeMS = now + fDelayTime;
230 if (selectLength > 0 && millis() - fEffectStartMillis >=
unsigned(selectLength) * 1000L)
241 if (*cmd++ ==
'D' && *cmd++ ==
'P')
243 long int cmdvalue = 0;
245 while (*c >=
'0' && *c <=
'9')
247 cmdvalue = cmdvalue * 10 + (*c++ -
'0');
258 byte bits = fLC.getRow(fID, YELLOWBLOCK);
259 fLC.setRow(fID, YELLOWBLOCK, (((top&7)<<5)|(bottom&7)<<2)|(bits&3));
267 byte bits = fLC.getRow(fID, GREENBLOCK);
268 fLC.setRow(fID, GREENBLOCK, ((top&7)<<5)|((bottom&7)<<2)|(bits&3));
276 byte bits = fLC.getRow(fID, BARGRAPH_LEFT) & ~B10;
279 fLC.setRow(fID, BARGRAPH_LEFT, bits);
287 byte bits = fLC.getRow(fID, BARGRAPH_RIGHT) & ~B10;
290 fLC.setRow(fID, BARGRAPH_RIGHT, bits);
298 byte bits = fLC.getRow(fID, BOTTOMLED);
299 fLC.setRow(fID, BOTTOMLED, (((top&7)<<5)|(bottom&7)<<2)|(bits&3));
307 fLC.setRow(fID, BLUELED, pattern<<2);
325 value = min((
int)value, 6);
332 fLC.setRow(fID, BARGRAPH_LEFT, bits | (fLC.getRow(fID, BARGRAPH_LEFT) & 3));
333 fLC.setRow(fID, BARGRAPH_RIGHT, bits | (fLC.getRow(fID, BARGRAPH_RIGHT) & 3));
342 byte bits = fLC.getRow(fID, BARGRAPH_LEFT);
343 if (bits == fLC.getRow(fID, BARGRAPH_RIGHT))
347 if (!(bits & (B100<<i)))
360 signed char fBarValue;
361 signed char fBarDirection;
362 unsigned long fLastTimeBar;
363 unsigned long fLastTimeBlue;
364 unsigned long fLastTimeRed;
365 unsigned long fLastTimeBottom;
366 unsigned long fLastTimeTop;
367 unsigned long fNextStepTimeMS;
368 unsigned long fEffectStartMillis;
370 long fDisplayEffectVal;
371 long fPreviousEffectVal;
374 unsigned long fDelayTime = 300;
376 static const int YELLOWBLOCK = 4;
377 static const int GREENBLOCK = 5;
379 static const int BARGRAPH_LEFT = 2;
380 static const int BARGRAPH_RIGHT = 3;
382 static const int REDLED_LEFT = 2;
383 static const int REDLED_RIGHT = 3;
385 static const int BLUELED = 0;
386 static const int BOTTOMLED = 1;
388 static const int TOPBLOCKSPEED = 70;
389 static const int BOTTOMLEDSPEED = 200;
390 static const int REDLEDSPEED = 500;
391 static const int BLUELEDSPEED = 500;
392 static const int BARGRAPHSPEED = 100;