Skip to content

Commit

Permalink
make sure JLedSequence stays off after Stop is called (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Jun 29, 2023
1 parent b83a042 commit 5b10437
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# JLed changelog (github.com/jandelgado/jled)

## [2023-06-29] 4.12.2

* fix: `JLedSequence` starting again after call to `Stop` (https://github.com/jandelgado/jled/issues/115)

## [2023-01-11] 4.12.1

* fix: add missing keywords to keywords.txt
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "JLed",
"version": "4.12.1",
"version": "4.12.2",
"description": "An embedded library to control LEDs",
"license": "MIT",
"frameworks": ["espidf", "arduino", "mbed"],
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=JLed
version=4.12.1
version=4.12.2
author=Jan Delgado <jdelgado[at]gmx.net>
maintainer=Jan Delgado <jdelgado[at]gmx.net>
sentence=An Arduino library to control LEDs
Expand Down
3 changes: 2 additions & 1 deletion src/jled_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,9 @@ class TJLedSequence {
}

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

Expand Down
18 changes: 18 additions & 0 deletions test/test_jled_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ TEST_CASE("stop on sequence stops all JLeds and turns them off",
}
}

TEST_CASE("sequence will stay off after stop when update is called"
" again (https://github.com/jandelgado/jled/issues/115)",
"[jled_sequence]") {
auto mode = GENERATE(TestJLedSequence::eMode::SEQUENCE,
TestJLedSequence::eMode::PARALLEL);
SECTION("sequence stays off") {
INFO("mode = " << mode);
TestJLed leds[] = {TestJLed(HalMock(1)).On()};
auto seq = TestJLedSequence(mode, leds).Forever();

REQUIRE(seq.Update());
seq.Stop();
REQUIRE(!leds[0].IsRunning());
REQUIRE(!seq.Update());
}
}


TEST_CASE("repeat plays the sequence N times", "[jled_sequence]") {
constexpr uint8_t expected[]{255, 0, 255, 0, 0};

Expand Down

0 comments on commit 5b10437

Please sign in to comment.