Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ Checks: >
-bugprone-easily-swappable-parameters,
-cert-err58-cpp,
-bugprone-throwing-static-initialization,
-modernize-concat-nested-namespaces,
-misc-include-cleaner
-modernize-concat-nested-namespaces
# MaxMatrix's own, for good:
# cert-err58-cpp, bugprone-throwing-static-initialization, its name in clang-tidy 23: reports
# the simulator's static objects, which a sketch has as well: a static
Expand All @@ -60,10 +59,6 @@ Checks: >
# shapes and of internal::Panel::ConvertDotToBuffer(), the three pins of internal::Chain, a
# port and its mask, and the same in the host code. FN-16 asks for a type each, which the
# review of FN-16 in OIL 41 weighs against the shapes' parameters as Adafruit GFX names them.
# misc-include-cleaner, apart from the rest of misc-*: some 540 places, a header included
# for every symbol it provides, and its fix names <cstdint>, which avr-gcc lacks, and
# <avr/pgmspace.h>, which the host lacks. Its includes are written by hand, in a pull request
# of their own.
# house-*: the checks of our own, in tools/lib/tidy_module/; tools/tidy.sh loads them. Without
# the module, as in clangd, the name matches nothing. house-bitwise-in-bit-class takes the
# bit class to be any class named Bit (docs/CodingStyle.md H-9); a project whose class has
Expand Down Expand Up @@ -182,7 +177,13 @@ CheckOptions:
# include-cleaner does not take back to <avr/io.h>. Any core's folder, not
# only cores/arduino/ of Arduino's: a third party's core has its own, as
# cores/xmega/ of XMegaForArduino's, where Serial comes from.
misc-include-cleaner.IgnoreHeaders: '.*/cores/[^/]+/.*;.*/variants/.*;.*/avr/io[^/]*\.h'
# MaxMatrix's own, at the end, alike: a header that a public one includes and
# include-cleaner takes for the provider of a name. avr/common.h, SREG's,
# which <avr/io.h> includes; glibc's bits/ and sys/poll.h, which <poll.h>,
# <sys/socket.h> and <sys/time.h> include; Linux's asm-generic/, through
# <sys/ioctl.h>; and the port of wxWidgets, wx/gtk/ and wx/generic/, which
# wx/panel.h or wx/app.h include, and which a build on Windows does not have.
misc-include-cleaner.IgnoreHeaders: '.*/cores/[^/]+/.*;.*/variants/.*;.*/avr/io[^/]*\.h;.*/avr/common\.h;.*/bits/.*;.*/sys/poll\.h;.*/asm-generic/.*;.*/wx/(gtk|generic)/.*'
# Google's names, which readability-identifier-naming checks only once it is told them; the
# same block in every project, so that every project names alike. Two exceptions Google
# makes itself are general: an accessor is named like the variable it gives (group(),
Expand Down
11 changes: 10 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ does the same from `simulator/` (`"Host/SimulatorSerialHost.h"`), in its own fil
tests. A header includes what it uses itself, rather than relying on a header included before
it.

Every file includes what it uses (F-5, `misc-include-cleaner`), the C library's headers as
`<stdint.h>`, as avr-gcc has no `<cstdint>`. `MaxMatrix.h` exports the headers whose names a
sketch uses, with `// IWYU pragma: export`, so that a sketch includes it alone and, of avr-libc,
what it uses itself, as `<avr/pgmspace.h>`; a new public header is exported there as well.
`MaxMatrixTestSupport.h` exports `MaxMatrix.h` to the tests, which must see the library after
`#define private public`: a test that included `"Font/Font.h"` itself would have it sorted
before the define, and lose its private members.

#### Comments

Comments say *why*, not what — the reasoning that is not recoverable from the code, such as
Expand Down Expand Up @@ -561,7 +569,8 @@ MD_MAX72XX gives those names; the README's table says the same and changes with
The mock has a `Serial` that reads `mock::serial_input` and appends what the sketch prints to
`mock::serial_output`, so that `SerialControl` builds into a simulator as well; `F()`, `PSTR()`,
`strcmp_P()` and `pgm_read_ptr()` take strings in RAM there, as the host has no separate flash, but
`F()` keeps the type `__FlashStringHelper const*` of the core.
`F()` keeps the type `__FlashStringHelper const*` of the core. What avr-libc declares lies in
`test/mock/avr/`, as on the board, so that a file includes the same header for both.
The mock also has `millis()`, `micros()` and `delay()` on the host clock, for the simulator;
`delay()` really waits. A test that times something holds the clock with `mock::SetMillis()`
instead, until the next `mock::Reset()`; `delay()` then moves it on without waiting. The library
Expand Down
23 changes: 21 additions & 2 deletions OIL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Status: `open`, `in progress`, `done`, `dropped` (with the reason in the item).
| 38 | Results that must not be ignored | 36 | done | #94 |
| 39 | MC/DC coverage | 34 | done | #95, #96 |
| 40 | Braced initialization checked | 34 | done | #93 |
| 41 | The template's rules that review checks | 36 | in progress | #99, #100, #101, #102, #104, #105, #106, #107 |
| 41 | The template's rules that review checks | 36 | in progress | #99, #100, #101, #102, #104, #105, #106, #107, #113 |
| 42 | A newer avr-gcc as a cross-check | 41 | done | |
| 43 | Bit operations in one class, from the template | 41 | done | #109 |

