96 lines
3.1 KiB
C++
96 lines
3.1 KiB
C++
|
|
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 (singleSecond) {
|
|
strip.SetPixelColor(MOD(int(currentSec * NUM_LEDS / 60 + 0), NUM_LEDS), secondsColor);
|
|
}
|
|
#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);
|
|
#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_STATE_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_STATE_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_STATE_AP_MODE) {
|
|
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_STATE_BOOT || iotWebConf.getState() == IOTWEBCONF_STATE_NOT_CONFIGURED) {
|
|
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;
|
|
int x;
|
|
if (ldrValue == 0) {
|
|
strip.SetBrightness( MAX_BRIGHTNESS );
|
|
}
|
|
else {
|
|
x = int(MINIMAL_BRIGHTNESS + (MAX_BRIGHTNESS - MINIMAL_BRIGHTNESS) / ((ldrValue / LDR_SCALE) + 1) );
|
|
strip.SetBrightness(x);
|
|
}
|
|
//Serial.println("Brightness: " + String(strip.GetBrightness()) + "(" + String(ldrValue) + ")");
|
|
ldrValue = 0;
|
|
strip.Show();
|
|
}
|
|
#endif
|