Fully functional code for LÜTR v1.

Dependencies:   PM2_Libary Adafruit_GFX BME680

Files at this revision

API Documentation at this revision

Comitter:
pfammjur
Date:
Wed Apr 21 17:54:30 2021 +0000
Parent:
3:81509cdb4b15
Child:
5:ae69059b2799
Commit message:
Kommentiert;

Changed in this revision

BME680OLED.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BME680OLED.cpp	Wed Apr 21 17:49:23 2021 +0000
+++ b/BME680OLED.cpp	Wed Apr 21 17:54:30 2021 +0000
@@ -1,13 +1,6 @@
 /*
- *  Copyright (c) 2012 Neal Horman - http://www.wanlink.com
- *  
- *  License: MIT open source (http://opensource.org/licenses/MIT)
- *      Summary;
- *      Use / modify / distribute / publish it how you want and 
- *      if you use it, or don't, you can't hold me liable for how
- *      it does or doesn't work.
- *      If it doesn't work how you want, don't use it, or change
- *      it so that it does work.
+ *  Inspired by Neal Horman - http://www.wanlink.com
+            and Adafruit - http://www.adafruit.com
  */
  
 #include "mbed.h"
@@ -25,15 +18,15 @@
   
 #define SEALEVELPRESSURE_HPA (1013.25)
   
-using namespace std::chrono;                    //Namespce für printf
+using namespace std::chrono;                                                    //Namespce für printf
   
 //BME680
-I2C i2c(I2C_SDA, I2C_SCL);                      // I2C Zuweisung Used inside the BME680 Mbed Lib.
-BME680 bme680(0x77 << 1);                       //Object erstellen (<<1 für mbed 8bit Adresse)
+I2C i2c(I2C_SDA, I2C_SCL);                                                      // I2C Zuweisung Used inside the BME680 Mbed Lib.
+BME680 bme680(0x77 << 1);                                                       //Object erstellen (<<1 für mbed 8bit Adresse)
 
 //OLED
 DigitalOut myled(LED1);
-static BufferedSerial pc(USBTX, USBRX);         //pc Seriel für baud
+static BufferedSerial pc(USBTX, USBRX);                                         //pc Seriel für baud
 // an I2C sub-class that provides a constructed default
 class I2CPreInit : public I2C
 {
@@ -52,17 +45,17 @@
 
 
 
-void setup(){                                   //Setup wird 1 mal durchlaufen
-    thread_sleep_for(1000);                     //Logo Anzeigen lassen
-    pc.set_baud(9600);                          //baudrate
-    set_time(1619033310);  // Set RTC time to Wed, 21. April 2021 19:28:30
+void setup(){                                                                   //Setup wird 1 mal durchlaufen
+    thread_sleep_for(1000);                                                     //Logo Anzeigen lassen
+    pc.set_baud(9600);                                                          //baudrate
+    set_time(1619033310);                                                       // Set RTC time to Wed, 21. April 2021 19:28:30 https://www.epochconverter.com/
     oled.clearDisplay();
     oled.drawPixel (10, 10,WHITE);
     oled.display();
     thread_sleep_for(1000);
     oled.clearDisplay();
-    if (!bme680.begin()) {                          //begin() startet Sensor: Vorheizen usw...
-        oled.printf("BME680 Begin failed \r\n");     //Fehlermeldung
+    if (!bme680.begin()) {                                                      //begin() startet Sensor: Vorheizen usw...
+        oled.printf("BME680 Begin failed \r\n");                                //Fehlermeldung
     }
     
 }
@@ -75,15 +68,15 @@
     while(true)
     {
         oled.setTextCursor(0,0);
+        
         //Zeit
         time_t seconds = time(NULL);
-        //oled.printf("%s", ctime(&seconds));
-        char buffer[32];
-        strftime(buffer, 32, "%b %d %Y  %H:%M:%S", localtime(&seconds));                //Nur Stunde, Minuten, Sekunden auslesen
-        oled.printf("%s", buffer);
+        char timebuffer[32];
+        strftime(timebuffer, 32, "%b %d %Y  %H:%M:%S", localtime(&seconds));                //Nur Stunde, Minuten, Sekunden auslesen
+        oled.printf("%s", timebuffer);
         
+        //BME680
         oled.setTextCursor(0,15);
-        //BME680
         if (bme680.performReading()) {                                                                          //Sensor auslesen
             oled.printf("Temperatur: %.2f C \r\n",bme680.getTemperature());
             oled.printf("Humidity: %.2f %% \r\n",bme680.getHumidity());