LumaShow/src/dmx.h

45 lines
755 B
C
Raw Normal View History

2024-08-15 20:44:16 -06:00
//
// Created by illyum on 8/15/2024.
//
2024-08-16 02:17:43 -06:00
#ifndef DMX_H
#define DMX_H
2024-08-15 20:44:16 -06:00
2024-08-16 02:17:43 -06:00
#include <vector>
#include <tuple>
#include <atomic>
#include <thread>
2024-08-16 20:12:02 -06:00
#include "serial_port.h"
const int DMX_BAUD_RATE = 250000;
2024-08-16 02:17:43 -06:00
struct DMXFixture {
unsigned char r, g, b;
int channel;
};
class DMXEngine {
public:
2024-08-16 20:12:02 -06:00
DMXEngine(const char* portName);
2024-08-16 02:17:43 -06:00
~DMXEngine();
void start();
void stop();
void setChannelValue(int channel, unsigned char value);
private:
2024-08-16 20:12:02 -06:00
void configurePort();
2024-08-16 02:17:43 -06:00
void sendDMXData();
void dumpZeros();
static void dmxThreadFunc(DMXEngine* engine);
2024-08-16 20:12:02 -06:00
SerialPort* serialPort;
2024-08-16 02:17:43 -06:00
std::vector<unsigned char> buffer;
std::thread dmxThread;
2024-08-16 20:12:02 -06:00
bool running;
static const int DMX_CHANNELS = 512;
2024-08-16 02:17:43 -06:00
};
#endif // DMX_H