Skip to content

Shared code blocks of the sprayer and seed drill programs marked, with a CI check - #113

Merged
renatorgr merged 1 commit into
mainfrom
shared-blocks-check
Nov 7, 2026
Merged

renatorgr merged 1 commit into
mainfrom
shared-blocks-check

Conversation

@renatorgr

Copy link
Copy Markdown
Owner

Sixth and last PR of the firmware review (after #108 to #112; stacked on page-cards, so GitHub retargets it once that one is merged).

What changes for Renato

  • The code the two ESP32 modules share is marked. The seed drill program grew out of the sprayer program, and 422 lines in 14 blocks are the same in both: the Wi-Fi and web helpers, the network settings (save, scan, restart, update), the common PGN cases (239, 229, 200, 238, 201) and the UDP receive, the relay driving, the Wi-Fi settings in flash, the checksum and the event log. Each block now starts with // ==== shared "name" and ends with // ==== end shared "name", the same name in both programs.
  • A new check, "Shared code", runs on every pull request that touches either program: .github/scripts/check_shared_blocks.py pairs the blocks by name and fails with a diff (file and line) when one program's block differs from the other's, or a block is missing, unclosed or nested. So a fix made to one module can no longer be forgotten in the other.
  • To make two more blocks identical: the sprayer's log line on saving the network settings now says "network settings saved from the page, restarting" (as the seed drill's, and as the page's card is called since Cards: Status tab reordered, Machine tab reads PGN 161, 64 sections on the XIAO, one Network settings card #112); the seed drill gets a masterOn that is always true, so applyOutputs() is the same code in both (no change in what the relays do).
  • A rule in CLAUDE.md and a note in both READMEs (Notes section). The sprayer's sources now name the seed drill module in these markers: that is the point of the check, but say so if you would rather keep the Sprayer folder free of it.

How to test

  • python3 .github/scripts/check_shared_blocks.py → "OK: 14 shared blocks, 422 lines the same in Sprayer_ESP32 and Seeder_ESP32".
  • Change one line inside a marked block of one program only and run it again: it fails and shows the diff with the file and line of both programs (tried here).
  • The modules behave as before: sprayer page Module tab → Save and restart, the Events card says "network settings saved from the page, restarting".

Checks

  • Sprayer and Seeder compile (arduino-cli, esp32 core 3.3.12); the simulator build + smoke test pass (the simulator's sprayer log line mirrors the new text); check_changelog.py OK.
  • Not touched: the Teensy and XIAO programs, the pages, what the modules send.

Generated by Claude Code

…h a CI check

- 14 blocks (422 lines) that are the same code in Sprayer_ESP32 and
  Seeder_ESP32 are marked `// ==== shared "name"` ... `// ==== end
  shared "name"`: web helpers, request helpers, the status log, the
  network settings POST and the Wi-Fi scan, restart and update, the
  common PGN cases, the subnet case and the UDP receive, the relay level
  and the output driving, the Wi-Fi settings load/save/reset, the
  checksum and the event log.
- .github/scripts/check_shared_blocks.py pairs the blocks by name and
  fails on a difference, a block missing from one program, an unclosed
  or nested block, with a diff that names the file and line. The "Shared
  code" GitHub Action runs it on every pull request that touches either
  program.
- To make two more blocks identical: the sprayer's log line on saving
  the network settings says "network settings" (as the seed drill's and
  the page's card); the seed drill gets a masterOn that is always true,
  so applyOutputs() is the same in both.
- Rule in CLAUDE.md; a note in both READMEs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VKEBDHXJYvAsZZ4zDMuykv
Base automatically changed from page-cards to main November 7, 2026 09:29
@renatorgr
renatorgr marked this pull request as ready for review November 7, 2026 09:29
@renatorgr
renatorgr merged commit d5941e4 into main Nov 7, 2026
4 checks passed
@renatorgr
renatorgr deleted the shared-blocks-check branch November 7, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants