Skip to content

Commit

Permalink
Merge 4d5bd38 into 0672dc0
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Jun 19, 2021
2 parents 0672dc0 + 4d5bd38 commit 891b207
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ framework = arduino
build_flags = -Isrc
src_filter = +<../../src/> +<./>
upload_protocol=stlink
debug_speed=auto

[env:esp8266]
platform = espressif8266
Expand Down
9 changes: 6 additions & 3 deletions src/jled_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ class TJLed {
uint16_t delay_after_ = 0; // delay after each repetition
};

template<typename T> T* ptr(T &obj) {return &obj;} // NOLINT
template<typename T> T* ptr(T *obj) {return obj;}

// a group of JLed objects which can be controlled simultanously, in parallel
// or sequentially.
template <typename T>
Expand All @@ -458,7 +461,7 @@ class TJLedSequence {
bool UpdateParallel() {
auto result = false;
for (auto i = 0u; i < n_; i++) {
result |= leds_[i].Update();
result |= ptr(leds_[i])->Update();
}
return result;
}
Expand All @@ -469,15 +472,15 @@ class TJLedSequence {
if (cur_ >= n_) {
return false;
}
if (!leds_[cur_].Update()) {
if (!ptr(leds_[cur_])->Update()) {
return ++cur_ < n_;
}
return true;;
}

void ResetLeds() {
for (auto i = 0u; i < n_; i++) {
leds_[i].Reset();
ptr(leds_[i])->Reset();
}
}

Expand Down

0 comments on commit 891b207

Please sign in to comment.