rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
esc_stick.h File Reference

Stick programming: an ESC (electronic speed controller) programmed through its throttle-stick menu, with the beeps counted in the supply current. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "esc_profile.h"

Go to the source code of this file.

Data Structures

struct  esc_stick_timing_t
 How the beeps are timed and told apart from the ESC's idle current. More...
struct  esc_stick_change_t
 One selection: the profile's item and value, as indices. More...
struct  esc_det_t
 The beep detector: hysteresis on the current above its idle floor, pulse and gap lengths judged in readings, groups split by silence. More...
struct  esc_stick_bench_t
 What the bench is doing, each step. More...
struct  esc_stick_sample_t
 One supply sample. seq is the supply's count of its own readings, modulo 65536 (supply_state_t's samples): it moves when the reading is new, and a step of more than one is a reading the panel never saw. at_ms is when the panel first had the reading (taken_ms), so a supply whose count stops is a supply whose readings stop, however often the panel reads its page. More...
struct  esc_stick_out_t
 What the bench is to do, after a step. More...
struct  esc_stick_t
 State of one stick programming run. More...
struct  esc_stick_light_t
 The green light: on while the detector holds a pulse, from the reading that rose above the threshold to the one that fell below the release, and for at least ESC_STICK_BEEP_LIGHT_MS from the first look that sees a pulse begun, so a pulse that rises and falls between two looks still shows. More...

Macros

#define ESC_STICK_MAX_CHANGES   16u
 The most selections one run makes.
#define ESC_STICK_SIGNAL_MS   1000u
 The throttle at the entry position before the supply comes on, ms: the ESC has to see the signal when it starts.
#define ESC_STICK_ARM_WAIT_MS   3000u
 How long the bench is given to arm, and the supply to report its output on, ms.
#define ESC_STICK_POWER_WAIT_MS   3000u
 Time the supply is given to report its output on, ms.
#define ESC_STICK_STALE_MS   1000u
 No new reading for this long ends the run, ms.
#define ESC_STICK_SETTLE_MS   500u
 Readings ignored for the floor after the output comes on: the ESC's input capacitors charging, ms.
#define ESC_STICK_LATE_RUN   3u
 This many late readings in a row end the run: the supply reads too slowly for the beeps the timing describes.
#define ESC_STICK_HAND_WAIT_MS   60000u
 A manual step not confirmed within this long ends the run, ms.
#define ESC_STICK_HAND_MIN_MS   1000u
 DONE counts only this long after its step is asked, ms, so one tap meant for the step before cannot confirm the next.
#define ESC_STICK_OFF_MA   20
 The output counts as off only once the supply itself reports it off and the current has stayed at or under ESC_STICK_OFF_MA for ESC_STICK_OFF_SETTLE_MS, in readings taken after the run asked it off: the panel's own OFF is a request, and the module answers it later.
#define ESC_STICK_OFF_SETTLE_MS   200u
 Time the current must stay at or under ESC_STICK_OFF_MA, ms.
#define ESC_STICK_PCT_MIN   0.0f
 Throttle positions as the output's percentage of travel.
#define ESC_STICK_PCT_MID   50.0f
 Throttle middle, as the output's percentage of travel.
#define ESC_STICK_PCT_MAX   100.0f
 Throttle maximum, as the output's percentage of travel.
#define ESC_STICK_BEEP_LIGHT_MS   150u
 A beep shown for less than this would fall between two frames, ms: the green light stays on at least this long from the frame that first sees the pulse.

Enumerations

enum  esc_stick_kind_t { ESC_STICK_KIND_NONE = 0 , ESC_STICK_KIND_TWO_STAGE , ESC_STICK_KIND_ONE_STAGE }
 Menu kind the engine runs for a profile. More...
enum  esc_stick_rating_t { ESC_STICK_RATING_OK = 0 , ESC_STICK_RATING_V_OVER , ESC_STICK_RATING_V_UNDER , ESC_STICK_RATING_I_OVER }
 What a supply's set points break of the ESC's ratings. More...
enum  esc_det_event_t { ESC_DET_NONE = 0 , ESC_DET_PULSE , ESC_DET_GROUP , ESC_DET_STUCK }
 Event the beep detector reports for one reading. More...
