-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathx10.h
71 lines (54 loc) · 2.06 KB
/
x10.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
x10.cpp - X10 transmission library for Arduino version 0.4
Copyright (c) 2007 by Tom Igoe ([email protected])
This file is free software; you can redistribute it and/or modify
it under the terms of either the GNU General Public License version 2
or the GNU Lesser General Public License version 2.1, both as
published by the Free Software Foundation.
Original library (0.1)
Timing bug fixes (0.2)
#include bug fixes for 0012 (0.3)
Refactored version following Wire lib API (0.4)
Sends X10 commands.
*/
// ensure this library description is only included once
#ifndef x10_h
#define x10_h
// include types & constants of core API (for Arduino after 0022)
#include <Arduino.h>
#include "x10constants.h"
// library interface description
class x10Class : public Stream
{
public:
// constructors:
x10Class();
void begin(int _rxPin=3,int _txPin=4, int _zcPin=2);
void beginTransmission(uint8_t data);
void beginTransmission(int data);
void endTransmission(void);
// uint8_t requestFrom(uint8_t, uint8_t);
// uint8_t requestFrom(int, int);
virtual size_t write(uint8_t data);
virtual size_t write(const char *data);
virtual size_t write(const uint8_t *, size_t);
// the following are not implemented yet:
virtual int available(void);
virtual int read(void);
virtual int peek(void);
virtual void flush(void);
// void onReceive( void (*)(int) );
// void onRequest( void (*)(void) );
private:
static uint8_t zeroCrossingPin; // AC zero crossing pin
static uint8_t txPin; // data out pin
static uint8_t rxPin; // data in pin
static uint8_t houseCode; // house code
static uint8_t transmitting; // whether or not you're transmitting
// sends the individual bits of the commands:
void sendBits(byte cmd, byte numBits, byte isStartCode); // does bit shifting of a command
void sendCommand(byte houseCode, byte numberCode); // sends a command
void waitForZeroCross(int pin, int howManyTimes); // checks for AC zero crossing
};
extern x10Class x10;
#endif