/*
* Title: Smart Room 8 sided die controller
* Description: Using an accelerometer to control lights based on orientation.
* Author: Liv Bouligny
* Date: 14 July 2022
*/
#include <SPI.h>
#include <Ethernet.h>
#include <mac.h>
#include <wemo.h>
#include <hue.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneButton.h>
#include "colors.h"
#include <Wire.h>
#include <math.h>
const int SCREENWIDTH = 128;
const int SCREENHEIGHT = 64;
const int OLEDRESET = -1;
const int SCREENADDRESS = 0x3C;
const int PIXELPIN = 8;
const int PIXELCOUNT = 32;
const int PXDELAY = 42;
const int LOGOHEIGHT = 64;
const int LOGOWIDTH = 128;
float rad;
float angle;
byte count, i;
int px = 0;
int currentTime;
int lastTime = 1000;
bool buttonState;
bool rollMode = LOW;
bool moveState = LOW;
bool last = LOW;
bool onState = LOW;
int previousSide;
int currentSide;
int deviceArray[8] = {1,2,3,4,5,6,0,1};
OneButton button1(20,false);
Adafruit_MPU6050 mpu;
Adafruit_NeoPixel pixel(PIXELCOUNT, PIXELPIN, NEO_GRB + NEO_KHZ800);
Adafruit_SSD1306 display(SCREENWIDTH, SCREENHEIGHT, &Wire, OLEDRESET);
const unsigned char myBitmap [] PROGMEM = {
// '130-1308417_unicorn-silhouette-free-unicorn-silhouette-svg, 128x64px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x00, 0x02, 0x07, 0x97, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xc0, 0x02, 0x7f, 0x9b, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x03, 0x7f, 0xcf, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0x03, 0xf8, 0x67, 0xe3, 0xe7, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xc7, 0xf8, 0xf3, 0xe3, 0xfb, 0xf8, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xff, 0xf0, 0x78, 0x03, 0xff, 0x7e, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xff, 0xfc, 0xff, 0x07, 0xff, 0x81, 0xfe, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xfd, 0xcf, 0xcf, 0xff, 0xd8, 0x78, 0xf6, 0x7c, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xff, 0xde, 0xfe, 0x7e, 0xd9, 0x91, 0x0c, 0x3f, 0xfc, 0x7c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x7e, 0xc6, 0xdb, 0xf7, 0xc4, 0x77, 0xff, 0x0e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x1f, 0xc7, 0xb7, 0xef, 0x36, 0x6c, 0x7f, 0xc3, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xa7, 0xc7, 0xed, 0xdf, 0xfe, 0x6b, 0x9f, 0xe1, 0x80, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xbb, 0xff, 0xfb, 0xbf, 0xd6, 0xe7, 0xcf, 0xf8, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xbe, 0x1f, 0x0f, 0x80, 0x4d, 0xe3, 0xc2, 0xff, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x3f, 0x80, 0x31, 0xff, 0x3b, 0xe1, 0xcf, 0xff, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x7f, 0xc0, 0x07, 0xff, 0x9f, 0xc3, 0xbf, 0x7f, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xd7, 0xff, 0x6f, 0x38, 0xff, 0xde, 0x1c, 0xff, 0x7f, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0x97, 0xfe, 0x27, 0x27, 0xe7, 0xcf, 0x3f, 0xff, 0x7f, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0x97, 0xfe, 0x69, 0x3e, 0xc3, 0xcd, 0xff, 0xff, 0x7f, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x6f, 0xff, 0x17, 0xff, 0xfe, 0xfe, 0xf7, 0xcc, 0x71, 0xff, 0x3f, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x47, 0xff, 0x17, 0xff, 0x9f, 0xfd, 0xbf, 0xc0, 0x79, 0xff, 0x3f, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x07, 0xfe, 0x16, 0xff, 0xff, 0xff, 0xbf, 0xcc, 0x7f, 0xff, 0x3f, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x07, 0xfc, 0x16, 0xff, 0xff, 0xff, 0xdf, 0x9d, 0xff, 0xff, 0x37, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x07, 0xfc, 0x06, 0xff, 0x3b, 0xff, 0xe7, 0x1f, 0xff, 0xff, 0x37, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x03, 0xfc, 0x04, 0xdf, 0x3b, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0x37, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x03, 0xfc, 0x04, 0x5f, 0x77, 0xff, 0xff, 0xff, 0xf7, 0xff, 0x27, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x1f, 0x9f, 0xff, 0xff, 0xff, 0xe1, 0xff, 0x27, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0x27, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xeb, 0xfe, 0x27, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x27, 0xd8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xfc, 0x27, 0xd0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x03, 0xff, 0xfc, 0x27, 0xd0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xfc, 0x27, 0x90, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xfc, 0x37, 0x90, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xfe, 0x37, 0xb0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0xff, 0xfe, 0x37, 0xb0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0xff, 0xff, 0x17, 0xa0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x7e, 0xff, 0x17, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00, 0x3f, 0x3f, 0x97, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x3f, 0x1f, 0xc7, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x3f, 0x0f, 0xc7, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x1f, 0x8f, 0xe7, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x1f, 0x07, 0xc7, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x1f, 0x07, 0xc7, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x1e, 0x07, 0xc3, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xc3, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3c, 0x03, 0xc3, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3c, 0x03, 0xc3, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3c, 0x03, 0xc1, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x38, 0x03, 0xc1, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x78, 0x03, 0xc0, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x78, 0x03, 0xc0, 0x70, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x01, 0xf0, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x01, 0xe0, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x03, 0xc0, 0x07, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x07, 0xc0, 0x07, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x07, 0xc0, 0x07, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x07, 0x80, 0x0f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x06, 0x00, 0x0f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00
};
void setup() {
Serial.begin(9600);
button1.attachClick(click1);
button1.attachDoubleClick(doubleClick1);
button1.attachLongPressStart(longPressStart1);
button1.attachLongPressStop(longPressStop1);
button1.attachDuringLongPress(longPress1);
button1.setClickTicks(500);
button1.setPressTicks(2000);
button1.setDebounceTicks(50);
// while(!Serial);
// Serial.printf("Serial Monitor Initialized\n");
Wire.begin();
// Serial.printf("Adafruit MPU6050 test!\n");
if (!mpu.begin()) {
// Serial.printf("Failed to find MPU6050 chip\n");
while (1) {
delay(10);
}
}
// Serial.printf("MPU6050 Found!\n");
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
// Serial.printf("Accelerometer range set to: 8G\n");
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREENADDRESS)) {
// Serial.printf("SSD1306 allocation failed");
for (;;);
}
Ethernet.begin(mac);
delay(200); //ensure Serial Monitor is up and running
printIP();
// Serial.printf("LinkStatus: %i \n",Ethernet.linkStatus());
display.display();
delay(2000);
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.clearDisplay();
display.display();
pixel.begin();
pixel.setBrightness(125);
pixel.show();
i=0;
}
void loop() {
// Serial.printf("Acceleration Y: %0.03f X:%0.03f\n:",a.acceleration.y,a.acceleration.x);
// Serial.printf("Radians: %0.03f\n",rad);
// Serial.printf("Angle: %0.03f\n",angle);
//
// delay(500);
// currentAngle = ((360*rad) / (2*M_PI) + 180);
button1.tick();
while (!rollMode) {
button1.tick();
if (buttonState != last) {
if (buttonState) {
// Serial.printf("ButtonState: %i\n",buttonState);
if (i < 6) {
// Serial.printf("Hue light %i on!\n",deviceArray[i]);
setHue(deviceArray[i],true,HueRainbow[(i)],200,255);
pixel.fill(green, 0, 32);
pixel.show();
}
if ((i==6) || (i==7)) {
// Serial.printf("Wemo %i on!\n",deviceArray[i]);
switchON(deviceArray[i]);
pixel.fill(green, 0, 32);
pixel.show();
}
}
else {
// Serial.printf("ButtonState: %i\n",buttonState);
if (i < 6) {
// Serial.printf("Hue light %i off!\n",deviceArray[i]);
pixel.fill(red, 0, 32);
pixel.show();
setHue(deviceArray[i],false,0,0,0);
}
if ((i==6) || (i==7)) {
// Serial.printf("Wemo %i off!\n",deviceArray[i]);
switchOFF(deviceArray[i]);
pixel.fill(red, 0, 32);
pixel.show();
}
}
last = buttonState;
}
}
readAccel();
currentSide = checkSide(angle);
previousSide = currentSide;
while (rollMode) {
button1.tick();
readAccel();
currentSide = checkSide(angle);
if (currentSide != previousSide) {
delay(5000);
readAccel();
currentSide = checkSide(angle);
if (currentSide == 8) {
critSuccess ();
}
if (currentSide == 1) {
critFail();
}
if (currentSide == 2) {
rollTwo();
}
if (currentSide == 3) {
rollThree();
}
if (currentSide == 4) {
rollFour();
}
if (currentSide == 5) {
rollFive();
}
if (currentSide == 6) {
rollSix();
}
if (currentSide == 7) {
rollSeven();
}
// Serial.printf("Current side up: %i\n%f\n",currentSide,angle);
previousSide = currentSide;
}
}
}
void printIP() {
// Serial.printf("My IP address: ");
for (byte thisByte = 0; thisByte < 3; thisByte++) {
// Serial.printf("%i.",Ethernet.localIP()[thisByte]);
}
// Serial.printf("%i\n",Ethernet.localIP()[3]);
}
void click1() {
buttonState = !buttonState;
}
void doubleClick1() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
display.printf("Now controlling...\n");
display.display();
i++;
if(i > 7) {
i = 0;
}
if (i < 6) {
display.printf("Hue Light: %i\n",deviceArray[i]);
display.display();
}
else {
display.printf("Wemo: %i\n",deviceArray[i]);
display.display();
}
}
void longPressStart1() {
}
void longPress1() {
}
void longPressStop1() {
rollMode = !rollMode;
if (rollMode == true) {
// Serial.printf("rollMode: %i Automatic Roll mode initiated!\n",rollMode);
}
else {
// Serial.printf("rollMode: %i Manual mode initiated!\n",rollMode);
}
}
void readAccel() {
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
rad = atan2(a.acceleration.x,a.acceleration.y);
angle = ((360 * rad) / (2 * M_PI) + 180);
}
int checkSide(float inputAngle) {
int answer;
if ((inputAngle > 75)&&(inputAngle < 105)) {
answer = 8;
return answer;
}
if ((inputAngle > 30)&&(inputAngle < 60)) {
answer = 2;
return answer;
}
if (((inputAngle > 345)&&(inputAngle <= 360)) || ((inputAngle >=0)&&(inputAngle<15))) {
answer = 5;
return answer;
}
if ((inputAngle > 300)&&(inputAngle < 330)) {
answer = 6;
return answer;
}
if ((inputAngle > 255)&&(inputAngle < 285)) {
answer = 1;
return answer;
}
if ((inputAngle > 210)&&(inputAngle < 240)) {
answer = 4;
return answer;
}
if ((inputAngle > 165)&&(inputAngle < 195)) {
answer = 7;
return answer;
}
if ((inputAngle > 120)&&(inputAngle < 150)) {
answer = 3;
return answer;
}
else {
answer = 0;
return answer;
}
}
void critSuccess () {
int j;
switchON(deviceArray[7]);
drawBitMap();
for (px = 0; px < 33; (px-0)) {
for ( i = 0; i < 7; i++) {
pixel.setPixelColor(px, rainbow[i]);
pixel.show();
delay(PXDELAY);
px++;
}
}
pixel.fill(black,0,32);
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
delay(PXDELAY);
for (px = 0; px < 33; (px-0)) {
for ( i = 0; i < 7; i++) {
pixel.setPixelColor(px, rainbow[i]);
pixel.show();
delay(PXDELAY);
px++;
}
drawBitMap();
}
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
for (j=0; j<3;j++) {
drawBitMap();
for ( i = 0; i < 7; i++) {
pixel.fill(rainbow[i],16,4);
pixel.show();
px++;
if (i<6) {
setHue(deviceArray[i],true,HueRainbow[(i)],200,255);
}
else {
switchON(deviceArray[7]);
}
}
delay(PXDELAY);
pixel.clear();
pixel.show();
delay(PXDELAY);
}
for (i=0;i<7;i++) {
if (i<6) {
setHue(deviceArray[i],false,0,0,0);
}
else {
delay(5000);
switchOFF(deviceArray[7]);
}
}
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void critFail() {
switchON(deviceArray[6]);
display.setCursor(0,0);
display.printf("Warning! Alien Invasion Imminent!\n");
display.display();
for (px = 0; px < 33; (px++)) {
pixel.setPixelColor(px, red);
pixel.show();
delay(PXDELAY);
}
pixel.fill(black,0,32);
pixel.show();
delay(PXDELAY);
for (px = 0; px < 33; (px++)) {
pixel.setPixelColor(px, red);
pixel.show();
delay(PXDELAY);
}
pixel.clear();
pixel.show();
for (i=0; i<7;i++) {
if (i<6) {
setHue(deviceArray[i],true,HueRed,200,255);
delay(20);
}
else {
switchON(deviceArray[6]);
}
for (px = 0; px < 4; (px++)) {
pixel.setPixelColor(px, red);
pixel.show();
}
delay(PXDELAY);
pixel.clear();
pixel.show();
delay(PXDELAY);
}
delay(2000);
for (i=0;i<7;i++) {
if (i<6) {
setHue(deviceArray[i],false,0,0,0);
}
else {
delay(5000);
switchOFF(deviceArray[6]);
}
}
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollTwo() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 2!\nHue Light 1 Activated!\n");
display.display();
pixel.fill(lime, 20, 4);
pixel.show();
setHue(deviceArray[0],true,HueGreen,200,255);
delay(5000);
setHue(deviceArray[0],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollThree() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 3!\nHue Light 2 Activated!\n");
display.display();
pixel.fill(teal, 12, 4);
pixel.show();
setHue(deviceArray[1],true,HueBlue,200,255);
delay(5000);
setHue(deviceArray[1],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollFour() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 4!\nHue Light 3 Activated!\n");
display.display();
pixel.fill(violet, 4, 4);
pixel.show();
setHue(deviceArray[2],true,HueViolet,200,255);
delay(5000);
setHue(deviceArray[2],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollFive() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 5!\nHue Light 4 Activated!\n");
display.display();
pixel.fill(yellow, 24, 4);
pixel.show();
setHue(deviceArray[3],true,HueYellow,200,255);
delay(5000);
setHue(deviceArray[3],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollSix() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 6!\nHue Light 5 Activated!\n");
display.display();
pixel.fill(orange, 28, 4);
pixel.show();
setHue(deviceArray[4],true,HueOrange,200,255);
delay(5000);
setHue(deviceArray[4],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void rollSeven() {
display.clearDisplay();
display.setCursor(0,0);
display.display();
pixel.clear();
pixel.show();
display.printf("You rolled a 7!\nHue Light 6 Activated!\n");
display.display();
pixel.fill(blue, 8, 4);
pixel.show();
setHue(deviceArray[5],true,HueBlue,200,255);
delay(5000);
setHue(deviceArray[5],false,0,0,0);
pixel.clear();
pixel.show();
display.clearDisplay();
display.setCursor(0,0);
display.display();
}
void drawBitMap () {
display.clearDisplay();
display.setCursor(0,0);
display.display();
display.drawBitmap (
(display.width() - LOGOWIDTH ) /2,
(display.height() - LOGOHEIGHT) /2,
myBitmap, LOGOWIDTH, LOGOHEIGHT, 1);
display.display();
delay(1000);
}
Comments
Please log in or sign up to comment.