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

MOTOR & ESC as a workbench (ui_workbench.h): the task strip at the top, and the CONTROL card's TARGET row. More...

#include <stdio.h>
#include <string.h>
#include "motor_screen.h"
#include "out_bind.h"
#include "port_view.h"
#include "ui_pinlist.h"
#include "ui_target_row.h"
#include "ui_text.h"
#include "ui_theme.h"
#include "ui_workbench.h"
#include "motor_screen_int.h"

Data Structures

struct  [struct].w

Macros

#define MOTOR_TASKS

Functions

static void strip_widen (void)
 The strip's tabs laid out again at MOTOR & ESC's sizes, MO_TAB_W x MO_STRIP_H from (MO_STRIP_X, MO_STRIP_Y): the tasks, their order and their labels as ui_wb_strip_init() set them.
void mwb_reset (void)
 The strip and the TARGET row laid out; LIVE.
void mwb_enter (void)
void mwb_cancel (void)
void mwb_opened_outputs (void)
ui_wb_task_t mwb_task (void)
uint32_t mwb_revision (void)
gfx_rect_t mwb_strip_area (void)
gfx_rect_t mwb_target_rect (void)
bool mwb_pressed (void)
mwb_ev_t mwb_event (const touch_event_t *evt, bool strip, bool locked)
void mwb_render_strip (gfx_canvas_t *c)
void mwb_render_target (gfx_canvas_t *c, const char *value, bool warn, bool locked)
unsigned motor_target_cells (void)
uint8_t motor_dshot_ports (void)
static bool put_item (char *out, size_t size, size_t *n, const char *item, unsigned cells, size_t reserve)
static void item_text (unsigned i, uint64_t pins, uint8_t ports, char *buf, size_t cap)
static unsigned bits (uint64_t m)
static void target_with_ports (char *out, size_t size, const char *name, uint64_t pins, uint8_t ports, unsigned cells)
bool motor_throttle_target (char *out, size_t size, uint8_t proto, uint64_t pins, bool known, unsigned cells)
 The TARGET row's value, protocol pins ("DSHOT300 GPIO 0 GPIO 1"), in at most cells characters.

Variables

static struct  w

Detailed Description

MOTOR & ESC as a workbench (ui_workbench.h): the task strip at the top, and the CONTROL card's TARGET row.

The strip shows LIVE (the plot or the table, and the throttle), PROGRAM (the registry's MOTOR rows, motor_program_page.c) and SETTINGS (the ESC / BENCH rows, motor_settings_page.c). A tile opens LIVE; a tab switch is no navigation level. Leaving the screen switches the bench to SAFE whichever task is shown (motor_screen.c's leave()).

The TARGET row reads what the throttle drives as protocol pins ("DSHOT300 GPIO 0 GPIO 1") and is the control that changes it: a tap opens SETUP's OUTPUTS screen, where the motor's pins are bound, and the home tag there comes back to this screen on the task it left. The row is locked while the bench is not SAFE (an ARM held, asked or in force, or a DISARM not yet answered) and while the servo programmer holds its port, which is when ARM is locked too.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ MOTOR_TASKS

#define MOTOR_TASKS
Value:
(UI_WB_HAS(UI_WB_LIVE) | UI_WB_HAS(UI_WB_PROGRAM) \
| UI_WB_HAS(UI_WB_SETTINGS))
#define UI_WB_HAS(task)
Definition ui_workbench.h:48

Function Documentation

◆ motor_dshot_ports()

uint8_t motor_dshot_ports ( void )

The programming ports the bench throttle drives, bit n for port n: FUNC DSHOT150 to DSHOT600 and a pin the IOmcu holds, as port_view.h last read them.

◆ motor_target_cells()

unsigned motor_target_cells ( void )

The TARGET row's value box in 8-pixel cells (ui_target_row_cells()).

◆ motor_throttle_target()

bool motor_throttle_target ( char * out,
size_t size,
uint8_t proto,
uint64_t pins,
bool known,
unsigned cells )

The TARGET row's value, protocol pins ("DSHOT300 GPIO 0 GPIO 1"), in at most cells characters.

The protocol's catalogue name for proto, MIXED for MOTOR_PROTO_MIXED, the pins alone for a protocol not known, and as many pins as fit, then "+N" (ui_target_text()). The DShot programming ports the throttle reaches (motor_dshot_ports()) follow the pins as PORT n. A port alone is DSHOT300 PROG PORT 2 GPIO 14 where that fits, DSHOT300 PORT 2 GPIO 14 where that fits (the CONTROL card's 25 cells), and DSHOT300 PORT 2 where neither does; slots and ports of different rates read MIXED.

Parameters
outtakes the text
sizebytes at out
protothe throttle's protocol, a catalogue index or MOTOR_PROTO_MIXED; 0 for none known
pinsthe throttle pins, bit n for GPIO n
knownwhether the binding is read
cellsthe characters the value box holds
Returns
true when the value is a warning (the binding is not read, or neither a pin nor a port is bound as a motor), which the row draws in the warning colour