#include <Adafruit_NeoPixel.h>
/*********************************************************************
This is an example for our nRF51822 based Bluefruit LE modules
Pick one up today in the adafruit shop!
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/
#include <string.h>
#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"
#if SOFTWARE_SERIAL_AVAILABLE
#include <SoftwareSerial.h>
#endif
/*=========================================================================
APPLICATION SETTINGS
FACTORYRESET_ENABLE Perform a factory reset when running this sketch
Enabling this will put your Bluefruit LE module
in a 'known good' state and clear any config
data set in previous sketches or projects, so
running this at least once is a good idea.
When deploying your project, however, you will
want to disable factory reset by setting this
value to 0. If you are making changes to your
Bluefruit LE device via AT commands, and those
changes aren't persisting across resets, this
is the reason why. Factory reset will erase
the non-volatile memory where config data is
stored, setting it back to factory default
values.
Some sketches that require you to bond to a
central device (HID mouse, keyboard, etc.)
won't work at all with this feature enabled
since the factory reset will clear all of the
bonding data stored on the chip, meaning the
central device won't be able to reconnect.
MINIMUM_FIRMWARE_VERSION Minimum firmware version to have some new features
MODE_LED_BEHAVIOUR LED activity, valid options are
"DISABLE" or "MODE" or "BLEUART" or
"HWUART" or "SPI" or "MANUAL"
-----------------------------------------------------------------------*/
#define FACTORYRESET_ENABLE 1
#define MINIMUM_FIRMWARE_VERSION "0.6.6"
#define MODE_LED_BEHAVIOUR "MODE"
/*=========================================================================*/
// Create the bluefruit object, either software serial...uncomment these lines
/*
SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);
Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);
*/
/* ...or hardware serial, which does not need the RTS/CTS pins. Uncomment this line */
Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN);
/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
//Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
/* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */
//Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO,
// BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS,
// BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
// A small helper
void error(const __FlashStringHelper*err) {
Serial.println(err);
while (1);
}
// function prototypes over in packetparser.cpp
uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout);
float parsefloat(uint8_t *buffer);
void printHex(const uint8_t * data, const uint32_t numBytes);
// the packet buffer
extern uint8_t packetbuffer[];
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, 9, NEO_GRB + NEO_KHZ800);
int pixelsinorder[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
uint8_t curcolor = strip.Color(50,50,50);
boolean playinggame = false;
int playerpos = 0;
int targetpos = 0;
boolean caughttarget = false;
int score = 0;
long gametimer = 0;
long curtime = 0;
long stopgametime = 0;
uint8_t playercolor = strip.Color(0,50,0);
uint8_t targetcolor = strip.Color(50,0,0);
boolean changedpos = false;
/**************************************************************************/
/*!
@brief Sets up the HW an the BLE module (this function is called
automatically on startup)
*/
/**************************************************************************/
void setup(void)
{
strip.begin();
strip.show(); // Initialize all pixels to 'off'
randomSeed(analogRead(A0));
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
//while (!Serial); // required for Flora & Micro
delay(500);
Serial.begin(115200);
Serial.println(F("Adafruit Bluefruit App Controller Example"));
Serial.println(F("-----------------------------------------"));
/* Initialise the module */
Serial.print(F("Initialising the Bluefruit LE module: "));
if ( !ble.begin(VERBOSE_MODE) )
{
error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
}
Serial.println( F("OK!") );
if ( FACTORYRESET_ENABLE )
{
/* Perform a factory reset to make sure everything is in a known state */
Serial.println(F("Performing a factory reset: "));
if ( ! ble.factoryReset() ){
error(F("Couldn't factory reset"));
}
}
/* Disable command echo from Bluefruit */
ble.echo(false);
Serial.println("Requesting Bluefruit info:");
/* Print Bluefruit information */
ble.info();
Serial.println(F("Please use Adafruit Bluefruit LE app to connect in Controller mode"));
Serial.println(F("Then activate/use the sensors, color picker, game controller, etc!"));
Serial.println();
ble.verbose(false); // debug info is a little annoying after this point!
/* Wait for connection */
while (! ble.isConnected()) {
delay(500);
}
Serial.println(F("******************************"));
// LED Activity command is only supported from 0.6.6
if ( ble.isVersionAtLeast(MINIMUM_FIRMWARE_VERSION) )
{
// Change Mode LED Activity
Serial.println(F("Change LED activity to " MODE_LED_BEHAVIOUR));
ble.sendCommandCheckOK("AT+HWModeLED=" MODE_LED_BEHAVIOUR);
}
// Set Bluefruit to DATA mode
Serial.println( F("Switching to DATA mode!") );
ble.setMode(BLUEFRUIT_MODE_DATA);
Serial.println(F("******************************"));
}
/**************************************************************************/
/*!
@brief Constantly poll for new command or response data
*/
/**************************************************************************/
void loop(void)
{
// check for time over in the minigame
if(playinggame)
{
curtime = millis();
if(curtime >= stopgametime)
{
colorMiniStrip(strip.Color(0,0,0), 0, 11, 800);
for(int h = 0; h < score; h++)
{
colorMiniStrip(strip.Color(127,127,127), 0, 11, 300);
colorMiniStrip(strip.Color(0,0,0), 0, 11, 300);
}
playinggame = false;
score = 0;
}
}
/* Wait for new data to arrive */
uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT);
if (len == 0) return;
/* Got a packet! */
// printHex(packetbuffer, len);
// Color
if (packetbuffer[1] == 'C') {
uint8_t red = packetbuffer[2];
uint8_t green = packetbuffer[3];
uint8_t blue = packetbuffer[4];
Serial.print ("RGB #");
if (red < 0x10) Serial.print("0");
Serial.print(red, HEX);
if (green < 0x10) Serial.print("0");
Serial.print(green, HEX);
if (blue < 0x10) Serial.print("0");
Serial.println(blue, HEX);
curcolor = strip.Color(red, green, blue);
colorWipe(strip.Color(red, green, blue), 50);
}
// Buttons
if (packetbuffer[1] == 'B') {
uint8_t buttnum = packetbuffer[2] - '0';
boolean pressed = packetbuffer[3] - '0';
//Serial.print ("Button "); Serial.print(buttnum);
if (pressed) {
//Serial.println(" pressed");
if(buttnum == 1)
{
playinggame = false; // stop the minigame if running
digitalWrite(6, HIGH);
Nightmare();
digitalWrite(6, LOW);
}
else if(buttnum == 2)
{
playinggame = false; // stop the minigame if running
digitalWrite(12, HIGH);
Mariah();
digitalWrite(12, LOW);
}
else if(buttnum == 3)
{
playinggame = false; // stop the minigame if running
digitalWrite(10, HIGH);
delay(250);
digitalWrite(10, LOW);
}
else if(buttnum == 4) // play a minigame
{
// start the game
playinggame = true;
gametimer = millis();
curtime = millis();
stopgametime = curtime + 20000; // 20 second game
score = 0;
targetpos = (int)random(0,12);
playerpos = (int)random(0,12);
// don't let the player and target be on top of each other
while(targetpos == playerpos)
targetpos = (int)random(0,12);
colorMiniStrip(strip.Color(0,0,0),0,11,1);
colorMiniStrip(strip.Color(50,50,0), playerpos, playerpos, 1);
colorMiniStrip(strip.Color(0,0,50), targetpos, targetpos, 1);
}
// play the game
if(playinggame)
{
// up. I defined pixel 4 as the "topmost" pixel. these move you toward pixel 4
if(buttnum == 5)
{
if(playerpos == 11)
{
playerpos = 0;
changedpos = true;
}
else if(playerpos == 10)
{
playerpos = playerpos + 1;
changedpos = true;
}
else if(playerpos >= 0 && playerpos <= 3)
{
playerpos = playerpos + 1;
changedpos = true;
}
else if(playerpos <= 9 && playerpos >= 5)
{
playerpos = playerpos - 1;
changedpos = true;
}
}
// 6 is down. 10 is the bottommost pixel
else if(buttnum == 6)
{
if(playerpos == 0)
{
playerpos = 11;
changedpos = true;
}
else if(playerpos == 11)
{
playerpos = 10;
changedpos = true;
}
else if(playerpos >= 1 && playerpos <= 4)
{
playerpos = playerpos - 1;
changedpos = true;
}
else if(playerpos <= 9 && playerpos >= 4)
{
playerpos = playerpos + 1;
changedpos = true;
}
}
// left. 6 is the leftmost pixel
else if(buttnum == 7)
{
if(playerpos == 0)
{
playerpos = 11;
changedpos = true;
}
else if(playerpos == 1)
{
playerpos = playerpos - 1;
changedpos = true;
}
else if(playerpos <= 5 && playerpos >= 2)
{
playerpos = playerpos + 1;
changedpos = true;
}
else if(playerpos >= 7 && playerpos <= 11)
{
playerpos = playerpos - 1;
changedpos = true;
}
}
// right. 2 is the rightmost pixel
else if(buttnum == 8)
{
if(playerpos == 11)
{
playerpos = 0;
changedpos = true;
}
else if(playerpos == 1 || playerpos == 0)
{
playerpos = playerpos + 1;
changedpos = true;
}
else if(playerpos <= 6 && playerpos >= 3)
{
playerpos = playerpos - 1;
changedpos = true;
}
else if(playerpos >= 7 && playerpos <= 10)
{
playerpos = playerpos + 1;
changedpos = true;
}
}
if(changedpos)
{
// redraw pixels if you moved.If you scored a point, randomize positions again
if(playerpos == targetpos)
{
score++;
playerpos = (int)random(0,12);
targetpos = (int)random(0,12);
while(targetpos == playerpos)
targetpos = (int)random(0,12);
}
colorMiniStrip(strip.Color(0,0,0),0,11,1);
colorMiniStrip(strip.Color(0,0,50), targetpos, targetpos, 1);
colorMiniStrip(strip.Color(50,50,0), playerpos, playerpos, 1);
changedpos = false;
}
}// end if playing game
}
else {
Serial.println(" released");
}
}
// GPS Location
if (packetbuffer[1] == 'L') {
float lat, lon, alt;
lat = parsefloat(packetbuffer+2);
lon = parsefloat(packetbuffer+6);
alt = parsefloat(packetbuffer+10);
Serial.print("GPS Location\t");
Serial.print("Lat: "); Serial.print(lat, 4); // 4 digits of precision!
Serial.print('\t');
Serial.print("Lon: "); Serial.print(lon, 4); // 4 digits of precision!
Serial.print('\t');
Serial.print(alt, 4); Serial.println(" meters");
}
// Accelerometer
if (packetbuffer[1] == 'A') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Accel\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Magnetometer
if (packetbuffer[1] == 'M') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Mag\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Gyroscope
if (packetbuffer[1] == 'G') {
float x, y, z;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
Serial.print("Gyro\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.println();
}
// Quaternions
if (packetbuffer[1] == 'Q') {
float x, y, z, w;
x = parsefloat(packetbuffer+2);
y = parsefloat(packetbuffer+6);
z = parsefloat(packetbuffer+10);
w = parsefloat(packetbuffer+14);
Serial.print("Quat\t");
Serial.print(x); Serial.print('\t');
Serial.print(y); Serial.print('\t');
Serial.print(z); Serial.print('\t');
Serial.print(w); Serial.println();
}
}
boolean needToCancel()
{
uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT);
if (len == 0) return false;
// Buttons
if (packetbuffer[1] == 'B') {
uint8_t buttnum = packetbuffer[2] - '0';
boolean pressed = packetbuffer[3] - '0';
Serial.print ("Button "); Serial.print(buttnum);
if (pressed) {
Serial.println(" pressed");
if(buttnum == 3)
{
return true;
}
}
}
return false;
}
// some example procedures
// Some example procedures showing how to display to the pixels:
// colorWipe(strip.Color(255, 0, 0), 50); // Red
// colorWipe(strip.Color(0, 255, 0), 50); // Green
//colorWipe(strip.Color(0, 0, 255), 50); // Blue
//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
// Send a theater pixel chase in...
//theaterChase(strip.Color(127, 127, 127), 50); // White
//theaterChase(strip.Color(127, 0, 0), 50); // Red
//theaterChase(strip.Color(0, 0, 127), 50); // Blue
//theaterChaseDuration(strip.Color(127, 0, 0), 50, 2000); // Red
//theaterChaseDuration(strip.Color(0, 0, 127), 50, 5000); // Blue
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void colorWipeDurationMini(uint32_t c, int lowlight, int highlight, int duration) {
int numlights = highlight - lowlight + 1;
duration = (int)duration;
int durationperlight = (int)(duration / numlights) ;
if(numlights == 12)
{
for(int i = 0; i <= 11; i++)
{
strip.setPixelColor(pixelsinorder[i],c);
strip.show();
delay(durationperlight);
}
}
else{
for(int i=lowlight; i<=highlight; i++) {
strip.setPixelColor(i, c);
strip.show();
delay(durationperlight);
}
}
}
void colorWipeDurationMiniReverse(uint32_t c, int lowlight, int highlight, int duration) {
int numlights = highlight - lowlight + 1;
duration = (int)duration;
int durationperlight = (int)(duration / numlights) ;
for(int i=highlight; i>=lowlight; i--) {
strip.setPixelColor(i, c);
strip.show();
delay(durationperlight);
}
}
void twoColorWipeDurationMiniReverse(uint32_t c, uint32_t c2, int lowlight, int highlight, int duration) {
int numlights = highlight - lowlight + 1;
duration = (int)duration;
int durationperlight = (int)(duration / numlights) ;
for(int i=highlight; i>=lowlight; i--) {
if(i%2 == 0)
strip.setPixelColor(i, c);
else
strip.setPixelColor(i,c2);
strip.show();
delay(durationperlight);
}
}
void colorWipeRainbowDurationMini(int lowlight, int highlight, int duration) {
int numlights = highlight - lowlight + 1;
duration = (int)duration;
int durationperlight = (int)(duration / numlights) ;
long r = random(0,6);
uint32_t rainbowcolors[] = {strip.Color(50,0,0),strip.Color(50,50,0),strip.Color(0,50,0),strip.Color(0,50,50),strip.Color(0,0,50),strip.Color(50,0,50)};
for(int i=lowlight; i<=highlight; i++) {
strip.setPixelColor(i, rainbowcolors[r]);
r++;
if(r == 6)
r = 0;
strip.show();
delay(durationperlight);
}
}
void colorMiniStrip(uint32_t c, int lowlight, int highlight, int duration)
{
int numlights = highlight - lowlight;
int durationperlight = duration / numlights;
for(int i=lowlight; i<=highlight; i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(duration);
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
void rainbowDuration(uint8_t wait, int duration) {
uint16_t i, j;
int totaltime = 0;
while(totaltime < duration)
{
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
totaltime += wait;
if(totaltime >= duration)
{
return;
}
}
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights.
void theaterChaseDuration(uint32_t c, uint8_t wait, int duration) {
int j = 0;
int q = 0;
uint16_t i = 0;
int totaltime = 0;
int lightnum;
duration = (int)duration;
while(totaltime < duration)
{
for (uint16_t i=0; i <= 11; i=i+3) {
lightnum = i+q;
if(lightnum > 11)
{
lightnum = lightnum - 11 - 1;
}
strip.setPixelColor(pixelsinorder[lightnum], c); //turn every third pixel on
}
strip.show();
delay(wait);
totaltime += wait;
for (uint16_t i=0; i <= 11; i=i+3) {
lightnum = i+q;
if(lightnum > 11)
{
lightnum = lightnum - 11 - 1;
}
strip.setPixelColor(pixelsinorder[lightnum], 0); //turn every third pixel off
}
q++;
if(q >= 3)
q = 0;
}
// when time is up turn lights off
for(uint16_t i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i,0);
}
strip.show();
}
void theaterChaseMiniDuration(uint32_t c, int lowlight, int highlight, uint8_t wait, int duration) {
int j = 0;
int q = 0;
uint16_t i = 0;
int totaltime = 0;
duration = (int)duration;
while(totaltime < duration)
{
int lightnum;
for (int i=lowlight; i <= highlight; i=i+3) {
lightnum = i+q;
if(lightnum > highlight)
{
lightnum = lightnum - highlight - 1 + lowlight;
}
strip.setPixelColor(lightnum, c); //turn every third pixel on
}
strip.show();
delay(wait);
totaltime += wait;
for (uint16_t i=lowlight; i <= highlight; i=i+3) {
lightnum = i+q;
if(lightnum > highlight)
{
lightnum = lightnum - highlight - 1 + lowlight;
}
strip.setPixelColor(lightnum, 0); //turn every third pixel off
}
q++;
if(q >= 3)
q = 0;
}
// when time is up turn lights off
for(uint16_t i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i,0);
}
strip.show();
}
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbowDuration(uint8_t wait, int duration) {
int totaltime = 0;
int lightnum;
while(totaltime < duration)
{
for (int j=0; j < 256; j = j + 10) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i <= 11; i=i+3) {
lightnum = i+q;
if(lightnum > 11)
{
lightnum = lightnum - 11 - 1;
}
strip.setPixelColor(pixelsinorder[lightnum], Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i <= 11; i=i+3) {
lightnum = i+q;
if(lightnum > 11)
{
lightnum = lightnum - 11 - 1;
}
strip.setPixelColor(pixelsinorder[lightnum], 0); //turn every third pixel off
}
totaltime += wait;
if(totaltime >= duration)
{
for(uint16_t m = 0; m < strip.numPixels(); m++)
strip.setPixelColor(m,0);
strip.show();
delay(10);
return;
}
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
// brightens a strip of pixels over a duration
// assumes duration is over like 1000
// first parameter is 1 if red, 2 if green, 3 if blue, 4 if white
void brightenMiniDuration(int hue, int lowlight, int highlight, int duration)
{
//duration = duration - 127; // need to shorten, there are delays in here
int mspershade = (int)((duration / 100) * 0.9);
if(duration < 256)
mspershade = 2;
if(duration < 128)
mspershade = 1;
int totaltime = 0;
uint32_t c;
int i = 0;
while(totaltime < duration)
{
if(hue == 1)
c =strip.Color(i, 0, 0);
else if (hue == 2)
c = strip.Color(0,i,0);
else if (hue == 3)
c = strip.Color(0,0,i);
else
c = strip.Color(i,i,i);
for(int index = lowlight; index <= highlight; index++)
{
strip.setPixelColor(index, c);
}
strip.show();
i+= 1;
delay(mspershade);
totaltime += mspershade;
}
return;
}
void Mariah()
{
int bpm = 60;
int msperbeat = 60000 / bpm;
//delay(500);
colorWipeDurationMini(strip.Color(200,0,0),0, 11, (msperbeat * 6)-100);
if(needToCancel()) return;
theaterChaseRainbowDuration(50,(msperbeat * 6)-50);
if(needToCancel()) return;
colorWipeDurationMini(strip.Color(0,127,0),0, 2, msperbeat*2);
colorWipeDurationMini(strip.Color(127,0,0),6, 8, msperbeat*2);
colorWipe(strip.Color(0,0,0),50);
colorWipeDurationMini(strip.Color(127,127,127),3, 5, msperbeat);
colorWipeDurationMini(strip.Color(127,127,127),9, 11, msperbeat-50);
if(needToCancel()) return;
theaterChaseRainbowDuration(50,msperbeat * 3);
colorMiniStrip(strip.Color(0,0,127), 3, 5, msperbeat / 2);
colorMiniStrip(strip.Color(0,0,127), 9, 11, msperbeat / 2);
colorMiniStrip(strip.Color(0,0,127), 6, 8, msperbeat / 2);
colorMiniStrip(strip.Color(0,0,127), 0, 2, msperbeat / 2);
theaterChaseMiniDuration(strip.Color(127,127,127), 6,8, 50, msperbeat);
theaterChaseMiniDuration(strip.Color(127,127,127), 0,2,50, msperbeat);
theaterChaseRainbowDuration(50,(msperbeat * 2)-50);
if(needToCancel()) return;
colorWipeDurationMini(strip.Color(0,255,0),0, 11, msperbeat * 4);
theaterChaseDuration(strip.Color(127,0,127), 200, (msperbeat * 4)-50);
if(needToCancel()) return;
rainbowDuration(50, msperbeat * 4);
theaterChaseMiniDuration(strip.Color(127,127,0),9,11, 100, msperbeat * 3 - 50);
if(needToCancel()) return;
colorWipeDurationMini(strip.Color(127,127,127), 3,5, msperbeat * 4);
rainbowDuration(50, msperbeat * 4 - 30);
if(needToCancel()) return;
colorWipe(strip.Color(0,0,0),15);
delay(400);
for(int h = 0; h < 3; h++)
{
colorMiniStrip(strip.Color(127,127,127), 0, 11, msperbeat / 10);
colorMiniStrip(strip.Color(0,0,0), 0, 11, msperbeat / 10);
colorMiniStrip(strip.Color(127,127,127), 0, 11, msperbeat / 10 * 2);
colorMiniStrip(strip.Color(0,0,0), 0, 11, msperbeat / 10);
}
colorMiniStrip(strip.Color(127,127,127), 0, 11, msperbeat / 10*2);
colorMiniStrip(strip.Color(0,0,0), 0, 11, msperbeat / 10);
// Just about perfect introduction
// now for the main verse
bpm = 75;
msperbeat = (int)(60000 / bpm);
brightenMiniDuration(3, 0, 11, (msperbeat * 4)-100);
theaterChaseMiniDuration(strip.Color(127,127,127),0,11,100,msperbeat * 4);
brightenMiniDuration(1, 0, 11, msperbeat * 4-50);
if(needToCancel()) return;
theaterChaseMiniDuration(strip.Color(127,127,127),0,11,100,msperbeat * 4-50);
colorMiniStrip(strip.Color(0,127,0),6,8,msperbeat);
colorMiniStrip(strip.Color(0,127,0),0,2,msperbeat);
colorMiniStrip(strip.Color(0,0,0),6,8,msperbeat);
colorMiniStrip(strip.Color(0,0,0),0,2,msperbeat);
colorMiniStrip(strip.Color(0,127,0),3,5,msperbeat);
colorMiniStrip(strip.Color(0,127,0),9,11,msperbeat);
colorMiniStrip(strip.Color(0,0,0),3,5,msperbeat);
colorMiniStrip(strip.Color(0,0,0),9,11,msperbeat);
colorMiniStrip(strip.Color(127,0,0),6,8,msperbeat);
colorMiniStrip(strip.Color(127,0,0),0,2,msperbeat);
colorMiniStrip(strip.Color(0,0,0),6,8,msperbeat);
if(needToCancel()) return;
colorMiniStrip(strip.Color(0,0,0),0,2,msperbeat);
colorMiniStrip(strip.Color(127,0,0),3,5,msperbeat);
colorMiniStrip(strip.Color(127,0,0),9,11,msperbeat);
colorMiniStrip(strip.Color(0,0,0),3,5,msperbeat);
colorMiniStrip(strip.Color(0,0,0),9,11,msperbeat);
theaterChaseMiniDuration(strip.Color(0,0,127),3,5,50,msperbeat);
theaterChaseMiniDuration(strip.Color(0,0,127),9,11,50,msperbeat);
theaterChaseMiniDuration(strip.Color(127,0,127),6,8,50,msperbeat);
theaterChaseMiniDuration(strip.Color(127,0,127),0,2,50,msperbeat);
if(needToCancel()) return;
colorWipeDurationMini(strip.Color(127,0,0),0, 11, msperbeat * 2);
colorWipeDurationMini(strip.Color(0,127,0),0, 11, msperbeat * 2);
...
This file has been truncated, please download it to see its full contents.
Comments