-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHCRadio.h
More file actions
63 lines (51 loc) · 1.44 KB
/
Copy pathHCRadio.h
File metadata and controls
63 lines (51 loc) · 1.44 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
#ifndef HCRADIO_H_
#define HCRADIO_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
// Number of maximum High/Low changes per packet.
// We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync
#define HCRADIO_MAX_TIMINGS 67
class HCRadioResult
{
public:
bool ready;
unsigned int pulse_length;
unsigned int timings[HCRADIO_MAX_TIMINGS];
unsigned int len_timings;
unsigned long last_time;
unsigned int repeat_count;
unsigned int change_count;
};
class HCRadio
{
public:
HCRadio();
void enable_status(int pin);
void disable_status();
void enable_receive(int irq);
void disable_receive();
void enable_send(int pin, int repeat = 10, int pulse_length = 380);
void disable_send();
void set_pulse_length(int pulse_length);
void set_send_repeat(int repeat);
void send_0();
void send_1();
void send_f();
void sync();
bool send_tristate(char* code);
bool send_raw(unsigned long* timings, unsigned int len_timings);
bool send_raw(const char* c);
bool decode(HCRadioResult* result);
private:
int status_pin;
int irq;
int pulse_length;
int send_pin;
int send_repeat;
void transmit(int high, int low);
static void receive_interrupt();
};
#endif