Diltech RM Consultant / Mbed OS Double_I2C_Sample

Dependencies:   TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "PinNames.h"
00002 #include "mbed.h"
00003 #include "TextLCD.h"  // Important d'avoir la bonne librairie 
00004 #include "DS18B20.h"
00005 
00006 I2C i2c_pin(I2C_SDA, I2C_SCL);
00007 DigitalOut myLed(PC_13);
00008 TextLCD_I2C lcd(&i2c_pin, 0x4E);
00009 
00010 
00011 
00012 
00013 DS18B20 sensor(PA_5); 
00014 int col = 0;
00015 
00016 
00017 // main() runs in its own thread in the OS
00018 int main()
00019 {
00020   // *********** Oled 128 x 64 *********
00021   
00022 
00023   // ******* LCD 1602 *************
00024   //lcd.locate(0, 0); //    Position initial
00025   lcd.setCursor(TextLCD::CurOff_BlkOff);
00026   lcd.cls();
00027   lcd.setBacklight(TextLCD::LightOn);
00028   lcd.printf("  Thermal sonde\n");
00029 
00030   while (true) {
00031     
00032     myLed = !myLed;
00033     float temperature = sensor.readTemp();
00034     // ***** LCD 1602 ***
00035     lcd.locate(0, 1);
00036     lcd.printf("Temp: %0.1f",temperature);
00037     
00038     for (int g = 6;g>0;g--) {
00039         
00040         lcd.locate(g+9,1);
00041         lcd.putc(127);
00042         HAL_Delay(200);
00043         lcd.putc(' ');
00044         
00045     }
00046     
00047     // ******* Oled 128 x 64 *******
00048     
00049 
00050     
00051       HAL_Delay(50);
00052     
00053   }
00054 }