delta transfer
This commit is contained in:
parent
9350b6f77d
commit
3a2aedb11a
2
.vscode/arduino.json
vendored
Normal file → Executable file
2
.vscode/arduino.json
vendored
Normal file → Executable file
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"board": "esp8266:esp8266:generic",
|
"board": "esp8266:esp8266:generic",
|
||||||
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=115200,FlashSize=512K0,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=921600,FlashSize=512K0,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
||||||
"sketch": "frontend.ino",
|
"sketch": "frontend.ino",
|
||||||
"port": "/dev/ttyUSB0"
|
"port": "/dev/ttyUSB0"
|
||||||
}
|
}
|
0
.vscode/settings.json
vendored
Normal file → Executable file
0
.vscode/settings.json
vendored
Normal file → Executable file
0
front.svg
Normal file → Executable file
0
front.svg
Normal file → Executable file
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
41
frontend.ino
Normal file → Executable file
41
frontend.ino
Normal file → Executable file
@ -1,16 +1,20 @@
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <ESP8266mDNS.h>
|
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include "SSD1306Brzo.h"
|
#include "SSD1306Brzo.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <FS.h>
|
||||||
|
|
||||||
String inTemp,outTemp,pressure,humid;
|
String inTemp,outTemp,pressure,humid;
|
||||||
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
||||||
short int lastBeep;
|
short int lastBeep;
|
||||||
const String httpAddr="http://192.168.100.100:1880";
|
const String httpAddr="http://meteo-front:1880";
|
||||||
|
int alarms[10]={660,1260};
|
||||||
|
int alarmDuration(6);
|
||||||
|
int alarmStop(0);
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP);
|
NTPClient timeClient(ntpUDP);
|
||||||
@ -24,12 +28,11 @@ void setup(){
|
|||||||
display.setContrast(255);
|
display.setContrast(255);
|
||||||
//==WIFI CONNECT==
|
//==WIFI CONNECT==
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
// wifiConnect();
|
|
||||||
MDNS.begin("esp8266-frontend");
|
|
||||||
//==NTP INIT==
|
//==NTP INIT==
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
timeClient.setTimeOffset(timeOffset*3600);
|
timeClient.setTimeOffset(timeOffset*3600);
|
||||||
netTasks();
|
netTasks();
|
||||||
|
// SPIFFS.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
@ -47,7 +50,35 @@ void loop(){
|
|||||||
else {
|
else {
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
|
checkAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void checkAlarm()
|
||||||
|
{
|
||||||
|
for (int i(0);i<10;i++)
|
||||||
|
{
|
||||||
|
if ((timeClient.getHours()*60+timeClient.getMinutes() >= alarms[i])&&(timeClient.getHours()*60+timeClient.getMinutes() - alarms[i] < alarmDuration)&&(alarms[i] != 0))
|
||||||
|
{
|
||||||
|
if (alarmStop != alarms[i])
|
||||||
|
{
|
||||||
|
tone(15,1000);
|
||||||
|
delay(100);
|
||||||
|
noTone(15);
|
||||||
|
delay(100);
|
||||||
|
tone(15,1000);
|
||||||
|
delay(100);
|
||||||
|
noTone(15);
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
if (!digitalRead(0)) //button
|
||||||
|
alarmStop = alarms[i];
|
||||||
|
if (timeClient.getHours()*60+timeClient.getMinutes() - alarms[i] > alarmDuration)//stop current alarm
|
||||||
|
alarmStop = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void netTasks() {
|
void netTasks() {
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
WiFi.forceSleepWake();
|
WiFi.forceSleepWake();
|
||||||
@ -55,7 +86,7 @@ void netTasks() {
|
|||||||
wifiConnect(false);
|
wifiConnect(false);
|
||||||
}
|
}
|
||||||
http.begin(httpAddr+"/inTemp");
|
http.begin(httpAddr+"/inTemp");
|
||||||
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
if (http.GET() < 0)
|
||||||
return;
|
return;
|
||||||
inTemp="i:"+http.getString()+"C";
|
inTemp="i:"+http.getString()+"C";
|
||||||
http.end();
|
http.end();
|
||||||
|
Loading…
Reference in New Issue
Block a user