Files

101 lines
3.7 KiB
Markdown

# N7 board-side action API
The macros below construct C steps in the authoritative
`firmware/application/ota_self_compose_plan.h`. The build helper copies that file
into a clean generated compiler tree on every build; do not edit or reuse
`build/gcc/application_source`. The runtime reads the board's restored/live Hall
position at each step. `mm_x100` and `degree_x100` are fixed point with two decimals.
## Direction and range
| Axis | Motor | Fixed Hall | Physical range | Toward far | Toward near |
|---|---:|---:|---:|---|---|
| 前后 | 0 | 480 | 215.00 mm | `OTA_SEAT_SLIDE_BACKWARD` | `OTA_SEAT_SLIDE_FORWARD` |
| 高度/坐盆 | 1 | 373 | 55.00 mm | `OTA_SEAT_HEIGHT_UP` | `OTA_SEAT_HEIGHT_DOWN` |
| 靠背 | 2 | 917 | 68.00° | `OTA_SEAT_BACKREST_RECLINE_DOWN` | `OTA_SEAT_BACKREST_RAISE` |
| 腿托 | 3 | 647 | 72.00° | `OTA_SEAT_LEGREST_RAISE` | `OTA_SEAT_LEGREST_LOWER` |
Nearest is position zero. Normal DIY Hall bounds are 24..456, 19..354, 46..871,
and 33..614 for motors 0..3. Do not seek the physical 0%/100% endpoint from an
ordinary DIY image. If board position is invalid, do not blind-move the mechanism.
## Speed and stall
- `OTA_SEAT_SPEED_LOW`: 60%
- `OTA_SEAT_SPEED_MEDIUM`: 80%
- `OTA_SEAT_SPEED_HIGH`: 95%
- `OTA_SEAT_SPEED_DEFAULT`: 80%
- `OTA_SEAT_SPEED_CUSTOM(n)`: custom 1%..95%
Motor 3 ignores the duty argument and always uses 60%. After each actual PWM start
or reversal, its Hall stall window starts only after 2 seconds. In the following
continuous 1000 ms window, at most 2 rising edges is stall; at least 3 is movement.
## Actions
Timed motion:
```c
OTA_SEAT_SLIDE_FOR(direction, durationMs, duty, pauseMs)
OTA_SEAT_HEIGHT_FOR(direction, durationMs, duty, pauseMs)
OTA_SEAT_BACKREST_FOR(direction, durationMs, duty, pauseMs)
OTA_SEAT_LEGREST_FOR(direction, durationMs, duty, pauseMs)
```
If a timed action reaches 5% or 95%, it reverses and continues the remaining time.
Absolute board position:
```c
OTA_SEAT_SLIDE_TO(positionMmX100, duty, pauseMs)
OTA_SEAT_HEIGHT_TO(positionMmX100, duty, pauseMs)
OTA_SEAT_BACKREST_TO(angleDegX100, duty, pauseMs)
OTA_SEAT_LEGREST_TO(angleDegX100, duty, pauseMs)
```
Relative distance/angle:
```c
OTA_SEAT_SLIDE_BY(direction, distanceMmX100, duty, pauseMs)
OTA_SEAT_HEIGHT_BY(direction, distanceMmX100, duty, pauseMs)
OTA_SEAT_BACKREST_BY(direction, angleDegX100, duty, pauseMs)
OTA_SEAT_LEGREST_BY(direction, angleDegX100, duty, pauseMs)
```
Absolute and relative targets clamp to the axis's 5%..95% interval and stop there.
Cycles:
```c
OTA_SEAT_SLIDE_CYCLE(firstDirection, cycles, duty, endpointPauseMs)
OTA_SEAT_HEIGHT_CYCLE(firstDirection, cycles, duty, endpointPauseMs)
OTA_SEAT_BACKREST_CYCLE(firstDirection, cycles, duty, endpointPauseMs)
OTA_SEAT_LEGREST_CYCLE(firstDirection, cycles, duty, endpointPauseMs)
```
One cycle is two boundary legs. `cycles == 0` continues until explicit STOP or a
user-requested program duration. The board owns execution after one `TEST_START`.
## Required CAN position contract
Retain the Base `SEAT_INFO` implementation at 500 kbit/s using request ID `0x6A0`
and response ID `0x6A2`, DLC 8. Selectors 0..14 retain their existing job, four live
position/range, four flags, four physical range, persistent state, and runtime-kind
meanings. Continue servicing these queries and explicit STOP during every action,
but never use communication activity as an action lease.
## Minimal C plan
```c
#define OTA_SELF_COMPOSE_STEP_COUNT (2u)
#define OTA_SELF_COMPOSE_PROGRAM_REPEAT (1u)
#define OTA_SELF_COMPOSE_MAX_RUNTIME_MS (0ul)
static const ota_self_compose_step_t otaSelfComposePlan[] =
{
OTA_SEAT_HEIGHT_TO(3000ul, OTA_SEAT_SPEED_MEDIUM, 200ul),
OTA_SEAT_BACKREST_BY(OTA_SEAT_BACKREST_RECLINE_DOWN, 3000ul,
OTA_SEAT_SPEED_CUSTOM(75u), 0ul),
};
```