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

ESC STICK, the session MOTOR & ESC > PROGRAM opens: an ESC (electronic speed controller) with no wire to talk on, programmed through its throttle-stick menu. Its list is the ESC profiles (esc_profile.h), its parameters are the profile's menu items, and its write is a run of the stick programmer (esc_stick.h): the bench arms, holds the throttle at the entry position, switches the supply on and counts the beeps in the supply current. A run starts only from a red warning held for two seconds, as ARM and the servo's HV warning are, and every move it makes goes out as the MOTOR & ESC screen's commands do, through the arming policy and the output bank. More...

#include "esc_stick_panel.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "esc_profile.h"
#include "prog_registry.h"
#include "settings.h"
#include "supply_screen.h"
#include "ui_text.h"
#include "ui_textkey.h"
#include "ui_widgets.h"
#include "esc_stick_panel_int.h"

Functions

void esc_stick_panel_reset (void)
 The page set's init: the panel's state cleared and its controls laid out, TIMING's keypad closed.
void esc_stick_panel_enter (void)
 The host's entry.
void esc_stick_panel_open (void)
 The session opens on the makers, from the top, the search as typed; TIMING and its keypad closed.
size_t sp_changes (esc_stick_change_t *ch, size_t *picked)
 The picks as changes, in item order.
void sp_timing (esc_stick_timing_t *t)
 The timing as the settings hold it, the profile's own entry where it states one.
void sp_supply (uint32_t *mv, uint32_t *ma)
 The supply's set points for a run, mV and mA: VOLTAGE, or the profile's cell count when it is 0.
static const char * sp_bench_why (void)
static bool sp_plan (esc_stick_change_t *ch, size_t *n, esc_stick_timing_t *t, uint32_t *mv, uint32_t *ma)
bool sp_supply_reads_off (void)
 Whether the supply reads off now, by the rule a run holds the supply to.
bool sp_warn_gated (void)
 Whether the warning asks a step at an unpowered ESC of the operator and may not, as the supply does not read off.
bool sp_warn_steps_fit (const esc_profile_t *p)
 Whether the warning shows every before-power step of p whole.
unsigned sp_later_steps (const esc_profile_t *p)
 The steps of p the run stops for after the warning's.
bool sp_hold_blocked (void)
 Whether HOLD TO RUN may not count.
bool sp_can_run (void)
 Whether a run can start now.
static void sp_push (motor_cmd_kind_t kind, float value)
void sp_follow (void)
 What the run asks for, onto the paths an operator's own presses take.
static void sp_start (void)
void sp_end_hold (void)
 The warning's hold dropped, with nothing started.
static uint32_t sp_signature (void)
void esc_stick_panel_tick (float dt_s)
 A frame.
void esc_stick_panel_leave (void)
 The host is left: a run ends, the warning, the search's keyboard and TIMING's keypad close, and TIMING asks for a save of what it changed.
static bool sp_drop_drive (void)
void sp_end_run (esc_stick_reason_t why)
 The run ends now as why; nothing it queued survives.
void esc_stick_panel_cancel (void)
 Touches were lost: a press that may become a tap ends, a hold ends, a key held on the keyboard or the keypad is let go with what was typed kept, and a run whose arm is not yet in force ends.
void esc_stick_panel_bench (uint32_t now_ms, bool armed, uint32_t stops, uint32_t pressed, bool link_up)
void esc_stick_panel_set_throttle (bool read, uint8_t channels)
void esc_stick_panel_tone (const tone_readout_t *r)
void esc_stick_panel_supply (const supply_state_t *st)
bool esc_stick_panel_poll_cmd (motor_cmd_t *out)
const esc_profile_t * esc_stick_panel_profile (void)
uint32_t esc_stick_panel_runs (void)
const esc_stick_t * esc_stick_panel_stick (void)
const char * esc_stick_panel_search (void)
bool esc_stick_panel_typing (void)
int esc_stick_panel_listed (int *top)
int esc_stick_panel_level (void)
const char * esc_stick_panel_maker (void)
int esc_stick_panel_model (void)
const esc_profile_t * esc_stick_panel_row (int i, int *model)
const char * esc_stick_panel_row_why (int i)
int esc_stick_panel_item_at (int i)
const char * esc_stick_panel_row_warn (int i)
const char * esc_stick_panel_result_head (void)
const char * esc_stick_panel_result_more (void)
const char * esc_stick_panel_left_text (void)
const char * esc_stick_panel_note (void)
const char * esc_stick_panel_maker_at (int i)
uint32_t esc_stick_panel_entry_shown (void)
bool esc_stick_panel_supply_reads_off (void)
const char * esc_stick_panel_hand_why (void)
const esc_profile_t * esc_stick_panel_page (void)
bool esc_stick_panel_hand_shown (void)
void esc_stick_panel_lights (bool *red, bool *green)

Variables

const setting_id_t sp_settings_list []
 The TIMING page's settings, SP_SETTINGS of them, in the order the page lists them.
