Skip to content

Commit

Permalink
updates to a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
jaminNZx committed Apr 8, 2017
1 parent a4feafc commit b5a938a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
54 changes: 27 additions & 27 deletions ESP8266-WS28xx-Blynk.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void setup() {
varZone = 1;
varRainbowSpeed = 0; // Start stationary
/******** FASTLED ************/
#if defined(LED_LIMIT_MILLIAMPS)
#ifdef LED_LIMIT_MILLIAMPS
FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
#endif
FastLED.addLeds<LED_TYPE, DATA_PIN, LED_ARRANGE>(leds, LED_NUMBER);
Expand All @@ -56,7 +56,7 @@ void setup() {
terminal.println(F(" Device started"));
terminal.flush();

timer.setInterval(250, updateColours);
timer.setInterval(500, updateColours);
}

// List of patterns to cycle through. Each is defined as a separate function below.
Expand All @@ -66,25 +66,36 @@ uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns

void updateColours() {
if (varManualMode) {
HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
FormattedRGB = "#" + String(HexRGB, HEX);
Blynk.setProperty(vPIN_HUE, "color", FormattedRGB);
}

}
BLYNK_WRITE(vPIN_HUE) {
if ( (varZone == ZONE) || (varZone == 1)) {
varHue = param.asInt();
if (varManualMode) {
HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
FormattedRGB = "#" + String(HexRGB, HEX);
Blynk.setProperty(vPIN_HUE, "color", FormattedRGB);
}
}
}
BLYNK_WRITE(vPIN_SATURATION) {
if ( (varZone == ZONE) || (varZone == 1)) {
varSaturation = param.asInt();
if (varManualMode) {
HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
FormattedRGB = "#" + String(HexRGB, HEX);
Blynk.setProperty(vPIN_HUE, "color", FormattedRGB);
}
}
}
BLYNK_WRITE(vPIN_BRIGHTNESS) {
if ( (varZone == ZONE) || (varZone == 1)) {
varBrightness = param.asInt();
if (varManualMode) {
HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
FormattedRGB = "#" + String(HexRGB, HEX);
Blynk.setProperty(vPIN_HUE, "color", FormattedRGB);
}
}
}
BLYNK_WRITE(vPIN_PRESET) {
Expand All @@ -111,9 +122,7 @@ BLYNK_WRITE(vPIN_COLOUR_BLUE) {
}
}
BLYNK_WRITE(vPIN_FPS) {
if ( (varZone == ZONE) || (varZone == 1)) {
varUpdatesPerSec = param.asInt();
}
if ( (varZone == ZONE) || (varZone == 1)) varUpdatesPerSec = param.asInt();
}
BLYNK_WRITE(vPIN_COLOUR_RED) {
if ( (varZone == ZONE) || (varZone == 1)) {
Expand Down Expand Up @@ -153,8 +162,11 @@ BLYNK_WRITE(vPIN_COLOUR_WHITE) {
}
}
BLYNK_WRITE(vPIN_MANUAL) {
if ( (varZone == ZONE) || (varZone == 1)) {
varManualMode = param.asInt();
if ( (varZone == ZONE) || (varZone == 1)) varManualMode = param.asInt();
if (param.asInt()) {
HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
FormattedRGB = "#" + String(HexRGB, HEX);
Blynk.setProperty(vPIN_HUE, "color", FormattedRGB);
}
}
BLYNK_WRITE(vPIN_SYNC_GHUE) {
Expand Down Expand Up @@ -192,11 +204,6 @@ BLYNK_WRITE(vPIN_COLOUR_YELLOW) {
}
BLYNK_WRITE(vPIN_ALERT) {
varAlertMode = param.asInt();
terminal.print(NICKNAME);
terminal.print(" | ALERT: ");
terminal.print(" CODE=");
terminal.println(varAlertMode);
terminal.flush();
}
BLYNK_WRITE(vPIN_OFF) {
if ( (varZone == ZONE) || (varZone == 1)) {
Expand Down Expand Up @@ -390,15 +397,11 @@ void loop()
//int numLedsToLight = map(val, 0, 1023, 0, NUM_LEDS);

FastLED.clear();
for (int led = 0; led < testLEDnumber; led++) {
leds[led] = CRGB::Blue;
}
for (int led = 0; led < testLEDnumber; led++) leds[led] = CRGB::Blue;
break;
default:
gPatterns[gCurrentPatternNumber]();
EVERY_N_MILLISECONDS( 20 ) {
gHue++; // slowly cycle the "base color" through the rainbow
}
EVERY_N_MILLISECONDS( 20 ) gHue++; // slowly cycle the "base color" through the rainbow
break;

}
Expand All @@ -408,7 +411,6 @@ void loop()
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern() {
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

Expand All @@ -425,9 +427,7 @@ void rainbowWithGlitter() {
}

void addGlitter( fract8 chanceOfGlitter) {
if ( random8() < chanceOfGlitter) {
leds[ random16(LED_NUMBER) ] += CRGB::White;
}
if ( random8() < chanceOfGlitter) leds[ random16(LED_NUMBER) ] += CRGB::White;
FastLED.delay(1000 / varUpdatesPerSec);
}

Expand Down
4 changes: 2 additions & 2 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
In my home, I have 2 nodes in each room. So I call them OFFICE1, OFFICE2, LOUNGE1, LOUNGE2.
--------------------------------------
*/
#define NICKNAME "OFFICE2"
#define NICKNAME "OFFICE1"
/*
--------------------------------------
Over The Air Hostname
Expand All @@ -47,7 +47,7 @@
Althought you can use what ever you like.
--------------------------------------
*/
#define OTA_HOSTNAME "LED-OFFICE2"
#define OTA_HOSTNAME "LED-OFFICE1"
/*
Local Server Settings (uncomment to use local server)
*/
Expand Down

0 comments on commit b5a938a

Please sign in to comment.