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

The SERVO screen's seam between its own five files. More...

#include <stdbool.h>
#include <stdint.h>
#include "outputs.h"
#include "servo_screen_int.h"

Go to the source code of this file.

Data Structures

struct  rail_t
 What the servo rail's meter reads, at the precision it is drawn with. More...

Macros

#define SHAFT_X   (PAD + 392)
 The output shaft, which everything on LIVE's card is drawn around.
#define SHAFT_Y   ((CARD_Y + READ_LBL_Y) / 2)
#define ARC_R   150
#define HORN_L   98
#define BODY_W   260
#define BODY_H   88
#define TAB_HOLE_R   12
#define TAB_MARGIN   6
#define TAB_INNER   8
#define TAB_OVER   6
#define TAB_W   (TAB_MARGIN + 2 * TAB_HOLE_R + TAB_INNER + TAB_OVER)
#define TAB_H   BODY_H
#define TAB_HOLE_DY   (BODY_H / 2 - TAB_MARGIN - TAB_HOLE_R)
 Bore's offset from the flange's centre line, px.
#define PHI(a)
 Screen angle from servo angle a: the identity, as zero is the arm pointing straight out and positive is counter-clockwise.
#define SPEED_FULL_SPAN_S   (2u * OUT_SPAN)
 SPEED's full span: two spans of OUT_SPAN a second, which is 360 degrees a second.
#define CUR_KEY_NONE   INT32_MIN
 The CURRENT row's key when it shows the dashes: INT32_MIN.

Enumerations

enum  { PS_V = 0 , PS_A , PS_W , PS_COUNT }

Functions

bool svs_command (float deg)
 A position from an input, refused while the value is not live.
void svs_drop_motion (void)
 A motion command still waiting is dropped as the bench stops driving; a release, an arm and a disarm stay.
void svs_ask_disarm (void)
 DISARM asked of an armed bench: the value leaves LIVE now.
float svs_deg_to_us_f (float deg)
 The angle deg as a pulse, us, through the profile, the trim, REVERSE and the ends; svs_deg_to_us() rounds it.
uint16_t svs_deg_to_us (float deg)
 The angle deg as a pulse, us, rounded.
servo_map_t svs_map_now (void)
 The mapping in force now.
float svs_map_cmd_to_us (const servo_map_t *m, float cmd)
 A command of m's range as a pulse, us.
float svs_map_us_to_deg (const servo_map_t *m, float us)
 A pulse as m's angle, degrees, held to its TRAVEL.
float svs_us_to_cmd (float us)
 A pulse as the far end's command, 0..OUT_SPAN of the range a command carries, and back.
float svs_cmd_to_us (float cmd)
 A far-end command, 0 to OUT_SPAN, as a pulse, us.
float svs_rest_deg (void)
 The angle the pin drives on an armed bench while nothing commands it: the outputs layer's rest for a surface.
uint16_t svs_slew_of (int pct)
 SPEED as the bench's slew.
void svs_hold_sweep (void)
 The sweep paused where the output has got to, as PAUSE does.
void svs_restart_sweep (void)
 The sweep started over under the curve the settings give now.
void svs_toggle_sweep (void)
 SWEEP's tap: start, pause or resume, or undo a tap whose command has not left.
bool svs_same_sweep (const sweep_cfg_t *a, const sweep_cfg_t *b)
 Whether two curves are the same: kind, rate, amplitude and dwell.
bool svs_speed_limits_sweep (void)
 Whether SPEED is slower than the fastest change the curve asks for, so the slew and not the curve shapes the sweep.
void svs_tick_body (float dt_s)
 The frame step: the holds, the supply followed, the sweep drawn and the drawn output moved towards the command at SPEED.
int32_t svs_fixed_of (float x, float per)
 x in units of 1/per, rounded half away from zero, held to +-10^8.
rail_t svs_rail_now (void)
 The servo rail as its meter reads it: what arrived, at the precision it is drawn with.
bool svs_arm_locked (void)
 Whether ARM takes no press: the programmer or a limit run holds the port and the bench is not armed.
bool svs_safe_at (int x, int y)
 Whether a DOWN at (x, y) lands on a control whose press stops what the bench drives.
