update
This commit is contained in:
parent
cfbe271e45
commit
b0f4209ed4
@ -1,7 +1,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#define SSID "Galaxy"
|
||||
#define PASSWORD "changeme"
|
||||
#define PASSWORD "pyvy9067"
|
||||
|
||||
#define NTP_SERVER "0.be.pool.ntp.org"
|
||||
|
||||
|
@ -1,11 +1,23 @@
|
||||
[env:d1_mini_lite]
|
||||
platform = espressif8266
|
||||
board = d1_mini_lite
|
||||
framework = arduino
|
||||
build_flags = -fexceptions
|
||||
build_unflags = -fno-exceptions
|
||||
; upload_protocol = espota
|
||||
; upload_port = 192.168.1.157
|
||||
; upload_speed = 115200
|
||||
lib_deps = Adafruit NeoPixel
|
||||
NTPClient
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:d1_mini_lite]
|
||||
platform = espressif8266
|
||||
board = d1_mini_lite
|
||||
framework = arduino
|
||||
build_flags = -fexceptions
|
||||
build_unflags = -fno-exceptions
|
||||
upload_protocol = espota
|
||||
upload_port = 192.168.52.129
|
||||
upload_speed = 115200
|
||||
lib_deps =
|
||||
Adafruit NeoPixel
|
||||
NTPClient
|
||||
adafruit/RTClib@^2.1.3
|
18
src/main.cpp
18
src/main.cpp
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user