Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
08b2d91
plan: audit 2026-11-19, full, on b015593 (13 findings open)
arcadien Nov 19, 2026
7a31600
hw: WIRING analog input and JP3 match the netlist, v2.2 differences, …
arcadien Nov 19, 2026
af78a15
hw: BACKLOG statuses (R8 done, R19 in progress), superseded 2026-11-0…
arcadien Nov 19, 2026
b45a966
docs: Oregon v2.1, pre-push hook prefixes, env and test lists, v2.2-o…
arcadien Nov 19, 2026
c2419ca
req(TECH-HAL-004): JP6 delivered open (1-2 I2C 0x76, 2-3 SDO to PA5);…
arcadien Nov 19, 2026
e5eae5f
req(PLAT-POWER-007): v2.2 board checked on the bench (pull-ups to SEN…
arcadien Nov 19, 2026
d71affe
req(CONF-DECODE-002): CI artifacts firmware-tinydecoders-promicro and…
arcadien Nov 19, 2026
c7bdcba
req(CONF-DECODE-003): the Pro Micro is the production receiver (power…
arcadien Nov 19, 2026
dd3e4bb
req(CONF-DECODE-004): the Pro Mini is the alternative receiver build
arcadien Nov 19, 2026
ae484c6
req(CONF-BUILD-015): CI runs every emitter native env and builds ever…
arcadien Nov 19, 2026
7d2904b
arch(TECH-HAL-004): row states the PA5 DIDR0 input-buffer disable
arcadien Nov 19, 2026
9f20275
arch(PLAT-POWER-007): row records the v2.2 bench check
arcadien Nov 19, 2026
16cbc71
arch(CONF-DECODE-002): row gives the promicro and promini artifact names
arcadien Nov 19, 2026
b5c0e0a
arch(CONF-DECODE-003): the Pro Micro is the production receiver in th…
arcadien Nov 19, 2026
b880c7e
arch(CONF-DECODE-004): row marks the Pro Mini as the alternative build
arcadien Nov 19, 2026
1cb9aaa
arch(CONF-BUILD-015): row for the emitter CI coverage
arcadien Nov 19, 2026
0f7c612
conf(CONF-BUILD-015): CI tests native_cycle_oregon_divider and builds…
arcadien Nov 19, 2026
4122119
conf(CONF-DECODE-002): tinyDecoders artifacts firmware-tinydecoders-p…
arcadien Nov 19, 2026
4844a49
conf(CONF-DECODE-003): platformio.ini comments name the Pro Micro pro…
arcadien Nov 19, 2026
38cfc74
plan: audit 2026-11-19, all 13 findings fixed
arcadien Nov 19, 2026
23e0e01
req(TECH-HAL-004): bench check still pending (mushroom not reflashed …
arcadien Nov 19, 2026
9644991
req(PLAT-POWER-007): v2.2 pull-ups to SENSOR_VCC confirmed, BME280 be…
arcadien Nov 19, 2026
1bbc93d
arch(PLAT-POWER-007): row says the v2.2 bench check is pending
arcadien Nov 19, 2026
f28946b
plan: audit 2026-11-19 resolution notes the pending bench check
arcadien Nov 19, 2026
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
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Run native tests
run: pio test -d emitter -e native_debug -e native_cycle_oregon -e native_cycle_oregon_vcc -e native_cycle_lacrosse -e native_cycle_x10
run: pio test -d emitter -e native_debug -e native_cycle_oregon -e native_cycle_oregon_vcc -e native_cycle_oregon_divider -e native_cycle_lacrosse -e native_cycle_x10
- name: Run tinyDecoders native tests
run: pio test -d tinyDecoders -e native
- name: Compile-fail checks
Expand All @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
env: [S_02, S_03, S_04, S_05, robot, devmodule, SOLAR_TEST]
env: [S_02, S_03, S_04, S_05, robot, devmodule, SOLAR_TEST, mushroom]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
Expand All @@ -86,7 +86,7 @@ jobs:
if-no-files-found: error
retention-days: 30

# 433 MHz receiver firmware: promini (production), promicro (prototype)
# 433 MHz receiver firmware: promicro (production), promini (alternative build)
build-tinydecoders:
name: Build tinyDecoders
runs-on: ubuntu-latest
Expand All @@ -111,7 +111,7 @@ jobs:
- name: Upload promini firmware artifact
uses: actions/upload-artifact@v7
with:
name: firmware-tinydecoders
name: firmware-tinydecoders-promini
path: |
tinyDecoders/.pio/build/promini/firmware.hex
tinyDecoders/.pio/build/promini/firmware.elf
Expand Down Expand Up @@ -146,7 +146,6 @@ jobs:
mkdir release
for d in firmware/*/; do
n=$(basename "$d"); n=${n#firmware-}
[ "$n" = tinydecoders ] && n=tinydecoders-promini
for f in "$d"*; do cp "$f" "release/$n.${f##*.}"; done
done
ls release
Expand Down
19 changes: 10 additions & 9 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
PlatformIO is the build system. The emitter firmware is the PlatformIO project in `emitter/` (`src/`, `include/`, `test/`, `platformio.ini`); `lib/` at the repository root is shared with the receiver `tinyDecoders/`. On this machine `pio` runs as `uvx --from platformio pio`. Run from the repository root:

```bash
# Run all native tests (fast — runs on host, no hardware needed)
pio test -d emitter -e native_debug
# Run all native tests (fast — runs on host, no hardware needed).
# native_debug ignores test_main_cycle, which runs in the native_cycle_* environments.
pio test -d emitter -e native_debug -e native_cycle_oregon -e native_cycle_oregon_vcc -e native_cycle_oregon_divider -e native_cycle_lacrosse -e native_cycle_x10

# Run a single test suite
pio test -d emitter -e native_debug -f test_oregon
Expand All @@ -27,7 +28,7 @@ Paths below without a folder (`src/`, `include/`, `test/`, `platformio.ini`) are

## Architecture

The firmware is entirely build-time configured: every physical sensor unit is a separate PlatformIO environment (`S_02`–`S_05`, `robot`, `devmodule`, `SOLAR_TEST`), each with its own `build_flags` selecting the protocol, sensor type, calibration values, and sleep interval. There is no runtime configuration.
The firmware is entirely build-time configured: every physical sensor unit is a separate PlatformIO environment (`S_02`–`S_05`, `robot`, `devmodule`, `SOLAR_TEST`, `mushroom`), each with its own `build_flags` selecting the protocol, sensor type, calibration values, and sleep interval. There is no runtime configuration.

### HAL abstraction

Expand All @@ -42,7 +43,7 @@ Protocol encoders receive a `Hal*` at construction and call only HAL methods —

| Library | Class | Protocol | Output |
|---|---|---|---|
| `lib/oregon` | `OregonV3` | Oregon Scientific v3 | 433 MHz OOK via `RadioGoHigh/Low` |
| `lib/oregon` | `OregonV3` | Oregon Scientific v2.1 (frame layout; the class keeps its old name) | 433 MHz OOK via `RadioGoHigh/Low` |
| `lib/LacrosseWS7000` | `LacrosseWS7000` | Lacrosse WS7000 | same |
| `lib/x10` | `x10rf` | X10 RF | same — used for battery/analog reporting |
| `lib/softSerial` | `SoftSerial` | UART (debug only) | via `SerialWriteBit` |
Expand All @@ -51,17 +52,17 @@ Protocol encoders receive a `Hal*` at construction and call only HAL methods —

### Test approach

Tests run on the host (`-e native_debug`, `-DNATIVE`). The test harness instantiates `TestHal_` and passes it to the encoder under test. Protocol correctness is verified by checking the `Orders` vector against expected character sequences — e.g., a zero bit must produce `{'H','D','L','P','H','D'}`. This verifies timing ordering without hardware.
Tests run on the host (`-e native_debug` and the `native_cycle_*` environments, `-DNATIVE`). The test harness instantiates `TestHal_` and passes it to the encoder under test. Protocol correctness is verified by checking the `Orders` vector against expected character sequences — e.g., a zero bit must produce `{'H','D','L','P','H','D'}`. This verifies timing ordering without hardware.

Test suites: `test_oregon`, `test_lacrosseWS7000`, `test_x10`, `test_conversionTools`, `test_analogFiltering`, `test_power`, `test_led`, `test_softSerial`, `test_ds18b20`, `test_x10_hal`, `test_environment`, `test_main_cycle`.
Test suites: `test_oregon`, `test_lacrosseWS7000`, `test_x10`, `test_conversionTools`, `test_analogFiltering`, `test_power`, `test_led`, `test_softSerial`, `test_ds18b20`, `test_x10_hal`, `test_environment`, `test_main_cycle` (only in `native_cycle_*`).

### `src/main.cpp`

`main()` is a single `while(1)` loop: power on sensors → `ReadEnvironment()` fills a `Measurements` (`include/Measurements.h`) → X10 meters → luminosity → environment frame → power off → hibernate. The environment protocol is a build-time alias, `EnvironmentEncoder` (`include/EnvironmentEncoder.h`), loaded with `ApplyMeasurements()` — no virtual call. Luminosity (`LightSensor`, BH1750) always goes out through a dedicated Lacrosse encoder. Sensor selection stays via `#ifdef` (`USE_BMP280` / `USE_BME280` / `USE_DS18B20` / `USE_BH1750`); wrappers (`BMx280`, `Ds18b20`, `LightSensor`) take a `Hal*` and stub out on native builds. Details: `docs/architecture.md`, section *Main loop structure*.
`main()` loops on `runCycle(&hal)`; one cycle: power on sensors → `ReadEnvironment()` fills a `Measurements` (`include/Measurements.h`) → X10 meters → luminosity → environment frame → power off → hibernate. The environment protocol is a build-time alias, `EnvironmentEncoder` (`include/EnvironmentEncoder.h`), loaded with `ApplyMeasurements()` — no virtual call. Luminosity (`LightSensor`, BH1750) always goes out through a dedicated Lacrosse encoder. Sensor selection stays via `#ifdef` (`USE_BMP280` / `USE_BME280` / `USE_DS18B20` / `USE_BH1750`); wrappers (`BMx280`, `Ds18b20`, `LightSensor`) take a `Hal*` and stub out on native builds. Details: `docs/architecture.md`, section *Main loop structure*.

### Debugging

Step-debugging uses PlatformIO + AVaRICE + AVR Dragon over debugWIRE (the legacy Atmel Studio tree was removed). Toolchain, DWEN fuse procedure and hardware constraints (dedicated debug board) are in [`docs/debugging.md`](docs/debugging.md).
Step-debugging uses PlatformIO + AVaRICE + AVR Dragon over debugWIRE (the legacy Atmel Studio tree was removed). Toolchain, DWEN fuse procedure and hardware constraints (v3.0 meets them with R5 10 kΩ and no RESET capacitor; v2.2 and earlier need a dedicated debug board) are in [`docs/debugging.md`](docs/debugging.md).

### RBD workflow

Expand Down Expand Up @@ -133,7 +134,7 @@ Current-limiting and pull resistors sit **at the board end**, never at the LED o
Strip EXIF/GPS from every image before committing: `python3 ~/.claude/skills/hardware-change/scripts/strip_exif.py <paths>` (`--check` to verify).

### Commits
No pre-push hook; prefixes are the RBD ones above plus `hw:` for hardware (`enclosing/`, `hardware/`) and `docs:` for doc-only commits. Make granular commits, one per area, and push after each.
The rbd plugin's pre-push hook (a Claude Code hook on `git push`) checks the prefixes. It accepts the RBD ones above (`req()`…`arch()` must cite a validated ID), `plan:`, `hw:` for hardware (`enclosing/`, `hardware/`, from `.rbd/config.yml` `extra_commit_prefixes`), `docs:` for doc-only commits, and `fix:`, `chore:`, `style:`, `refactor:`. Make granular commits, one per area, and push after each.

## Modeling

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Large part of the code, especially wireless encoders, are unit-tested.
* "one pin" emitters. Tested with low-cost 433 MHz emitters.

## Wireless protocols
* Environment frame (temperature, humidity, pressure): Oregon Scientific v3 **or** Lacrosse WS7000, at most one per build. A build without either sends no environment frame.
* Environment frame (temperature, humidity, pressure): Oregon Scientific v2.1 (class `OregonV3`) **or** Lacrosse WS7000, at most one per build. A build without either sends no environment frame.
* Luminosity: always a dedicated Lacrosse WS7000 frame (Oregon has no light frame), so `LACROSSE_ID` is required whenever the BH1750 is fitted.
* Battery level and analog input: optional X10 RFXmeter frames, not sent when the battery is low.

Expand All @@ -45,19 +45,20 @@ Various libraries are used here, and some where tweaked to remove any Arduino de

## Development

The firmware is built with [PlatformIO](https://platformio.org/) and configured entirely at build time: each physical sensor is one PlatformIO environment (`S_02`…`S_05`, `robot`, `devmodule`, `SOLAR_TEST`) whose `build_flags` select protocol, sensors and calibration. See [docs/environments.md](docs/environments.md) to calibrate or add a board.
The firmware is built with [PlatformIO](https://platformio.org/) and configured entirely at build time: each physical sensor is one PlatformIO environment (`S_02`…`S_05`, `robot`, `devmodule`, `SOLAR_TEST`, `mushroom`) whose `build_flags` select protocol, sensors and calibration. See [docs/environments.md](docs/environments.md) to calibrate or add a board.

```bash
pio test -d emitter -e native_debug # encoder and library unit tests, on the host
pio test -d emitter -e native_cycle_oregon # one measurement cycle (runCycle) per build variant;
# also native_cycle_oregon_vcc, _lacrosse, _x10
# also native_cycle_oregon_vcc, _oregon_divider,
# _lacrosse, _x10
pio run -d emitter -e S_02 # firmware for one board
pio run -d emitter -e S_02 -t upload # flash it
```

> **Flashing with a BME280 plugged in.** ISP and I2C share the ATtiny84A pins PA4 (SCK / SCL) and PA6 (MOSI / SDA). On **v3.0**, R9 and R10 (330 Ω) sit in series between the MCU and the sensor connectors J3/J14, so the programmer drives SCK and MOSI without the sensor holding them: the board should flash with the BME280 in place (not yet checked on a built board). On **v2.2 and earlier**, unplug the BME280 before flashing, otherwise flashing fails; always wire it through its JST connector, never solder it to the board.

CI runs the native tests, compile-fail checks for invalid flag combinations (`emitter/test/compile_fail/`), sensor-variant checks (`emitter/test/build_variants/`), `clang-format` and a build of every board.
CI runs the native tests (`native_debug` and every `native_cycle_*`), compile-fail checks for invalid flag combinations (`emitter/test/compile_fail/`), sensor-variant checks (`emitter/test/build_variants/`), `clang-format` and a build of every board (including `mushroom`).

* Architecture: [docs/architecture.md](docs/architecture.md)
* Step debugging over debugWIRE: [docs/debugging.md](docs/debugging.md)
Expand All @@ -72,7 +73,7 @@ The cycle for each change:
1. **Requirement.** The change is first written as a requirement with an ID such as `FUNC-OREGON-001` (category, domain, number), a status (`validated` or `draft`) and its dependencies.
2. **Tests.** Tests are written next. Each Unity test function carries the ID it verifies on the line above it: `// @req FUNC-OREGON-001`. Requirements that no host test can observe (AVR registers, wiring, bench measurements) say instead how they are verified: by inspection, by a build, or on the bench.
3. **Code.** The code then makes the tests pass. The linter (`clang-format` 18.1.8) and the full native test suite must pass before each commit.
4. **Commit.** Each commit names what it serves: `req(ID):`, `test(ID):`, `feat(ID):`, `tech(ID):`, `conf(ID):` or `arch(ID):`; `plan:` for workflow files; `hw:`, `docs:`, `fix:` or `chore:` outside the code cycle. A pre-push hook rejects a code commit whose ID is missing or not `validated`.
4. **Commit.** Each commit names what it serves: `req(ID):`, `test(ID):`, `feat(ID):`, `tech(ID):`, `perf(ID):`, `ui(ID):`, `conf(ID):` or `arch(ID):`; `plan:` for workflow files; `hw:`, `docs:`, `fix:`, `chore:`, `style:` or `refactor:` outside the code cycle (`hw:` is added in `.rbd/config.yml`, `extra_commit_prefixes`). The rbd plugin's pre-push hook rejects any other prefix, and a code commit whose ID is missing or not `validated`.

`git log --grep FUNC-MAIN-001` and `grep -rn FUNC-MAIN-001 emitter/test` show where a requirement was written, tested and implemented.

Expand Down
Loading