2023-03-07 10:30:34 +01:00
|
|
|
#include "Program.h"
|
|
|
|
|
2023-04-04 15:37:55 +02:00
|
|
|
int distance;
|
|
|
|
|
|
|
|
|
2023-03-07 10:30:34 +01:00
|
|
|
Program::Program(){
|
2023-05-02 10:11:22 +02:00
|
|
|
Serial.begin(MONITOR_SPEED); //motitor pour debug
|
|
|
|
Serial1.begin(MONITOR_SPEED); //port serie pour l'esp
|
|
|
|
|
|
|
|
///////INITIALISATION OBJ//////
|
2023-04-24 16:05:50 +02:00
|
|
|
this->api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
2023-05-02 10:11:22 +02:00
|
|
|
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
|
|
|
|
this->balance = new Balance(POID_DOUT,POID_SCK);
|
|
|
|
///////INITIALISATION OK//////
|
|
|
|
|
2023-04-24 16:05:50 +02:00
|
|
|
this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
|
|
|
|
2023-05-02 10:11:22 +02:00
|
|
|
Serial.print("start calibr : ");
|
|
|
|
this->balance->initCalibration();
|
|
|
|
Serial.println("OK");
|
|
|
|
|
|
|
|
this->balance->setCalibrationFact(1077);
|
2023-03-07 10:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Program::loop(){
|
2023-04-04 15:37:55 +02:00
|
|
|
distance = this->ultrasonic->read();
|
|
|
|
|
2023-05-02 10:11:22 +02:00
|
|
|
|
|
|
|
//this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); //TODO: faire estimation poubelle plenne
|
|
|
|
this->api->sendValue(this->balance->getValue(), TRASHCAN_TWO, ,false)
|
2023-04-04 15:37:55 +02:00
|
|
|
Serial.print("Distance in CM: ");
|
|
|
|
Serial.println(distance);
|
2023-04-24 16:05:50 +02:00
|
|
|
delay(10000);
|
2023-03-07 10:30:34 +01:00
|
|
|
}
|