Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Timer functionality #1

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions WetterViz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void applyConditions(boolean forceUpdate = false);

// allows to turn on and off the device via the App
BLYNK_WRITE(V1) {
setLightsOn();
setLights(true);
if (param.asInt()) {
setActive();
} else {
Expand All @@ -56,7 +56,7 @@ BLYNK_WRITE(V1) {

// allow conditions update on user input
BLYNK_WRITE(V2) {
setLightsOn();
setLights(true);
if (param.asInt()) {
setActive();
lastcheck = millis();
Expand All @@ -67,7 +67,7 @@ BLYNK_WRITE(V2) {
// light up panes for weather conditions indepent of the real weather
// turns off the update functionality
BLYNK_WRITE(V3) {
setLightsOn();
setLights(true);
setInactive();

switch (param.asInt()) {
Expand Down Expand Up @@ -109,7 +109,7 @@ BLYNK_WRITE(V4) {
// function to light up panes with a color received from Blynk
// turns off the update functionality
BLYNK_WRITE(V5) {
setLightsOn();
setLights(true);
setInactive();

int red = param[0].asInt();
Expand All @@ -127,23 +127,19 @@ BLYNK_WRITE(V5) {
}

BLYNK_WRITE(V6) {
setLightsOn();
setLights(true);
setInactive();
animationMode = param.asInt();
}

// allow user to completely disable lights
BLYNK_WRITE(V7) {
lightsOn = param.asInt();
if (!lightsOn) {
FastLED.clear();
FastLED.show();
digitalWrite(TOP_LED, LOW);
} else {
digitalWrite(TOP_LED, HIGH);
if (isActive)
applyConditions(true);
}
setLights(param.asInt());
}

// Timer to turn off lights between certain times
BLYNK_WRITE(V8) {
setLights(param.asInt());
}


Expand Down Expand Up @@ -371,9 +367,22 @@ void showPane(int pane, CRGB color) {
FastLED.show();
}

void setLightsOn() {
lightsOn = true;
Blynk.virtualWrite(V7, HIGH);
void setLights(boolean on) {
lightsOn = on;

if (!lightsOn) {
Blynk.virtualWrite(V7, LOW);
FastLED.clear();
FastLED.show();
digitalWrite(TOP_LED, LOW);
} else {
Blynk.virtualWrite(V7, HIGH);
if (isActive) {
applyConditions(true);
} else
digitalWrite(TOP_LED, HIGH);

}
}

void setActive() {
Expand Down