Expand Down Expand Up @@ -1036,7 +1036,26 @@ A first look found, besides those two:
the rule, assignability, where the rule says never. That is the template's to take up, in
the rule's text or its "Checked by". `Batch` was the only such member in the repository.
- F-5: `misc-include-cleaner` is still off, with some 540 places, waiting for the pull request
36 named for it.
36 named for it. As built, it is on, and every file includes what it uses: some 175 includes
in 59 files, and 7 that nothing used are gone. The C library's headers are written as
`<stdint.h>` and `<stddef.h>`, as the template and Utl write them, since avr-gcc has no
`<cstdint>`. `MaxMatrix.h` exports the headers whose names a sketch uses, with
`// IWYU pragma: export`, so that a sketch includes it alone and, of avr-libc, what it uses
itself: `<stdint.h>`, and `<avr/pgmspace.h>` where it keeps a table in flash.
`MaxMatrixTestSupport.h` exports `MaxMatrix.h` to the tests, which must see the library after
`#define private public`. The mock has avr-libc's `avr/pgmspace.h`, `avr/io.h` and
`avr/interrupt.h`, as the core has them, so that a file of the library includes the same
header on the host and the board.

Where include-cleaner takes for a name's provider a header that a public one includes,
`IgnoreHeaders` leaves it out, as the template does for `avr/io*.h`, decided on 2026-11-16
against a NOLINT on each of some 20 lines: `avr/common.h`, where `SREG` is, which the
template's pattern misses as well and is the template's to take up; glibc's `bits/` and
`sys/poll.h`, Linux's `asm-generic/`, and the GTK port of wxWidgets. Six includes that the
check takes for unused stay, with `// IWYU pragma: keep`: four of wxWidgets that only include
the port's header, `<sys/time.h>` for `timeval`, and `MaxMatrixConfig.h` in
`MaxMatrixErrorReport.cpp`, whose switch the variant with `MAXMATRIX_DEV_ERROR_DETECT` sets
with `-D`. Every example is the same size in every variant.
- S-5: the reasons in `.clang-tidy` for `bugprone-easily-swappable-parameters` and
`bugprone-too-small-loop-variable` name `MaxMatrixChain` and `MAXMATRIX_NUMBER_OF_COLUMNS`,
which are gone. As built, every check the project turns off was run again with clang-tidy 23.
Expand Down
1 change: 1 addition & 0 deletions control/ControlCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "ControlCommand.h"

#include <ctype.h>
#include <stdint.h>
#include <stdlib.h>

#include <array>
Expand Down
6 changes: 6 additions & 0 deletions control/ControlDotPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
#include "ControlDotPanel.h"

#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <wx/dcbuffer.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/types.h>

#include <algorithm>
#include <functional>
#include <utility>
#include <vector>

#include "ControlCommand.h"
#include "MaxMatrixConfig.h"
Expand Down
4 changes: 4 additions & 0 deletions control/ControlLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@

#include "ControlLink.h"

#include <stddef.h>
#include <stdint.h>

#include <string>
#include <utility>
#include <vector>

#include "ControlCommand.h"
#include "ControlPort.h"

ControlLink::ControlLink(ControlPort& port) : port_{port} {}

Expand Down
3 changes: 3 additions & 0 deletions control/ControlSerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <termios.h>
#include <unistd.h>
#endif
#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <array>
#include <string>
Expand Down
4 changes: 3 additions & 1 deletion control/ControlTcpPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#endif
#include <stddef.h>
#include <stdint.h>

#include <array>
#include <string>

Expand Down
16 changes: 12 additions & 4 deletions control/ControlWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@
#include "ControlWindow.h"

#include <inttypes.h>
#include <stdint.h>
#include <wx/aboutdlg.h>
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/combobox.h>
#include <wx/button.h> // IWYU pragma: keep
#include <wx/checkbox.h> // IWYU pragma: keep
#include <wx/combobox.h> // IWYU pragma: keep
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/menu.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/spinctrl.h>
#include <wx/statbox.h>
#include <wx/statbox.h> // IWYU pragma: keep
#include <wx/stattext.h>
#include <wx/strconv.h>
#include <wx/stringimpl.h>
#include <wx/textctrl.h>
#include <wx/timer.h>
#include <wx/types.h>

