-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransmitterIR.h
83 lines (67 loc) · 1.27 KB
/
TransmitterIR.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
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* IR transmitter (Version 0.0.4)
*
* Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
* http://shinta.main.jp/
*/
#ifndef _TRANSMITTER_IR_H_
#define _TRANSMITTER_IR_H_
#include <mbed.h>
#include "RemoteIR.h"
/**
* IR transmitter class.
*/
class TransmitterIR {
public:
/**
* Constructor.
*
* @param txpin Pin for transmit IR signal.
*/
explicit TransmitterIR(PinName txpin);
/**
* Destructor.
*/
~TransmitterIR();
typedef enum {
Idle,
Leader,
Data,
Trailer
} State;
/**
* Get state.
*
* @return Current state.
*/
State getState(void);
/**
* Set data.
*
* @param format Format.
* @param buf Buffer of a data.
* @param bitlength Bit length of the data.
*
* @return Data bit length.
*/
int setData(RemoteIR::Format format, uint8_t *buf, int bitlength);
private:
typedef struct {
State state;
int bitcount;
int leader;
int data;
int trailer;
} work_t;
typedef struct {
RemoteIR::Format format;
int bitlength;
uint8_t buffer[64];
} data_t;
PwmOut tx;
Ticker ticker;
data_t data;
work_t work;
void tick();
};
#endif