Skip to content

Commit 5b10437

Browse files
authored
make sure JLedSequence stays off after Stop is called (#116)
1 parent b83a042 commit 5b10437

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# JLed changelog (github.com/jandelgado/jled)
22

3+
## [2023-06-29] 4.12.2
4+
5+
* fix: `JLedSequence` starting again after call to `Stop` (https://github.com/jandelgado/jled/issues/115)
6+
37
## [2023-01-11] 4.12.1
48

59
* fix: add missing keywords to keywords.txt

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "JLed",
3-
"version": "4.12.1",
3+
"version": "4.12.2",
44
"description": "An embedded library to control LEDs",
55
"license": "MIT",
66
"frameworks": ["espidf", "arduino", "mbed"],

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=JLed
2-
version=4.12.1
2+
version=4.12.2
33
author=Jan Delgado <jdelgado[at]gmx.net>
44
maintainer=Jan Delgado <jdelgado[at]gmx.net>
55
sentence=An Arduino library to control LEDs

src/jled_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,9 @@ class TJLedSequence {
553553
}
554554

555555
void Stop() {
556+
is_running_ = false;
556557
for (auto i = 0u; i < n_; i++) {
557-
leds_[i].Stop();
558+
ptr(leds_[i])->Stop();
558559
}
559560
}
560561

test/test_jled_sequence.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ TEST_CASE("stop on sequence stops all JLeds and turns them off",
9090
}
9191
}
9292

93+
TEST_CASE("sequence will stay off after stop when update is called"
94+
" again (https://github.com/jandelgado/jled/issues/115)",
95+
"[jled_sequence]") {
96+
auto mode = GENERATE(TestJLedSequence::eMode::SEQUENCE,
97+
TestJLedSequence::eMode::PARALLEL);
98+
SECTION("sequence stays off") {
99+
INFO("mode = " << mode);
100+
TestJLed leds[] = {TestJLed(HalMock(1)).On()};
101+
auto seq = TestJLedSequence(mode, leds).Forever();
102+
103+
REQUIRE(seq.Update());
104+
seq.Stop();
105+
REQUIRE(!leds[0].IsRunning());
106+
REQUIRE(!seq.Update());
107+
}
108+
}
109+
110+
93111
TEST_CASE("repeat plays the sequence N times", "[jled_sequence]") {
94112
constexpr uint8_t expected[]{255, 0, 255, 0, 0};
95113

0 commit comments

Comments
 (0)