enum  esc_stick_phase_t {
  ESC_STICK_IDLE = 0 , ESC_STICK_ARMING , ESC_STICK_SIGNAL , ESC_STICK_POWER ,
  ESC_STICK_ENTRY , ESC_STICK_ITEMS , ESC_STICK_VALUES , ESC_STICK_STORE ,
  ESC_STICK_CYCLE , ESC_STICK_HAND_OFF , ESC_STICK_HAND_ON , ESC_STICK_HAND_END ,
  ESC_STICK_OFF , ESC_STICK_DONE , ESC_STICK_ABORTED
}
 Phase of a stick programming run. More...
enum  esc_stick_reason_t {
  ESC_STICK_R_NONE = 0 , ESC_STICK_R_STOP , ESC_STICK_R_BENCH_STOP , ESC_STICK_R_DISARMED ,
  ESC_STICK_R_LINK , ESC_STICK_R_SUPPLY_OFF , ESC_STICK_R_SUPPLY_LOST , ESC_STICK_R_STALE ,
  ESC_STICK_R_RATE , ESC_STICK_R_NOT_ARMED , ESC_STICK_R_NO_POWER , ESC_STICK_R_SUPPLY_ON ,
  ESC_STICK_R_NO_BEEPS , ESC_STICK_R_HIGH , ESC_STICK_R_TIMEOUT , ESC_STICK_R_HAND ,
  ESC_STICK_R_TOUCH , ESC_STICK_R_USER , ESC_STICK_R_LEFT
}
 Reason a run ended. More...

Functions

void esc_stick_timing_defaults (esc_stick_timing_t *t)
 The defaults the settings start from.
uint32_t esc_stick_read_max_ms (const esc_stick_timing_t *t)
 The longest interval between two readings the timing allows: the shorter of a beep and a gap, so every beep and every gap holds at least one reading.
esc_stick_kind_t esc_stick_kind (const esc_profile_t *p, const char **why)
 Which menu the engine runs for p, or ESC_STICK_KIND_NONE with the reason in why (a static string; may be NULL).
esc_throttle_t esc_stick_listen (const esc_profile_t *p)
 Where the stick rests while the menu sounds: the profile's listen move, else where the entry left it.
float esc_stick_pct (esc_throttle_t pos)
 A throttle position as the output's percentage.
uint32_t esc_stick_profile_mv (const esc_profile_t *p)
 The supply voltage a profile asks for, mV: the lowest stated cell count among its models at 3800mV a LiPo cell or 1200mV a NiMH cell, which is above that model's cut-off and under every model's maximum. 0 when no model states a cell count.
uint32_t esc_stick_model_mv (const esc_profile_t *p, int model)
 The supply voltage for model model of p, mV: its own lowest cell count at the rates above, where it states one; else, and for -1, the family's (esc_stick_profile_mv()).
uint32_t esc_stick_model_v_max (const esc_profile_t *p, int model)
 The highest supply voltage model model of p is rated for, mV: its v_max_mv.
uint32_t esc_stick_model_ma_max (const esc_profile_t *p, int model)
 The continuous current model model of p is rated for, mA: its current_a.
uint32_t esc_stick_model_v_min (const esc_profile_t *p, int model)
 The lowest input model model of p takes, mV: its v_min_mv.
esc_stick_rating_t esc_stick_rating (const esc_profile_t *p, int model, uint32_t mv, uint32_t ma, bool by_hand)
 Whether mv and ma suit model model of p (-1: every model of the family).
bool esc_stick_rating_unknown (const esc_profile_t *p, int model, uint32_t mv, bool by_hand)
 Whether the data cannot vouch for mv on model model: the rated voltage is not stated, and the voltage is set by hand (by_hand) or is not the model's own cell count's – the family's lowest standing in for a model that states none, or none at all.
bool esc_stick_is_action (const esc_item_t *it)
 Whether it is an action rather than a setting: keyed reset or exit.
const char * esc_stick_not_offered (const esc_item_t *it)
 Why it is not offered as a change, or NULL when it is: an action, or an item with a single value, which is either the only setting there is or a rule written as a value ("N beeps = N cells") – nothing to choose either way, and nothing the menu would sound in order.
esc_throttle_t esc_stick_change_entry (const esc_profile_t *p, const esc_stick_change_t *c)
 The stick position change c is powered up from: its value's entry_throttle where the manual names one, else the profile's entry.
bool esc_stick_check (const esc_profile_t *p, const esc_stick_change_t *ch, size_t n, const esc_stick_timing_t *t, const char **why)
 Whether a run of n changes under t can start on p; the reason in why when not.
void esc_det_init (esc_det_t *d, const esc_stick_timing_t *t, uint8_t long_equals_short)
 Set up the beep detector.
