Red Light Work

Fork of realtimeMMLib by Graham Nicholson

MBedStation.cpp

Committer:
ChrisAydon
Date:
2017-10-02
Revision:
1:b80e5f26b233
Parent:
0:9f82ee1feae7
Child:
2:ed0430db9b2b

File content as of revision 1:b80e5f26b233:


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


MBedStation::MBedStation() :light_1(LED2), 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(LED2);
    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;
    */
}

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;
}