156 Commits

Author SHA1 Message Date
Nic Newdigate 2c8ec5ac1d Merge pull request #16 from newdigate/claude/init-k08rmx
Support multiple concurrent IntervalTimers (Teensy parity)
2026-06-24 21:10:47 +01:00
Claude 9835f5ee2b Support multiple concurrent IntervalTimers (Teensy parity)
The previous implementation used a single static SIGALRM handler and one
ITIMER_REAL, so a second IntervalTimer silently clobbered the first
despite the API documenting up to 4 simultaneous timers.

Reimplement with one std::thread per active timer, each invoking its
callback at the requested period via sleep_until. A static slot counter
caps concurrent timers at 4 (matching the Teensy 4.x PIT channels);
begin() returns false once all 4 are in use, and end() frees the slot.
update() retimes the next interval, and a self-end() from within a
callback detaches rather than joining to avoid deadlock.

Because the library now uses std::thread, src/CMakeLists.txt links
Threads::Threads PUBLIC so consumers (e.g. test/blink) link pthread
transitively. Adds a test/bugs regression test covering four concurrent
timers, the max-4 limit, and slot reuse after end().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 20:08:25 +00:00
Nic Newdigate 4da12b0928 Merge pull request #15 from newdigate/claude/init-k08rmx
Add CI workflow that builds and runs the test/bugs harness
2026-06-24 21:01:52 +01:00
Claude f10fa5c08c Add CI workflow that builds and runs the test/bugs harness
Adds .github/workflows/bugs.yml, which configures, builds, and runs
test/bugs (linked against the local src/). The harness exits non-zero on
any failed check, so regressions in the fixed timing/serial/stream
behaviour now fail CI. Also adds a matching status badge to the README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 19:59:57 +00:00
Nic Newdigate 489338f5a9 Merge pull request #14 from newdigate/claude/init-k08rmx
Fix README typos and clarify consumer build setup
2026-06-24 20:57:16 +01:00
Claude 9bea221927 Fix README typos and clarify consumer build setup
- Correct typos: debuging, emlation, runnning, simial.
- CMake consumer snippet: note where cmake_declare_and_fetch.cmake.in
  comes from, and add cmake_minimum_required + CMAKE_CXX_STANDARD 17 so it
  matches the test apps and compiles the C++17 headers.
- Note that the root build only produces the library and point readers to
  the standalone test apps to run something.
- Mention supported platforms (Linux, macOS, Windows/MSVC).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 18:10:34 +00:00
Nic Newdigate c73b14967e Merge pull request #13 from newdigate/claude/init-k08rmx
Fix emulation-layer bugs (timing, serial, stream) + regression tests
2026-06-24 19:06:16 +01:00
Claude 062123a574 Fix emulation-layer bugs covered by test/bugs
- nanos() no longer subtracts the start baseline a second time; it now
  returns micros()*1000 (core_pins.cpp).
- t_start is declared extern as unsigned to match its definition in
  Arduino.cpp; the previous time_t declaration read 8 bytes from a 4-byte
  object (UB) and the MSVC branch duplicated the definition (core_pins.cpp).
- HardwareSerial::peek() now checks the simulated-input queue before
  falling back to std::cin, matching read() so the Stream parsers work on
  queued input (hardware_serial.cpp).
- HardwareSerial::write() returns the number of bytes written (1 / count)
  instead of 0, honouring the Print contract (hardware_serial.cpp).
- HardwareSerial::available() returns the queued byte count instead of
  collapsing to 0/1 (hardware_serial.cpp).
- Stream::readString()/readStringUntil() re-check the string length each
  iteration so the max cap is enforced, and break (not continue) on
  timeout to avoid spinning (Stream.cpp).

