49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#include "Program.h"
|
|
|
|
|
|
Program::Program(){
|
|
////////SERIALS//////
|
|
Serial1.begin(MONITOR_SPEED);
|
|
Serial.begin(MONITOR_SPEED);
|
|
|
|
//////Oled Screen/////
|
|
this->screen = new OledScreen(OLED_WIDTH, OLED_HEIGHT, OLED_RESET);
|
|
this->screen->wifiWaiting();
|
|
|
|
////////API///////
|
|
this->api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
|
this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
|
|
|
|
|
//////CAPTEUR/////
|
|
this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, ULTRA_SOUND_FULL);
|
|
this->dht = new HumiTemp(DHTPIN, DHTTYPE, DHT_FULL);
|
|
this->balance = new Balance(POID_DOUT,POID_SCK, POID_FULL);
|
|
this->balance->tar(1077);
|
|
|
|
this->screen->clear();
|
|
}
|
|
|
|
void Program::loop(){
|
|
String distance = this->ultrasonic->read();
|
|
String humitemp = this->dht->read();
|
|
String poid = this->balance->read();
|
|
|
|
|
|
this->screen->printVal(distance, poid, humitemp);
|
|
|
|
this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
|
|
Serial.println(this->ultrasonic->isFull()?" true":" false");
|
|
|
|
Serial.println("humiTemp = " + humitemp);
|
|
this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
|
|
Serial.println(this->dht->isFull()?" true":" false");
|
|
|
|
Serial.println("poid = " + poid);
|
|
this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull());
|
|
Serial.println(this->balance->isFull()?" true":" false");
|
|
|
|
Serial.println();
|
|
|
|
delay(1000);
|
|
} |