void esc_det_count (esc_det_t *d)
 Pulses and groups from the next reading on; the floor is kept.
esc_det_event_t esc_det_reading (esc_det_t *d, uint32_t t_ms, int32_t ma, bool late)
 One reading, at t_ms, of ma; late marks it as having come too long after the one before.
int32_t esc_det_floor_ma (const esc_det_t *d)
 The idle floor, mA.
const char * esc_stick_reason_text (esc_stick_reason_t r)
 A word or two for the screen.
esc_stick_reason_t esc_stick_stop_reason (uint32_t stops, uint32_t pressed)
 The end stops stops give, pressed of them pressed by an operator, both counted over the same span: STOP when every one was pressed, BENCH STOPPED when any was not, so a stop the bench raised is never hidden by a press that came with it.
bool esc_stick_reason_is_fault (esc_stick_reason_t r)
 Whether a run that ended for r ended because something was not as expected: a reading, the supply, the link, the arm, the ESC, or a stop the bench raised itself.
const char * esc_stick_phase_text (esc_stick_phase_t ph)
 Short text for a run phase.
bool esc_stick_start (esc_stick_t *e, const esc_profile_t *p, const esc_stick_change_t *ch, size_t n, const esc_stick_timing_t *t, uint32_t mv, uint32_t ma, const esc_stick_bench_t *b, const char **why)
 Start a run. mv and ma are the supply's set points, already held to the caps by the caller.
void esc_stick_sample (esc_stick_t *e, const esc_stick_sample_t *s)
 One supply sample, as it arrives.
void esc_stick_step (esc_stick_t *e, const esc_stick_bench_t *b)
 Advance to b->now_ms and judge the bench.
void esc_stick_abort (esc_stick_t *e, esc_stick_reason_t why)
 End the run now, for why: throttle to its rest, supply off, disarmed.
bool esc_stick_running (const esc_stick_t *e)
 Whether the run is under way: started and neither done nor aborted.
const esc_stick_out_t * esc_stick_out (const esc_stick_t *e)
 What the bench is to do now.
const esc_manual_t * esc_stick_hand (const esc_stick_t *e)
 The manual step the run waits for, or NULL when it waits for none.
uint32_t esc_stick_change_entry_ms (const esc_profile_t *p, const esc_stick_change_t *c, const esc_stick_timing_t *t)
 Power-on to the menu for change c, ms, as the run waits it: its value's entry_hold_ms where the manual gives one (Kontronik SUN PLUS modes 4 to 6, 5s), else t's entry, and no less than the longest hold of the profile's at_power_up steps. c NULL: the entry's.
uint32_t esc_stick_entry_ms (const esc_stick_t *e)
 Power-on to the menu at this power-up, ms: esc_stick_change_entry_ms() of the change it makes.
bool esc_stick_cut_short (const esc_stick_t *e)
 Whether the run ended between a selection and the DONE of the profile's before_power_off steps, or before the last of the moves that store the value (esc_stick_store_move()) – while the ESC stored or confirmed: the value may not be stored.
bool esc_stick_end_locks (const esc_stick_t *e)
 Whether a before_power_off step of the run's profile marks locks: a cut before every such step is confirmed may lock the ESC, whichever step is asked.
bool esc_stick_lock_risk (const esc_stick_t *e)
 esc_stick_cut_short() and esc_stick_end_locks(): the ESC may have locked itself.
bool esc_stick_hand_ready (const esc_stick_t *e)
 Whether DONE would count now: ESC_STICK_HAND_MIN_MS after the step was asked.
uint32_t esc_stick_hand_left_ms (const esc_stick_t *e)
 The time left to confirm the step asked, ms; 0 when none is.
bool esc_stick_confirm (esc_stick_t *e)
 DONE: the step asked is done.
esc_throttle_t esc_stick_store_move (const esc_stick_t *e, unsigned k)
 The k-th move after a selection, from 0, or ESC_THR_NONE past the last: the profile's store move, then the moves the stored value asks for (esc_value_t's after: Kontronik's car modes go to the brake after full throttle).
unsigned esc_stick_done_count (const esc_stick_t *e)
 How many selections have been made.
bool esc_stick_unsure (const esc_stick_t *e, unsigned i)
 Whether change i was selected, but the run was cut short before the ESC stored or confirmed it (esc_stick_cut_short()): the selection being stored when the run ended.
unsigned esc_stick_made_count (const esc_stick_t *e)
 The selections made for certain: esc_stick_done_count() less the one esc_stick_unsure() names.
