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",
|
||||
"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",
|
||||
"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 <WiFiClient.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <NTPClient.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include "SSD1306Brzo.h"
|
||||
#include "wifi.h"
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <FS.h>
|
||||
|
||||
String inTemp,outTemp,pressure,humid;
|
||||
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
||||
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;
|
||||
NTPClient timeClient(ntpUDP);
|
||||
@ -24,12 +28,11 @@ void setup(){
|
||||
display.setContrast(255);
|
||||
//==WIFI CONNECT==
|
||||
WiFi.mode(WIFI_STA);
|
||||
// wifiConnect();
|
||||
MDNS.begin("esp8266-frontend");
|
||||
//==NTP INIT==
|
||||
timeClient.begin();
|
||||
timeClient.setTimeOffset(timeOffset*3600);
|
||||
netTasks();
|
||||
// SPIFFS.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
@ -47,7 +50,35 @@ void loop(){
|
||||
else {
|
||||
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() {
|
||||
HTTPClient http;
|
||||
WiFi.forceSleepWake();
|
||||
@ -55,7 +86,7 @@ void netTasks() {
|
||||
wifiConnect(false);
|
||||
}
|
||||
http.begin(httpAddr+"/inTemp");
|
||||
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
||||
if (http.GET() < 0)
|
||||
return;
|
||||
inTemp="i:"+http.getString()+"C";
|
||||
http.end();
|
||||
|
Loading…
Reference in New Issue
Block a user