101 lines
3.3 KiB
Arduino
101 lines
3.3 KiB
Arduino
|
|
||
|
void ledRefreshCallback() {
|
||
|
temp = allDotsOn ? backlightColor : black;
|
||
|
strip.ClearTo(temp);
|
||
|
for (int dot = 0; dot < NUM_LEDS; dot++) {
|
||
|
#if NUM_LEDS == 60
|
||
|
//1 dot hour marking
|
||
|
if (MOD(dot, 5) == 0) {
|
||
|
strip.SetPixelColor(dot, hourMarkingColor);
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_LEDS == 24
|
||
|
//1 dot quarter marking
|
||
|
if (MOD(dot, 6) == 0) {
|
||
|
strip.SetPixelColor(dot, hourMarkingColor);
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
strip.SetPixelColor(0, highnoonColor); //define high noon
|
||
|
|
||
|
#if NUM_LEDS == 60
|
||
|
//3 dots hour
|
||
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 - 1 + hourOffset), NUM_LEDS), hourColor);
|
||
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS), hourColor);
|
||
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 1 + hourOffset), NUM_LEDS), hourColor);
|
||
|
if (singleSecond) {
|
||
|
strip.SetPixelColor(MOD(int(currentSec * NUM_LEDS / 60 + 0), NUM_LEDS), allDotsOn ? secondsColor : backlightColor);
|
||
|
}
|
||
|
#else
|
||
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS) , hourColor);
|
||
|
#endif
|
||
|
strip.SetPixelColor(MOD(int(currentMin * NUM_LEDS / 60 + 0), NUM_LEDS), minuteColor);
|
||
|
strip.Show();
|
||
|
}
|
||
|
|
||
|
void bootAnimCallback() {
|
||
|
strip.ClearTo(black);
|
||
|
int tail = -1;
|
||
|
if (clockwiseRing) {
|
||
|
currentSec++;
|
||
|
if (currentSec >= NUM_LEDS) {
|
||
|
currentSec = 0;
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
currentSec--;
|
||
|
tail = 1;
|
||
|
if (currentSec < 0) {
|
||
|
currentSec = NUM_LEDS - 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (iotWebConf.getState() == iotwebconf::OnLine && !NTPreachable) {
|
||
|
strip.ClearTo(white);
|
||
|
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), black);
|
||
|
strip.SetPixelColor(MOD((currentSec - 1 * tail), NUM_LEDS), black);
|
||
|
strip.SetPixelColor(MOD((currentSec - 2 * tail), NUM_LEDS), black);
|
||
|
}
|
||
|
if (iotWebConf.getState() == iotwebconf::Connecting ) {
|
||
|
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), white);
|
||
|
strip.SetPixelColor(MOD((currentSec - 1 * tail), NUM_LEDS), whiter);
|
||
|
strip.SetPixelColor(MOD((currentSec - 2 * tail), NUM_LEDS), white12);
|
||
|
}
|
||
|
if (iotWebConf.getState() == iotwebconf::ApMode ) {
|
||
|
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), lightgreen);
|
||
|
strip.SetPixelColor(MOD((currentSec - 1 * tail), NUM_LEDS), green);
|
||
|
strip.SetPixelColor(MOD((currentSec - 2 * tail), NUM_LEDS), darkgreen);
|
||
|
}
|
||
|
if (iotWebConf.getState() == iotwebconf::Boot || iotWebConf.getState() == iotwebconf::NotConfigured) {
|
||
|
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), orangered);
|
||
|
strip.SetPixelColor(MOD((currentSec - 1 * tail), NUM_LEDS), red);
|
||
|
strip.SetPixelColor(MOD((currentSec - 2 * tail), NUM_LEDS), darkred);
|
||
|
}
|
||
|
|
||
|
strip.Show();
|
||
|
}
|
||
|
|
||
|
#ifdef LDR_PIN
|
||
|
void brightnessAdjustmentCallback() {
|
||
|
//Serial.println(ldrValue);
|
||
|
//brigthness begin
|
||
|
ldrValue = ldrValue / 10;
|
||
|
if (ldrValue == 0) {
|
||
|
targetBrightness = MAX_BRIGHTNESS;
|
||
|
}
|
||
|
else {
|
||
|
targetBrightness = int(MINIMAL_BRIGHTNESS + (MAX_BRIGHTNESS - MINIMAL_BRIGHTNESS) / ((ldrValue / LDR_SCALE) + 1) );
|
||
|
}
|
||
|
//Serial.println("Brightness: " + String(strip.GetBrightness()) + "(" + String(ldrValue) + ")");
|
||
|
}
|
||
|
|
||
|
void brightnessFadingCallback() {
|
||
|
int currentBrightness = strip.GetBrightness();
|
||
|
int diff = targetBrightness - currentBrightness;
|
||
|
int rate = rint(diff / 10);
|
||
|
strip.SetBrightness(currentBrightness + rate);
|
||
|
strip.Show();
|
||
|
//Serial.println("Brightness: " + String(currentBrightness) + " diff " + String(rate));
|
||
|
}
|
||
|
#endif
|