1
0
Fork 0

DMX protocol defines in own header

This commit is contained in:
Kevin Matz 2021-08-07 13:48:00 -04:00
parent c8041ca857
commit 47a5adcc8a
4 changed files with 53 additions and 17 deletions

View File

@ -37,6 +37,7 @@ set(SOURCE_FILES
acn/sdt.cpp
acn/sdt.h
build/has_rtti.h
dmx/dmx.h
dmx/universe.cpp
dmx/universe.h
otp/opt.h

44
dmx/dmx.h Normal file
View File

@ -0,0 +1,44 @@
/*
dmx.h
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <cstdint>
namespace DMX {
// Table D1 - Reserved START Codes
static const uint8_t E111_NULL_START = 0;
static const uint8_t E111_ASC_TEXT_ASCII = 23;
static const uint8_t E111_ASC_TEST = 85;
static const uint8_t E111_ASC_TEXT_UTF8 = 144;
static const uint8_t E111_ASC_MANUFACTURER = 145;
static const uint8_t E111_ASC_SIP = 207;
// 8.5.3.1 Alternate START code refresh interval
// A DMX512 transmitter interleaving NULL START Code packets with
// Alternate START Code packets shall send a NULL START Code packet at least
// once per second.
static const uint16_t E111_DATA_LOSS_TIMEOUT = 1000;
} // namespace DMX

View File

@ -26,7 +26,6 @@
namespace DMX {
/**
* @brief Universe::Universe
*/
@ -69,6 +68,7 @@ uint8_t Universe::slot(const uint16_t address)
double Universe::rxRate()
{
rx_timeout_();
// updates per second
return rx_times_.size() / (rx_timeout_period_ / 1000.0);
}
@ -93,6 +93,7 @@ void Universe::setData(std::vector<uint8_t> vect) {
}
}
/**
set value of a specific slot
@ -106,6 +107,7 @@ void Universe::setValue(const uint16_t address, const uint8_t value)
null_start_data_[address] = value;
}
/**
set value of a block of slots
@ -122,6 +124,7 @@ void Universe::setValue(const uint16_t start, const uint16_t footprint,
null_start_data_[start + i] = profile[i];
}
/**
register a data consumer callback function
@ -152,4 +155,4 @@ void Universe::rx_timeout_(bool add_now)
rx_times_.pop();
}
} // DMX
} // namespace DMX

View File

@ -23,6 +23,8 @@
*/
#pragma once
#include "dmx.h"
#include <chrono>
#include <cstdint>
#include <functional>
@ -31,20 +33,6 @@
namespace DMX {
// Table D1 - Reserved START Codes
static const uint8_t E111_NULL_START = 0;
static const uint8_t E111_ASC_TEXT_ASCII = 23;
static const uint8_t E111_ASC_TEST = 85;
static const uint8_t E111_ASC_TEXT_UTF8 = 144;
static const uint8_t E111_ASC_MANUFACTURER = 145;
static const uint8_t E111_ASC_SIP = 207;
// 8.5.3.1 Alternate START code refresh interval
// A DMX512 transmitter interleaving NULL START Code packets with
// Alternate START Code packets shall send a NULL START Code packet at least
// once per second.
static const int E111_DATA_LOSS_TIMEOUT = 1000;
class Universe; // forward declare the Univserse class
using DataHandler = std::function<void(Universe *)>;
using DimmerData = std::array<uint8_t, 513>;
@ -82,4 +70,4 @@ class Universe {
const int rx_timeout_period_;
};
} // DMX
} // namespace DMX