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

[bug] night time always 0 #12

Open
Blaubeermuffin opened this issue Aug 23, 2019 · 2 comments
Open

[bug] night time always 0 #12

Blaubeermuffin opened this issue Aug 23, 2019 · 2 comments

Comments

@Blaubeermuffin
Copy link

I just tested your script and I'm pretty happy with it. Great work. I just found a small bug though with the night cutoff.

Current code:

boolean night() {
  
  if (currentDateTime.hour >= NIGHTCUTOFF && currentDateTime.hour <= MORNINGCUTOFF) 
    return true;    
}

This is checking if the current hour bigger than the night cutoff AND smaller than the morning cutoff. What you want to do instead, is to check if the current hour is bigger than the night cutoff OR smaller than the morning cutoff.
You could implement it pretty easy with something like this:

boolean night() {
  return ( currentDateTime.hour >= NIGHTCUTOFF ) || ( currentDateTime.hour <= MORNINGCUTOFF );    
}
@BlackCatPeanut
Copy link

BlackCatPeanut commented Mar 1, 2021

Just wanted to say thanks to @Blaubeermuffin for the updated code as this has fixed the night light brightness for me.

@FransKrau
Copy link

FransKrau commented Apr 30, 2021

The bug found above, is not the only bug, I think :)
When the clock starts in daytime, daytime brightness is oke, Then the clock switches to nightbrightness, at the desired time, but at the morningcutoff time the clock stays (1 hour) in nightbrightness. I think this should be the solution:

add
#define DAYBRIGHTNESS 255 // Brightness level from 0 (off) to 255 (full brightness)

change ( currentDateTime.hour <= MORNINGCUTOFF) in ( currentDateTime.hour < MORNINGCUTOFF)

and the 2 last lines of code of this:
if ( night() && USE_NIGHTCUTOFF == true )
FastLED.setBrightness (NIGHTBRIGHTNESS);
else
FastLED.setBrightness (DAYBRIGHTNESS);

Input-BDF added a commit to Input-BDF/Round-LED-Clock that referenced this issue Oct 24, 2021
[FIX] integrated solutions of leonvandenbeukel#12
[FIX] ESP8266 first pixel flickering
[ADD] define day led brightness
[ADD] fancy startup effect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants