|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The private seam between motor_screen.c, the MOTOR & ESC screen's state, commands and interface, motor_events.c, its touch events and frames, and motor_draw.c, its drawing: LIVE's layout inside motor_screen_int.h's, the channels, the state and the functions one calls in another. The other files of the screen (motor_workbench.c, motor_program_page.c, motor_settings_page.c) keep their own state and do not include this header. Nothing outside shared/ui includes it. More...
#include <stdbool.h>#include <stdint.h>#include "gfx.h"#include "motor_screen.h"#include "touch_types.h"#include "ui_plot.h"#include "ui_slider.h"#include "ui_tabs.h"#include "ui_text.h"#include "ui_value_gate.h"#include "ui_widgets.h"#include "motor_screen_int.h"Go to the source code of this file.
Data Structures | |
| struct | mo_state_t |
| MOTOR & ESC's LIVE state: the plot, the throttle slider and the bench's report, the ARM gate, the knob's pending command, the revisions each frame buffer last drew and the touches tracked. More... | |
Macros | |
| #define | SUB_Y (UP_Y + TITLE_H + 6) |
| #define | SUB_H 40 |
| #define | SUB_W 200 |
| #define | LEG_Y (SUB_Y + SUB_H + 4) |
| #define | LEG_H 20 |
| #define | PLOT_X (LEFT_X + INNER) |
| #define | PLOT_W (LEFT_W - 2 * INNER) |
| #define | PLOT_Y (LEG_Y + LEG_H + 4) |
| #define | PLOT_H (UP_Y + UP_H - INNER - PLOT_Y) |
| #define | RATE_X (PLOT_X + SUB_W + 14) |
| The poll rate and the link's errors, right of PLOT | TABLE. | |
| #define | ROW_Y (LO_Y + 4) |
| #define | READOUT_W 260 |
| #define | READOUT_H 46 |
| #define | READOUT_X (LEFT_X + LEFT_W - INNER - READOUT_W) |
| #define | NUDGE_W 72 |
| #define | NUDGE_H 56 |
| #define | CTRL_Y (ROW_Y + READOUT_H + 4) |
| #define | TRACK_H 48 |
| #define | TRACK_Y (CTRL_Y + (NUDGE_H - TRACK_H) / 2) |
| #define | TRACK_X (LEFT_X + INNER + NUDGE_W + 8) |
| #define | THR_R (RC_X - UI_TAP_MIN) |
| The right end of the step keys' row: UI_TAP_MIN left of the rail's column, so a finger that misses DISARM to its left lands on no throttle control. +1 is x 528 to 599, DISARM from x 648. | |
| #define | TRACK_W (THR_R - NUDGE_W - 8 - TRACK_X) |
| The track's length: 422px, between the two step keys. | |
| #define | HINT_Y (CTRL_Y + NUDGE_H + 8) |
| #define | HINT_X (LEFT_X + INNER) |
| The hint's left edge, at the card's padding. The hint draws in MO_FONT_FINE: the German one is 61 cells, 488px. | |
| #define | ARM_HOLD_S UI_HOLD_S |
| ARM is a hold, not a press: two seconds from the OK green to the danger red, and the command goes when the fade completes. A release before then arms nothing, and neither does a finger that leaves the button: the gesture is contact with the control, not with the panel. A bench that spins a propeller should not do it on a touch that could have been an elbow. | |
| #define | SAMPLE_HZ 20.0f |
| The panel's polling rate, 20Hz: one sample per plot column, so the time base is PLOT_W / 20s. | |
| #define | s mo_s |
| Short name for mo_s inside the MOTOR & ESC files. | |
Enumerations | |
| enum | { S_VOLT = 0 , S_CURR , S_POWER , S_RPM , S_COUNT } |
Functions | |
| void | mo_bind_colours (void) |
| Sets the plot's and the slider's colours from the active theme. | |
| bool | mo_value_live (void) |
| Returns whether the throttle follows its controls: only in UI_VALUE_LIVE, not on a disarmed bench, not between the ARM hold and the bench's answer, and not after a DISARM or STOP until the bench reports disarmed. | |
| void | mo_end_drag (void) |
| Ends a drag on the track and keeps the knob out of the frame. | |
| void | mo_post (motor_cmd_kind_t kind, float value) |
| Posts a command in the one slot, coalescing: a new command overwrites the pending one, except that a pending DISARM survives everything. | |
| bool | mo_arm_locked (void) |
| Whether ARM takes no press: the servo programmer holds a port, or the binding names no motor pin. DISARM takes a press in both. | |
| bool | mo_no_motor_pin (void) |
| Whether the throttle's binding is read and names no motor pin: no GPIO (general-purpose input/output) pin and no DShot port. The TARGET row then reads NO MOTOR PIN, and nothing can be driven. | |
| void | mo_throttle_from_zero (void) |
| Puts the slider, the readout and the step keys at 0% across an arm or disarm edge, drops a pending throttle and releases a drag. | |
| bool | mo_bench_safe (void) |
| Returns whether the bench is SAFE as this screen sees it: disarmed, with no ARM or DISARM asked and unanswered. | |
| bool | mo_endpoints_free (void) |
| Returns whether the Idle pulse and Full pulse may change: SAFE and ARM not held. | |
| bool | mo_target_locked (void) |
| Returns whether the TARGET row takes no press: the bench is not SAFE, ARM is held or the servo programmer holds its port. | |
| bool | mo_safe_at (int x, int y) |
Returns whether a DOWN at (x, y) is on a control whose press stops what the bench drives: a session's ABORT, or DISARM while the button reads DISARM. | |
| void | mo_event (const touch_event_t *evt) |
| Takes a touch event. | |
| void | mo_tick (float dt_s) |
| Advances the screen by one frame: the ARM hold and flash animations, the knob and the polled state. | |
| void | mo_render (gfx_canvas_t *c, int buffer_index) |
Draws the screen into frame buffer buffer_index. | |
Variables | |
| mo_state_t | mo_s |
| MOTOR & ESC's LIVE state, in motor_screen.c. | |
| const ui_plot_series_t | mo_series [S_COUNT] |
| The four channels' plot series: volts, amps, power and RPM. | |
| const uint16_t | mo_ok [S_COUNT] |
| Per channel, the bench report flags that make its reading valid. | |
| const ui_text_id_t | mo_names [S_COUNT] |
| Per channel, the text id of its name. | |
The private seam between motor_screen.c, the MOTOR & ESC screen's state, commands and interface, motor_events.c, its touch events and frames, and motor_draw.c, its drawing: LIVE's layout inside motor_screen_int.h's, the channels, the state and the functions one calls in another. The other files of the screen (motor_workbench.c, motor_program_page.c, motor_settings_page.c) keep their own state and do not include this header. Nothing outside shared/ui includes it.
Included last: it names the state s, which no header included after it may meet. What one file calls or reads in another carries the prefix mo_.
SPDX-License-Identifier: MIT
| #define ARM_HOLD_S UI_HOLD_S |
ARM is a hold, not a press: two seconds from the OK green to the danger red, and the command goes when the fade completes. A release before then arms nothing, and neither does a finger that leaves the button: the gesture is contact with the control, not with the panel. A bench that spins a propeller should not do it on a touch that could have been an elbow.
The timing, the fade and the flash are ui_widgets' (UI_HOLD_S, ui_hold_fill, ui_hold_flash), so the other gesture that is held rather than pressed cannot come to look different from this one.
| #define LEG_H 20 |
Its height, px.
| #define NUDGE_H 56 |
Its height, px.
| #define NUDGE_W 72 |
A step key's width, px.
| #define READOUT_H 46 |
Its height, px.
| #define READOUT_W 260 |
Its box, at the right, px.
| #define ROW_Y (LO_Y + 4) |
The readout's top, px.
| #define SUB_H 40 |
Their height, px.
| #define SUB_W 200 |
Their row: two of 98px.
| #define TRACK_H 48 |
The track's height, px.
| bool mo_arm_locked | ( | void | ) |
Whether ARM takes no press: the servo programmer holds a port, or the binding names no motor pin. DISARM takes a press in both.
| bool mo_bench_safe | ( | void | ) |
Returns whether the bench is SAFE as this screen sees it: disarmed, with no ARM or DISARM asked and unanswered.
| bool mo_endpoints_free | ( | void | ) |
Returns whether the Idle pulse and Full pulse may change: SAFE and ARM not held.
| void mo_event | ( | const touch_event_t * | evt | ) |
Takes a touch event.
| evt | the event |
| bool mo_no_motor_pin | ( | void | ) |
Whether the throttle's binding is read and names no motor pin: no GPIO (general-purpose input/output) pin and no DShot port. The TARGET row then reads NO MOTOR PIN, and nothing can be driven.
| void mo_post | ( | motor_cmd_kind_t | kind, |
| float | value ) |
Posts a command in the one slot, coalescing: a new command overwrites the pending one, except that a pending DISARM survives everything.
| kind | the command |
| value | the throttle for MOTOR_CMD_THROTTLE, percent |
| void mo_render | ( | gfx_canvas_t * | c, |
| int | buffer_index ) |
Draws the screen into frame buffer buffer_index.
| c | canvas drawn on |
| buffer_index | the frame buffer |
| bool mo_safe_at | ( | int | x, |
| int | y ) |
Returns whether a DOWN at (x, y) is on a control whose press stops what the bench drives: a session's ABORT, or DISARM while the button reads DISARM.
| x | column, px |
| y | row, px |
| bool mo_target_locked | ( | void | ) |
Returns whether the TARGET row takes no press: the bench is not SAFE, ARM is held or the servo programmer holds its port.
| void mo_tick | ( | float | dt_s | ) |
Advances the screen by one frame: the ARM hold and flash animations, the knob and the polled state.
| dt_s | time since the last tick, s |
| bool mo_value_live | ( | void | ) |
Returns whether the throttle follows its controls: only in UI_VALUE_LIVE, not on a disarmed bench, not between the ARM hold and the bench's answer, and not after a DISARM or STOP until the bench reports disarmed.