2016-05-02 10:56:15 +02:00
|
|
|
#include "SensorPhotocell.h"
|
2016-05-02 16:39:39 +02:00
|
|
|
#include <Arduino.h>
|
2016-02-24 14:37:48 +01:00
|
|
|
|
2016-05-31 21:11:53 +02:00
|
|
|
unsigned int SensorPhotocell::pulse = 0;
|
|
|
|
|
|
2016-05-18 17:06:34 +02:00
|
|
|
void SensorPhotocell::interruptHandler()
|
|
|
|
|
{
|
2016-05-31 21:11:53 +02:00
|
|
|
digitalWrite(INDICATOR_PIN, HIGH);
|
|
|
|
|
DEBUG("PHCELL: INTERRUPT");
|
2016-05-18 17:06:34 +02:00
|
|
|
++pulse;
|
2016-05-31 21:11:53 +02:00
|
|
|
digitalWrite(INDICATOR_PIN, LOW);
|
2016-05-18 17:06:34 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-24 14:37:48 +01:00
|
|
|
|
2016-05-02 10:56:15 +02:00
|
|
|
void SensorPhotocell::setup()
|
2016-02-24 14:37:48 +01:00
|
|
|
{
|
2016-05-26 16:35:22 +02:00
|
|
|
Interrupt::setPinCallback(SensorPhotocell::interruptHandler);
|
2016-05-02 16:39:39 +02:00
|
|
|
Interrupt::setupPinInterrupt(PC2); //PC3
|
2016-02-24 14:37:48 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-10 16:04:39 +02:00
|
|
|
void SensorPhotocell::read(PowerData& data)
|
2016-02-24 14:37:48 +01:00
|
|
|
{
|
2016-05-10 16:04:39 +02:00
|
|
|
data.consumption = pulse;
|
2016-02-24 14:37:48 +01:00
|
|
|
pulse = 0;
|
2016-05-18 17:06:34 +02:00
|
|
|
}
|