Fixed build issue
This commit is contained in:
parent
bfc7308cce
commit
853f1d0fe8
14 changed files with 172 additions and 115 deletions
|
|
@ -1,18 +1,18 @@
|
||||||
#ifndef HALCONFIGURATION_H
|
#ifndef HALCONFIGURATION_H
|
||||||
#define HALCONFIGURATION_H
|
#define HALCONFIGURATION_H
|
||||||
|
|
||||||
#include "Definitions.h"
|
#include "HalDefinitions.h"
|
||||||
|
|
||||||
|
|
||||||
// POWER CONSUMPTION SENSOR
|
// POWER CONSUMPTION SENSOR
|
||||||
#define POWERCON_ENABLED // comment out to disable sensor
|
#define POWERCON_ENABLED // comment out to disable sensor
|
||||||
#define POWERCON_HARDWARE HardwareDH1750()
|
#define POWERCON_HARDWARE HardwareBH1750()
|
||||||
#define POWERCON_PROTOCOL ProtocolOregon(118)
|
#define POWERCON_PROTOCOL ProtocolOregon(118)
|
||||||
#define POWER_TIMER_MULTIPLIER 1 // poling in minutes
|
#define POWER_TIMER_MULTIPLIER 1 // poling in minutes
|
||||||
|
|
||||||
// TEMPERATURE SENSOR
|
// TEMPERATURE SENSOR
|
||||||
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
||||||
#define TEMPERATURE_HARDWARE HW_DHT11
|
#define TEMPERATURE_HARDWARE HardwareDHT11(5)
|
||||||
#define TEMPERATURE_PROTOCOL ProtocolOregon(100)
|
#define TEMPERATURE_PROTOCOL ProtocolOregon(100)
|
||||||
#define TEMPERATURE_TIMER_MULTIPLIER 1 // poling in minutes
|
#define TEMPERATURE_TIMER_MULTIPLIER 1 // poling in minutes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef HALINTERFACES_H
|
#ifndef HALINTERFACES_H
|
||||||
#define HALINTERFACES_H
|
#define HALINTERFACES_H
|
||||||
|
|
||||||
|
|
||||||
class Hardware
|
class Hardware
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -11,7 +12,7 @@ class HardwarePowerConsumption : public Hardware
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// returns number of pulses from power meter
|
// returns number of pulses from power meter
|
||||||
virtual int getConsumption() = 0;
|
virtual unsigned int getConsumption() = 0;
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ class HardwareLight : public Hardware
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void setup() = 0;
|
virtual void setup() = 0;
|
||||||
virtual int getLuminosity() = 0;
|
virtual unsigned int getLuminosity() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,4 +39,23 @@ public:
|
||||||
virtual void send() = 0;
|
virtual void send() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ProtocolPowerConsumption : public Protocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void setConsumption(unsigned int cons) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProtocolTemperature : public Protocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void setTemperature(float temp) = 0;
|
||||||
|
virtual void setHumidity(unsigned char humidity) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProtocolLight : public Protocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void setLuminosity(int lumen) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // HALINTERFACES_H
|
#endif // HALINTERFACES_H
|
||||||
|
|
@ -2,52 +2,64 @@
|
||||||
A interrupt based sensor device that reads multiple sensors and transmits
|
A interrupt based sensor device that reads multiple sensors and transmits
|
||||||
the data to a central location.
|
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 timerMultiplierMAX;
|
||||||
unsigned int timerMultiplier = 0;
|
unsigned int timerMultiplier = 0;
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
HardwarePowerConsumption powerSensor;
|
HardwarePowerConsumption* powerSensor;
|
||||||
HardwareTemperature tempSensor;
|
HardwareTemperature* tempSensor;
|
||||||
HardwareLight lightSensor;
|
HardwareLight* lightSensor;
|
||||||
|
|
||||||
// Protocols
|
// Protocols
|
||||||
HardwarePowerConsumption powerProtocol;
|
ProtocolPowerConsumption* powerProtocol;
|
||||||
HardwareTemperature tempProtocol;
|
ProtocolTemperature* tempProtocol;
|
||||||
HardwareLight lightProtocol;
|
ProtocolLight* lightProtocol;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void timerInterrupt();
|
void timerInterruptFunc();
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
timerMultipleMAX = POWER_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER * LIGHT_TIMER_MULTIPLIER; // Find a lowest common denominator
|
timerMultiplierMAX = POWER_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER * LIGHT_TIMER_MULTIPLIER; // Find a lowest common denominator
|
||||||
pinInterrupt = InterruptUtil(timerInterrupt);
|
interrupt = new Interrupt(timerInterruptFunc);
|
||||||
pinInterrupt.setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
interrupt->setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
||||||
|
|
||||||
// Setup Sensors and protocols
|
// Setup Sensors and protocols
|
||||||
#ifdef POWERCON_ENABLED
|
#ifdef POWERCON_ENABLED
|
||||||
powerSensor = POWERCON_HARDWARE;
|
powerSensor = new POWERCON_HARDWARE;
|
||||||
powerSensor.setup();
|
powerSensor->setup();
|
||||||
powerProtocol = POWERCON_PROTOCOL;
|
powerProtocol = new POWERCON_PROTOCOL;
|
||||||
powerProtocol.setup();
|
powerProtocol->setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEMPERATURE_ENABLED
|
#ifdef TEMPERATURE_ENABLED
|
||||||
tempSensor = TEMPERATURE_HARDWARE;
|
tempSensor = new TEMPERATURE_HARDWARE;
|
||||||
tempSensor.setup();
|
tempSensor->setup();
|
||||||
tempProtocol = TEMPERATURE_PROTOCOL;
|
tempProtocol = new TEMPERATURE_PROTOCOL;
|
||||||
tempProtocol.setup();
|
tempProtocol->setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIGHT_ENABLED
|
#ifdef LIGHT_ENABLED
|
||||||
lightSensor = LIGHT_HARDWARE;
|
lightSensor = new LIGHT_HARDWARE;
|
||||||
lightSensor.setup();
|
lightSensor->setup();
|
||||||
lightProtocol = LIGHT_PROTOCOL;
|
lightProtocol = new LIGHT_PROTOCOL;
|
||||||
lightProtocol.setup();
|
lightProtocol->setup();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +67,7 @@ void setup()
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
|
||||||
|
|
||||||
void timerInterrupt()
|
void timerInterruptFunc()
|
||||||
{
|
{
|
||||||
++timerMultiplier;
|
++timerMultiplier;
|
||||||
if (timerMultiplier > timerMultiplierMAX)
|
if (timerMultiplier > timerMultiplierMAX)
|
||||||
|
|
@ -65,10 +77,10 @@ void timerInterrupt()
|
||||||
#ifdef POWERCON_ENABLED
|
#ifdef POWERCON_ENABLED
|
||||||
if(timerMultiplier == POWER_TIMER_MULTIPLIER)
|
if(timerMultiplier == POWER_TIMER_MULTIPLIER)
|
||||||
{
|
{
|
||||||
unsigned int consumption = powerSensor.getConsumption();
|
unsigned int consumption = powerSensor->getConsumption();
|
||||||
powerSensor.reset();
|
powerSensor->reset();
|
||||||
powerProtocol.setConsumption(consumption);
|
powerProtocol->setConsumption(consumption);
|
||||||
powerProtocol.send();
|
powerProtocol->send();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -76,11 +88,11 @@ void timerInterrupt()
|
||||||
#ifdef TEMPERATURE_ENABLED
|
#ifdef TEMPERATURE_ENABLED
|
||||||
if(timerMultiplier == TEMPERATURE_TIMER_MULTIPLIER)
|
if(timerMultiplier == TEMPERATURE_TIMER_MULTIPLIER)
|
||||||
{
|
{
|
||||||
unsigned int temperature = tempSensor.getTemperature();
|
unsigned int temperature = tempSensor->getTemperature();
|
||||||
unsigned int humidity = tempSensor.getHumidity();
|
unsigned int humidity = tempSensor->getHumidity();
|
||||||
tempProtocol.setTemperature(temperature);
|
tempProtocol->setTemperature(temperature);
|
||||||
tempProtocol.setHumidity(humidity);
|
tempProtocol->setHumidity(humidity);
|
||||||
tempProtocol.send();
|
tempProtocol->send();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -88,9 +100,9 @@ void timerInterrupt()
|
||||||
#ifdef TEMPERATURE_ENABLED
|
#ifdef TEMPERATURE_ENABLED
|
||||||
if(timerMultiplier == LIGHT_TIMER_MULTIPLIER)
|
if(timerMultiplier == LIGHT_TIMER_MULTIPLIER)
|
||||||
{
|
{
|
||||||
unsigned int lumen = lightSensor.getLuminosity();
|
unsigned int lumen = lightSensor->getLuminosity();
|
||||||
lightProtocol.setLuminosity(lumen);
|
lightProtocol->setLuminosity(lumen);
|
||||||
lightProtocol.send();
|
lightProtocol->send();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,13 @@ based on Christopher Laws, March, 2013 code.
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
|
||||||
BH1750::BH1750() {}
|
void HardwareBH1750::setup() {
|
||||||
|
|
||||||
void BH1750::begin(uint8_t mode) {
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
//write8(mode);
|
configure(BH1750_CONTINUOUS_HIGH_RES_MODE);
|
||||||
configure(mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH1750::configure(uint8_t mode) {
|
void HardwareBH1750::configure(uint8_t mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case BH1750_CONTINUOUS_HIGH_RES_MODE:
|
case BH1750_CONTINUOUS_HIGH_RES_MODE:
|
||||||
case BH1750_CONTINUOUS_HIGH_RES_MODE_2:
|
case BH1750_CONTINUOUS_HIGH_RES_MODE_2:
|
||||||
|
|
@ -45,8 +42,16 @@ void BH1750::configure(uint8_t mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int HardwareBH1750::getConsumption()
|
||||||
|
{
|
||||||
|
return pulses;
|
||||||
|
}
|
||||||
|
void HardwareBH1750::reset()
|
||||||
|
{
|
||||||
|
pulses = 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t BH1750::readLightLevel(void) {
|
unsigned int HardwareBH1750::getLuminosity(void) {
|
||||||
uint16_t level;
|
uint16_t level;
|
||||||
|
|
||||||
Wire.beginTransmission(BH1750_I2CADDR);
|
Wire.beginTransmission(BH1750_I2CADDR);
|
||||||
|
|
@ -81,7 +86,7 @@ uint16_t BH1750::readLightLevel(void) {
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
void BH1750::write8(uint8_t d) {
|
void HardwareBH1750::write8(uint8_t d) {
|
||||||
Wire.beginTransmission(BH1750_I2CADDR);
|
Wire.beginTransmission(BH1750_I2CADDR);
|
||||||
#if (ARDUINO >= 100)
|
#if (ARDUINO >= 100)
|
||||||
Wire.write(d);
|
Wire.write(d);
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,12 @@ http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-
|
||||||
based on Christopher Laws, March, 2013 code.
|
based on Christopher Laws, March, 2013 code.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HARDWAREBH1750_H
|
#ifndef HARDWAREBH1750_H
|
||||||
#define HARDWAREBH1750_H
|
#define HARDWAREBH1750_H
|
||||||
|
|
||||||
#if (ARDUINO >= 100)
|
#include <Wire.h>
|
||||||
#include <Arduino.h>
|
#include "HalInterfaces.h"
|
||||||
#else
|
|
||||||
#include <WProgram.h>
|
|
||||||
#endif
|
|
||||||
#include "Wire.h"
|
|
||||||
|
|
||||||
#define BH1750_DEBUG 0
|
#define BH1750_DEBUG 0
|
||||||
|
|
||||||
|
|
@ -58,14 +54,16 @@ based on Christopher Laws, March, 2013 code.
|
||||||
#define BH1750_ONE_TIME_LOW_RES_MODE 0x23
|
#define BH1750_ONE_TIME_LOW_RES_MODE 0x23
|
||||||
|
|
||||||
|
|
||||||
class BH1750 {
|
class HardwareBH1750 : public HardwarePowerConsumption, public HardwareLight{
|
||||||
public:
|
public:
|
||||||
BH1750();
|
virtual void setup();
|
||||||
void begin(uint8_t mode = BH1750_CONTINUOUS_HIGH_RES_MODE);
|
virtual unsigned int getLuminosity();
|
||||||
void configure(uint8_t mode);
|
virtual unsigned int getConsumption();
|
||||||
uint16_t readLightLevel(void);
|
virtual void reset();
|
||||||
|
|
||||||
private:
|
void configure(uint8_t mode);
|
||||||
|
private:
|
||||||
|
unsigned int pulses;
|
||||||
void write8(uint8_t data);
|
void write8(uint8_t data);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@
|
||||||
// + added references
|
// + added references
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "dht11.h"
|
#include "HardwareDHT11.h"
|
||||||
|
|
||||||
// returnvalues:
|
// returnvalues:
|
||||||
// 0 : OK
|
// 0 : OK
|
||||||
// -1 : checksum error
|
// -1 : checksum error
|
||||||
// -2 : timeout
|
// -2 : timeout
|
||||||
int dht11::read(int pin)
|
int HardwareDHT11::read()
|
||||||
{
|
{
|
||||||
// BUFFER TO RECEIVE
|
// BUFFER TO RECEIVE
|
||||||
uint8_t bits[5];
|
uint8_t bits[5];
|
||||||
|
|
@ -80,6 +80,4 @@ int dht11::read(int pin)
|
||||||
if (bits[4] != sum) return -1;
|
if (bits[4] != sum) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// END OF FILE
|
|
||||||
//
|
|
||||||
|
|
|
||||||
|
|
@ -12,26 +12,26 @@
|
||||||
// George Hadjikyriacou - Original version
|
// George Hadjikyriacou - Original version
|
||||||
// see dht.cpp file
|
// see dht.cpp file
|
||||||
// *** Terry King: Changed include Arduino.h for 1.0x
|
// *** Terry King: Changed include Arduino.h for 1.0x
|
||||||
// include core Wiring API and now Arduino
|
|
||||||
#if defined(ARDUINO) && ARDUINO >= 100
|
|
||||||
#include "Arduino.h"
|
|
||||||
#else
|
|
||||||
#include "WProgram.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef dht11_h
|
#ifndef dht11_h
|
||||||
#define dht11_h
|
#define dht11_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "HalInterfaces.h"
|
||||||
|
|
||||||
#define DHT11LIB_VERSION "0.3.2"
|
#define DHT11LIB_VERSION "0.3.2"
|
||||||
|
|
||||||
class dht11
|
class HardwareDHT11 : public HardwareTemperature
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int read(int pin);
|
HardwareDHT11(int pin);
|
||||||
int humidity;
|
virtual void setup(){};
|
||||||
int temperature;
|
virtual int getTemperature();
|
||||||
|
virtual int getHumidity();
|
||||||
|
int read();
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int pin;
|
||||||
|
float temperature;
|
||||||
|
unsigned char humidity;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
//
|
|
||||||
// END OF FILE
|
|
||||||
//
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
|
#include "HardwarePhotocell.h"
|
||||||
|
|
||||||
|
|
||||||
public void pinInterrupt()
|
void pinInterrupt()
|
||||||
{
|
{
|
||||||
++pulse;
|
//++pulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HardwarePhotocell::setup()
|
void HardwarePhotocell::setup()
|
||||||
{
|
{
|
||||||
pinInterrupt = InterruptUtil(pinInterrupt);
|
interrupt = new Interrupt(pinInterrupt);
|
||||||
pinInterrupt.setupPinInterrupt(PC2); //PC3
|
interrupt->setupPinInterrupt(PC2); //PC3
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsigned int HardwarePhotocell::getConsumption()
|
unsigned int HardwarePhotocell::getConsumption()
|
||||||
{
|
{
|
||||||
return pulse;
|
return pulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsigned int HardwarePhotocell::reset()
|
void HardwarePhotocell::reset()
|
||||||
{
|
{
|
||||||
pulse = 0;
|
pulse = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef HARDWAREPHOTOCELL_H
|
#ifndef HARDWAREPHOTOCELL_H
|
||||||
#define HARDWAREPHOTOCELL_H
|
#define HARDWAREPHOTOCELL_H
|
||||||
|
|
||||||
|
#include "HalInterfaces.h"
|
||||||
|
#include "Interrupt.h"
|
||||||
|
|
||||||
|
|
||||||
class HardwarePhotocell : public HardwarePowerConsumption
|
class HardwarePhotocell : public HardwarePowerConsumption
|
||||||
{
|
{
|
||||||
|
|
@ -10,7 +13,8 @@ public:
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Interrupt* interrupt;
|
||||||
unsigned int pulse;
|
unsigned int pulse;
|
||||||
}
|
};
|
||||||
|
|
||||||
#endif // HARDWAREPHOTOCELL_H
|
#endif // HARDWAREPHOTOCELL_H
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
|
#include "Interrupt.h"
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/sleep.h>
|
#include <avr/sleep.h>
|
||||||
|
|
||||||
|
|
||||||
void Interrupt::pinInterrupt() // here the interrupt is handled after wakeup
|
|
||||||
|
|
||||||
|
void pinInterrupt() // here the interrupt is handled after wakeup
|
||||||
{
|
{
|
||||||
// execute code here after wake-up before returning to the loop() function
|
// execute code here after wake-up before returning to the loop() function
|
||||||
// timers and code using timers (serial.print and more...) will not work here.
|
// timers and code using timers (serial.print and more...) will not work here.
|
||||||
|
|
@ -10,7 +13,12 @@ void Interrupt::pinInterrupt() // here the interrupt is handled after wak
|
||||||
// just want the thing to wake up
|
// just want the thing to wake up
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interrupt::setupInterrupt()
|
void Interrupt::setupPinInterrupt(int pin)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Interrupt::setupTimerInterrupt(unsigned int milliseconds)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The 5 different modes are:
|
* The 5 different modes are:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef INTERRUPT_H
|
#ifndef INTERRUPT_H
|
||||||
#define INTERRUPT_H
|
#define INTERRUPT_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
typedef void (*InterruptFunction) ();
|
typedef void (*InterruptFunction) ();
|
||||||
|
|
||||||
class Interrupt
|
class Interrupt
|
||||||
|
|
@ -10,9 +13,10 @@ public:
|
||||||
|
|
||||||
//static void sleep(int milliseconds);
|
//static void sleep(int milliseconds);
|
||||||
void setupPinInterrupt(int pin);
|
void setupPinInterrupt(int pin);
|
||||||
void setupTimerInterrupt(int milliseconds);
|
void setupTimerInterrupt(unsigned int milliseconds);
|
||||||
private:
|
private:
|
||||||
InterruptFunction callback;
|
InterruptFunction callback;
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif // INTERRUPT_H
|
#endif // INTERRUPT_H
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
#ifndef PROTOCOLNEXA_H
|
#ifndef PROTOCOLNEXA_H
|
||||||
#define PROTOCOLNEXA_H
|
#define PROTOCOLNEXA_H
|
||||||
|
|
||||||
|
#include "HalInterfaces.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PROTOCOLNEXA_H
|
#endif // PROTOCOLNEXA_H
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include <Wire.h>
|
#include "ProtocolOregon.h"
|
||||||
|
|
||||||
#define RF_TX_PIN = 10;
|
#define RF_TX_PIN 10
|
||||||
#define RF_DELAY = 512;
|
#define RF_DELAY 512
|
||||||
#define RF_DELAY_LONG RF_DELAY*2;
|
#define RF_DELAY_LONG RF_DELAY*2
|
||||||
#define RF_SEND_HIGH() digitalWrite(RF_TX_PIN, HIGH)
|
#define RF_SEND_HIGH() digitalWrite(RF_TX_PIN, HIGH)
|
||||||
#define RF_SEND_LOW() digitalWrite(RF_TX_PIN, LOW)
|
#define RF_SEND_LOW() digitalWrite(RF_TX_PIN, LOW)
|
||||||
|
|
||||||
|
|
@ -13,18 +13,18 @@ void ProtocolOregon::setup()
|
||||||
RF_SEND_LOW();
|
RF_SEND_LOW();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void ProtocolOregon::setTemperature(float temp)
|
void ProtocolOregon::setTemperature(float temp)
|
||||||
{
|
{
|
||||||
this.temperature = temp;
|
this->temperature = temp;
|
||||||
}
|
}
|
||||||
virtual void ProtocolOregon::setHumidity(unsigned char humidity)
|
void ProtocolOregon::setHumidity(unsigned char humidity)
|
||||||
{
|
{
|
||||||
this.humidity = humidity;
|
this->humidity = humidity;
|
||||||
}
|
}
|
||||||
virtual void ProtocolOregon::setConsumption(unsigned int cons)
|
void ProtocolOregon::setConsumption(unsigned int cons)
|
||||||
{
|
{
|
||||||
this.temperature = cons;
|
this->temperature = cons;
|
||||||
this.humidity = 0;
|
this->humidity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolOregon::send()
|
void ProtocolOregon::send()
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
#ifndef PROTOCOLOREGON_H
|
#ifndef PROTOCOLOREGON_H
|
||||||
#define PROTOCOLOREGON_H
|
#define PROTOCOLOREGON_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "HalInterfaces.h"
|
||||||
|
|
||||||
class ProtocolOregon : public ProtocolTemperature : public ProtocolPower
|
|
||||||
|
class ProtocolOregon : public ProtocolTemperature, public ProtocolPowerConsumption
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProtocolOregon(unsigned char address) : address(address){}
|
ProtocolOregon(unsigned char address) : address(address){};
|
||||||
|
|
||||||
virtual void setup();
|
virtual void setup();
|
||||||
virtual void setTemperature(float temp);
|
virtual void setTemperature(float temp);
|
||||||
|
|
@ -14,7 +17,7 @@ public:
|
||||||
virtual void send();
|
virtual void send();
|
||||||
private:
|
private:
|
||||||
unsigned char address;
|
unsigned char address;
|
||||||
unsigned float temperature;
|
float temperature;
|
||||||
unsigned char humidity;
|
unsigned char humidity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue