1
0
Fork 0

override setValue functions

This commit is contained in:
Kevin Matz 2021-09-01 12:37:38 -04:00
parent 958083f6a3
commit a8e997258b
2 changed files with 51 additions and 0 deletions

View File

@ -153,6 +153,52 @@ bool Universe::isSyncronized() const
};
void Universe::setValue (const uint16_t address, const uint8_t value)
{
// address valid?
if (address < 1 || address > null_start_data.size())
return;
// set active_data_slots to at least this address
if (address >= active_data_slots)
active_data_slots = address + 1; // + start code
// data not changed!
if (slot(address) == value)
return;
// set the value
DMX::Universe::setValue(address, value);
}
void Universe::setValue (const uint16_t start, const uint16_t footprint,
const uint8_t* data)
{
// start and footprint valid?
if (start < 1 || start + footprint >= null_start_data.size())
return;
// set active_data_slots to at least end of footprint
if (start + footprint >= active_data_slots)
active_data_slots = start + footprint + 1; // + start code
// get a copy of the current values
null_start_mutex.lock();
uint8_t og[footprint];
std::copy(std::begin(null_start_data) + start,
std::begin(null_start_data) + start + footprint, og);
null_start_mutex.unlock();
// data not changed!
if (memcmp(data, og, footprint) == 0)
return;
// set the values
DMX::Universe::setValue(start, footprint, data);
}
/**
* @brief Universe::source
* @return

View File

@ -56,6 +56,11 @@ public:
virtual bool isSyncronized() const;
virtual void synchronize(uint8_t = 0);
// DMX::Universe overrides
void setValue (const uint16_t address, const uint8_t value) override;
void setValue (const uint16_t start, const uint16_t footprint,
const uint8_t* data) override;
/**
* @brief destination IP address
*