DP

Dependencies:   FastAnalogIn mbed-rtos mbed

Fork of dipl_prace_v10 by Roman Krejci

ledsensor.cpp

Committer:
romankrej
Date:
2015-04-28
Revision:
1:28d74f044818
Parent:
0:f3b355df6f26

File content as of revision 1:28d74f044818:

#include "ledsensor.h"
#include "threads.h"


/*-- konstruktor --*/
cLedSensor::cLedSensor(PinName pinAnalog) : analog(pinAnalog) {
    voltage = 0;
    volt_temp = 0;
    i = 0;
}

cLedSensor::~cLedSensor() 
{

}

void cLedSensor::read(void) {
    volt_temp = analog.read();
    volt_s[i] = volt_temp;
    i++;
    if(i >= 5) {
        voltage = (volt_s[0] + volt_s[1] + volt_s[2] + volt_s[3] + volt_s[4]) / 5.0;
        i = 0;
        thread->signal_set(0x01);
    }
}

float cLedSensor::getVoltage(void) {
    return voltage;  
}