Hei all, I noticed one weird thing. When loop1 “activates” (every 60s) then loop lasts 12ms less that usually. Could anybody tell me why is it like that?
#include "FastLED.h"
#include "Scheduler.h"
#define NUM_LEDS 60
#define DATA_PIN 2
CRGB leds[NUM_LEDS];
int ss = 0, mm = 0, hh = 0;
unsigned long now_1 = 0, last_time_1 = 0, now_2 = 0, last_time_2 = 0, now_3 = 0, last_time_3 = 0;
void setup()
{
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
leds[ss].setRGB(0, 255, 0);
leds[mm].setRGB(0, 0, 255);
leds[hh].setRGB(255, 0, 0);
Serial.begin(115200);
Scheduler.startLoop(loop1);
Scheduler.startLoop(loop2);
}
void loop() //change ss
{
int i = 0; //all cycle must last 1000ms
for (ss = 0; ss < 60; ss++)
{
for (i; i < 40; i++)
{
leds[ss] += CRGB(0, 7, 0);
FastLED.show();
delay(10);
}
delay(16);
for (i; i >= 0; i--)
{
leds[ss] -= CRGB(0, 7, 0);
FastLED.show();
delay(10);
}
}
}
void loop1() //change mmutes
{
int i = 0;
for (mm = 0; mm < 60; mm++) //all cycle must last 60000ms
{
for (i; i < 40; i++) //this cycle tices 492ms
{
leds[mm] += CRGB(0, 0, 7);
FastLED.show();
delay(10);
}
delay(59016);
for (i; i >= 0; i--)
{
leds[mm] -= CRGB(0, 0, 7); //this cycle tices 492ms
FastLED.show();
delay(10);
}
}
yield();
}
void loop2() //change hour
{
int i = 0;
for (hh = 0; hh < 60; hh = hh + 5) //all cycle must last 3600000ms
{
for (i; i < 40; i++)
{
leds[hh] += CRGB(7, 0, 0);
FastLED.show();
delay(10);
}
delay(3599016);
for (i; i > 0; i--)
{
leds[hh] -= CRGB(7, 0, 0);
FastLED.show();
delay(10);
}
}
yield();
}