
Projet Long pour AGRAL
Dependencies: mbed OneWire DHT22 TSL2561 SSD1306
Diff: main.cpp
- Revision:
- 6:998a618b5385
- Parent:
- 5:e3a7dc396048
- Child:
- 7:7cbb4556e694
- Child:
- 8:2ba90555552e
--- a/main.cpp Mon Oct 02 12:19:32 2017 +0000 +++ b/main.cpp Mon Oct 02 15:28:05 2017 +0000 @@ -2,6 +2,9 @@ #include "OneWire.h" #include "TSL2561.h" #include "DHT22.h" +#include "ssd1306.h" +#include "standard_font.h" +#include "bold_font.h" //Déclaration variables TSL2561 Lum(PB_7,PB_6); // Luminosité (I2C:SDA,SCL) @@ -9,12 +12,27 @@ OneWire Tem_S(PA_8); // Température sol AnalogIn Hum_S(PA_0); // Huminidité sol Serial pc(PA_2,PA_3); //Serial : Tx,Rx +SSD1306 oled(PB_0,PB_4,PB_5,PA_5,PA_7); // OLED : CS,Reset,DC,Clock,Data int main() { //OneWire Tem_S char _id[16]; DeviceAddresses* devAddresses = Tem_S.getFoundDevAddresses(); uint8_t foundNum = Tem_S.getFoundDevNum(); + + //OLED + oled.initialise(); + oled.clear(); + oled.set_contrast(255); // max contrast + + oled.set_font(bold_font, 8); + oled.printf("Heading\r\n"); + + oled.set_font(standard_font, 6); + oled.printf("Hello World!\r\n"); + oled.printf("Some more text here.."); + + oled.update(); while(1) { OneWireDeviceTemperature::startConversationForAll(&Tem_S, OWTEMP_11_BIT); @@ -28,9 +46,31 @@ Tem_Hum_A.sample(); - printf( "Lum: %f \tTemp_A: %f \tHum_A: %f \tTemp_S: %f \tHum_S: %f\r\n", Lum.lux(),Tem_Hum_A.getTemperature()/10.0, Tem_Hum_A.getHumidity()/10.0,owDevice->sendGetCommand(GET_TEMPERATURE),Hum_S.read()); - delete owDevice; + + float Lumux = Lum.lux(); + float Temp_Air = Tem_Hum_A.getTemperature()/10.0; + float Hum_Air = Tem_Hum_A.getHumidity()/10.0; + float Temp_Sol = owDevice->sendGetCommand(GET_TEMPERATURE); + float Hum_Sol = Hum_S.read(); + + printf( "Lum: %f \tTemp_A: %f \tHum_A: %f \tTemp_S: %f \tHum_S: %f\r\n", Lumux, Temp_Air, Hum_Air, Temp_Sol, Hum_Sol); + delete owDevice; + + wait(2); + oled.set_font(bold_font, 8); + oled.printf("Capteurs\r\n"); + oled.printf("\r\n"); + oled.set_font(standard_font, 6); + oled.printf("Lum: %f\r\n", Lumux); + oled.printf("Temp_A: %f\r\n", Temp_Air); + oled.printf("Hum_A: %f\r\n", Hum_Air); + oled.printf("Temp_S: %f\r\n",Temp_Sol); + oled.printf("Hum_S: %f\r\n", Hum_Sol); + oled.printf("\r\n"); + oled.update(); } - wait(5); // Frenquence : 200Hz + //wait(5); // Frenquence : 200Hz } + + }