sp_state_t esc_stick_s
 The state, esc_stick_s, in esc_stick_panel.c, so its .bss stays where psram_bss.lf puts esc_stick_panel's. The files read it as s, the name it had as the one file's static: the object's own name keeps it apart from the SERVO screen's s.

Detailed Description

ESC STICK, the session MOTOR & ESC > PROGRAM opens: an ESC (electronic speed controller) with no wire to talk on, programmed through its throttle-stick menu. Its list is the ESC profiles (esc_profile.h), its parameters are the profile's menu items, and its write is a run of the stick programmer (esc_stick.h): the bench arms, holds the throttle at the entry position, switches the supply on and counts the beeps in the supply current. A run starts only from a red warning held for two seconds, as ARM and the servo's HV warning are, and every move it makes goes out as the MOTOR & ESC screen's commands do, through the arming policy and the output bank.

The profile list has two levels: the makers, alphabetical, and one maker's models, by current, voltage and name, each opening its family's profile. A search field filters both. Its keyboard docks on the right while it is open and the rows narrow to its left, so the list filters with every key and stays in view. A run shows a stack light: green while the detector holds a beep, red on a result that ended because something was not as expected (esc_stick_reason_is_fault()).

A profile whose ESC needs a person at it – a jumper, a button – lists those steps (esc_profile_t's manual). Its page carries MANUAL INTERVENTION REQUIRED, which shows them over the screen, as does the first opening; the warning lists those due before the power-up, and a run that waits for one covers the page with DONE and ABORT.

The pages draw on the session's layout, the body under MOTOR & ESC's output strip, and take their controls through the session's tap walk (esc_stick_int.h, esc_stick_pages.c). The interface is esc_stick_panel.h.

This file is the state, a run and the application's side. The profile list is esc_stick_list.c, the presses esc_stick_touch.c, the list and a profile's pages drawn esc_stick_draw.c, and a run, the RUN warning and the manual steps drawn esc_stick_draw_run.c, with esc_stick_panel_int.h between them.

SPDX-License-Identifier: MIT

Function Documentation

◆ esc_stick_panel_bench()

void esc_stick_panel_bench ( uint32_t now_ms,
bool armed,
uint32_t stops,
uint32_t pressed,
bool link_up )

The bench as this frame found it, before the frame's touch: the time, whether it is armed, how many stops have been counted and how many of those an operator pressed (arming_pressed_count()), and whether the IOmcu answers. A stop count that moved ends the warning's hold, and a run: with STOP when every new stop was pressed, else with BENCH STOPPED.

◆ esc_stick_panel_entry_shown()

uint32_t esc_stick_panel_entry_shown ( void )

The entry time the profile's page shows, ms; for tests.

◆ esc_stick_panel_hand_shown()

bool esc_stick_panel_hand_shown ( void )

Whether the manual steps' pop-up is open; for tests.

◆ esc_stick_panel_hand_why()

const char * esc_stick_panel_hand_why ( void )

Why the manual steps' pop-up says its profile does not run, for the model it was opened for; NULL when it runs or no pop-up is open. For tests.

◆ esc_stick_panel_item_at()

int esc_stick_panel_item_at ( int i)

The item row i of the page shows, as an index into the profile's items; -1 past the last. For tests.

◆ esc_stick_panel_left_text()

const char * esc_stick_panel_left_text ( void )

The prompt's line on what no DONE does, as the prompt would draw it now; for tests.

◆ esc_stick_panel_level()

int esc_stick_panel_level ( void )

The list's level: 0 the makers, 1 one maker's models; the maker open ("" on level 0); the page's model index (-1 for none); and the rows of each level, NULL past the end. For tests.

◆ esc_stick_panel_lights()

void esc_stick_panel_lights ( bool * red,
bool * green )

What the stack light shows; for tests.

◆ esc_stick_panel_listed()

int esc_stick_panel_listed ( int * top)

How many profiles the list holds under the search, and the index in it of the top row shown; for tests.

◆ esc_stick_panel_note()

const char * esc_stick_panel_note ( void )

The note the page shows under RUN: why a run cannot start, "" for none; for tests.

◆ esc_stick_panel_page()

const esc_profile_t * esc_stick_panel_page ( void )

The profile whose page is open, or NULL on the list; for tests.

◆ esc_stick_panel_poll_cmd()

bool esc_stick_panel_poll_cmd ( motor_cmd_t * out)

A command a stick run asks for, oldest first; true when there was one.

◆ esc_stick_panel_profile()

const esc_profile_t * esc_stick_panel_profile ( void )

The profile of a stick run under way, for the simulated ESC on the panel's modelled supply; NULL when none is.

◆ esc_stick_panel_result_head()

const char * esc_stick_panel_result_head ( void )

The result's count of the selections made, and its line for the changes past the fourth ("" when all show), as drawn now; for tests.

◆ esc_stick_panel_row_warn()

const char * esc_stick_panel_row_warn ( int i)

The warning row i shows while it runs: the ESC's voltage rating unknown; NULL for none. For tests.

◆ esc_stick_panel_row_why()

const char * esc_stick_panel_row_why ( int i)

Why row i of a maker's models does not run, in the language showing, or NULL when it runs or there is no such row; for tests.

◆ esc_stick_panel_runs()

uint32_t esc_stick_panel_runs ( void )

How many stick runs have started, so a new one starts a fresh simulation.

◆ esc_stick_panel_search()

const char * esc_stick_panel_search ( void )

The ESC STICK search as typed, "" for none, and whether its keyboard is open; for tests.

◆ esc_stick_panel_set_throttle()

void esc_stick_panel_set_throttle ( bool read,
uint8_t channels )

The output binding, every frame: whether one is read (BIND_READ_OK), and the channels it binds as a throttle (outputs_role_channels(), one bit each). RUN is refused while none is read or it binds no throttle, and while the supply is the panel's model (supply_screen_model()); the note names which. Zero at start: nothing is known until the application says.

◆ esc_stick_panel_stick()

const esc_stick_t * esc_stick_panel_stick ( void )

The stick run, under way or ended, for tests.

◆ esc_stick_panel_supply()

void esc_stick_panel_supply ( const supply_state_t * st)

One supply sample, every one, in the order they were taken.

◆ esc_stick_panel_supply_reads_off()

bool esc_stick_panel_supply_reads_off ( void )

Whether the supply reads off now, by the rule a run holds it to: its own state off, the current at or under ESC_STICK_OFF_MA for ESC_STICK_OFF_SETTLE_MS, in a reading no older than ESC_STICK_STALE_MS. For tests.

◆ esc_stick_panel_tick()

void esc_stick_panel_tick ( float dt_s)

A frame.

Parameters
dt_sThe frame's time, s.

◆ esc_stick_panel_tone()

void esc_stick_panel_tone ( const tone_readout_t * r)

The phase tap as the control task last read it (tone_link_readout()), every frame. While the tap is enabled on SETUP a stick run's page shows it: its state, the last window's pitch, the last beeps, and the counts of beeps lost and beeps not read. The pitch and the lost count read "--" while tone_readout_t.read is false. Read only: the run still counts its beeps from the supply current.

◆ sp_can_run()

bool sp_can_run ( void )

Whether a run can start now.

Returns
true when a run can start

◆ sp_changes()

size_t sp_changes ( esc_stick_change_t * ch,
size_t * picked )

The picks as changes, in item order.

Parameters
chthe changes, ESC_STICK_MAX_CHANGES of them at most
pickedhow many were picked in all
Returns
the changes written to ch

◆ sp_end_run()

void sp_end_run ( esc_stick_reason_t why)

The run ends now as why; nothing it queued survives.

Parameters
whythe reason the run ends

◆ sp_hold_blocked()

bool sp_hold_blocked ( void )

Whether HOLD TO RUN may not count.

Returns
true when the hold is blocked

◆ sp_later_steps()

unsigned sp_later_steps ( const esc_profile_t * p)

The steps of p the run stops for after the warning's.

Parameters
pthe profile
Returns
the number of steps

◆ sp_supply()

void sp_supply ( uint32_t * mv,
uint32_t * ma )

The supply's set points for a run, mV and mA: VOLTAGE, or the profile's cell count when it is 0.

Parameters
mvthe voltage, written, mV
mathe current, written, mA

◆ sp_supply_reads_off()

bool sp_supply_reads_off ( void )

Whether the supply reads off now, by the rule a run holds the supply to.

Returns
true when the supply reads off

◆ sp_timing()

void sp_timing ( esc_stick_timing_t * t)

The timing as the settings hold it, the profile's own entry where it states one.

Parameters
tthe timing, written

◆ sp_warn_gated()

bool sp_warn_gated ( void )

Whether the warning asks a step at an unpowered ESC of the operator and may not, as the supply does not read off.

Returns
true when the warning is gated

◆ sp_warn_steps_fit()

bool sp_warn_steps_fit ( const esc_profile_t * p)

Whether the warning shows every before-power step of p whole.

Parameters
pthe profile
Returns
true when every step fits

Variable Documentation

◆ sp_settings_list

const setting_id_t sp_settings_list[]
Initial value:
= {
SET_STICK_V, SET_STICK_I, SET_STICK_BEEP_MIN, SET_STICK_GAP_MIN,
SET_STICK_LONG, SET_STICK_LONG_MAX, SET_STICK_GROUP_GAP, SET_STICK_ENTRY,
SET_STICK_STORE, SET_STICK_OFF, SET_STICK_SILENCE, SET_STICK_TIMEOUT,
SET_STICK_THRESHOLD, SET_STICK_HYST,
}

The TIMING page's settings, SP_SETTINGS of them, in the order the page lists them.