Turn dmx_into into class with state.

This is much nicer to read and in the future more state will be added to support all the rdm stuff.
This commit is contained in:
Arne
2023-08-14 15:18:54 +02:00
committed by Will Tatam
parent 0ad31c90f6
commit a3bcf92ea5
4 changed files with 111 additions and 70 deletions

23
wled00/dmx_input.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
#include <cstdint>
/*
* Support for DMX/RDM input via serial (e.g. max485) on ESP32
* ESP32 Library from:
* https://github.com/sparkfun/SparkFunDMX
*/
class DMXInput
{
public:
void init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPortNum);
void update();
private:
uint8_t inputPortNum = 255; // TODO make this configurable
/// True once the dmx input has been initialized successfully
bool initialized = false; // true once init finished successfully
/// True if dmx is currently connected
bool connected = false;
/// Timestamp of the last time a dmx frame was received
unsigned long lastUpdate = 0;
};