BLYNK TEST

Dependencies:   mbed Blynk

Revision:
2:6cd3b0947188
Parent:
1:0e75de2a5d21
diff -r 0e75de2a5d21 -r 6cd3b0947188 oled.cpp
--- a/oled.cpp	Mon Jun 13 02:21:11 2016 +0000
+++ b/oled.cpp	Wed Jun 15 03:08:40 2016 +0000
@@ -1,9 +1,10 @@
 #include "mbed.h"
-#include "Adafruit_SSD1306.h"
 #include "oled.h"
 
-I2C g_i2c(P0_11, P0_10);//SDA, SCL
-Adafruit_SSD1306_I2c adaf(g_i2c, P0_13, 0x78, 64, 128);
+//I2C g_i2c(P0_11, P0_10);//SDA, SCL
+extern I2C g_i2c;
+//Adafruit_SSD1306_I2c adaf(g_i2c, P0_13, 0x78, 64, 128);
+
 //U8GLIB_SSD1306_MICRODUINO_128X64 u8g(U8G_I2C_OPT_NONE);     //设置OLED型号
 //-------字体设置,大、中、小
 #if 0
@@ -40,7 +41,7 @@
     0x1E,0x00,0xF8,0x1F,0x00,0xE0,0x07,0x00,0x80,0x01
 };
 
-void oled_init(void)
+void oled_init(Adafruit_SSD1306_I2c &adaf)
 {
     adaf.setTextColor(1, 0);
     //adaf.setTextColor(0, 1);
@@ -99,29 +100,29 @@
     //gpio_write(&g_LED, 0);
 }
 #elif 1
-void oled(float temp, float humi, float light, float pm25, float etoh)
+void oled(Adafruit_SSD1306_I2c &adaf, float temp, float humi, float light, float pm25, float etoh)
 {
     adaf.clearDisplay();
     
     //adaf.drawBitmap(4, 1, bmp_tem, 15, 32, WHITE);
     //adaf.drawBitmap(70, 2, bmp_hum, 24, 30, WHITE);
 
-    temp = 32.2;
+    //temp = 32.2;
     adaf.setTextCursor(0, 5);         //设置文字开始坐标
     adaf.printf("Temp:%.1f'C", temp);
     
-    light = 210.0;
+    //light = 210.0;
     adaf.setTextCursor(74, 5);          //设置文字开始坐标
     adaf.printf("%.1fLux", light);            //光照强度
     
-    humi = 90.6;
+    //humi = 90.6;
     adaf.setTextCursor(0, 30);        //设置文字开始坐标
     adaf.printf("Humi:%.1f%%", humi);
 
-    pm25 = 9.7;
+    //pm25 = 9.7;
     adaf.printf("   %.1fug/m3", pm25);             //PM2.5
     
-    etoh = 2.6;
+    //etoh = 2.6;
     adaf.setTextCursor(1, 52);         //设置文字开始坐标
     adaf.printf("%.1f ppm", etoh);             //甲醛