unsigned esc_stick_beeps (const esc_stick_t *e)
 The beeps of the group under way.
void esc_stick_light_reset (esc_stick_light_t *l, const esc_stick_t *e)
 Start watching e: pulses already counted do not light it.
bool esc_stick_light_green (esc_stick_light_t *l, const esc_stick_t *e, uint32_t now_ms)
 Whether the green light is on at now_ms.

Detailed Description

Stick programming: an ESC (electronic speed controller) programmed through its throttle-stick menu, with the beeps counted in the supply current.

The ESC is powered from the bench supply with a resistor load in place of the motor, or a motor mounted solid with no propeller. It sounds its menu through the load or the windings, so each beep is a pulse in the supply current. The engine drives the throttle to the profile's positions, switches the supply, counts the pulses into groups and moves the throttle on the group that names the wanted item or value.

Pure C, no I/O (input/output): the caller hands over each supply reading and the bench's state, and reads back what the throttle, the arm and the supply are to be. It sends nothing itself, so every move it asks for goes through the same arming, output and supply paths an operator's does, and a STOP or a disarm reaches the ESC without the engine.

No ESC has been recorded. Every time in esc_stick_timing_t is a default standing in for a measurement, not a measurement; see docs/StickProgramming.md.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ ESC_STICK_HAND_WAIT_MS

#define ESC_STICK_HAND_WAIT_MS   60000u

A manual step not confirmed within this long ends the run, ms.

No manual states how long an ESC waits for its jumper or button; this is the operator's time to reach the ESC, not the ESC's.

Enumeration Type Documentation

◆ esc_det_event_t

Event the beep detector reports for one reading.

Enumerator
ESC_DET_PULSE 

a pulse ended

ESC_DET_GROUP 

a group ended: count and valid say what

ESC_DET_STUCK 

the current has stayed high past a beep

◆ esc_stick_kind_t

Menu kind the engine runs for a profile.

Enumerator
ESC_STICK_KIND_NONE 

the engine does not run this profile

ESC_STICK_KIND_TWO_STAGE 

select picks an item, value_select stores the value sounded

ESC_STICK_KIND_ONE_STAGE 

the groups sound values; select stores

◆ esc_stick_phase_t

Phase of a stick programming run.

Enumerator
ESC_STICK_ARMING 

waiting for the bench to arm

ESC_STICK_SIGNAL 

throttle at entry, supply still off

ESC_STICK_POWER 

supply asked on, waiting for the output

ESC_STICK_ENTRY 

powered, waiting for the menu

ESC_STICK_ITEMS 

counting item groups

ESC_STICK_VALUES 

counting value groups

ESC_STICK_STORE 

held at the selection while it is stored

ESC_STICK_CYCLE 

supply off before the next entry

ESC_STICK_HAND_OFF 

supply off, waiting for a manual step's DONE before the power-up

ESC_STICK_HAND_ON 

powered, waiting for a manual step's DONE before the menu

ESC_STICK_HAND_END 

powered, the stick where it stored, waiting for a before_power_off step's DONE before the supply goes off

ESC_STICK_OFF 

supply off, the stick where it stored

◆ esc_stick_rating_t

What a supply's set points break of the ESC's ratings.

Enumerator
ESC_STICK_RATING_V_OVER 

mv over the rated voltage

ESC_STICK_RATING_V_UNDER 

mv under the lowest input stated

ESC_STICK_RATING_I_OVER 

ma over the rated current

◆ esc_stick_reason_t

Reason a run ended.

Enumerator
ESC_STICK_R_STOP 

STOP pressed

ESC_STICK_R_BENCH_STOP 

a stop the bench raised itself: touch that stopped answering or was lost, the IOmcu's refusal or failsafe

ESC_STICK_R_DISARMED 

the bench disarmed under the run

ESC_STICK_R_LINK 

the IOmcu stopped answering

ESC_STICK_R_SUPPLY_OFF 

the output went off: a trip, a lost ON

ESC_STICK_R_SUPPLY_LOST 

the supply stopped answering

ESC_STICK_R_STALE 

no new reading for ESC_STICK_STALE_MS

ESC_STICK_R_RATE 

readings too far apart for the beeps

ESC_STICK_R_NOT_ARMED 

the bench did not arm

ESC_STICK_R_NO_POWER 

the output did not come on

ESC_STICK_R_SUPPLY_ON 

the output did not go off when asked

