|
RSeries astromech firmware
|
|
Go to the documentation of this file. 1 #ifndef ChargeBayIndicator_h
2 #define ChargeBayIndicator_h
46 fID(ledControl.addDevice()),
49 fAnalogInput(analogInput)
78 fDisplayEffectVal = inputNum;
79 fPreviousEffectVal = ~fDisplayEffectVal;
87 selectEffect((
long int)seq * 10000L + (
long int)speedScale * 100 + numSeconds);
95 fLC.clearDisplay(fID);
96 fLC.setIntensity(fID, 15);
97 fLC.setPower(fID,
true);
106 unsigned long now = millis();
107 if (fDisplayEffectVal != fPreviousEffectVal)
109 fLC.setIntensity(fID, 15);
110 fLC.clearDisplay(fID);
114 fEffectStartMillis = millis();
115 fPreviousEffectVal = fDisplayEffectVal;
117 else if (now < fNextStepTimeMS)
122 int selectSequence = (fDisplayEffectVal % 1000000) / 10000;
123 int selectSpeed = (fDisplayEffectVal % 1000) / 100;
124 int selectLength = (fDisplayEffectVal % 100);
128 switch (selectSequence)
131 fLC.setIntensity(fID, random(15));
163 fNextStepTimeMS = now + fDelayTime;
164 if (selectLength > 0 && millis() - fEffectStartMillis >=
unsigned(selectLength) * 1000L)
175 if (*cmd++ ==
'C' && *cmd++ ==
'B')
177 long int cmdvalue = 0;
179 while (*c >=
'0' && *c <=
'9')
181 cmdvalue = cmdvalue * 10 + (*c++ -
'0');
194 fLC.setRow(fID, row, data << 3);
202 fLC.setLed(fID, 6, 5, on);
210 fLC.setLed(fID, 5, 5, on);
218 fLC.setLed(fID, 4, 5, on);
236 setRow(random(4), fLC.randomRow(random(4)));
237 if (random(100) < 30)
239 if (random(100) < 20)
241 if (random(100) < 10)
273 fSeqStep = (++fSeqStep <= 1) ? fSeqStep : 0;
304 fSeqStep = (++fSeqStep <= 2) ? fSeqStep : 0;
379 fSeqStep = (++fSeqStep <= 9) ? fSeqStep : 0;
447 fLC.clearDisplay(fID);
450 fSeqStep = (++fSeqStep <= 10) ? fSeqStep : 0;
459 fAnalogInput = analogInput;
460 if (fAnalogInput != -1)
461 pinMode(fAnalogInput, INPUT);
469 fVCC = (fAnalogInput != -1) ? ((analogRead(fAnalogInput) * 5.0) / 1024.0) / (R2/(R1+R2)) : 0;
477 unsigned long fNextStepTimeMS;
478 unsigned long fEffectStartMillis;
480 long fDisplayEffectVal;
481 long fPreviousEffectVal;
484 static constexpr
float GREEN_VCC = 12.5;
485 static constexpr
float YELLOW_VCC = 12.0;
489 static constexpr
float R1 = 47000.0;
490 static constexpr
float R2 = 24000.0;
495 unsigned long fDelayTime = 300;
499 void ESBoperatingSEQ()
504 setRow(0,0,B01101101);
505 setRow(0,1,B00000110);
506 setRow(0,2,B11011011);
507 setRow(0,3,B00010011);
508 setRow(0,4,B11000011);
509 setRow(0,5,B01000011);
510 setRow(0,6,B00110011);
514 setRow(0,0,B01100101);
515 setRow(0,1,B00000110);
516 setRow(0,2,B10010111);
517 setRow(0,3,B00001011);
518 setRow(0,4,B00100001);
519 setRow(0,5,B11000001);
520 setRow(0,6,B10101011);
523 setRow(0,0,B00000110);
524 setRow(0,1,B00010011);
525 setRow(0,2,B10110001);
526 setRow(0,3,B00001011);
527 setRow(0,4,B11101001);
528 setRow(0,5,B10100000);
529 setRow(0,6,B11101001);
532 setRow(0,0,B10000111);
533 setRow(0,1,B00010011);
534 setRow(0,2,B10110111);
535 setRow(0,3,B11000010);
536 setRow(0,4,B00000011);
537 setRow(0,5,B10010000);
538 setRow(0,6,B10001000);
541 setRow(0,0,B01010001);
542 setRow(0,1,B00010011);
543 setRow(0,2,B10010111);
544 setRow(0,3,B11001000);
545 setRow(0,4,B11001000);
546 setRow(0,5,B10101001);
547 setRow(0,6,B00000001);
550 setRow(0,0,B01010101);
551 setRow(0,1,B01010011);
552 setRow(0,2,B00010011);
553 setRow(0,3,B01001100);
554 setRow(0,4,B00000001);
555 setRow(0,5,B00010000);
556 setRow(0,6,B11000001);
559 setRow(0,0,B00010011);
560 setRow(0,1,B00010011);
561 setRow(0,2,B00010011);
562 setRow(0,3,B10100110);
563 setRow(0,4,B10000001);
564 setRow(0,5,B00010000);
565 setRow(0,6,B11000001);
568 setRow(0,0,B00010011);
569 setRow(0,1,B00000110);
570 setRow(0,2,B10011011);
571 setRow(0,3,B00010011);
572 setRow(0,4,B11001010);
573 setRow(0,5,B11001000);
574 setRow(0,6,B10100000);
577 setRow(0,0,B00010011);
578 setRow(0,1,B10100101);
579 setRow(0,2,B10000010);
580 setRow(0,3,B00110101);
581 setRow(0,4,B10110000);
582 setRow(0,5,B00000011);
583 setRow(0,6,B11001000);
586 setRow(0,0,B00001110);
587 setRow(0,1,B00010011);
588 setRow(0,2,B01000010);
589 setRow(0,3,B00000110);
590 setRow(0,4,B10101011);
591 setRow(0,5,B00000001);
592 setRow(0,6,B10101011);
595 setRow(0,0,B01000011);
596 setRow(0,1,B00000110);
597 setRow(0,2,B00010011);
598 setRow(0,3,B00000110);
599 setRow(0,4,B10101011);
600 setRow(0,5,B11101001);
601 setRow(0,6,B00000011);
604 setRow(0,0,B01100101);
605 setRow(0,1,B00110011);
606 setRow(0,2,B00010111);
607 setRow(0,3,B00000110);
608 setRow(0,4,B10100000);
609 setRow(0,5,B11101001);
610 setRow(0,6,B10101011);
613 setRow(0,0,B00100000);
614 setRow(0,1,B00010011);
615 setRow(0,2,B10001000);
616 setRow(0,3,B00011000);
617 setRow(0,4,B00000001);
618 setRow(0,5,B00000011);
619 setRow(0,6,B11001000);
622 setRow(0,0,B10000000);
623 setRow(0,1,B00010011);
624 setRow(0,2,B10110101);
625 setRow(0,3,B10010110);
626 setRow(0,4,B00000001);
627 setRow(0,5,B11101001);
628 setRow(0,6,B11101001);
631 setRow(0,0,B10100110);
632 setRow(0,1,B01010001);
633 setRow(0,2,B01010011);
634 setRow(0,3,B10100000);
635 setRow(0,4,B11001000);
636 setRow(0,5,B10110000);
637 setRow(0,6,B00000011);
640 setRow(0,0,B10101000);
641 setRow(0,1,B01010001);
642 setRow(0,2,B00010001);
643 setRow(0,3,B10000000);
644 setRow(0,4,B11101001);
645 setRow(0,5,B11101001);
646 setRow(0,6,B10101011);
649 setRow(0,0,B10000011);
650 setRow(0,1,B00100000);
651 setRow(0,2,B10010011);
652 setRow(0,3,B11000010);
653 setRow(0,4,B10101011);
654 setRow(0,5,B00000001);
655 setRow(0,6,B00000011);
658 setRow(0,0,B10000010);
659 setRow(0,1,B00010011);
660 setRow(0,2,B00010010);
661 setRow(0,3,B11000010);
662 setRow(0,4,B00110000);
663 setRow(0,5,B11101001);
664 setRow(0,6,B00110000);
667 setRow(0,0,B01100101);
668 setRow(0,1,B00010011);
669 setRow(0,2,B00100000);
670 setRow(0,3,B00000110);
671 setRow(0,4,B11001000);
672 setRow(0,5,B00011001);
673 setRow(0,6,B01000001);
676 setRow(0,0,B10100011);
677 setRow(0,1,B00010011);
678 setRow(0,2,B01010101);
679 setRow(0,3,B01100101);
680 setRow(0,4,B00110000);
681 setRow(0,5,B01010000);
682 setRow(0,6,B01100001);
685 setRow(0,0,B10000000);
686 setRow(0,1,B10000000);
687 setRow(0,2,B01010001);
688 setRow(0,3,B00001011);
689 setRow(0,4,B11101001);
690 setRow(0,5,B11001000);
691 setRow(0,6,B11001000);
694 setRow(0,0,B00000110);
695 setRow(0,1,B00100000);
696 setRow(0,2,B11011000);
697 setRow(0,3,B01001100);
698 setRow(0,4,B10101011);
699 setRow(0,5,B01010000);
700 setRow(0,6,B00000010);
703 setRow(0,0,B01000011);
704 setRow(0,1,B00011000);
705 setRow(0,2,B10011000);
706 setRow(0,3,B01000011);
707 setRow(0,5,B00000010);
708 setRow(0,6,B11001010);
711 setRow(0,0,B00101100);
712 setRow(0,1,B00010011);
713 setRow(0,2,B01011010);
714 setRow(0,3,B01000011);
715 setRow(0,4,B01010000);
716 setRow(0,5,B10101011);
717 setRow(0,6,B11001010);
720 setRow(0,0,B10101010);
721 setRow(0,1,B00100000);
722 setRow(0,2,B01001100);
723 setRow(0,3,B01000010);
724 setRow(0,4,B00000011);
725 setRow(0,5,B11001010);
726 setRow(0,6,B01010000);
729 setRow(0,0,B00000110);
730 setRow(0,1,B00000110);
731 setRow(0,2,B10001100);
732 setRow(0,3,B00000110);
733 setRow(0,4,B01001000);
734 setRow(0,5,B01010000);
735 setRow(0,6,B00000010);
738 setRow(0,0,B00000110);
739 setRow(0,1,B00010011);
740 setRow(0,2,B00111000);
741 setRow(0,3,B01001100);
742 setRow(0,4,B11001010);
743 setRow(0,5,B00000001);
744 setRow(0,6,B10101011);
747 setRow(0,0,B00000110);
748 setRow(0,1,B00010011);
749 setRow(0,2,B01001100);
750 setRow(0,3,B01000011);
751 setRow(0,4,B00000011);
752 setRow(0,5,B11001000);
753 setRow(0,6,B11001000);
756 fSeqStep = (++fSeqStep <= 10) ? fSeqStep : 0;
void setGreenLight(bool on)
Turn the green LED on or off.
Definition: ChargeBayIndicator.h:200
@ kBlink
Definition: ChargeBayIndicator.h:64
EffectValue
Definition: ChargeBayIndicator.h:53
Sequence
Definition: ChargeBayIndicator.h:57
Base class for all command enabled devices. CommandEvent::handleCommand() is called for each device e...
Definition: CommandEvent.h:17
@ kVCCOnly
Definition: ChargeBayIndicator.h:66
ChargeBayIndicator(LedControl &ledControl, int analogInput=-1)
Constructor.
Definition: ChargeBayIndicator.h:44
@ kFlicker
Definition: ChargeBayIndicator.h:61
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
void blinkSEQ()
Test utility routine for blinking all LEDs every two seconds.
Definition: ChargeBayIndicator.h:249
#define UNUSED(x)
Definition: ReelTwo.h:172
virtual void handleCommand(const char *cmd) override
ChargeBayIndicator Commands start with 'CB'.
Definition: ChargeBayIndicator.h:173
void setRow(byte row, byte data)
This function is only for the grid pattern not the VCC LEDs.
Definition: ChargeBayIndicator.h:192
void randomSEQ()
Update LEDs randomly for one frame.
Definition: ChargeBayIndicator.h:234
void chargingSEQ()
Animate the LEDs like ESB charging sequence.
Definition: ChargeBayIndicator.h:311
virtual void animate() override
Perform a single frame of LED animation based on the selected sequence.
Definition: ChargeBayIndicator.h:104
void operatingSEQ()
Operating sequence.
Definition: ChargeBayIndicator.h:386
ChargeBayIndicator (CBI) controller.
Definition: ChargeBayIndicator.h:36
void heartSEQ()
Pulse.
Definition: ChargeBayIndicator.h:280
@ kCharging
Definition: ChargeBayIndicator.h:63
virtual void setup() override
Perform any initialzation not possible in the constructor.
Definition: ChargeBayIndicator.h:93
void setYellowLight(bool on)
Turn the yellow LED on or off.
Definition: ChargeBayIndicator.h:208
void setRedLight(bool on)
Turn the red LED on or off.
Definition: ChargeBayIndicator.h:216
@ kNormal
Definition: ChargeBayIndicator.h:59
void setVCCAnalogInputPin(int analogInput)
Specify the analog pint used by the voltage divider.
Definition: ChargeBayIndicator.h:457
void setSequence(Sequence seq=kNormal, uint8_t speedScale=0, uint8_t numSeconds=0)
Select the specified effect sequence.
Definition: ChargeBayIndicator.h:85
void selectEffect(long inputNum)
Select the specified effect using a 32-bit integer.
Definition: ChargeBayIndicator.h:76
float getVCC()
Read the voltage level from the voltage divider.
Definition: ChargeBayIndicator.h:467
@ kNormalVal
Definition: ChargeBayIndicator.h:55
@ kHeart
Definition: ChargeBayIndicator.h:65
void displayVCC()
Set the green/yellow/red LEDs based on the voltage levels read from the voltage divider.
Definition: ChargeBayIndicator.h:224
@ kDisabled
Definition: ChargeBayIndicator.h:60
@ kNaboo
Definition: ChargeBayIndicator.h:62