|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A simulated ESC in its stick menu. More...
Enumerations | |
| enum | seg_t { SEG_NONE = 0 , SEG_BEEP , SEG_GAP , SEG_PAUSE , SEG_WAIT } |
| Segment of the sound the simulated ESC is making. More... | |
Functions | |
| void | esc_sim_defaults (esc_sim_cfg_t *c) |
| Fill a simulator config with its default settings. | |
| void | esc_sim_init (esc_sim_t *s, const esc_profile_t *p, const esc_sim_cfg_t *c) |
| Start a simulated ESC on a profile. | |
| uint8_t | esc_sim_stored (const esc_sim_t *s, uint8_t item) |
| Value stored for an item. | |
| static esc_throttle_t | classify (float pct) |
| Classify a throttle percentage as a position. | |
| static esc_throttle_t | listen_pos (const esc_sim_t *s) |
| Where the stick rests while the menu sounds: the profile's listen position, else where this power-up entered. | |
| static bool | enters_from (const esc_profile_t *p, esc_throttle_t pos) |
Whether a power-up at pos enters the menu: the profile's entry, or the position any value is programmed from. | |
| static esc_throttle_t | value_entry (const esc_profile_t *p, uint8_t item, uint8_t value) |
The position the value numbered value of item item is programmed from. | |
| static bool | two_stage (const esc_profile_t *p) |
| Whether a profile has a two-stage menu. | |
| static void | add_sorted (esc_sim_t *s, uint8_t v) |
| Add a number to the loop, in ascending order. | |
| static void | add_extra (esc_sim_t *s) |
| Add the extra groups past the highest number. | |
| static void | build_loop (esc_sim_t *s) |
| The loop a mode sounds: the items, one item's values, or every value. | |
| static uint32_t | pulse_ms (const esc_sim_t *s) |
| Length of the pulse being sounded. | |
| static void | start_beep (esc_sim_t *s, uint32_t at) |
| Start one pulse of a group. | |
| static void | start_group (esc_sim_t *s, uint32_t at, uint8_t n, bool menu, bool tone) |
A group of n beeps, longs first, or one long tone when tone. | |
| static void | sound_next (esc_sim_t *s, uint32_t at) |
| Sound the next group of the loop. | |
| static void | begin_menu (esc_sim_t *s, uint32_t at) |
| Start the menu sounds. | |
| static void | segment_over (esc_sim_t *s, uint32_t at) |
A segment ended at at: what follows it. | |
| static bool | in_window (const esc_sim_t *s, uint32_t now, uint32_t profile_ms) |
| Whether a move now answers the group that ended last: inside the window the configuration or the profile gives, or with neither, before the next group begins. | |
| unsigned | esc_sim_store_moves (const esc_profile_t *p, uint8_t item, uint8_t value, esc_throttle_t *out, size_t cap) |
| List the moves that store a selected value. | |
| static void | store (esc_sim_t *s, uint32_t now, uint8_t item, uint8_t value) |
| Store a selected value. | |
| static void | moved (esc_sim_t *s, uint32_t now) |
| React to a throttle move in the current mode. | |
| int32_t | esc_sim_step (esc_sim_t *s, uint32_t now_ms, bool powered, float throttle_pct) |
| Advance the simulated ESC to a time and return its supply current. | |
| void | esc_sim_hand (esc_sim_t *s, uint32_t now_ms) |
| Record the person's action at the ESC. | |
A simulated ESC in its stick menu.
See esc_sim.h.
The sound is a list of segments – a beep, the gap after it, the pause after a group, a wait – each with the time it ends, walked forward to the time asked for. A throttle move is judged after the walk, against the group that ended last.
SPDX-License-Identifier: MIT
| enum seg_t |
|
static |
Add the extra groups past the highest number.
Adds the configured number of groups after the highest one in the loop, stopping at 255.
| s | The simulator. |
|
static |
Add a number to the loop, in ascending order.
Adds nothing when the number is already in the loop or the loop is full.
| s | The simulator. |
| v | The group number to add. |
|
static |
Start the menu sounds.
| s | The simulator. |
| at | Time the menu starts, ms. |
|
static |
The loop a mode sounds: the items, one item's values, or every value.
| s | The simulator. |
|
static |
Classify a throttle percentage as a position.
Below 15 percent is MIN, 35 to 65 percent is MID and above 85 percent is MAX. Anything else, or a negative value, is ESC_THR_NONE.
| pct | The throttle, percent of travel; negative for no signal. |
|
static |
Whether a power-up at pos enters the menu: the profile's entry, or the position any value is programmed from.
| p | The profile. |
| pos | The stick position at power-up. |
| void esc_sim_defaults | ( | esc_sim_cfg_t * | c | ) |
Fill a simulator config with its default settings.
| c | Receives the defaults. |
| void esc_sim_hand | ( | esc_sim_t * | s, |
| uint32_t | now_ms ) |
Record the person's action at the ESC.
The person's action at the ESC – the jumper pulled, the button pressed – at now_ms. With wait_hand, a menu waiting for it starts; one done before the entry ends lets the menu start when it does.
| s | The simulator. |
| now_ms | Time of the action, ms. |
| void esc_sim_init | ( | esc_sim_t * | s, |
| const esc_profile_t * | p, | ||
| const esc_sim_cfg_t * | c ) |
Start a simulated ESC on a profile.
| s | The simulator to set up. |
| p | The profile the simulated ESC follows. |
| c | The timing and fault settings. |
| int32_t esc_sim_step | ( | esc_sim_t * | s, |
| uint32_t | now_ms, | ||
| bool | powered, | ||
| float | throttle_pct ) |
Advance the simulated ESC to a time and return its supply current.
Advance to now_ms with the supply powered and the signal at throttle_pct, negative for no signal. Returns the current it draws, mA. Call it often enough for its pulses: in the host suite every few milliseconds, on the panel at the supply's 50ms.
| s | The simulator. |
| now_ms | Time of this step, ms. |
| powered | Whether the supply is on. |
| throttle_pct | Throttle signal, percent; negative for no signal. |
| unsigned esc_sim_store_moves | ( | const esc_profile_t * | p, |
| uint8_t | item, | ||
| uint8_t | value, | ||
| esc_throttle_t * | out, | ||
| size_t | cap ) |
List the moves that store a selected value.
The moves that store value value of the item numbered item once it is selected, into out: the profile's store move, then the value's own after_select, of the first item and value of those numbers – items that apply to different models may share both. At most cap are written; returns how many.
| p | The profile. |
| item | Item number. |
| value | Value number. |
| out | Receives the moves. |
| cap | Capacity of out, in moves. |
| uint8_t esc_sim_stored | ( | const esc_sim_t * | s, |
| uint8_t | item ) |
Value stored for an item.
The value stored for the item numbered item, 0 when none was.
| s | The simulator. |
| item | Item number. |
|
static |
Whether a move now answers the group that ended last: inside the window the configuration or the profile gives, or with neither, before the next group begins.
| s | The simulator. |
| now | Time of the move, ms. |
| profile_ms | The profile's window, ms; 0 for none. |
|
static |
Where the stick rests while the menu sounds: the profile's listen position, else where this power-up entered.
| s | The simulator. |
|
static |
React to a throttle move in the current mode.
| s | The simulator. |
| now | Time of the move, ms. |
|
static |
Length of the pulse being sounded.
| s | The simulator. |
|
static |
A segment ended at at: what follows it.
| s | The simulator. |
| at | Time the segment ended, ms. |
|
static |
Sound the next group of the loop.
| s | The simulator. |
| at | Time the group starts, ms. |
|
static |
Start one pulse of a group.
| s | The simulator. |
| at | Time the pulse starts, ms. |
|
static |
A group of n beeps, longs first, or one long tone when tone.
| s | The simulator. |
| at | Time the group starts, ms. |
| n | Number the group sounds. |
| menu | true when the group is a menu entry. |
| tone | true for one long tone. |
|
static |
Store a selected value.
Starts the store moves when the value has any; otherwise stores the value at once and starts the stored tone.
| s | The simulator. |
| now | Time of the store, ms. |
| item | Item number. |
| value | Value number. |
|
static |
Whether a profile has a two-stage menu.
| p | The profile. |
|
static |
The position the value numbered value of item item is programmed from.
| p | The profile. |
| item | Item number. |
| value | Value number. |