27#ifndef RCBENCH_ESC_STICK_H
28#define RCBENCH_ESC_STICK_H
43#define ESC_STICK_MAX_CHANGES 16u
49#define ESC_STICK_SIGNAL_MS 1000u
54#define ESC_STICK_ARM_WAIT_MS 3000u
56#define ESC_STICK_POWER_WAIT_MS 3000u
60#define ESC_STICK_STALE_MS 1000u
65#define ESC_STICK_SETTLE_MS 500u
70#define ESC_STICK_LATE_RUN 3u
77#define ESC_STICK_HAND_WAIT_MS 60000u
82#define ESC_STICK_HAND_MIN_MS 1000u
89#define ESC_STICK_OFF_MA 20
91#define ESC_STICK_OFF_SETTLE_MS 200u
96#define ESC_STICK_PCT_MIN 0.0f
98#define ESC_STICK_PCT_MID 50.0f
100#define ESC_STICK_PCT_MAX 100.0f
248 ESC_STICK_RATING_OK = 0,
273 uint32_t mv, uint32_t ma,
bool by_hand);
392 uint32_t rise_ms, last_high_ms, before_rise_ms;
404 bool group_open, group_bad;
405 uint8_t shorts, longs;
421 uint8_t long_equals_short);
480 ESC_STICK_R_NONE = 0,
922#define ESC_STICK_BEEP_LIGHT_MS 150u
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.
Definition esc_det.c:116
int32_t esc_det_floor_ma(const esc_det_t *d)
The idle floor, mA.
Definition esc_det.c:61
void esc_det_count(esc_det_t *d)
Pulses and groups from the next reading on; the floor is kept.
Definition esc_det.c:47
void esc_det_init(esc_det_t *d, const esc_stick_timing_t *t, uint8_t long_equals_short)
Set up the beep detector.
Definition esc_det.c:16
ESC (electronic speed controller) programming profiles: how to enter an ESC's throttle-stick programm...
esc_throttle_t
Throttle stick position that a step uses.
Definition esc_profile.h:99
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,...
Definition esc_stick.c:515
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.
Definition esc_stick.c:430
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 manua...
Definition esc_stick.c:444
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.
Definition esc_stick.c:480
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,...
Definition esc_stick.c:577
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.
Definition esc_stick.c:466
void esc_stick_timing_defaults(esc_stick_timing_t *t)
The defaults the settings start from.
Definition esc_stick.c:43
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,...
Definition esc_stick.c:62
void esc_stick_sample(esc_stick_t *e, const esc_stick_sample_t *s)
One supply sample, as it arrives.
Definition esc_stick.c:845
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.
Definition esc_stick.c:598
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.
Definition esc_stick.c:726
bool esc_stick_confirm(esc_stick_t *e)
DONE: the step asked is done.
Definition esc_stick.c:500
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.
Definition esc_stick.c:486
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.
Definition esc_stick.c:96
void esc_stick_step(esc_stick_t *e, const esc_stick_bench_t *b)
Advance to b->now_ms and judge the bench.
Definition esc_stick.c:940
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 con...
Definition esc_stick.c:582
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.
Definition esc_stick.c:106
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.
Definition esc_stick.c:160
esc_det_event_t
Event the beep detector reports for one reading.
Definition esc_stick.h:358
@ ESC_DET_STUCK
Definition esc_stick.h:362
@ ESC_DET_PULSE
Definition esc_stick.h:360
@ ESC_DET_GROUP
Definition esc_stick.h:361
esc_stick_kind_t
Menu kind the engine runs for a profile.
Definition esc_stick.h:145
@ ESC_STICK_KIND_TWO_STAGE
Definition esc_stick.h:147
@ ESC_STICK_KIND_NONE
Definition esc_stick.h:146
@ ESC_STICK_KIND_ONE_STAGE
Definition esc_stick.h:149
esc_stick_phase_t
Phase of a stick programming run.
Definition esc_stick.h:456
@ ESC_STICK_STORE
Definition esc_stick.h:464
@ ESC_STICK_VALUES
Definition esc_stick.h:463
@ ESC_STICK_CYCLE
Definition esc_stick.h:465
@ ESC_STICK_ITEMS
Definition esc_stick.h:462
@ ESC_STICK_HAND_OFF
Definition esc_stick.h:466
@ ESC_STICK_ENTRY
Definition esc_stick.h:461
@ ESC_STICK_POWER
Definition esc_stick.h:460
@ ESC_STICK_ARMING
Definition esc_stick.h:458
@ ESC_STICK_HAND_END
Definition esc_stick.h:470
@ ESC_STICK_OFF
Definition esc_stick.h:473
@ ESC_STICK_SIGNAL
Definition esc_stick.h:459
@ ESC_STICK_HAND_ON
Definition esc_stick.h:468
esc_stick_reason_t
Reason a run ended.
Definition esc_stick.h:479
@ ESC_STICK_R_SUPPLY_OFF
Definition esc_stick.h:487
@ ESC_STICK_R_STOP
Definition esc_stick.h:481
@ ESC_STICK_R_STALE
Definition esc_stick.h:489
@ ESC_STICK_R_NOT_ARMED
Definition esc_stick.h:491
@ ESC_STICK_R_SUPPLY_ON
Definition esc_stick.h:493
@ ESC_STICK_R_LINK
Definition esc_stick.h:486
@ ESC_STICK_R_DISARMED
Definition esc_stick.h:485
@ ESC_STICK_R_NO_POWER
Definition esc_stick.h:492
@ ESC_STICK_R_RATE
Definition esc_stick.h:490
@ ESC_STICK_R_HAND
Definition esc_stick.h:497
@ ESC_STICK_R_BENCH_STOP
Definition esc_stick.h:482
@ ESC_STICK_R_HIGH
Definition esc_stick.h:495
@ ESC_STICK_R_SUPPLY_LOST
Definition esc_stick.h:488
@ ESC_STICK_R_TOUCH
Definition esc_stick.h:498
@ ESC_STICK_R_LEFT
Definition esc_stick.h:500
@ ESC_STICK_R_USER
Definition esc_stick.h:499
@ ESC_STICK_R_TIMEOUT
Definition esc_stick.h:496
@ ESC_STICK_R_NO_BEEPS
Definition esc_stick.h:494
#define ESC_STICK_MAX_CHANGES
The most selections one run makes.
Definition esc_stick.h:43
esc_stick_rating_t
What a supply's set points break of the ESC's ratings.
Definition esc_stick.h:247
@ ESC_STICK_RATING_I_OVER
Definition esc_stick.h:251
@ ESC_STICK_RATING_V_OVER
Definition esc_stick.h:249
@ ESC_STICK_RATING_V_UNDER
Definition esc_stick.h:250
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
unsigned esc_stick_done_count(const esc_stick_t *e)
How many selections have been made.
Definition esc_stick_read.c:109
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.
Definition esc_stick_read.c:124
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_s...
Definition esc_stick_read.c:118
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,...
Definition esc_stick_read.c:48
bool esc_stick_running(const esc_stick_t *e)
Whether the run is under way: started and neither done nor aborted.
Definition esc_stick_read.c:98
const char * esc_stick_reason_text(esc_stick_reason_t r)
A word or two for the screen.
Definition esc_stick_read.c:13
const esc_stick_out_t * esc_stick_out(const esc_stick_t *e)
What the bench is to do now.
Definition esc_stick_read.c:104
const char * esc_stick_phase_text(esc_stick_phase_t ph)
Short text for a run phase.
Definition esc_stick_read.c:76
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: ST...
Definition esc_stick_read.c:39
unsigned esc_stick_beeps(const esc_stick_t *e)
The beeps of the group under way.
Definition esc_stick_read.c:133
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.
Definition esc_stick_rules.c:293
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...
Definition esc_stick_rules.c:144
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.
Definition esc_stick_rules.c:312
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.
Definition esc_stick_rules.c:502
bool esc_stick_is_action(const esc_item_t *it)
Whether it is an action rather than a setting: keyed reset or exit.
Definition esc_stick_rules.c:363
float esc_stick_pct(esc_throttle_t pos)
A throttle position as the output's percentage.
Definition esc_stick_rules.c:26
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 ...
Definition esc_stick_rules.c:244
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,...
Definition esc_stick_rules.c:263
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,...
Definition esc_stick_rules.c:348
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.
Definition esc_stick_rules.c:273
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...
Definition esc_stick_rules.c:383
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,...
Definition esc_stick_rules.c:369
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).
Definition esc_stick_rules.c:329
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.
Definition esc_stick_rules.c:17
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
The beep detector: hysteresis on the current above its idle floor, pulse and gap lengths judged in re...
Definition esc_stick.h:380
uint32_t n_low
Definition esc_stick.h:402
uint32_t fall_ms
Definition esc_stick.h:401
uint32_t quiet_from
Definition esc_stick.h:397
uint32_t busy_from
Definition esc_stick.h:399
bool have_prev
Definition esc_stick.h:387
bool seeded
Definition esc_stick.h:385
bool fell
Definition esc_stick.h:400
uint32_t prev_ms
Definition esc_stick.h:388
bool busy
Definition esc_stick.h:398
int32_t floor_x16
Definition esc_stick.h:386
bool counting
Definition esc_stick.h:384
uint32_t iv_max_ms
Definition esc_stick.h:389
bool wait_quiet
Definition esc_stick.h:395
uint8_t long_equals_short
Definition esc_stick.h:382
bool quiet_known
Definition esc_stick.h:396
One menu item: its name, sounded number and values.
Definition esc_profile.h:156
A step a person does at the ESC besides the throttle and the power: fit or pull a jumper,...
Definition esc_profile.h:206
One ESC programming profile: its family, menu and steps.
Definition esc_profile.h:233
What the bench is doing, each step.
Definition esc_stick.h:547
uint32_t pressed
Definition esc_stick.h:552
bool link_up
Definition esc_stick.h:551
uint32_t stops
Definition esc_stick.h:550
uint32_t now_ms
Definition esc_stick.h:548
bool armed
Definition esc_stick.h:549
One selection: the profile's item and value, as indices.
Definition esc_stick.h:317
uint8_t value
Definition esc_stick.h:319
uint8_t item
Definition esc_stick.h:318
The green light: on while the detector holds a pulse, from the reading that rose above the threshold ...
Definition esc_stick.h:935
uint32_t from_ms
Definition esc_stick.h:937
uint32_t pulses
Definition esc_stick.h:936
bool held
Definition esc_stick.h:938
What the bench is to do, after a step.
Definition esc_stick.h:578
uint32_t supply_ma
Definition esc_stick.h:583
float throttle_pct
Definition esc_stick.h:580
bool supply_on
Definition esc_stick.h:581
bool arm
Definition esc_stick.h:579
uint32_t supply_mv
Definition esc_stick.h:582
One supply sample. seq is the supply's count of its own readings, modulo 65536 (supply_state_t's samp...
Definition esc_stick.h:564
uint32_t at_ms
Definition esc_stick.h:566
bool output
Definition esc_stick.h:569
bool current_ok
Definition esc_stick.h:568
int32_t ma
Definition esc_stick.h:567
bool reported_on
Definition esc_stick.h:570
bool online
Definition esc_stick.h:572
State of one stick programming run.
Definition esc_stick.h:587
bool cycle_moved
Definition esc_stick.h:615
bool link_seen
Definition esc_stick.h:604
uint32_t heard_ms
Definition esc_stick.h:637
bool reported_on
Definition esc_stick.h:607
bool sig_moved
Definition esc_stick.h:616
bool hand_done
Definition esc_stick.h:658
uint32_t hand_ms
Definition esc_stick.h:663
bool last_in_order
Definition esc_stick.h:647
uint8_t active
Definition esc_stick.h:594
uint8_t store_step
Definition esc_stick.h:612
uint32_t entry_wait
Definition esc_stick.h:653
uint32_t off_since_ms
Definition esc_stick.h:610
bool prev_trusted
Definition esc_stick.h:641
bool armed_seen
Definition esc_stick.h:619
uint8_t prev
Definition esc_stick.h:640
uint32_t groups
Definition esc_stick.h:644
uint8_t entries
Definition esc_stick.h:651
bool off_since_known
Definition esc_stick.h:611
bool have_reading
Definition esc_stick.h:627
uint32_t off_asked_ms
Definition esc_stick.h:608
uint32_t off_seq
Definition esc_stick.h:609
bool off_seen
Definition esc_stick.h:605
uint32_t read_ms
Definition esc_stick.h:626
uint32_t now_ms
Definition esc_stick.h:599
bool last_trusted
Definition esc_stick.h:649
uint32_t pulses
Definition esc_stick.h:670
uint8_t run
Definition esc_stick.h:642
uint8_t hi
Definition esc_stick.h:643
uint32_t iv_ms
Definition esc_stick.h:634
esc_throttle_t entry
Definition esc_stick.h:652
bool end_open
Definition esc_stick.h:664
bool hand_menu
Definition esc_stick.h:660
uint8_t hand
Definition esc_stick.h:656
uint32_t on_ms
Definition esc_stick.h:632
uint32_t phase_ms
Definition esc_stick.h:598
How the beeps are timed and told apart from the ESC's idle current.
Definition esc_stick.h:108
uint32_t gap_min_ms
Definition esc_stick.h:110
uint32_t long_ms
Definition esc_stick.h:111
uint32_t group_gap_ms
Definition esc_stick.h:113
uint32_t off_ms
Definition esc_stick.h:116
uint32_t entry_ms
Definition esc_stick.h:114
uint32_t beep_min_ms
Definition esc_stick.h:109
uint32_t store_ms
Definition esc_stick.h:115
uint32_t long_max_ms
Definition esc_stick.h:112
uint32_t threshold_ma
Definition esc_stick.h:119
uint32_t silence_ms
Definition esc_stick.h:117
uint32_t hysteresis_ma
Definition esc_stick.h:120
uint32_t timeout_ms
Definition esc_stick.h:118