hal/arduino/HalMultiSensor/SensorPhotocell.cpp

26 lines
501 B
C++
Raw Normal View History

#include "SensorPhotocell.h"
2016-05-02 16:39:39 +02:00
#include <Arduino.h>
unsigned int SensorPhotocell::pulse = 0;
2016-05-18 17:06:34 +02:00
void SensorPhotocell::interruptHandler()
{
digitalWrite(INDICATOR_PIN, HIGH);
DEBUG("PHCELL: INTERRUPT");
2016-05-18 17:06:34 +02:00
++pulse;
digitalWrite(INDICATOR_PIN, LOW);
2016-05-18 17:06:34 +02:00
}
void SensorPhotocell::setup()
{
Interrupt::setPinCallback(SensorPhotocell::interruptHandler);
2016-05-02 16:39:39 +02:00
Interrupt::setupPinInterrupt(PC2); //PC3
}
2016-05-10 16:04:39 +02:00
void SensorPhotocell::read(PowerData& data)
{
2016-05-10 16:04:39 +02:00
data.consumption = pulse;
pulse = 0;
2016-05-18 17:06:34 +02:00
}