first_commit
This commit is contained in:
111
ESP8266/MatrixLedsRGB/src/main.cpp
Normal file
111
ESP8266/MatrixLedsRGB/src/main.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
|
||||
#include <NTPClient.h>
|
||||
#include <WiFiUdp.h>
|
||||
//#include <TaskScheduler.h>
|
||||
|
||||
WiFiUDP ntpUDP;
|
||||
NTPClient timeClient(ntpUDP, "0.south-america.pool.ntp.org", -18000, 6000);
|
||||
|
||||
#include "matrix.hpp"
|
||||
#include "mqtt.hpp"
|
||||
#include "ota.hpp"
|
||||
|
||||
const char *ssid = "mdchaparror";
|
||||
const char *password = "un260874";
|
||||
long timeAnterior;
|
||||
long matrix_time;
|
||||
|
||||
|
||||
// void t1Callback();
|
||||
// void t2Callback();
|
||||
// void serialEvent();
|
||||
|
||||
// Task t1(120, TASK_FOREVER, &t1Callback);
|
||||
// Task t2(100, TASK_FOREVER, &t2Callback);
|
||||
|
||||
// Scheduler runner;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED)
|
||||
{
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
Serial.println(WiFi.localIP());
|
||||
mensaje += WiFi.localIP().toString();
|
||||
|
||||
ota_init();
|
||||
mqtt_init();
|
||||
|
||||
timeClient.begin();
|
||||
matrix_init();
|
||||
|
||||
|
||||
// runner.init();
|
||||
// runner.addTask(t1);
|
||||
// runner.addTask(t2);
|
||||
// delay(1000);
|
||||
// t1.enable();
|
||||
// t2.enable();
|
||||
}
|
||||
// void loop()
|
||||
// {
|
||||
// runner.execute();
|
||||
// }
|
||||
|
||||
// void t1Callback()
|
||||
// {
|
||||
// ArduinoOTA.handle();
|
||||
// show_matrix();
|
||||
// }
|
||||
|
||||
// void t2Callback()
|
||||
// {
|
||||
|
||||
// if ((millis() - timeAnterior) > 1000)
|
||||
// {
|
||||
// timeAnterior = millis();
|
||||
// if (!client.connected())
|
||||
// {
|
||||
// reconnect();
|
||||
// }
|
||||
// timeClient.update(); //sincronizamos con el server NTP
|
||||
// hora = timeClient.getFormattedTime();
|
||||
// texto = mensaje + " " + hora;
|
||||
// longitud = longitud = texto.length() * 5 + 64;
|
||||
// }
|
||||
|
||||
// client.loop();
|
||||
// }
|
||||
|
||||
|
||||
void loop(){
|
||||
ArduinoOTA.handle();
|
||||
if((millis() - matrix_time) > 100){
|
||||
matrix_time = millis();
|
||||
show_matrix();
|
||||
}
|
||||
|
||||
|
||||
if ((millis() - timeAnterior) > 1000)
|
||||
{
|
||||
timeAnterior = millis();
|
||||
if (!client.connected())
|
||||
{
|
||||
reconnect();
|
||||
}
|
||||
timeClient.update(); //sincronizamos con el server NTP
|
||||
hora = timeClient.getFormattedTime();
|
||||
texto = mensaje + " " + hora;
|
||||
longitud = texto.length() * 5 + 64;
|
||||
}
|
||||
|
||||
client.loop();
|
||||
}
|
||||
Reference in New Issue
Block a user