BLYNK TEST

Dependencies:   mbed Blynk

main.cpp

Committer:
lixianyu
Date:
2016-06-15
Revision:
2:6cd3b0947188
Parent:
1:0e75de2a5d21
Child:
3:4cd9171ba989

File content as of revision 2:6cd3b0947188:

#include "mbed.h"

#include "MicroduinoPinNames.h"
DigitalOut myled(P0_20);
I2C g_i2c(P0_11, P0_10);//SDA, SCL
#if 1
#include "SimpleTimer.h"
#include "userDef.h"
#include "sensor.h"
#include "oled.h"
#endif
//#include "WiFiBlynk.h"

//Serial pc(P0_4, P0_0); // tx, rx

Timer g_Timer;

void led_flash()
{
    static int count = 0;
    count++;
    //pc.printf("count : %d, ms : %d\r\n", count, g_Timer.read_ms());
    //myled = 1;
    wait_ms(70);
    myled = 0;
}

Adafruit_SSD1306_I2c adaf(g_i2c, P0_13, 0x78, 64, 128);
void update_oled()
{
    myled = 1;
    wait_ms(70);
    myled = 0;
    oled(adaf, sensor_tem, sensor_hum, sensor_light, sensorPM25, Sensor_etoh);
}

int main()
{
    //pc.baud(9600);
    //myled = 1;
    g_Timer.start();
    SimpleTimer gSimpleTimer(g_Timer);
    
    //Serial.begin(9600); // See the connection status in Serial Monitor
    // Set ESP8266 baud rate
    //EspSerial.begin(115200);

    //Blynk.begin(auth, wifi, SSID, PASS);

    // Setup a function to be called every second
    //gSimpleTimer.setInterval(2000L, senTempHumi);
    gSimpleTimer.setInterval(1000, updateLight);
    gSimpleTimer.setInterval(5000, updateCH4);
    gSimpleTimer.setInterval(4000, updateTempHumi);
    //gSimpleTimer.setInterval(3000, PM25);
    //gSimpleTimer.setInterval(4000, led_flash);
    gSimpleTimer.setInterval(1000, update_oled);
    
    //PM25_init();
    wait_ms(2000);
    oled_init(adaf);
    int pretime = g_Timer.read_ms();
    while(1) {
        //pc.printf("Enter while(1)\r\n");
        //myled = !myled;
        //Blynk.run(); // All the Blynk Magic happens here...
        gSimpleTimer.run();
        #if 0
        int curtime = g_Timer.read_ms();
        if (curtime - pretime > 4000) {
            //updateTempHumi();
            led_flash();
            pretime = curtime;
        }
        #endif
        
    }
}