#include <array>
#include <chrono>
Expand All @@ -32,6 +39,7 @@

#include "ControlCommand.h"
#include "ControlDotPanel.h"
#include "ControlLink.h"
#include "MaxMatrixConfig.h"

namespace {
Expand Down
2 changes: 2 additions & 0 deletions docu/DocuPictures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* fails when the library changes and the pictures were not written again.
*/

#include <stdint.h>
#include <string.h>

#include <array>
Expand All @@ -29,6 +30,7 @@

#include "Arduino.h"
#include "DocuSvg.h"
#include "Max7219.h"
#include "MaxMatrix.h"
#include "Utility/Bit.h"

Expand Down
3 changes: 3 additions & 0 deletions docu/DocuSvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#include "DocuSvg.h"

#include <stdint.h>

#include <sstream>
#include <string>

namespace {
Expand Down
1 change: 1 addition & 0 deletions examples/Animation/Animation.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <stdint.h>

uint32_t const kStepIntervalMs{40};

Expand Down
2 changes: 2 additions & 0 deletions examples/Band/Band.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
#include <stdint.h>

uint32_t const kStepIntervalMs{60};

Expand Down
1 change: 1 addition & 0 deletions examples/Basics/Basics.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <stdint.h>

/* a chain of four modules, with the buffer for them; one of eight is
* max_matrix::MatrixOf<8> */
Expand Down
1 change: 1 addition & 0 deletions examples/Messages/Messages.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <stdint.h>

/* a text must stay valid while it is shifted, so none of them is a local
* variable; the blanks at the end let it leave the matrix before the next one
Expand Down
1 change: 1 addition & 0 deletions examples/ScrollText/ScrollText.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* is max_matrix::MatrixOf<8>.
*/
#include <MaxMatrix.h>
#include <stdint.h>

uint8_t const kDataInPin{11};
uint8_t const kChipSelectPin{10};
Expand Down
1 change: 1 addition & 0 deletions examples/SerialControl/SerialControl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <stdint.h>

uint8_t const kDataInPin{11};
uint8_t const kChipSelectPin{10};
Expand Down
2 changes: 2 additions & 0 deletions examples/Shapes/Shapes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
#include <stdint.h>

uint32_t const kShowMs{1000};
uint8_t const kNumberOfShapes{4};
Expand Down
1 change: 1 addition & 0 deletions examples/Sprites/Sprites.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* DIN -> 11, CS -> 10, CLK -> 13
*/
#include <MaxMatrix.h>
#include <stdint.h>

uint16_t const kStepDelayMs{100};
int16_t const kSpriteY{2};
Expand Down
6 changes: 6 additions & 0 deletions simulator/Avr/SimulatorAvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
#include <avr_ioport.h>
#include <avr_spi.h>
#include <avr_uart.h>
#include <sim_avr.h>
#include <sim_avr_types.h>
#include <sim_elf.h>
#include <sim_io.h>
#include <sim_irq.h>
#include <sim_time.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>

#include "Arduino.h"
Expand Down
2 changes: 2 additions & 0 deletions simulator/Avr/mainAvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* of an example that moves.
*/

#include <stdint.h>

#include <chrono>
#include <iostream>
#include <thread>
Expand Down
3 changes: 3 additions & 0 deletions simulator/Host/SimulatorSerialHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#include "SimulatorSerialHost.h"

#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

#include <array>
Expand Down
7 changes: 5 additions & 2 deletions simulator/Host/SimulatorSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

#include "SimulatorSocket.h"

#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/time.h> // IWYU pragma: keep: timeval, which glibc declares in bits/
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

#include <string>
Expand Down
4 changes: 4 additions & 0 deletions simulator/Host/SimulatorWebHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
#include "SimulatorWebHost.h"

#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

#include <array>
#include <fstream>
#include <sstream>
#include <string>
Expand Down
2 changes: 2 additions & 0 deletions simulator/Host/SimulatorWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "SimulatorWebSocket.h"

#include <ctype.h>
#include <stddef.h>
#include <stdint.h>

#include <array>
#include <string>
Expand Down
4 changes: 4 additions & 0 deletions simulator/SimulatorFrontEnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

#include "SimulatorFrontEnd.h"

#include <stdint.h>

#include <iostream>
#include <string>

#include "Arduino.h"
#include "SimulatorOptions.h"
#include "SimulatorPanel.h"
#include "SimulatorTerminal.h"

SimulatorFrontEnd::SimulatorFrontEnd() = default;
Expand Down
Loading
Loading