45 lines
755 B
C++
45 lines
755 B
C++
//
|
|
// Created by illyum on 8/15/2024.
|
|
//
|
|
|
|
#ifndef DMX_H
|
|
#define DMX_H
|
|
|
|
#include <vector>
|
|
#include <tuple>
|
|
#include <atomic>
|
|
#include <thread>
|
|
#include "serial_port.h"
|
|
|
|
const int DMX_BAUD_RATE = 250000;
|
|
|
|
struct DMXFixture {
|
|
unsigned char r, g, b;
|
|
int channel;
|
|
};
|
|
|
|
class DMXEngine {
|
|
public:
|
|
DMXEngine(const char* portName);
|
|
~DMXEngine();
|
|
|
|
void start();
|
|
void stop();
|
|
void setChannelValue(int channel, unsigned char value);
|
|
|
|
private:
|
|
void configurePort();
|
|
void sendDMXData();
|
|
void dumpZeros();
|
|
static void dmxThreadFunc(DMXEngine* engine);
|
|
|
|
SerialPort* serialPort;
|
|
std::vector<unsigned char> buffer;
|
|
std::thread dmxThread;
|
|
bool running;
|
|
|
|
static const int DMX_CHANNELS = 512;
|
|
};
|
|
|
|
#endif // DMX_H
|