more ways to set universe data
This commit is contained in:
parent
88c7787f41
commit
2858d64218
|
@ -38,9 +38,10 @@ Universe::Universe() {
|
|||
@param uint16_t address of the requested slot.
|
||||
@return const uint8_t value of the slot.
|
||||
*/
|
||||
const uint8_t Universe::slot (uint16_t address) const
|
||||
const uint8_t Universe::slot (const uint16_t address) const
|
||||
{
|
||||
if (address > 512) return 0;
|
||||
if (address == 0) return 0;
|
||||
if (address > null_start_data_.size() - 1) return 0;
|
||||
return null_start_data_[address];
|
||||
}
|
||||
|
||||
|
@ -63,6 +64,35 @@ void Universe::set(vector<uint8_t> vect) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
set value of a specific slot
|
||||
|
||||
@param uint16_t address of the slot being changed
|
||||
@param uint8_t value being set
|
||||
*/
|
||||
void Universe::set(const uint16_t address, const uint8_t value)
|
||||
{
|
||||
if (address == 0) return;
|
||||
if (address > null_start_data_.size() - 1) return;
|
||||
null_start_data_[address] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
set value of a block of slots
|
||||
|
||||
@param uint16_t address of the slot being changed
|
||||
@param uint16_t footprint of profile
|
||||
@param uint8_t* values being set
|
||||
*/
|
||||
void Universe::set(const uint16_t start, const uint16_t footprint,
|
||||
const uint8_t* profile)
|
||||
{
|
||||
if (start == 0) return;
|
||||
if (start + footprint > null_start_data_.size() - 1) return;
|
||||
for (int i = 0; i < footprint; i++)
|
||||
null_start_data_[start + i] = profile[i];
|
||||
}
|
||||
|
||||
/**
|
||||
register a data consumer callback function
|
||||
|
||||
|
|
|
@ -60,9 +60,11 @@ class Universe {
|
|||
Universe ();
|
||||
|
||||
const DimmerData * data() const { return &null_start_data_; }
|
||||
const uint8_t slot (uint16_t address) const;
|
||||
const uint8_t slot (const uint16_t) const;
|
||||
|
||||
void set (vector<uint8_t>);
|
||||
void set (const uint16_t, const uint8_t);
|
||||
void set (const uint16_t, const uint16_t, const uint8_t*);
|
||||
void onData (const DataHandler);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue