Dissolved oxygen code

Dependencies:   mbed

BME280/BME280.hpp

Committer:
e58136782000
Date:
2017-11-03
Revision:
0:9522c4dc43b8

File content as of revision 0:9522c4dc43b8:

#include "mbed.h"

#ifndef BME280_HPP
#define BME280_HPP

#define BME280_size 5

Serial sensor(PA_11,PA_12);// Tx,Rx
Serial pc(USBTX,USBRX);
class BME280{
public:
    void judgement_data(char buf[]);
    int data_read();

    int datareadfuiction(int data);
    void receive();   
private:
    int buf[BME280_size];
    void send_AT();

    int data;

};
int BME280::datareadfuiction(int data)
{
   return  buf[data];
}
void BME280::judgement_data(char buf[])
{
//    int i=0;
    
/*    if(buf[i++]== 0x5A){
        //pc.printf("first_step\n");
        if(buf[i++]== 0x5A){
            //pc.printf("second_step\n");
           //i++;//go to data type
            if(buf[i] == 0x15){
                //pc.printf("Lux type\n");
                i++;//04
                Lux = ((buf[i+1]<<24) | (buf[i+2]<<16) | (buf[i+3]<<8) | buf[i+4])/100;
                //Lux = (0x00<<24) | (0x00<<16) | (0xFE<<8) | 0x40;//test
                //pc.printf("Lux = %d\n", Lux);
            }else if(buf[i] == 0x45){
                //pc.printf("temp type\n");
                i++;//0A
                Temp = ((buf[i+1]<<8)|(buf[i+2]))/100;
                Preesure = ((buf[i+3]<<24)|(buf[i+4]<<16)|(buf[i+5]<<8)|(buf[i+6]))/100;
                Hum = ((buf[i+7]<<8)|(buf[i+8]))/100;
                Height = ((buf[i+9]<<8)|(buf[i+10]));
                //pc.printf("Temp = %d\n", Temp);
                //pc.printf("Preesure = %d\n", Preesure);
                //pc.printf("Hum = %d\n", Hum);
                //pc.printf("Height = %d\n", Height);
            }
        }
    }*/
}
void BME280::receive()
{
    pc.printf("start receive\n");
    pc.printf("buf 0 %d\n",buf[0]);
    for(int i=0;i<BME280_size;i++){
        buf[i] = sensor.getc(); 
        pc.printf("data %d\n",i); 
        //pc.putc(buf[i]);
    }
    
}

int BME280::data_read()
{\
    receive();
    //wait(0.2);
//    judgement_data(this->buf);
    
    return data;
}

#endif