rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_screen_core_int.h
Go to the documentation of this file.
1
19#pragma once
20
21#include <stdbool.h>
22#include <stdint.h>
23
24#include "outputs.h"
25#include "servo_screen_int.h"
26
35#define SHAFT_X (PAD + 392)
36/* Integer division on purpose: this is a pixel row. */
37/* NOLINTNEXTLINE(bugprone-integer-division) */
38#define SHAFT_Y ((CARD_Y + READ_LBL_Y) / 2)
39#define ARC_R 150
40#define HORN_L 98
41#define BODY_W 260
42#define BODY_H 88
43_Static_assert(SHAFT_X - BODY_W + 24 - 62 >= PAD + 12,
44 "the servo's lead starts inside LIVE's card");
45_Static_assert(SHAFT_X + ARC_R + 26 + 24 <= PAD + LCARD_W - 12,
46 "the dial's labels end inside LIVE's card");
47_Static_assert(SHAFT_Y - ARC_R - 36 >= CARD_Y + 4,
48 "the dial's +90 label ends inside LIVE's card");
49_Static_assert(SHAFT_Y + ARC_R + 36 <= READ_LBL_Y - 4,
50 "the dial's -90 label ends above the readings");
51_Static_assert(PAD + 10 + BOX_W <= SHAFT_X - 36,
52 "the run's box stays clear of the horn and its rings");
53/*
54 * The mounting flanges run the full width of the case end, as on a servo.
55 *
56 * The three clearances are the chosen numbers. The flange width is what
57 * holds a bore with TAB_MARGIN of material outside it and TAB_INNER between
58 * it and the case, and the hole positions follow from the same margin top
59 * and bottom.
60 */
61#define TAB_HOLE_R 12
62#define TAB_MARGIN 6
63#define TAB_INNER 8
64#define TAB_OVER 6
65#define TAB_W (TAB_MARGIN + 2 * TAB_HOLE_R + TAB_INNER + TAB_OVER)
66#define TAB_H BODY_H
68#define TAB_HOLE_DY (BODY_H / 2 - TAB_MARGIN - TAB_HOLE_R)
69
70/*
71 * Screen angle from servo angle.
72 *
73 * The case lies along the card with its output at the right-hand end; zero
74 * is the arm pointing straight out, and positive is counter-clockwise, the
75 * convention every other angle on the bench uses.
76 */
81#define PHI(a) (a)
82
83/* The power plot's series: the servo rail's voltage, current and power. */
84enum { PS_V = 0, PS_A, PS_W, PS_COUNT };
85
86/*
87 * SPEED as the bench's slew, in channel-span units a second.
88 *
89 * The horn's full travel is 180 degrees and a channel's span covers it, so
90 * SPEED_FULL_SPAN_S, two spans a second, is 360 degrees a second. Below
91 * 100% the bench ramps the command at that fraction of it, and a servo
92 * asked for 30% takes three times as long to cross as one asked for 90%.
93 *
94 * 100% is immediate rather than two spans a second, at the far end and in
95 * the drawing (slew_per_ms()). It is the value the screen starts at, so
96 * anybody who never touches the slider gets the servo at its own rate,
97 * with nothing in front of it.
98 */
103#define SPEED_FULL_SPAN_S (2u * OUT_SPAN)
104
105/* What the servo rail's meter reads, at the precision it is drawn with. */
110typedef struct {
111 bool v_ok,
113 float v;
114 float i;
115 float p;
116 int32_t q_a;
117 bool clipped;
118} rail_t;
119
120/* What the CURRENT row shows: the dashes, or the digits and their colour. */
122#define CUR_KEY_NONE INT32_MIN
123
124/* --- the functions one file calls of another ---------------------------- */
125
126/* servo_screen.c */
127
133bool svs_command(float deg);
136void svs_drop_motion(void);
138void svs_ask_disarm(void);
144float svs_deg_to_us_f(float deg);
150uint16_t svs_deg_to_us(float deg);
162float svs_map_cmd_to_us(const servo_map_t *m, float cmd);
169float svs_map_us_to_deg(const servo_map_t *m, float us);
175float svs_us_to_cmd(float us);
181float svs_cmd_to_us(float cmd);
186float svs_rest_deg(void);
192uint16_t svs_slew_of(int pct);
193
194/* servo_screen_sweep.c */
195
197void svs_hold_sweep(void);
199void svs_restart_sweep(void);
202void svs_toggle_sweep(void);
209bool svs_same_sweep(const sweep_cfg_t *a, const sweep_cfg_t *b);
214bool svs_speed_limits_sweep(void);
220void svs_tick_body(float dt_s);
221
222/* servo_screen_link.c */
223
231int32_t svs_fixed_of(float x, float per);
236rail_t svs_rail_now(void);
237
238/* servo_screen_touch.c */
239
244bool svs_arm_locked(void);
252bool svs_safe_at(int x, int y);
254void svs_knob_note_owner(void);
257void svs_knob_withdraw(void);
264void svs_drag_tick(float dt_s);
270void svs_drag_filter_end(void);
276void svs_drag_end(void);
284void svs_drag_on_post(servo_cmd_kind_t kind, uint16_t us);
289void svs_event_body(const touch_event_t *evt);
290
291/* servo_screen_draw.c */
292
298void svs_render(gfx_canvas_t *c, int buffer_index);
#define PAD
Definition analyser_screen.c:26
#define LCARD_W
Definition analyser_screen.c:52
#define CARD_Y
Definition balance_screen.c:44
#define BOX_W
Definition motor_settings_page.c:74
The intermediary every output goes through: one set of rules for arming, clamping,...
servo_cmd_kind_t
The kind of a command of the SERVO screen.
Definition servo_cmd.h:23
uint16_t svs_slew_of(int pct)
SPEED as the bench's slew.
Definition servo_screen.c:221
float svs_cmd_to_us(float cmd)
A far-end command, 0 to OUT_SPAN, as a pulse, us.
Definition servo_screen.c:182
float svs_map_us_to_deg(const servo_map_t *m, float us)
A pulse as m's angle, degrees, held to its TRAVEL.
Definition servo_screen.c:154
servo_map_t svs_map_now(void)
The mapping in force now.
Definition servo_screen.c:137
void svs_drop_motion(void)
A motion command still waiting is dropped as the bench stops driving; a release, an arm and a disarm ...
Definition servo_screen.c:430
void svs_ask_disarm(void)
DISARM asked of an armed bench: the value leaves LIVE now.
Definition servo_screen.c:616
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 ...
Definition servo_screen.c:195
bool svs_command(float deg)
A position from an input, refused while the value is not live.
Definition servo_screen.c:412
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() ro...
Definition servo_screen.c:110
uint16_t svs_deg_to_us(float deg)
The angle deg as a pulse, us, rounded.
Definition servo_screen.c:120
float svs_map_cmd_to_us(const servo_map_t *m, float cmd)
A command of m's range as a pulse, us.
Definition servo_screen.c:146
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.
Definition servo_screen.c:174
rail_t svs_rail_now(void)
The servo rail as its meter reads it: what arrived, at the precision it is drawn with.
Definition servo_screen_link.c:333
void svs_restart_sweep(void)
The sweep started over under the curve the settings give now.
Definition servo_screen_sweep.c:201
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.
Definition servo_screen_touch.c:29
#define BODY_W
Definition servo_screen_core_int.h:41
void svs_knob_note_owner(void)
The owners the knob yields to, latched for the frame's turn.
Definition servo_screen_touch.c:106
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.
Definition servo_screen_sweep.c:229
void svs_render(gfx_canvas_t *c, int buffer_index)
The frame: what changed since buffer_index was last drawn.
Definition servo_screen_draw.c:935
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 sha...
Definition servo_screen_sweep.c:223
void svs_knob_withdraw(void)
The knob's position command withdrawn, with the value it replaced put back.
Definition servo_screen_touch.c:121
void svs_toggle_sweep(void)
SWEEP's tap: start, pause or resume, or undo a tap whose command has not left.
Definition servo_screen_sweep.c:274
void svs_tick_body(float dt_s)
The frame step: the holds, the supply followed, the sweep drawn and the drawn output moved towards th...
Definition servo_screen_sweep.c:609
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 o...
Definition servo_screen_touch.c:186
void svs_hold_sweep(void)
The sweep paused where the output has got to, as PAUSE does.
Definition servo_screen_sweep.c:111
#define SHAFT_X
The output shaft, which everything on LIVE's card is drawn around.
Definition servo_screen_core_int.h:35
void svs_drag_end(void)
The dial's drag ends before its finger lifted – a press, a release the router or the tracker made,...
Definition servo_screen_touch.c:167
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,...
Definition servo_screen_touch.c:162
void svs_event_body(const touch_event_t *evt)
A touch event on the screen's own controls and pages.
Definition servo_screen_touch.c:260
#define ARC_R
Definition servo_screen_core_int.h:39
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.
Definition servo_screen_touch.c:45
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 he...
Definition servo_screen_touch.c:173
int32_t svs_fixed_of(float x, float per)
x in units of 1/per, rounded half away from zero, held to +-10^8.
Definition servo_screen_link.c:314
The SERVO screen's private seam between servo_screen*.c, the screen, servo_workbench....
#define READ_LBL_Y
Definition servo_screen_int.h:174
Definition gfx.h:129
What the servo rail's meter reads, at the precision it is drawn with.
Definition servo_screen_core_int.h:110
float i
Definition servo_screen_core_int.h:114
float p
Definition servo_screen_core_int.h:115
int32_t q_a
Definition servo_screen_core_int.h:116
bool clipped
Definition servo_screen_core_int.h:117
float v
Definition servo_screen_core_int.h:113
bool v_ok
Definition servo_screen_core_int.h:111
bool i_ok
Definition servo_screen_core_int.h:112
Definition servo_screen_int.h:300
Definition servo_sweep.h:55
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69