-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6f191e
commit c5f834b
Showing
3 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,72 @@ | ||
#pragma once | ||
#ifndef ARTNET_ARTPOLLREPLY_H | ||
#define ARTNET_ARTPOLLREPLY_H | ||
#ifndef ARTNET_ART_TRIGGER_H | ||
#define ARTNET_ART_TRIGGER_H | ||
|
||
#include "Common.h" | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
namespace art_net { | ||
namespace art_trigger { | ||
|
||
enum Index : uint16_t { | ||
ID = 0, | ||
OP_CODE_L = 8, | ||
OP_CODE_H = 9, | ||
PROTOCOL_VER_H = 10, | ||
PROTOCOL_VER_L = 11, | ||
FILTER_1 = 12, | ||
FILTER_2 = 13, | ||
OEM_H = 14, | ||
OEM_L = 15, | ||
KEY = 16, | ||
SUB_KEY = 17, | ||
PAYLOAD = 18 | ||
}; | ||
|
||
class ArtTrigger { | ||
uint16_t oem {0xFFFF}; | ||
uint8_t key {0xFF}; | ||
uint8_t subkey {0xFF}; | ||
|
||
public: | ||
void set_oem(uint16_t oem_) | ||
{ | ||
oem = oem_; | ||
} | ||
|
||
void set_key(uint8_t key_) | ||
{ | ||
key = key_; | ||
} | ||
|
||
void set_subkey(uint8_t subkey_) | ||
{ | ||
subkey = subkey_; | ||
} | ||
|
||
void set_header(uint8_t *packet) | ||
{ | ||
for (size_t i = 0; i < ID_LENGTH; i++) packet[i] = static_cast<uint8_t>(ARTNET_ID[i]); | ||
packet[OP_CODE_L] = (static_cast<uint16_t>(OpCode::Trigger) >> 0) & 0x00FF; | ||
packet[OP_CODE_H] = (static_cast<uint16_t>(OpCode::Trigger) >> 8) & 0x00FF; | ||
packet[PROTOCOL_VER_H] = (PROTOCOL_VER >> 8) & 0x00FF; | ||
packet[PROTOCOL_VER_L] = (PROTOCOL_VER >> 0) & 0x00FF; | ||
packet[FILTER_1] = 0; | ||
packet[FILTER_2] = 0; | ||
packet[OEM_H] = (oem >> 8) & 0x00FF; | ||
packet[OEM_L] = (oem >> 0) & 0x00FF; | ||
packet[KEY] = key; | ||
packet[SUB_KEY] = subkey; | ||
} | ||
|
||
void set_payload(uint8_t *packet, const uint8_t* const payload, uint16_t size) | ||
{ | ||
memcpy(packet, payload, size); | ||
} | ||
}; | ||
|
||
} // namespace art_trigger | ||
} // namespace art_net | ||
|
||
#endif // ARTNET_ARTPOLLREPLY_H | ||
#endif // ARTNET_ART_TRIGGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters