Files
AutoFilm-ESP32/docs/megaplans/refactor/P05-hal-wroom-motion.md
gronod 9b2c6bf3ee
ci / test (push) Failing after 11s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (push) Skipped
ci / firmware (wroom, sdkconfig.wroom, esp32) (push) Skipped
ci / test (pull_request) Failing after 11s
ci / firmware (jc4827w543, sdkconfig.s3, esp32s3) (pull_request) Skipped
ci / firmware (wroom, sdkconfig.wroom, esp32) (pull_request) Skipped
Mark P05 BLOCKED pending P03 HAL and app_machine
P05 requires landed app_machine + hal_* headers. Those files are absent
and P03 is still TODO. Record the block; do not invent public APIs.
2026-09-16 11:43:12 +00:00

108 lines
3.7 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.
BLOCKED: P03 artifacts missing on branch refactor/esp-idf-modular-ui @ 415c13a.
Required and absent:
- components/app_machine/ (include/app_machine.h, app_machine.c)
- components/hal_motor/include/hal_motor.h
- components/hal_temp/include/hal_temp.h
- components/hal_audio/include/hal_audio.h
Megaplan table still lists P03 STATUS=TODO. Protocol: P05 requires P03 APIs.
Do not invent or change public HAL/app_machine APIs. Do not implement P01–P04 in this session.
No device HAL, tasks, Arduino-as-component, or main.c cutover landed.
# P05 — WROOM HAL motor / temp / audio
STATUS: BLOCKED
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
- [ ] EN HIGH at init and on stop
- [ ] stop_req checked inside step loop
- [ ] OneWire only in temp_task
- [ ] tone/LEDC only in audio_task
- [ ] STATUS→DONE