ESC_STICK_R_NO_BEEPS 

no beep for silence_ms

ESC_STICK_R_HIGH 

the current stayed above the threshold

ESC_STICK_R_TIMEOUT 

the wanted group not heard

ESC_STICK_R_HAND 

a manual step not confirmed in time

ESC_STICK_R_TOUCH 

touch lost before the arm was taken

ESC_STICK_R_USER 

ABORT pressed

ESC_STICK_R_LEFT 

the screen was left

Function Documentation

◆ esc_det_count()

void esc_det_count ( esc_det_t * d)

Pulses and groups from the next reading on; the floor is kept.

Parameters
dThe detector.

◆ esc_det_floor_ma()

int32_t esc_det_floor_ma ( const esc_det_t * d)

The idle floor, mA.

Parameters
dThe detector.
Returns
The idle floor, mA.

◆ esc_det_init()

void esc_det_init ( esc_det_t * d,
const esc_stick_timing_t * t,
uint8_t long_equals_short )

Set up the beep detector.

Parameters
dThe detector.
tThe timing.
long_equals_shortCount of short beeps that one long beep equals, 0 when every beep is short.

◆ esc_det_reading()

esc_det_event_t esc_det_reading ( esc_det_t * d,
uint32_t t_ms,
int32_t ma,
bool late )

One reading, at t_ms, of ma; late marks it as having come too long after the one before.

Parameters
dThe detector.
t_msTime of the reading, ms.
maCurrent, mA.
latetrue when the reading came too long after the one before.
Returns
The event the reading caused.

◆ esc_stick_abort()

void esc_stick_abort ( esc_stick_t * e,
esc_stick_reason_t why )

End the run now, for why: throttle to its rest, supply off, disarmed.

A run already over is left as it ended.

Parameters
eThe run.
whyThe end reason.

◆ esc_stick_beeps()

unsigned esc_stick_beeps ( const esc_stick_t * e)

The beeps of the group under way.

Parameters
eThe run.
Returns
The number of beeps.

◆ esc_stick_change_entry()

esc_throttle_t esc_stick_change_entry ( const esc_profile_t * p,
const esc_stick_change_t * c )

The stick position change c is powered up from: its value's entry_throttle where the manual names one, else the profile's entry.

A run moves the stick there with the supply off and seen off, holds it ESC_STICK_SIGNAL_MS, and only then switches the supply on.

Parameters
pThe profile.
cThe change.
Returns
The throttle position at power-up.

◆ esc_stick_change_entry_ms()

uint32_t esc_stick_change_entry_ms ( const esc_profile_t * p,
const esc_stick_change_t * c,
const esc_stick_timing_t * t )

Power-on to the menu for change c, ms, as the run waits it: its value's entry_hold_ms where the manual gives one (Kontronik SUN PLUS modes 4 to 6, 5s), else t's entry, and no less than the longest hold of the profile's at_power_up steps. c NULL: the entry's.

Parameters
pThe profile.
cThe change, or NULL for the entry.
tThe timing.
Returns
The power-on to menu time, ms.

◆ esc_stick_check()

bool esc_stick_check ( const esc_profile_t * p,
const esc_stick_change_t * ch,
size_t n,
const esc_stick_timing_t * t,
const char ** why )

Whether a run of n changes under t can start on p; the reason in why when not.

Refused, never adjusted: a timing that cannot fit the profile's select window is a setting to change, not one to guess.

Parameters
pThe profile.
chThe changes, in order.
nNumber of changes in ch.
tThe timing.
whyReceives the reason when refused, or NULL.
Returns
true when the run can start.

◆ esc_stick_confirm()

bool esc_stick_confirm ( esc_stick_t * e)

DONE: the step asked is done.

The run asks the next step due at the same point, or goes on. Ignored, returning false, when no step is asked or the step was asked less than ESC_STICK_HAND_MIN_MS ago.

Parameters
eThe run.
Returns
true when the step was confirmed.

◆ esc_stick_cut_short()

bool esc_stick_cut_short ( const esc_stick_t * e)

Whether the run ended between a selection and the DONE of the profile's before_power_off steps, or before the last of the moves that store the value (esc_stick_store_move()) – while the ESC stored or confirmed: the value may not be stored.

False while the run is under way, and for a value stored by its selection on a profile without such a step.

Parameters
eThe run.
Returns
true when the value may not be stored.

◆ esc_stick_done_count()

unsigned esc_stick_done_count ( const esc_stick_t * e)