void svs_knob_note_owner (void)
 The owners the knob yields to, latched for the frame's turn.
void svs_knob_withdraw (void)
 The knob's position command withdrawn, with the value it replaced put back.
void svs_drag_tick (float dt_s)
 The drag's frame: the filtered target moves towards the finger's by the share a frame of dt_s takes of SV_DRAG_TAU_MS, and is commanded; nothing while the value is not live.
void svs_drag_filter_end (void)
 The drag's filter ends where it has got to and commands nothing more. The one way it ends: a command, a value no longer live, its arrival, and every way the drag ends (svs_drag_end()).
void svs_drag_end (void)
 The dial's drag ends before its finger lifted – a press, a release the router or the tracker made, a touch loss, leaving, an arm edge – and its filter with it (svs_drag_filter_end()).
void svs_drag_on_post (servo_cmd_kind_t kind, uint16_t us)
 A post of kind at us ends the drag's filter, unless it is the filter's own or reissue() saying the held position again. A knob command ends it even at the pulse the filter last sent.
void svs_event_body (const touch_event_t *evt)
 A touch event on the screen's own controls and pages.
void svs_render (gfx_canvas_t *c, int buffer_index)
 The frame: what changed since buffer_index was last drawn.

Detailed Description

The SERVO screen's seam between its own five files.

The SERVO screen's own seam, between the five files the screen itself is: servo_screen.c, the state, the profile, the command and the screen's hooks; servo_screen_sweep.c, the sweep and the frame step; servo_screen_link.c, what the panel reports to the screen and takes from it; servo_screen_touch.c, the presses, the dial and the knob; and servo_screen_draw.c, the drawing. It holds the dial's geometry, the rail's reading, and the functions one of the five calls of another, prefixed svs_: among them the conversions between angle, pulse and command in servo_screen.c. Nothing outside these five files includes this header; the seam with the screen's pages and panels is servo_screen_int.h, which this header includes.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ ARC_R

#define ARC_R   150

The dial's radius, px: 22.5mm.

◆ BODY_H

#define BODY_H   88

The case's width, px.

◆ BODY_W

#define BODY_W   260

The case's length, px.

◆ HORN_L

#define HORN_L   98

The horn's length, shaft to tip, px.

◆ PHI

#define PHI ( a)
Value:
(a)

Screen angle from servo angle a: the identity, as zero is the arm pointing straight out and positive is counter-clockwise.

◆ SHAFT_X

#define SHAFT_X   (PAD + 392)

The output shaft, which everything on LIVE's card is drawn around.

It sits on the top face of the case, where a servo's output is, 392px into the card: the lead's left end, 298px left of it, and the +45 label's right edge, 200px right of it, stay inside the card. In y it is midway between the card's top and the readings' labels.

◆ SHAFT_Y

#define SHAFT_Y   ((CARD_Y + READ_LBL_Y) / 2)

The shaft's row, px.

◆ TAB_H

#define TAB_H   BODY_H

flange height: the case's width, px

◆ TAB_HOLE_R

#define TAB_HOLE_R   12

radius of a mounting bore, px

◆ TAB_INNER

#define TAB_INNER   8

between the bore and the case, px

◆ TAB_MARGIN

#define TAB_MARGIN   6

material outside the bore, px

◆ TAB_OVER

#define TAB_OVER   6

how far the case laps over the flange, px

◆ TAB_W

#define TAB_W   (TAB_MARGIN + 2 * TAB_HOLE_R + TAB_INNER + TAB_OVER)

flange width, px

Function Documentation

◆ svs_arm_locked()

bool svs_arm_locked ( void )

Whether ARM takes no press: the programmer or a limit run holds the port and the bench is not armed.

Returns
true when ARM is locked

◆ svs_cmd_to_us()

float svs_cmd_to_us ( float cmd)

A far-end command, 0 to OUT_SPAN, as a pulse, us.

Parameters
cmdthe command
Returns
the pulse, us

◆ svs_command()

bool svs_command ( float deg)

A position from an input, refused while the value is not live.

Parameters
degthe angle asked for, degrees; held to TRAVEL
Returns
true when the position was posted

