forked from mathertel/DMXSerial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDMXSerial.h
63 lines (47 loc) · 1.76 KB
/
DMXSerial.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
// - - - - -
// DMXSerial - A hardware supported interface to DMX.
// DMXSerial.h: Library header file
//
// Copyright (c) 2011 by Matthias Hertel, http://www.mathertel.de
// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
//
// Documentation and samples are available at http://www.mathertel.de/Arduino
// 25.07.2011 creation of the DMXSerial library.
// 01.12.2011 include file changed to work with the Arduino 1.0 environment
// 10.05.2012 added method noDataSince to check how long no packet was received
// - - - - -
#ifndef DmxSerial_h
#define DmxSerial_h
#include <avr/io.h>
// ----- Constants -----
#define DMXSERIAL_MAX 512 // max. number of supported DMX data channels
#define DmxModePin 2 // Arduino pin 2 for controlling the data direction
#define DmxModeOut HIGH // set the level to HIGH for outgoing data direction
#define DmxModeIn LOW // set the level to LOW for incomming data direction
// ----- Enumerations -----
// Mode of Operation
typedef enum {
DMXNone, // unspecified
DMXController, // always sending
DMXReceiver // always listening
} DMXMode;
// ----- Library Class -----
class DMXSerialClass
{
public:
// Initialize for specific mode.
void init (int mode);
// Set the maximum used channel for DMXController mode.
void maxChannel (int channel);
// Read the last known value of a channel.
uint8_t read (int channel);
// Write a new value of a channel.
void write (int channel, uint8_t value);
// Calculate how long no data backet was received
unsigned long noDataSince();
// Terminate operation.
void term (void);
};
// Use the DMXSerial library through the DMXSerial object.
extern DMXSerialClass DMXSerial;
#endif