diff --git a/Arduino/Animation.h b/Arduino/Animation.h index f26203f..5dab3e7 100644 --- a/Arduino/Animation.h +++ b/Arduino/Animation.h @@ -13,7 +13,7 @@ Arduino.ino: Add the caller to 'switch (Mode) {' as a new case 'case ###: if (LastMode != Mode) StartAnimation(xxx, -2); break;'. where ### is the enum name and xxx ths ID in the 'switch (CurrentAnimation)' */ byte CurrentAnimation; //Which AnimationCounter Animation is selected -byte TotalAnimations = 11; +byte TotalAnimations = 12; CRGB AnimationRGB = {0, 0, 0}; //================================================== @@ -305,7 +305,40 @@ void ShowAnimation(bool Start) { //This would be called to show an Animati UpdateLEDs = true; } } break; + case 12: { //PACMAN + //TODO maybe add a rare female PACMAN + +#define PacmanMouthOpen 16 +#define PacmanMouthOpenhalf PacmanMouthOpen / 2 +#define PacmanStartT 15 - PacmanMouthOpenhalf +#define PacmanStartB 15 + static byte _Counter, _Counter2; + static bool _Direcion, _Direcion2, _LeftMouth; + if (Start) { + _LeftMouth = random8(0, 2); + _Counter = 0; + _Counter2 = 0; + _Direcion = false; + _Direcion2 = false; + LED_Fill(0, TotalLEDs, CRGB(255, 255, 0)); + if (_LeftMouth) + LED_Fill(60 - LEDtoPosition(PacmanStartT - 1), 2, CRGB(0, 0, 0)); //Cut out the eye + else + LED_Fill(LEDtoPosition(PacmanStartT - 4), 2, CRGB(0, 0, 0)); //Cut out the eye + UpdateLEDs = true; + } + EVERY_N_MILLISECONDS(25) { + if (_LeftMouth) { + LED_BackAndForth(60 - LEDtoPosition(PacmanStartT), PacmanMouthOpenhalf, CRGB(255, 255, 0), &_Counter, & _Direcion, false); //Upper lip + LED_BackAndForth(60 - LEDtoPosition(PacmanStartB), PacmanMouthOpenhalf, CRGB(255, 255, 0), &_Counter2, & _Direcion2, true); //Lower lip + } else { + LED_BackAndForth(LEDtoPosition(PacmanStartT), PacmanMouthOpenhalf, CRGB(255, 255, 0), &_Counter, & _Direcion, false); //Upper lip + LED_BackAndForth(LEDtoPosition(PacmanStartB), PacmanMouthOpenhalf, CRGB(255, 255, 0), &_Counter2, & _Direcion2, true); //Lower lip + } + UpdateLEDs = true; + } + } break; default: AnimationCounter = 0; //Stop animation diff --git a/Arduino/Arduino.ino b/Arduino/Arduino.ino index d54b7ee..630c4c5 100644 --- a/Arduino/Arduino.ino +++ b/Arduino/Arduino.ino @@ -263,6 +263,7 @@ void loopLEDS() { case SINELON2: if (LastMode != Mode) StartAnimation(9, -2); break; case SMILEY: if (LastMode != Mode) StartAnimation(10, -2); break; case FLASH2: if (LastMode != Mode) StartAnimation(11, -2); break; + case PACMAN: if (LastMode != Mode) StartAnimation(12, -2); break; default: #ifdef SerialEnabled diff --git a/Arduino/functions.h b/Arduino/functions.h index 163ff9c..aef2031 100644 --- a/Arduino/functions.h +++ b/Arduino/functions.h @@ -6,10 +6,10 @@ struct TimeS { unsigned long Ticks; }; enum Modes {OFF, ON, WIFI, RESET, CLOCK, - BLINK, BPM, CONFETTI, FLASH, GLITTER, JUGGLE, MOVE, RAINBOW, SINELON, SINELON2, SMILEY, FLASH2 + BLINK, BPM, CONFETTI, FLASH, GLITTER, JUGGLE, MOVE, RAINBOW, SINELON, SINELON2, SMILEY, FLASH2, PACMAN }; //Just to make the code more clear to read, OFF=0 and ON=1 etc String ModesString[] = {"OFF", "ON", "WIFI", "RESET", "CLOCK", - "BLINK", "BPM", "CONFETTI", "FLASH", "GLITTER", "JUGGLE", "MOVE", "RAINBOW", "SINELON", "SINELON2", "SMILEY", "FLASH2" + "BLINK", "BPM", "CONFETTI", "FLASH", "GLITTER", "JUGGLE", "MOVE", "RAINBOW", "SINELON", "SINELON2", "SMILEY", "FLASH2", "PACMAN" }; //ALL CAPS! const byte Modes_Amount = sizeof(ModesString) / sizeof(ModesString[0]); //Why filling this in if we can automate that? :) diff --git a/Arduino/handler.ino b/Arduino/handler.ino index ca8d79e..83556e9 100644 --- a/Arduino/handler.ino +++ b/Arduino/handler.ino @@ -216,7 +216,7 @@ void handle_OnConnect() { "let Sg=new Slider('Green');" "let Sb=new Slider('Blue');" - "let Dm=new DropDown({name:'Mode',setParamName:'m',possibleValues:['OFF','ON','WIFI','CLOCK','BLINK','BPM','CONFETTI','FLASH','FLASH2','GLITTER','JUGGLE','MOVE','RAINBOW','SINELON','SINELON2','SMILEY'],modifySendParams:(oldParams)=>{if(Dm.value=='WIFI'){let extraData=this.getServerStateMessageData();return{...oldParams,...extraData};}},});" + "let Dm=new DropDown({name:'Mode',setParamName:'m',possibleValues:['OFF','ON','WIFI','CLOCK','BLINK','BPM','CONFETTI','FLASH','FLASH2','GLITTER','JUGGLE','MOVE','PACMAN','RAINBOW','SINELON','SINELON2','SMILEY'],modifySendParams:(oldParams)=>{if(Dm.value=='WIFI'){let extraData=this.getServerStateMessageData();return{...oldParams,...extraData};}},});" "let Dbm=new DropDown({name:'Bootmode',setParamName:'bm',possibleValues:['OFF','ON','WIFI','CLOCK']});" "let Ddm=new DropDown({name:'Doublepress mode',setParamName:'dm',possibleValues:['WIFI','CLOCK','BLINK','RAINBOW']});"