◆ svs_deg_to_us()

uint16_t svs_deg_to_us ( float deg)

The angle deg as a pulse, us, rounded.

Parameters
degthe angle, degrees
Returns
the pulse, us

◆ svs_deg_to_us_f()

float svs_deg_to_us_f ( float deg)

The angle deg as a pulse, us, through the profile, the trim, REVERSE and the ends; svs_deg_to_us() rounds it.

Parameters
degthe angle, degrees
Returns
the pulse, us

◆ svs_drag_on_post()

void svs_drag_on_post ( servo_cmd_kind_t kind,
uint16_t us )

A post of kind at us ends the drag's filter, unless it is the filter's own or reissue() saying the held position again. A knob command ends it even at the pulse the filter last sent.

Parameters
kindthe command posted
usits pulse, us

◆ svs_drag_tick()

void svs_drag_tick ( float dt_s)

The drag's frame: the filtered target moves towards the finger's by the share a frame of dt_s takes of SV_DRAG_TAU_MS, and is commanded; nothing while the value is not live.

Parameters
dt_sthe time since the last frame, seconds

◆ svs_event_body()

void svs_event_body ( const touch_event_t * evt)

A touch event on the screen's own controls and pages.

Parameters
evtthe event

◆ svs_fixed_of()

int32_t svs_fixed_of ( float x,
float per )

x in units of 1/per, rounded half away from zero, held to +-10^8.

Parameters
xthe reading
perthe units in one of x's
Returns
the count

◆ svs_map_cmd_to_us()

float svs_map_cmd_to_us ( const servo_map_t * m,
float cmd )

A command of m's range as a pulse, us.

Parameters
mthe mapping
cmdthe command, 0 to OUT_SPAN
Returns
the pulse, us

◆ svs_map_now()

servo_map_t svs_map_now ( void )

The mapping in force now.

Returns
the mapping

◆ svs_map_us_to_deg()

float svs_map_us_to_deg ( const servo_map_t * m,
float us )

A pulse as m's angle, degrees, held to its TRAVEL.

Parameters
mthe mapping
usthe pulse, us
Returns
the angle, degrees

◆ svs_rail_now()

rail_t svs_rail_now ( void )

The servo rail as its meter reads it: what arrived, at the precision it is drawn with.

Returns
the meter's reading

◆ svs_render()

void svs_render ( gfx_canvas_t * c,
int buffer_index )

The frame: what changed since buffer_index was last drawn.

Parameters
cthe canvas
buffer_indexthe frame buffer drawn into

◆ svs_rest_deg()

float svs_rest_deg ( void )

The angle the pin drives on an armed bench while nothing commands it: the outputs layer's rest for a surface.

Returns
the angle, degrees

◆ svs_safe_at()

bool svs_safe_at ( int x,
int y )

Whether a DOWN at (x, y) lands on a control whose press stops what the bench drives.

Parameters
xthe press, panel px
ythe press, panel px
Returns
true when the DOWN goes to that control first

◆ svs_same_sweep()

bool svs_same_sweep ( const sweep_cfg_t * a,
const sweep_cfg_t * b )

Whether two curves are the same: kind, rate, amplitude and dwell.

Parameters
aone curve
bthe other
Returns
true when all four match

◆ svs_slew_of()

uint16_t svs_slew_of ( int pct)

SPEED as the bench's slew.

Parameters
pctSPEED, %
Returns
channel-span units a second; 0 at 100%, which is no slew

◆ svs_speed_limits_sweep()

bool svs_speed_limits_sweep ( void )

Whether SPEED is slower than the fastest change the curve asks for, so the slew and not the curve shapes the sweep.

Returns
true when SPEED limits the sweep

◆ svs_tick_body()

void svs_tick_body ( float dt_s)

The frame step: the holds, the supply followed, the sweep drawn and the drawn output moved towards the command at SPEED.

Parameters
dt_sthe time since the last frame, seconds

◆ svs_us_to_cmd()

float svs_us_to_cmd ( float us)

A pulse as the far end's command, 0..OUT_SPAN of the range a command carries, and back.

Parameters
usthe pulse, us
Returns
the command, 0 to OUT_SPAN