mirror of
https://github.com/pyrou/X10RF-Arduino.git
synced 2026-07-27 19:56:18 +00:00
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
/*
|
|
x10rf.h
|
|
Library for sending x10 messages by RF.
|
|
Created by Pieter Paul Baron (embedded [at] ppbaron.nl), November 2013.
|
|
Released into the public domain.
|
|
|
|
Library to send x10 messages via a cheap 433Mhz OOK device. No X10 Firecracker (CMA17A) necessary.
|
|
Decoding messages is not implemented.
|
|
This library can emulate x10 switches and security devices and also RFXMeter and RFXSensor devices manufactured by RFXCom. (www.rfxcom.com)
|
|
|
|
Tested on a TI Stellarpad (LM4F120H5QR) and Energia 0101E0010. This should also work on Arduino (small modifications) or other TI Launchpad devices.
|
|
*/
|
|
|
|
// ensure this library description is only included once
|
|
#ifndef x10rf_h
|
|
#define x10rf_h
|
|
|
|
#define ON 0x00
|
|
#define OFF 0x20
|
|
#define BRIGHT 0x88
|
|
#define DIM 0x98
|
|
|
|
#include <stdlib.h>
|
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
|
#include "Arduino.h"
|
|
#elif defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific
|
|
#include "Energia.h"
|
|
#else
|
|
#include "WProgram.h"
|
|
#endif
|
|
|
|
class x10rf
|
|
{
|
|
public:
|
|
x10rf(uint8_t tx_pin, uint8_t led_pin, uint8_t rf_repeats);
|
|
void begin();
|
|
void RFXmeter(uint8_t rfxm_address, uint8_t rfxm_packet_type, long rfxm_value);
|
|
void RFXsensor(uint8_t rfxs_address,uint8_t rfxs_type, char rfxs_packet_type, uint8_t rfxs_value);
|
|
void x10Switch(char house_code, uint8_t unit_code, uint8_t command);
|
|
void x10Security(uint8_t address, uint8_t command);
|
|
private:
|
|
//void init(byte tx_pin, byte rf_repeats);
|
|
void SendX10RfByte(uint8_t data);
|
|
void SendX10RfBit(unsigned int databit);
|
|
void SendCommand(uint8_t *date, uint8_t size);
|
|
void SEND_HIGH();
|
|
void SEND_LOW();
|
|
uint8_t _tx_pin;
|
|
uint8_t _led_pin;
|
|
uint8_t _rf_repeats;
|
|
};
|
|
#endif |