How many selections have been made.

Parameters
eThe run.
Returns
The number of selections made.

◆ esc_stick_end_locks()

bool esc_stick_end_locks ( const esc_stick_t * e)

Whether a before_power_off step of the run's profile marks locks: a cut before every such step is confirmed may lock the ESC, whichever step is asked.

Parameters
eThe run.
Returns
true when a cut may lock the ESC.

◆ esc_stick_entry_ms()

uint32_t esc_stick_entry_ms ( const esc_stick_t * e)

Power-on to the menu at this power-up, ms: esc_stick_change_entry_ms() of the change it makes.

Parameters
eThe run.
Returns
The power-on to menu time, ms.

◆ esc_stick_hand()

const esc_manual_t * esc_stick_hand ( const esc_stick_t * e)

The manual step the run waits for, or NULL when it waits for none.

A run stops for a step a person does at the ESC where the profile says it is due, and goes on only on esc_stick_confirm():

  • before the supply comes on (ESC_STICK_HAND_OFF): each at_power_up step, and from the second power-up on each before_power step too – the first power-up's are on the warning a run starts from. The supply is off and the stick at the entry position; DONE switches the supply on. Such a step is asked only once the supply itself reads off (ESC_STICK_OFF_MA for ESC_STICK_OFF_SETTLE_MS, in readings taken since the run asked it off); a reading with the output on or the current up while it is asked ends the run with SUPPLY STAYS ON, and readings that stop end it with NO READINGS.
  • once the entry has had its time: each before_menu step, with the ESC powered and the stick at the power-up position (MIN, or MID where the value names it). One marked starts_menu is the action that starts the menu, and the run counts groups from the moment it asks for it (phase ITEMS or VALUES, the step still returned here): the first group in order with the one before it, or DONE, takes it as done. Any other, or one whose menu rests elsewhere, waits in ESC_STICK_HAND_ON for DONE, which goes on to the next step or the menu.
  • after the last move of a store, before the supply goes off: each before_power_off step (ESC_STICK_HAND_END). The ESC stays powered and the stick where the store left it; nobody touches the ESC, the operator watches it confirm the value (tones, LED) and taps DONE. DONE switches the supply off. An end while such a step is asked is told by esc_stick_cut_short(): the value may not be stored. Where the step marks locks – a Kontronik ESC that takes the programming as broken off and locks itself – esc_stick_lock_risk() says so.

STOP, ABORT, a disarm and every supply rule end a waiting run as any other: throttle to MIN, supply off, disarmed. No DONE within ESC_STICK_HAND_WAIT_MS ends it with ESC_STICK_R_HAND.

Parameters
eThe run.
Returns
The step asked, or NULL.

◆ esc_stick_hand_left_ms()

uint32_t esc_stick_hand_left_ms ( const esc_stick_t * e)

The time left to confirm the step asked, ms; 0 when none is.

Parameters
eThe run.
Returns
The time left, ms; 0 when no step is asked.

◆ esc_stick_hand_ready()

bool esc_stick_hand_ready ( const esc_stick_t * e)

Whether DONE would count now: ESC_STICK_HAND_MIN_MS after the step was asked.

Parameters
eThe run.
Returns
true when DONE counts.

◆ esc_stick_is_action()

bool esc_stick_is_action ( const esc_item_t * it)

Whether it is an action rather than a setting: keyed reset or exit.

Selecting one makes the ESC act on the select move; it sounds no values, and the engine does not offer it.

Parameters
itThe menu item.
Returns
true when the item is an action.

◆ esc_stick_kind()

esc_stick_kind_t esc_stick_kind ( const esc_profile_t * p,
const char ** why )

Which menu the engine runs for p, or ESC_STICK_KIND_NONE with the reason in why (a static string; may be NULL).

