-
Notifications
You must be signed in to change notification settings - Fork 17
/
espDMX.h
95 lines (73 loc) · 2.45 KB
/
espDMX.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
84
85
86
87
88
89
90
91
92
93
94
/*
espDMX v2 library
Copyright (c) 2016, Matthew Tong
https://github.com/mtongnz/espDMX
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/
*/
#ifndef espDMX_h
#define espDMX_h
#include <inttypes.h>
#include "Stream.h"
#define DMX_TX_CONF 0x3c //SERIAL_8N2
#define DMX_TX_BAUD 250000
#define DMX_FULL_UNI_TIMING 1000 // How often to output full 512 channel universe (in milliseconds)
#define DMX_NO_LED 200
#define DMX_MIN_CHANS 30 // Minimum channels output = this + DMX_ADD_CHANS
#define DMX_ADD_CHANS 30 // Add extra buffer to the number of channels output
#define byte uint8_t
// DMX states
enum dmx_state {
DMX_STOP,
DMX_START,
DMX_FULL_UNI,
DMX_DATA,
DMX_NOT_INIT
};
struct dmx_;
typedef struct dmx_ dmx_t;
class espDMX: public Stream {
public:
espDMX(uint8_t dmx_nr);
void begin() {
begin(DMX_NO_LED);
}
void begin(uint8_t ledPin, uint8_t intensity) {
begin(ledPin);
ledIntensity(intensity);
}
void begin(uint8_t);
void pause();
void unPause();
void end();
void ledIntensity(uint8_t);
void setChans(byte *data) {
setChans(data, 512, 1);
}
void setChans(byte *data, uint16_t numChans) {
setChans(data, numChans, 1);
}
void setChans(byte*, uint16_t, uint16_t);
void clearChans();
byte *getChans();
uint16_t numChans();
int available(void) override;
int peek(void) override;
int read(void) override;
void flush(void) override;
size_t write(uint8_t) override;
operator bool() const;
private:
friend void dmx_interrupt_handler(dmx_t* dmx);
void _tx_empty_irq(void);
int _dmx_nr;
dmx_t* _dmx = 0;
};
extern espDMX dmxA;
extern espDMX dmxB;
#endif