updated board
This commit is contained in:
parent
d6292768a9
commit
f161e467bf
2
.vscode/arduino.json
vendored
2
.vscode/arduino.json
vendored
@ -2,6 +2,6 @@
|
||||
"output": "Output",
|
||||
"port": "/dev/ttyUSB0",
|
||||
"board": "esp8266:esp8266:generic",
|
||||
"configuration": "CpuFrequency=80,VTable=flash,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,FlashSize=4M2M,led=2,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=921600",
|
||||
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=921600,FlashSize=4M2M,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
||||
"sketch": "frontend.ino"
|
||||
}
|
54
frontend.ino
54
frontend.ino
@ -14,26 +14,8 @@ const String httpAddr="http://192.168.100.101:1880";
|
||||
|
||||
WiFiUDP ntpUDP;
|
||||
NTPClient timeClient(ntpUDP);
|
||||
SSD1306Brzo display(0x3C, 5, 4); //oled display w/ address 0x3C with SDA on GPIO4 and SCL on GPIO5 //address == offset
|
||||
SSD1306Brzo display(0x3C, 5, 4);
|
||||
|
||||
void wifiConnect() {
|
||||
int beginMillis = millis();
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED && millis() - beginMillis < 30000) {
|
||||
delay(250);
|
||||
displayStatus(1);
|
||||
Serial.print(".");
|
||||
}
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
displayStatus(2);
|
||||
delay(10000);
|
||||
ESP.reset();
|
||||
} else {
|
||||
Serial.print("Connected to " + String(ssid) + "; IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
displayStatus(0);
|
||||
}
|
||||
}
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
//==DISPLAY INIT==
|
||||
@ -51,7 +33,7 @@ void setup(){
|
||||
}
|
||||
|
||||
void loop(){
|
||||
mainScreen();//it could be cool and smooth if we could update screen independently, in some kind of separate thread or smthn similar
|
||||
mainScreen();
|
||||
if (((timeClient.getHours()*60 + timeClient.getMinutes()) % beepDelay == 0)&&(timeClient.getSeconds() < 1)&&(!nightMode())){
|
||||
tone(15,1000);
|
||||
delay(100);
|
||||
@ -66,7 +48,6 @@ void loop(){
|
||||
delay(750);
|
||||
}
|
||||
}
|
||||
//====================IN PROGRESS===================
|
||||
void netTasks() {
|
||||
HTTPClient http;
|
||||
WiFi.forceSleepWake();
|
||||
@ -77,13 +58,13 @@ void netTasks() {
|
||||
http.begin(httpAddr+"/inTemp");
|
||||
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
||||
return;
|
||||
inTemp="i:"+http.getString();
|
||||
inTemp="i:"+http.getString()+"C";
|
||||
http.end();
|
||||
|
||||
http.begin(httpAddr+"/outTemp");
|
||||
if (http.GET() < 0)
|
||||
return;
|
||||
outTemp="o:"+http.getString();
|
||||
outTemp="o:"+http.getString()+"C";
|
||||
http.end();
|
||||
|
||||
http.begin(httpAddr+"/humid");
|
||||
@ -95,7 +76,7 @@ void netTasks() {
|
||||
http.begin(httpAddr+"/pressure");
|
||||
if (http.GET() < 0)
|
||||
return;
|
||||
pressure="p:"+http.getString();
|
||||
pressure="p:"+http.getString()+"mBar";
|
||||
http.end();
|
||||
|
||||
updateNtp();
|
||||
@ -150,14 +131,31 @@ void displayStatus(int state){
|
||||
display.display();
|
||||
}
|
||||
void updateNtp() {
|
||||
// if (lastNtp != timeClient.getHours()) {
|
||||
while (!timeClient.update())
|
||||
Serial.println(timeClient.getHours());
|
||||
while (!timeClient.update())
|
||||
Serial.println(timeClient.getHours());
|
||||
}
|
||||
bool nightMode() {
|
||||
if ((timeClient.getHours() > offTime)||(timeClient.getHours() < onTime)) { //turn off screen between loaded time
|
||||
if ((timeClient.getHours() > offTime)||(timeClient.getHours() < onTime)) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void wifiConnect() {
|
||||
int beginMillis = millis();
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED && millis() - beginMillis < 30000) {
|
||||
delay(250);
|
||||
displayStatus(1);
|
||||
Serial.print(".");
|
||||
}
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
displayStatus(2);
|
||||
delay(10000);
|
||||
ESP.reset();
|
||||
} else {
|
||||
Serial.print("Connected to " + String(ssid) + "; IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
displayStatus(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user