Repository navigation
Version 2.0.0: a namespace, Status and Result, the template's checks (OIL 3) - #6
Merged
Merged
Conversation
The API of OIL 3, a clean break without aliases for the old names: - timer_two::Timer<Registers> drives an 8-bit Timer/Counter in phase correct PWM; its registers are a parameter (CodingStyle H-3). timer2.h hands in Timer/Counter2, and timer2, the one object a sketch uses, is made when compiling, without a constructor at run time (M-5); the overflow interrupt calls it. - Google's names: Begin(), SetPeriod(), Start(), Stop(), Resume(), AttachInterrupt(), DetachInterrupt(), EnablePwm(), SetPwmDuty(), DisablePwm(), Read(), GetState(); constants are constexpr, StandardTypes.h is gone. - A refusal is a Status of an enum class Error, Read() returns a Result, as MaxMatrix has them: no conversion to bool, the texts in flash. Stop() returns why it did nothing, and SetPeriod() and SetPwmDuty() are refused before Begin(). - The PWM takes no pin, as there is only pin 3. One more bug, from the datasheet and the core's init(), which runs Timer2 before setup(): the flag of an overflow stays set while the interrupt is off, so the first callback came at once when Start() enabled it. It is cleared first now, also when a callback is attached to a running timer. The tests make a timer of their own each, on the mock's registers set back in SetUp(), and no longer need a process each; the mock's counter can step on every n-th read, as a prescaler makes the CPU read a value several times. Coverage of src/: 100 % of the lines. src/.clang-tidy goes, and the exceptions in examples/.clang-tidy: every check of the template holds for the library now. Flash and RAM on the Uno: Basics 1298 / 20 bytes, from 1372 / 26; Read 3168 / 199, from 2894 / 211, as it prints why a call was refused now. The README says what changed for a sketch, with a table from version 1. 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.
The third step of OIL.md: the API of version 2.0.0, as decided on 2026-11-10. It breaks every name on purpose, so that a sketch of version 1 fails to compile rather than behaving otherwise without notice; there are no aliases. The release itself, with its version number and the Library Manager, is OIL 4.
What changes for a sketch
How it is built
The library drives an 8-bit timer whose registers are a parameter, as the coding style asks and as XmegaTimer does it; Timer2 is the one instance a sketch uses. A test makes a timer of its own, so the tests no longer need a process each. The last exceptions to the template's clang-tidy checks are gone: every check holds for the library now.
What was measured
make checkpasses from a clean build: 64 tests by GCC, by clang, under the sanitizers and with coverage, among them the tests of the clocks at 1, 16 and 20 MHz; lint, clang-tidy with every group, cppcheck, each header on its own for the host and the board, Doxygen, arduino-lint, the examples. Coverage of the library: 100 % of the lines.🤖 Generated with Claude Code