An assisted profile runs only through its manual steps (esc_profile_t's manual), and only when each can be waited for: no step during the menu, whose moment the run cannot know, and a hand at a powered ESC – an at_power_up or before_menu step – only with the stick at MIN for the entry. Otherwise the reason is "manual step".

Parameters
pThe profile.
whyReceives the reason when the engine cannot run it, or NULL.
Returns
The menu kind, or ESC_STICK_KIND_NONE.

◆ esc_stick_light_green()

bool esc_stick_light_green ( esc_stick_light_t * l,
const esc_stick_t * e,
uint32_t now_ms )

Whether the green light is on at now_ms.

Parameters
lThe light state.
eThe run.
now_msTime of the look, ms.
Returns
true when the green light is on at now_ms.

◆ esc_stick_light_reset()

void esc_stick_light_reset ( esc_stick_light_t * l,
const esc_stick_t * e )

Start watching e: pulses already counted do not light it.

Parameters
lThe light state.
eThe run.

◆ esc_stick_listen()

esc_throttle_t esc_stick_listen ( const esc_profile_t * p)

Where the stick rests while the menu sounds: the profile's listen move, else where the entry left it.

Parameters
pThe profile.
Returns
The throttle position to hold.

◆ esc_stick_lock_risk()

bool esc_stick_lock_risk ( const esc_stick_t * e)

esc_stick_cut_short() and esc_stick_end_locks(): the ESC may have locked itself.

Parameters
eThe run.
Returns
true when the ESC may have locked itself.

◆ esc_stick_made_count()

unsigned esc_stick_made_count ( const esc_stick_t * e)

The selections made for certain: esc_stick_done_count() less the one esc_stick_unsure() names.

Parameters
eThe run.
Returns
The number of certain selections.

◆ esc_stick_model_ma_max()

uint32_t esc_stick_model_ma_max ( const esc_profile_t * p,
int model )

The continuous current model model of p is rated for, mA: its current_a.

For -1, the lowest stated among its models. 0 where none is stated.

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
Returns
The rated current, mA, or 0 when not stated.

◆ esc_stick_model_mv()

uint32_t esc_stick_model_mv ( const esc_profile_t * p,
int model )

The supply voltage for model model of p, mV: its own lowest cell count at the rates above, where it states one; else, and for -1, the family's (esc_stick_profile_mv()).

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
Returns
The supply voltage, mV.

◆ esc_stick_model_v_max()

uint32_t esc_stick_model_v_max ( const esc_profile_t * p,
int model )

The highest supply voltage model model of p is rated for, mV: its v_max_mv.

For -1, the lowest of every model's, the one every model takes. 0 where the data does not state it – for -1, where a model does not, or there is none.

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
Returns
The rated voltage, mV, or 0 when not stated.

◆ esc_stick_model_v_min()

uint32_t esc_stick_model_v_min ( const esc_profile_t * p,
int model )

The lowest input model model of p takes, mV: its v_min_mv.

For -1, the highest stated among its models. 0 where none is stated.

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
Returns
The lowest input voltage, mV, or 0 when not stated.

◆ esc_stick_not_offered()

const char * esc_stick_not_offered ( const esc_item_t * it)

Why it is not offered as a change, or NULL when it is: an action, or an item with a single value, which is either the only setting there is or a rule written as a value ("N beeps = N cells") – nothing to choose either way, and nothing the menu would sound in order.

Parameters
itThe menu item.
Returns
A static reason string, or NULL when the item is offered.

◆ esc_stick_out()

const esc_stick_out_t * esc_stick_out ( const esc_stick_t * e)

What the bench is to do now.

Parameters
eThe run.
Returns
The bench's output for this step.

◆ esc_stick_pct()

float esc_stick_pct ( esc_throttle_t pos)

A throttle position as the output's percentage.

Parameters
posThe throttle position.
Returns
The output percentage of pos.

◆ esc_stick_phase_text()

const char * esc_stick_phase_text ( esc_stick_phase_t ph)

Short text for a run phase.

Parameters
phThe phase.
Returns
A static text.

◆ esc_stick_profile_mv()

uint32_t esc_stick_profile_mv ( const esc_profile_t * p)

The supply voltage a profile asks for, mV: the lowest stated cell count among its models at 3800mV a LiPo cell or 1200mV a NiMH cell, which is above that model's cut-off and under every model's maximum. 0 when no model states a cell count.

Parameters
pThe profile.
Returns
The supply voltage, mV, or 0 when no model states a cell count.

◆ esc_stick_rating()

esc_stick_rating_t esc_stick_rating ( const esc_profile_t * p,
int model,
uint32_t mv,
uint32_t ma,
bool by_hand )

Whether mv and ma suit model model of p (-1: every model of the family).

A voltage over the rated one (esc_stick_model_v_max()) is refused, set by hand (by_hand) or taken from the cell count, and so is one under the lowest input the model states (v_min_mv; for -1 the highest of its models'). A current over the rated one, where stated, is refused. A rating the data does not state refuses nothing: esc_stick_rating_unknown() says when the operator is to be told.

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
mvSupply voltage, mV.
maSupply current limit, mA.
by_handWhether the voltage was set by hand.
Returns
The rating that the set points break, or ESC_STICK_RATING_OK.

◆ esc_stick_rating_unknown()

bool esc_stick_rating_unknown ( const esc_profile_t * p,
int model,
uint32_t mv,
bool by_hand )

Whether the data cannot vouch for mv on model model: the rated voltage is not stated, and the voltage is set by hand (by_hand) or is not the model's own cell count's – the family's lowest standing in for a model that states none, or none at all.

The run goes ahead; the screen says the ESC's rating is unknown.

Parameters
pThe profile.
modelIndex into the models, or -1 for the family.
mvSupply voltage, mV.
by_handWhether the voltage was set by hand.
Returns
true when the rating is unknown.

◆ esc_stick_read_max_ms()

uint32_t esc_stick_read_max_ms ( const esc_stick_timing_t * t)

The longest interval between two readings the timing allows: the shorter of a beep and a gap, so every beep and every gap holds at least one reading.

Parameters
tThe timing.
Returns
The longest allowed interval between readings, ms.

◆ esc_stick_reason_is_fault()

bool esc_stick_reason_is_fault ( esc_stick_reason_t r)

Whether a run that ended for r ended because something was not as expected: a reading, the supply, the link, the arm, the ESC, or a stop the bench raised itself.

False for the ends an operator chose (STOP pressed, ABORT, leaving the screen) and for none. The screen's red light.

Parameters
rThe end reason.
Returns
true for a fault.

◆ esc_stick_reason_text()

const char * esc_stick_reason_text ( esc_stick_reason_t r)

A word or two for the screen.

Parameters
rThe reason.
Returns
A static text.

◆ esc_stick_running()

bool esc_stick_running ( const esc_stick_t * e)

Whether the run is under way: started and neither done nor aborted.

Parameters
eThe run.
Returns
true while the run is under way.

◆ esc_stick_sample()

void esc_stick_sample ( esc_stick_t * e,
const esc_stick_sample_t * s )

One supply sample, as it arrives.

Parameters
eThe run.
sThe sample.

◆ esc_stick_start()

bool esc_stick_start ( esc_stick_t * e,
const esc_profile_t * p,
const esc_stick_change_t * ch,
size_t n,
const esc_stick_timing_t * t,
uint32_t mv,
uint32_t ma,
const esc_stick_bench_t * b,
const char ** why )

Start a run. mv and ma are the supply's set points, already held to the caps by the caller.

Refused with why when esc_stick_check() refuses, and the run stays idle.

Parameters
eThe run to start.
pThe profile.
chThe changes to make, in order.
nNumber of changes in ch.
tThe timing.
mvSupply set point, mV.
maSupply current limit, mA.
bThe bench state at the start.
whyReceives the reason when refused, or NULL.
Returns
true when the run started.

◆ esc_stick_step()

void esc_stick_step ( esc_stick_t * e,
const esc_stick_bench_t * b )

Advance to b->now_ms and judge the bench.

Parameters
eThe run.
bThe bench state.

◆ esc_stick_stop_reason()

esc_stick_reason_t esc_stick_stop_reason ( uint32_t stops,
uint32_t pressed )

The end stops stops give, pressed of them pressed by an operator, both counted over the same span: STOP when every one was pressed, BENCH STOPPED when any was not, so a stop the bench raised is never hidden by a press that came with it.

Parameters
stopsStops counted over the span.
pressedOf those, the ones an operator pressed.
Returns
The end reason.

◆ esc_stick_store_move()

esc_throttle_t esc_stick_store_move ( const esc_stick_t * e,
unsigned k )

The k-th move after a selection, from 0, or ESC_THR_NONE past the last: the profile's store move, then the moves the stored value asks for (esc_value_t's after: Kontronik's car modes go to the brake after full throttle).

The run makes each STORE after the one before, then switches the supply off.

Parameters
eThe run.
kIndex of the move, from 0.
Returns
The throttle position of that move, or ESC_THR_NONE.

◆ esc_stick_timing_defaults()

void esc_stick_timing_defaults ( esc_stick_timing_t * t)

The defaults the settings start from.

Parameters
tReceives the default timing.

◆ esc_stick_unsure()

bool esc_stick_unsure ( const esc_stick_t * e,
unsigned i )

Whether change i was selected, but the run was cut short before the ESC stored or confirmed it (esc_stick_cut_short()): the selection being stored when the run ended.

Parameters
eThe run.
iIndex of the change.
Returns
true when the change is unsure.