-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpower433_lib.h
More file actions
84 lines (67 loc) · 2.75 KB
/
power433_lib.h
File metadata and controls
84 lines (67 loc) · 2.75 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _POWER433_LIB_H_
#define _POWER433_LIB_H_
/* uncomment/define if timing statistic is required */
#define POWER433_INCLUDE_TIMING_STATS
/* Protocol constants */
#define POWER433_BITS 24 /* bits per transmission */
#define POWER433_PULSES (POWER433_BITS << 1)
#define POWER433_RETRANS 8 /* code retransmissions (>=3) */
/* Pulse types from classifyPulse() function*/
#define POWER433_PULSE_TYPE_SYNC 0
#define POWER433_PULSE_TYPE_SHORT 1
#define POWER433_PULSE_TYPE_LONG 2
#define POWER433_PULSE_TYPE_UNKNOWN -1
/* Device and button constants */
#define POWER433_DEVICE_A 0x10
#define POWER433_DEVICE_B 0x08
#define POWER433_DEVICE_C 0x04
#define POWER433_DEVICE_D 0x02
#define POWER433_DEVICE_E 0x01
#define POWER433_BUTTON_OFF 0
#define POWER433_BUTTON_ON 1
/* Initialize library */
void Power433_init(int tx_gpio, int rx_gpio);
/* Get code if present, clear it afterwards */
unsigned int Power433_getCode(void);
/* Get code if present, clear it afterwards - code is not validated */
unsigned int Power433_getAnyCode(void);
/* Wait for code until one arrives, get it and clear */
unsigned int Power433_waitCode(void);
/* Wait for code until one arrives, get it and clear - code is not validated */
unsigned int Power433_waitAnyCode(void);
/* Send code once */
void Power433_sendCode(unsigned int code);
/* Send code n times */
void Power433_repeatCode(unsigned int code, int repeats);
/* Send command: */
/* systemid - 5-bit System Code (0-31) */
/* deviceid - button letter (channel) mask (5 bits) */
/* button - power button (0-OFF, 1-ON) */
int Power433_sendCommand(unsigned int systemid, unsigned int deviceid,
unsigned int button);
/* Decode raw code data for power switches, ie: Kemot: */
/* systemid - 5-bit System Code (0-31) */
/* deviceid - button letter (channel) mask (5 bits) */
/* button - power button (0-OFF, 1-ON) */
int Power433_decodeCommand(unsigned int code, int *systemid,
int *deviceid, int *button);
/* Construct raw code for power switches, ie: Kemot: */
/* systemid - 5-bit System Code (0-31) */
/* deviceid - button letter (channel) mask (5 bits) */
/* button - power button (0-OFF, 1-ON) */
unsigned int Power433_encodeCommand(unsigned int systemid,
unsigned int deviceid,
unsigned int button);
/* Get pulse type: */
/* 0 - sync pulse */
/* 1 - short pulse */
/* 2 - long pulse */
/* -1 - unclassified */
int Power433_classifyPulse(unsigned long microseconds);
#ifdef POWER433_INCLUDE_TIMING_STATS
/* Get timing data for statistics (in microseconds): */
/* timesync - sync time (31 times zero signal) */
/* tpbuf - array of timings for all code pulses */
void Power433_getTimingStats(unsigned long *timesync, unsigned long tpbuf[]);
#endif
#endif