lib for realteimMM funcs

MBedStation.cpp

Committer:
GTNicholson
Date:
2018-02-16
Revision:
4:af34fda1dfb0
Parent:
3:13301255d95a
Parent:
2:ed0430db9b2b
Child:
5:3906f93b8b39

File content as of revision 4:af34fda1dfb0:


#include "MBedStation.h"
#include "sensor_base.h"
#include "qeihw.h"
#include <cstdint>


MBedStation::MBedStation() :light_1(p17), light_2(LED4)
{
    
}

//sensor_base MBed::sensors[1]

void MBedStation::setup()
{    

    sensor_onoff sensor0(p5);
    sensor0.sensor_id = 1;
    sensor0.enabled = true;
    MBedStation::sensors[0] = sensor0;
    sensor_0 = sensor0;

    sensor_vin sensor1(p15);
    sensor1.sensor_id = 2;
    sensor1.enabled = true;
    MBedStation::sensors[1] = sensor1;
    sensor_1 = sensor1;

    sensor_vin sensor2(p16);
    sensor2.sensor_id = 3;
    sensor2.enabled = true;
    MBedStation::sensors[2] = sensor2;
    sensor_2 = sensor2;    
    
    DigitalOut light1(p17);
    light_1 = light1;
    
    DigitalOut light2(LED4);
    light_2 = light2;
    
    /*
    sensor_pulse sensor3(p6);
    sensor3.sensor_id = 4;
    sensor3.enabled = true;
    MBedStation::sensors[3] = sensor3;
    sensor_3 = sensor3;

    
    sensor_max6675 sensor4(p11,p12,p13,p18);
    sensor4.sensor_id = 5;
    sensor4.enabled = true;
    MBedStation::sensors[4] = sensor4;
    sensor_4 = sensor4;    


    sensor_max6675 sensor5(p11,p12,p13,p17);
    sensor5.sensor_id = 6;
    sensor5.enabled = true;
    MBedStation::sensors[5] = sensor5;
    sensor_5 = sensor5;  
    */   
    
}

int MBedStation::ProcessResponse(char * Response)
{
    int led_response;
    led_response = atoi(Response);
    if (led_response == 1  or led_response == 3)
    {
        light_1 = 1;  
    }
    else
    {
        light_1 =0;
    }
    
    if (led_response == 2 or led_response == 3)
    {
        light_2 = 1;  
    }
    else
    {
        light_2 =0;
    }    
    return 1;
}