update
This commit is contained in:
parent
cfbe271e45
commit
b0f4209ed4
@ -1,7 +1,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define SSID "Galaxy"
|
#define SSID "Galaxy"
|
||||||
#define PASSWORD "changeme"
|
#define PASSWORD "pyvy9067"
|
||||||
|
|
||||||
#define NTP_SERVER "0.be.pool.ntp.org"
|
#define NTP_SERVER "0.be.pool.ntp.org"
|
||||||
|
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
|
; 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]
|
[env:d1_mini_lite]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
board = d1_mini_lite
|
board = d1_mini_lite
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = -fexceptions
|
build_flags = -fexceptions
|
||||||
build_unflags = -fno-exceptions
|
build_unflags = -fno-exceptions
|
||||||
; upload_protocol = espota
|
upload_protocol = espota
|
||||||
; upload_port = 192.168.1.157
|
upload_port = 192.168.52.129
|
||||||
; upload_speed = 115200
|
upload_speed = 115200
|
||||||
lib_deps = Adafruit NeoPixel
|
lib_deps =
|
||||||
NTPClient
|
Adafruit NeoPixel
|
||||||
|
NTPClient
|
||||||
|
adafruit/RTClib@^2.1.3
|
18
src/main.cpp
18
src/main.cpp
@ -3,12 +3,15 @@
|
|||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <RTClib.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
|
||||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
|
RTC_DS1307 rtc;
|
||||||
NTPClient timeClient(ntpUDP, NTP_SERVER, 60 * 60);
|
NTPClient timeClient(ntpUDP, NTP_SERVER, 60 * 60);
|
||||||
|
|
||||||
const int LEDS_HOURS_1[] = { 2, 3, 4, 5 };
|
const int LEDS_HOURS_1[] = { 2, 3, 4, 5 };
|
||||||
@ -38,6 +41,7 @@ void display_progress(int percentage)
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
rtc.begin();
|
||||||
pixels.begin();
|
pixels.begin();
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
@ -47,6 +51,7 @@ void setup()
|
|||||||
WiFi.begin(SSID, PASSWORD);
|
WiFi.begin(SSID, PASSWORD);
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
|
int j=0;
|
||||||
while(WiFi.status() != WL_CONNECTED)
|
while(WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
delay(500);
|
delay(500);
|
||||||
@ -56,7 +61,11 @@ void setup()
|
|||||||
if(i >= NUMPIXELS)
|
if(i >= NUMPIXELS)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
|
j++;
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
|
|
||||||
|
if(rtc.isrunning() && j == 2)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +120,14 @@ void loop()
|
|||||||
{
|
{
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
|
|
||||||
|
rtc.adjust(DateTime(2024, 1, 1, timeClient.getHours(), timeClient.getMinutes(), timeClient.getSeconds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int seconds = timeClient.getSeconds();
|
auto now = rtc.now();
|
||||||
int minutes = timeClient.getMinutes();
|
int seconds = now.second();
|
||||||
int hours = timeClient.getHours();
|
int minutes = now.minute();
|
||||||
|
int hours = now.hour();
|
||||||
int hours_1 = hours % 10;
|
int hours_1 = hours % 10;
|
||||||
int hours_2 = (hours / 10) % 10;
|
int hours_2 = (hours / 10) % 10;
|
||||||
int minutes_1 = minutes % 10;
|
int minutes_1 = minutes % 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user