Fixed build issue
This commit is contained in:
parent
bfc7308cce
commit
853f1d0fe8
14 changed files with 172 additions and 115 deletions
|
|
@ -2,52 +2,64 @@
|
|||
A interrupt based sensor device that reads multiple sensors and transmits
|
||||
the data to a central location.
|
||||
*/
|
||||
#if (ARDUINO >= 100)
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
#include <Wire.h>
|
||||
|
||||
InterruptUtil timerInterrupt;
|
||||
#include "HalInterfaces.h"
|
||||
#include "HalDefinitions.h"
|
||||
#include "HalConfiguration.h"
|
||||
#include "Interrupt.h"
|
||||
|
||||
|
||||
Interrupt* interrupt;
|
||||
|
||||
unsigned int timerMultiplierMAX;
|
||||
unsigned int timerMultiplier = 0;
|
||||
|
||||
// Sensors
|
||||
HardwarePowerConsumption powerSensor;
|
||||
HardwareTemperature tempSensor;
|
||||
HardwareLight lightSensor;
|
||||
HardwarePowerConsumption* powerSensor;
|
||||
HardwareTemperature* tempSensor;
|
||||
HardwareLight* lightSensor;
|
||||
|
||||
// Protocols
|
||||
HardwarePowerConsumption powerProtocol;
|
||||
HardwareTemperature tempProtocol;
|
||||
HardwareLight lightProtocol;
|
||||
ProtocolPowerConsumption* powerProtocol;
|
||||
ProtocolTemperature* tempProtocol;
|
||||
ProtocolLight* lightProtocol;
|
||||
|
||||
|
||||
|
||||
void timerInterrupt();
|
||||
void timerInterruptFunc();
|
||||
|
||||
void setup()
|
||||
{
|
||||
timerMultipleMAX = POWER_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER * LIGHT_TIMER_MULTIPLIER; // Find a lowest common denominator
|
||||
pinInterrupt = InterruptUtil(timerInterrupt);
|
||||
pinInterrupt.setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
||||
timerMultiplierMAX = POWER_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER * LIGHT_TIMER_MULTIPLIER; // Find a lowest common denominator
|
||||
interrupt = new Interrupt(timerInterruptFunc);
|
||||
interrupt->setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
||||
|
||||
// Setup Sensors and protocols
|
||||
#ifdef POWERCON_ENABLED
|
||||
powerSensor = POWERCON_HARDWARE;
|
||||
powerSensor.setup();
|
||||
powerProtocol = POWERCON_PROTOCOL;
|
||||
powerProtocol.setup();
|
||||
powerSensor = new POWERCON_HARDWARE;
|
||||
powerSensor->setup();
|
||||
powerProtocol = new POWERCON_PROTOCOL;
|
||||
powerProtocol->setup();
|
||||
#endif
|
||||
|
||||
#ifdef TEMPERATURE_ENABLED
|
||||
tempSensor = TEMPERATURE_HARDWARE;
|
||||
tempSensor.setup();
|
||||
tempProtocol = TEMPERATURE_PROTOCOL;
|
||||
tempProtocol.setup();
|
||||
tempSensor = new TEMPERATURE_HARDWARE;
|
||||
tempSensor->setup();
|
||||
tempProtocol = new TEMPERATURE_PROTOCOL;
|
||||
tempProtocol->setup();
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT_ENABLED
|
||||
lightSensor = LIGHT_HARDWARE;
|
||||
lightSensor.setup();
|
||||
lightProtocol = LIGHT_PROTOCOL;
|
||||
lightProtocol.setup();
|
||||
lightSensor = new LIGHT_HARDWARE;
|
||||
lightSensor->setup();
|
||||
lightProtocol = new LIGHT_PROTOCOL;
|
||||
lightProtocol->setup();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +67,7 @@ void setup()
|
|||
void loop() {}
|
||||
|
||||
|
||||
void timerInterrupt()
|
||||
void timerInterruptFunc()
|
||||
{
|
||||
++timerMultiplier;
|
||||
if (timerMultiplier > timerMultiplierMAX)
|
||||
|
|
@ -65,10 +77,10 @@ void timerInterrupt()
|
|||
#ifdef POWERCON_ENABLED
|
||||
if(timerMultiplier == POWER_TIMER_MULTIPLIER)
|
||||
{
|
||||
unsigned int consumption = powerSensor.getConsumption();
|
||||
powerSensor.reset();
|
||||
powerProtocol.setConsumption(consumption);
|
||||
powerProtocol.send();
|
||||
unsigned int consumption = powerSensor->getConsumption();
|
||||
powerSensor->reset();
|
||||
powerProtocol->setConsumption(consumption);
|
||||
powerProtocol->send();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -76,11 +88,11 @@ void timerInterrupt()
|
|||
#ifdef TEMPERATURE_ENABLED
|
||||
if(timerMultiplier == TEMPERATURE_TIMER_MULTIPLIER)
|
||||
{
|
||||
unsigned int temperature = tempSensor.getTemperature();
|
||||
unsigned int humidity = tempSensor.getHumidity();
|
||||
tempProtocol.setTemperature(temperature);
|
||||
tempProtocol.setHumidity(humidity);
|
||||
tempProtocol.send();
|
||||
unsigned int temperature = tempSensor->getTemperature();
|
||||
unsigned int humidity = tempSensor->getHumidity();
|
||||
tempProtocol->setTemperature(temperature);
|
||||
tempProtocol->setHumidity(humidity);
|
||||
tempProtocol->send();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -88,9 +100,9 @@ void timerInterrupt()
|
|||
#ifdef TEMPERATURE_ENABLED
|
||||
if(timerMultiplier == LIGHT_TIMER_MULTIPLIER)
|
||||
{
|
||||
unsigned int lumen = lightSensor.getLuminosity();
|
||||
lightProtocol.setLuminosity(lumen);
|
||||
lightProtocol.send();
|
||||
unsigned int lumen = lightSensor->getLuminosity();
|
||||
lightProtocol->setLuminosity(lumen);
|
||||
lightProtocol->send();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue