This commit is contained in:
2024-04-19 20:11:01 +02:00
parent cfbe271e45
commit b0f4209ed4
3 changed files with 39 additions and 15 deletions

View File

@@ -3,12 +3,15 @@
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <SPI.h>
#include <RTClib.h>
#include "config.h"
#include "colors.h"
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
WiFiUDP ntpUDP;
RTC_DS1307 rtc;
NTPClient timeClient(ntpUDP, NTP_SERVER, 60 * 60);
const int LEDS_HOURS_1[] = { 2, 3, 4, 5 };
@@ -38,6 +41,7 @@ void display_progress(int percentage)
void setup()
{
rtc.begin();
pixels.begin();
pixels.clear();
Serial.begin(9600);
@@ -47,6 +51,7 @@ void setup()
WiFi.begin(SSID, PASSWORD);
int i=0;
int j=0;
while(WiFi.status() != WL_CONNECTED)
{
delay(500);
@@ -56,7 +61,11 @@ void setup()
if(i >= NUMPIXELS)
{
i = 0;
j++;
pixels.clear();
if(rtc.isrunning() && j == 2)
break;
}
}
@@ -111,11 +120,14 @@ void loop()
{
ArduinoOTA.handle();
timeClient.update();
rtc.adjust(DateTime(2024, 1, 1, timeClient.getHours(), timeClient.getMinutes(), timeClient.getSeconds()));
}
int seconds = timeClient.getSeconds();
int minutes = timeClient.getMinutes();
int hours = timeClient.getHours();
auto now = rtc.now();
int seconds = now.second();
int minutes = now.minute();
int hours = now.hour();
int hours_1 = hours % 10;
int hours_2 = (hours / 10) % 10;
int minutes_1 = minutes % 10;