diff --git a/dmx/universe.cpp b/dmx/universe.cpp index e4d4684..702389a 100644 --- a/dmx/universe.cpp +++ b/dmx/universe.cpp @@ -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 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 diff --git a/dmx/universe.h b/dmx/universe.h index 1b89777..20ffcec 100644 --- a/dmx/universe.h +++ b/dmx/universe.h @@ -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); + void set (const uint16_t, const uint8_t); + void set (const uint16_t, const uint16_t, const uint8_t*); void onData (const DataHandler); private: