Files
gronod 0b1d14d21a
ci / test (push) Successful in 2m10s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Failing after 1m19s
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Failing after 1m19s
ci / test (pull_request) Successful in 1m58s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (pull_request) Failing after 9m11s
ci / firmware (wroom, sdkconfig.wroom, esp32) (pull_request) Failing after 9m12s
Add temp and audio tasks off the UI path
2026-09-16 13:07:51 +00:00

96 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# P05 — WROOM HAL motor / temp / audio
STATUS: DONE
DEPENDS: P03
READ: this file, `include/config.h`, `src/motor.cpp`, `src/temperature.cpp`, `src/sound.cpp`, `components/hal_*/include/*.h`
OUT: rewriting `app_ui` / deleting menus; S3 motor pins; disabling WDT; `vTaskDelete` motor
FORBIDDEN: new Arduino libraries; `tone()` on machine task; blocking OneWire on UI task
## IN
Device implementations of `hal_motor`, `hal_temp`, `hal_audio` for `board_wroom`. Arduino-as-component **first allowed here**.
Keep AccelStepper behind `hal_motor`. Inner step loop **must** sample `stop_req` every `stepper.run()` and exit. Motor task is immortal: wait on notification for next `agitate_start`.
## Arduino component
`main/idf_component.yml`:
```yaml
dependencies:
espressif/arduino-esp32: "~3.1.0"
```
If 3.1 conflicts with IDF 5.4, pin the combo that compiles; Notes the versions. Only WROOM firmware enables Arduino this phase; S3 may compile without motor SRCS via `if(AUTOFILM_BOARD STREQUAL wroom)`.
AccelStepper: add as managed component **or** vendor `components/third_party/AccelStepper` (upstream 1.64). Prefer `idf_component.yml` git dep if it builds; else vendor the .cpp/.h used today.
OneWire + DallasTemperature: same policy. Keypad/LCD **not** this phase.
## Pins (wroom only, from config)
| fn | gpio |
|---|---|
| STEP | 12 |
| DIR | 14 |
| EN active-low | 27 |
| DS18B20 | 13 |
| beep | 25 |
`STEPS_PER_REV=4800` `RPM=60` `ACCEL=9600` `TEMP_OFFSET=0.4f`
## motor_task
Priority high, core 0. Loop:
```
wait notify
while !stop_req && agitating:
move CW cw_revs (run loop checks stop_req)
if stop_req break
move CCW ccw_revs
hal_motor_enable(false)
```
`hal_motor_request_stop`: atomic stop_req=1; `gpio_set_level(EN,1)` **immediately**; notify. ISR-safe: no heap, no stepper API.
Never `vTaskDelete`.
## temp_task
Low prio. Period: request conversion, `vTaskDelay(750ms)`, read, add 0.4, `app_machine_on_temp`. On disconnect `ok=false`. Do not write LCD.
## audio_task
Queue of `{SHORT, ALARM, CANCEL}`. SHORT: one 2 kHz 80–120 ms pulse (LEDC or Arduino `tone` **in this task only**). ALARM: 10× (2000 Hz 500 ms on / 250 ms off) **abort immediately on CANCEL or STOP queued**. Machine never `delay`s for sound.
## main.c (wroom)
`hal_*_init`, `app_process_init`, `app_machine_init`, create motor/temp/audio tasks. Do not start UI yet (P06). Optional: 1 Hz log remaining if RUNNING for bring-up.
S3 build: stub motor/temp/audio weak symbols or board-local no-ops so P01 S3 still links.
## VERIFY
Host tests still pass.
WROOM `idf.py` build pass.
Manual on hardware (if unavailable, Notes=`hw not flashed`; still land code):
1. Custom start (will need P06 for keypad — this phase may expose a 5 s auto-demo **behind `#ifdef AUTOFILM_MOTION_SMOKE` default off**). Do not enable smoke in production sdkconfig.
2. Logic-analyzer optional. Minimum: compile + review EN init HIGH.
## COMMITS
1. `Add Arduino-as-component and WROOM motor HAL with cooperative stop`
2. `Add temp and audio tasks off the UI path`
## DoD
- [x] EN HIGH at init and on stop
- [x] stop_req checked inside step loop
- [x] OneWire only in temp_task
- [x] tone/LEDC only in audio_task
- [x] STATUS→DONE