Repository navigation
TimerTwo on the template embedded-cpp-template (OIL 1) - #4
Merged
Merged
Conversation
…roject The AtmelStudio solution carried a copy of the Arduino core, its .atsuo files and the ignores of its Debug folders; arduino-cli and CMake take its place with the template. The sketch is examples/Read now, in UTF-8: its µ was Windows-1252. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`uvx copier copy --overwrite` with skeleton=false: the checks, CI and the dev container that Utl and MaxMatrix share, and GPL-3.0-or-later as TimerTwo's licence, which had none. The namespace timer_two and the prefix TIMERTWO are what version 2.0.0 is to use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read asked for PWM_PIN_11, which TimerTwo never offered, as OCR2A is the top of the counter, and printed on a Serial it had not begun; its comment opened twice. Basics is the example of the README, so that make examples builds what the README shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rmat once Each file starts with its copyright and SPDX line rather than the banner of "All rights reserved"; the blocks of the API move from TimerTwo.cpp into TimerTwo.h, where Doxygen and clangd read them, and say what each function refuses. The section banners are gone, as clang-format would have broken them at 80 columns. Then clang-format with the template's Google style, and what cpplint finds beyond it: an empty loop has braces. StandardTypes.h keeps its guard, against cpplint: the author's older libraries carry the same file under it, and a sketch with one of them would define E_OK twice otherwise. The fallback of nullptr to NULL before C++11 is gone; the library uses C++11 throughout. Flash and RAM of both examples on the Uno are those of before, to the byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of 2023 Nine places for the compilers, none a bug. The bit macros of StandardTypes.h computed in int and cut to eight bits on the assignment; they say so with a static_cast now. Four narrowings lie in a range the code makes sure of, each with the range beside its cast. The check of the duty against 256 was always true for a byte, and goes: avr-gcc had removed it already. clang-tidy's analyser found a read of TCNT2 in read() whose value the loop overwrote before using it; it goes, which makes examples/Read 4 bytes smaller. Flash and RAM are otherwise those of before, to the byte. For now src/.clang-tidy and examples/.clang-tidy turn off the template's groups that the code of 2023 fails: its names, macros, typedefs and C enums, some 450 places, which version 2.0.0 rewrites anyway (OIL 3). The examples need them as well, as clang-tidy holds a header to the checks of the file that includes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 tests of what TimerTwo does right today: mode 5 on init(), the top and the prescaler of each period, start(), stop() and resume() on the clock select bits, the interrupt and the callback, the PWM on pin 3, and read() at each prescaler and in both directions. What it does wrong waits for OIL 2, each with a test that fails first. The mock of avr/io.h has the registers as bytes, and TCNT2 as a counter that steps on each read while a clock is selected, up to OCR2A and down again: start() and read() wait for the counter to move, and would wait forever on a plain byte. ISR() makes the handler a function a test calls. Timer2 is a singleton that init() takes once, so each test needs a process of its own, which ctest gives it; the fixture says so if a test begins from a used timer. Coverage of src/: 97 % of the lines; what is left is a pin outside PwmPinType and the default of a switch over all the prescalers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OIL.md lists the four steps: this one onto the template, the bugs found on the way, version 2.0.0 and its release. AGENTS.md says what an agent has to know beyond the template: the singleton and its tests, the mock's counter, the exceptions until 2.0.0. The README links the examples and names the licence; library.properties says what TimerTwo does, in the category Timing. SIMAVR_MCU stays empty until SelfCheck checks the timer in simavr (OIL 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TimerTwo gets the checks, CI and dev container of the copier template embedded-cpp-template, which Utl and MaxMatrix share, so that a change to one reaches the others with
copier update. It is the first of four steps that the new OIL.md lists: the bugs found on the way (2), version 2.0.0 with a namespace (3) and its release (4) follow in pull requests of their own. In the template's roadmap this is R-3; the decision there was to bring TimerTwo in rather than retire it, as neither Utl nor the ETL drives a hardware timer.What changes
mainnow, as in the other projects.Behaviour
Unchanged for a sketch: same API, same results. The one change in the generated code is a read of the counter whose value was never used, which clang-tidy's analyser found; it goes.
What was measured
make checkpasses from a clean build: 27 of 27 tests by GCC, by clang, under the sanitizers and with coverage; lint, clang-tidy, cppcheck, each header on its own, Doxygen, arduino-lint, the examples. Coverage of the library: 97 % of the lines, the rest unreachable through the API.Found on the way, for OIL 2
Seven bugs, each listed in OIL.md with what it does wrong: among them, resuming a stopped timer leaves it marked stopped, the full duty is never full, and the time readout loses its lower steps. Each gets a test that fails first.
🤖 Generated with Claude Code