All 9 checks in test/bugs now pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 17:55:21 +00:00
Claude 6091349a28 Add regression tests reproducing emulation-layer bugs
Adds test/bugs, a standalone harness that links against the local src/
(rather than fetching from GitHub like the other test apps) and asserts
the correct behaviour for several bugs: nanos() double-subtracting its
baseline, peek() ignoring the simulated-input queue, readStringUntil()
not honouring its max cap, write() returning 0, and available()
collapsing to a 0/1 boolean. Run: ./bugs < /dev/null

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 17:38:31 +00:00
Nic Newdigate 591ac09959 Merge pull request #12 from newdigate/claude/init-k08rmx
Add CLAUDE.md with build and architecture guidance
2026-06-24 18:26:44 +01:00
Claude 84db05a768 Add CLAUDE.md with build and architecture guidance
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav
2026-06-24 17:02:21 +00:00
Nic Newdigate 4361dc2e15 Merge pull request #11 from newdigate/feature/HardwareSerialImprovement
remove serial1_initialized_callback
2025-04-06 12:49:05 +01:00
newdigate e80fa8498d remove serial1_initialized_callback 2025-04-06 12:48:19 +01:00
Nic Newdigate 68683b26a3 Update README.md 2025-04-06 10:03:43 +01:00
Nic Newdigate 333af29392 Merge pull request #10 from newdigate/feature/allow_dynamic_library
dynamic library linking, force setup and loop symbol naming
2025-04-06 09:59:53 +01:00
newdigate 486e172619 dynamic library linking, force setup and loop symbol naming 2025-04-06 09:58:43 +01:00
newdigate 310db809c5 fix/rename builds 2025-02-19 09:29:45 +00:00
newdigate 1ca17b2dcd Run CMake from correct directory 2025-02-19 09:25:55 +00:00
newdigate 227c19f8b0 Run CMake from correct directory 2025-02-19 09:25:11 +00:00
newdigate e41eb018e5 Merge remote-tracking branch 'origin/main' 2025-02-19 09:24:19 +00:00
newdigate 8facc3653d Run CMake from correct directory 2025-02-19 09:24:11 +00:00
newdigate 79c208c44d DecalreAndFetch should only load CMakeLists.txt of specified sources 2025-02-18 14:44:10 +00:00
newdigate fd06e99e2e #include <cstring> 2025-02-16 12:50:00 +00:00
newdigate 6e11005244 Merge remote-tracking branch 'origin/main' 2025-02-16 12:47:40 +00:00
newdigate 18e1a69598 #include "IntervalTimer.h" 2025-02-16 12:47:32 +00:00
Nic Newdigate bb1278f33c Update README.md 2025-02-16 12:42:28 +00:00
Nic Newdigate 8c08f088d2 Update README.md 2025-02-16 12:40:31 +00:00
Nic Newdigate 9b771b1000 Update README.md 2025-02-16 12:39:25 +00:00
newdigate f2525cb832 CMakeLists.txt cleanup 2025-02-16 12:11:23 +00:00
Nic Newdigate fe46bde4f6 Update README.md 2025-02-16 12:02:11 +00:00
Nic Newdigate 11b3875cbd Update README.md 2025-02-16 12:00:09 +00:00
Nic Newdigate f5c7ea1002 Update README.md 2025-02-16 11:54:40 +00:00
Nic Newdigate b857c5714d Merge pull request #9 from newdigate/noinstall
Use CMake to fetch dependencies instead of having to install them
2025-02-16 11:41:44 +00:00
Nic Newdigate 7ca327b6de Update README.md 2025-02-16 11:39:25 +00:00
newdigate 2b69addfb9 CMakeLists.txt 2025-02-15 15:47:48 +00:00
newdigate 57ac09fbb6 Merge remote-tracking branch 'origin/noinstall' into noinstall 2025-02-15 15:47:10 +00:00
newdigate a92d165ad4 CMakeLists.txt 2025-02-15 15:46:59 +00:00
Nic Newdigate 6cf24f5a7b Update README.md 2025-02-15 10:15:40 +00:00
Nic Newdigate afe44a46c1 Merge pull request #8 from newdigate/noinstall-latest
Noinstall latest
2025-02-15 10:13:03 +00:00
newdigate f85424bd43 include EventResponder.cpp in CMakeLists.txt 2025-02-15 09:47:02 +00:00
Nic Newdigate 0001f31369 Update README.md
add badge for basic-test github action
2025-02-09 19:47:30 +00:00
newdigate 54aff8b567 include EventResponder.cpp in CMakeLists.txt 2025-02-09 19:45:43 +00:00
Nic Newdigate a1561a1090 Merge pull request #7 from h4yn0nnym0u5e/feature/EventResponder
Feature/event responder
2025-02-09 19:07:56 +00:00
Jonathan Oakley 9ebf1d0464 Clean out some cruft
Make the EventResponder stub more stubby, removing
code we don't need or doesn't make sense within
a unit testing framework
2025-02-09 16:35:41 +00:00
Jonathan Oakley 6d5b34727b Added EventResponder stuff
May have broken other things ... we shall see
2025-02-09 15:58:53 +00:00
Nic Newdigate 819b3ab8e0 Update CMakeLists.txt
noinstall necessary
2024-10-12 09:54:59 +01:00
Newdigate f1a28e30be remove example projects from root CMakeLists.txt 2024-02-24 10:58:11 +00:00
Newdigate c3963b7b61 add a blink stetch! 2024-02-24 10:33:26 +00:00
Newdigate 6e5de9d46b just '\n' not '\r\n' 2024-02-24 10:23:10 +00:00
Newdigate b942e7a124 include corrections 2024-02-24 10:21:06 +00:00