Skip to content

Commit 1c79299

Browse files
authored
fix JLed::Update() returning wrong result sometimes (#124)
* also check the outcome of Update() in tests because this reveales the root cause of #122, that false is returned while the effect is acutally running * upgrade to catch2 v3 * update platformio to 6.1.10 * release 4.13.1 * update coversall action
1 parent 0633121 commit 1c79299

21 files changed

+24035
-18043
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: install python
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.8'
20+
python-version: '3.11'
2121

2222
- name: linter
2323
run: |
@@ -28,16 +28,16 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: checkout code
31-
uses: actions/checkout@v2
31+
uses: actions/checkout@v4
3232

3333
- name: install python
34-
uses: actions/setup-python@v2
34+
uses: actions/setup-python@v4
3535
with:
36-
python-version: '3.9'
36+
python-version: '3.11'
3737

3838
- name: install tools
3939
run: |
40-
pip install platformio==6.1.4
40+
pip install platformio==6.1.10
4141
sudo apt-get update && sudo apt-get install -y lcov
4242
4343
- name: run tests
@@ -47,10 +47,10 @@ jobs:
4747
make clean coverage OPT=-O0
4848
4949
- name: Upload coverage to coveralls
50-
uses: coverallsapp/github-action@v1.1.2
50+
uses: coverallsapp/github-action@v2.2.3
5151
with:
5252
github-token: ${{ secrets.github_token }}
53-
path-to-lcov: test/coverage.info
53+
file: test/coverage.lcov
5454

5555
- name: build examples
5656
run: make ci

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test/bin
1515
*.gcov
1616
*.gcno
1717
*.gcda
18+
*.lcov
1819
test/coverage.info
1920
test/report
2021
**/tags

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-09-10] 4.13.1
4+
5+
* fix: `Update()` sometimes returning wrong state (https://github.com/jandelgado/jled/issues/122)
6+
37
## [2023-08-20] 4.13.0
48

59
* new: `Stop()` takes optional parameter allowing to turn LED fully off

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ all: phony
1212

1313
lint: phony
1414
cpplint --filter -readability/check \
15-
--extensions=cpp,h,ino $(shell find . -maxdepth 3 \( ! -regex '.*/\..*' \) \
15+
--exclude test/catch2 \
16+
--extensions=cpp,h,ino $(shell find . -maxdepth 3 \( ! -regex '.*/\..*' \) \
1617
-type f -a \( -name "*\.cpp" -o -name "*\.h" -o -name "*\.ino" \) )
1718

1819
ci: phony

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.13.0",
3+
"version": "4.13.1",
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.13.0
2+
version=4.13.1
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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,17 +431,15 @@ class TJLed {
431431
if (t < period) {
432432
state_ = ST_RUNNING;
433433
Write(Eval(t));
434-
return true;
435434
} else {
436435
if (state_ == ST_RUNNING) {
437436
// when in delay after phase, just call Write()
438437
// once at the beginning.
439438
state_ = ST_IN_DELAY_AFTER_PHASE;
440439
Write(Eval(period - 1));
441-
return true;
442440
}
443441
}
444-
return false;
442+
return true;
445443
}
446444

447445
B& SetBrightnessEval(BrightnessEvaluator* be) {

test/Makefile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# JLed unit tests Makefile
22
# run `make coverage` to run all test and calculate coverage
3+
#
34
.PHONY: phony
45

56
CFLAGS=-std=c++14 -c -Wall -Wextra -I. -I../src -I./esp-idf \
@@ -10,29 +11,31 @@ CFLAGS=-std=c++14 -c -Wall -Wextra -I. -I../src -I./esp-idf \
1011

1112
LDFLAGS=-fprofile-arcs -ftest-coverage
1213

13-
TEST_ARDUINO_MOCK_SRC=Arduino.cpp test_arduino_mock.cpp test_main.cpp
14+
CATCH=catch2/catch_amalgamated.cpp
15+
16+
TEST_ARDUINO_MOCK_SRC=Arduino.cpp test_arduino_mock.cpp test_main.cpp ${CATCH}
1417
TEST_ARDUINO_MOCK_OBJECTS=$(TEST_ARDUINO_MOCK_SRC:.cpp=.o)
1518

16-
TEST_JLED_SRC=Arduino.cpp test_jled.cpp test_main.cpp ../src/jled_base.cpp
19+
TEST_JLED_SRC=Arduino.cpp test_jled.cpp test_main.cpp ../src/jled_base.cpp ${CATCH}
1720
TEST_JLED_OBJECTS=$(TEST_JLED_SRC:.cpp=.o)
1821

19-
TEST_JLED_SEQUENCE_SRC=Arduino.cpp test_jled_sequence.cpp test_main.cpp ../src/jled_base.cpp
22+
TEST_JLED_SEQUENCE_SRC=Arduino.cpp test_jled_sequence.cpp test_main.cpp ../src/jled_base.cpp ${CATCH}
2023
TEST_JLED_SEQUENCE_OBJECTS=$(TEST_JLED_SEQUENCE_SRC:.cpp=.o)
2124

2225
TEST_ESP32_SRC=esp-idf/esp_timer.cpp esp-idf/driver/ledc.cpp \
23-
test_esp32_hal.cpp ../src/esp32_hal.cpp test_main.cpp
26+
test_esp32_hal.cpp ../src/esp32_hal.cpp test_main.cpp ${CATCH}
2427
TEST_ESP32_OBJECTS=$(TEST_ESP32_SRC:.cpp=.o)
2528

26-
TEST_ESP8266_SRC=Arduino.cpp test_esp8266_hal.cpp test_main.cpp
29+
TEST_ESP8266_SRC=Arduino.cpp test_esp8266_hal.cpp test_main.cpp ${CATCH}
2730
TEST_ESP8266_OBJECTS=$(TEST_ESP8266_SRC:.cpp=.o)
2831

29-
TEST_MBED_SRC=mbed.cpp test_mbed_hal.cpp test_main.cpp
32+
TEST_MBED_SRC=mbed.cpp test_mbed_hal.cpp test_main.cpp ${CATCH}
3033
TEST_MBED_OBJECTS=$(TEST_MBED_SRC:.cpp=.o)
3134

32-
TEST_ARDUINO_SRC=Arduino.cpp test_arduino_hal.cpp test_main.cpp
35+
TEST_ARDUINO_SRC=Arduino.cpp test_arduino_hal.cpp test_main.cpp ${CATCH}
3336
TEST_ARDUINO_OBJECTS=$(TEST_ARDUINO_SRC:.cpp=.o)
3437

35-
TEST_MORSE_SRC=test_example_morse.cpp test_main.cpp
38+
TEST_MORSE_SRC=test_example_morse.cpp test_main.cpp ${CATCH}
3639
TEST_MORSE_OBJECTS=$(TEST_MORSE_SRC:.cpp=.o)
3740

3841

@@ -69,10 +72,10 @@ bin/test_example_morse: $(TEST_MORSE_OBJECTS)
6972
$(CXX) -o $@ $(LDFLAGS) $(TEST_MORSE_OBJECTS)
7073

7174
coverage: test
72-
lcov --config-file=.lcovrc --directory ../src --directory .. --capture --output-file coverage.info --no-external
73-
lcov --config-file=.lcovrc --list coverage.info
75+
lcov --config-file=.lcovrc --directory ../src --directory .. --capture --output-file coverage.lcov --no-external
76+
lcov --config-file=.lcovrc --list coverage.lcov
7477
mkdir -p report
75-
genhtml coverage.info -o report
78+
genhtml coverage.lcov -o report
7679

7780
test: depend all
7881
./bin/test_jled
@@ -93,7 +96,7 @@ bin:
9396
mkdir -p bin
9497

9598
clean: phony
96-
rm -f {./,esp-idf,esp-idf/driver}/{*.gcov,*.gcda,*.gcno,*.o} .depend
99+
rm -f {./,esp-idf,esp-idf/driver,catch2}/{*.gcov,*.gcda,*.gcno,*.o} .depend
97100

98101
clobber: clean
99102
rm -f bin/*

0 commit comments

Comments
 (0)