// WittyDemo2.ino 190506 4580b 113v distributed on w01-w10 // welcome with Rainbow and fast blink push n times // 1 push several move on-off and back to menu // 2 pushes same with pfm speed changes // 3 control with most TV IR 1pulse stop, 2,3,4,5 move // 4 demonstrate log dim // 5 count in binary // 6 test accelerometer Gy521 value in terminal 4 orientations on leds #include "Witty.h" #include "GetPush.h" #define Npix 8 // nombre de LEDs #define Brt 2 // max 31 brigtness #include "Apa102.h" #include "Telec.h" #include "Pfm.h" #include "Inter2.h" #include "TerSer.h" #define aadd 0x68*2 // a revoir #include "I2Ctwi.h" #include "Gy521.h" void setup() { SetupWitty(); SetupApa102(); // ApaClear (); // not required? SetupInter2(); SetupTerSer(); SetupI2Ctwi(); SetupGy521(); Cligno(2,200); } // Example of a not simple function binary counter 1 bright 0 dark but visible // That function has no reason to be included in the Apa102.h file // Show a byte in any color. void ShowByte (uint8_t nn,uint8_t rr,uint8_t gg,uint8_t bb) { ApaHead(); for (byte i=0; i0; pfmR--) {pfmL=pfmR; ApaLogGreen(pfmL/5); Dac;} for (pfmR=0; pfmR>-MaxVit; pfmR--) {pfmL=pfmR; ApaLogRed(-pfmL/5); Dac;} ApaLogGreen(2); for (pfmR=-MaxVit; pfmR<0; pfmR++) {pfmL=pfmR; ApaLogRed(-pfmL/5); Dac;} pfmL=0; pfmR=0; D1; } cli(); break; case 3: // Demo IRM control ApaLogWhite(10); byte nPress; while(1) { nPress= Compte(); switch (nPress) { case 1: // stop ApaLogRed(5); FreeG; FreeD; break; case 2: // avance ApaLogGreen(5); AvG; AvD; break; case 3: // tourneG ApaLogBlue(5); FreeG; AvD; break; case 4: // tourneG ApaLogPink(5); AvG; FreeD; break; case 5: // recule ApaLogYellow(10); RecG; RecD; break; default: // plus de 5 ShowByte (0x55,5,5,5); FreeG; FreeD; break; } // end switch } // end while // reset to quit case 5: // RGB // ApaLog requires interrupt sei(); for (volatile byte i=0;i<16;i++) {ApaLogRed(i); DelMs(100);} for (volatile byte i=16;i>0;i--) {ApaLogRed(i-1); DelMs(100);} ApaLogGreen(1);DelMs(1000);ApaLogBlue(1);DelMs(1000);ApaLogRed(1);DelMs(1000); ApaLogGreen(15);DelMs(1000);ApaLogBlue(15);DelMs(1000);ApaLogRed(15);DelMs(1000); // max intensity // add your own tricks cli(); break; case 6: while(1) { ShowByte (cnt5++,41,41,0); DelMs(200); } // reset to quit case 4: // Demo6 Gy521 color effect click on terminal before to sse data ApaLogYellow(10); Text("EnvoiSer Gy521"); CR(); while(1){ ReadGy521(); Text("AcX"); Dec16s(AcX); Text("GyX"); Dec16s(GyX); Text("AcY"); Dec16s(AcY); Text("GyY"); Dec16s(GyY); Text("AcZ"); Dec16s(AcZ); Text("GyZ"); Dec16s(GyZ); CR(); if (AcY> 10000) {ApaLogCyan(10);} else if (AcY<-10000) {ApaLogBlue(10);} if (AcZ>10000) {ApaLogRed(10);} else if (AcZ<-10000) {ApaLogGreen(10);} DelMs (200); } // reset to quit default: // blink wait return ; break; } // end switch } // end loop