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

MOTOR & ESC > SETTINGS: the ESC / BENCH category's 8 rows (SET_CAT_ESC), under PACK, MOTOR and THROTTLE OUTPUT. The rows are the settings SETUP listed before they moved here: one home each, the same label, help and value text. More...

#include <stdio.h>
#include <string.h>
#include "motor_screen.h"
#include "settings.h"
#include "ui_keypad.h"
#include "ui_setting_keypad.h"
#include "ui_text.h"
#include "ui_theme.h"
#include "ui_widgets.h"
#include "motor_screen_int.h"

Data Structures

struct  [struct].k_rows
struct  [struct].p
 The page's state. More...

Macros

#define ROW_COUNT   ((int)(sizeof(k_rows) / sizeof(k_rows[0])))
#define TOP_Y   (PAGE_Y + 8)
#define HEAD_H   28
#define HEAD_GAP   8
#define ROW_PITCH   68
#define BOX_H   UI_TAP_MIN
#define BOX_W   120
#define HELP_DY   (BOX_H + 2)
#define COL_W   ((PAGE_W - 30) / 2)
#define COL_X(k)
 Column k's left edge, px.
#define SAVE_Y   (STOP_FLOOR - 20)
#define MS_FONT   (&gfx_font_10x20)
#define MS_FINE   UI_FONT_FINE

Enumerations

enum  { HD_PACK = 0 , HD_MOTOR , HD_THROTTLE , HD_COUNT }

Functions

static uint8_t save_state (void)
static int col_of (int i)
 The column row i is in: THROTTLE OUTPUT's rows on the right.
static int row_y (int i)
 The top of row i: its column's headings above it and its place among the column's rows.
static gfx_rect_t box_rect (int i)
 Row i's value box, at its column's right.
static bool safe_only (int i)
static bool row_locked (int i, bool safe)
static int decimals_of (const setting_def_t *d)
static void open_keypad (int i)
static void close_keypad (void)
void msp_reset (void)
void msp_leave (void)
void msp_cancel (void)
bool msp_modal (void)
bool msp_pressed (void)
bool msp_back (void)
uint32_t msp_revision (void)
void msp_tick (bool safe)
void msp_event (const touch_event_t *evt, bool safe)
static void draw_row (gfx_canvas_t *c, int i, bool safe)
 Row i: its label, its value box at the column's right and its help line, or the lock's reason, under them.
void msp_render (gfx_canvas_t *c, bool safe)
 SETTINGS' page in its two columns, or the keypad over it.
int motor_screen_keypad_setting (void)
const ui_keypad_t * motor_screen_keypad (void)
 SETTINGS' keypad, open or closed, for a test to read what it opened with and where its keys are.
int motor_settings_rows (setting_id_t *out, int max)
int motor_settings_heading (int row)
const char * motor_endpoints_alert (endpoints_block_t why)
gfx_rect_t motor_settings_box (int row)

Variables

static const struct  k_rows []
static const ui_text_id_t k_heading [HD_COUNT]
static struct  p

Detailed Description

MOTOR & ESC > SETTINGS: the ESC / BENCH category's 8 rows (SET_CAT_ESC), under PACK, MOTOR and THROTTLE OUTPUT. The rows are the settings SETUP listed before they moved here: one home each, the same label, help and value text.

A tap on a row's value opens the keypad over the page and the strip; its OK sets the value onto the setting's step inside its range and asks for a save (settings_request_save()). The store is one set: the panel writes the whole of it when the bench is SAFE and no transfer runs, so a value changed on SETUP and not saved there is written with it. The line at the page's foot says where the store stands: SAVED, SAVE PENDING, NOT SAVED, or SETUP CHANGES NOT SAVED while SETUP holds a change nothing has asked to keep.

Idle pulse and Full pulse are the throttle's endpoints, which the IOmcu (the RP2350 board) takes only on a disarmed bench. They take a press only while the bench is SAFE and ARM is not held (motor_screen.c's mo_endpoints_free()); otherwise their help line says so, and a keypad open for one closes.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BOX_H

#define BOX_H   UI_TAP_MIN

A value box's height, px.

◆ BOX_W

#define BOX_W   120

Its width, px.

◆ COL_W

#define COL_W   ((PAGE_W - 30) / 2)

A column: 295px.

◆ COL_X

#define COL_X ( k)
Value:
(PAGE_X + 10 + (k) * (COL_W + 10))
#define COL_W
Definition analyser_screen.c:85
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
#define PAGE_X
Definition motor_screen_int.h:139

Column k's left edge, px.

◆ HEAD_GAP

#define HEAD_GAP   8

Over a heading under a row.

◆ HEAD_H

#define HEAD_H   28

A heading's line, px.

◆ HELP_DY

#define HELP_DY   (BOX_H + 2)

The help line, in a row.

◆ MS_FINE

#define MS_FINE   UI_FONT_FINE

The help lines: 8 x 16.

◆ MS_FONT

#define MS_FONT   (&gfx_font_10x20)

Labels, values, headings.

◆ ROW_PITCH

#define ROW_PITCH   68

From row to row, px.

◆ SAVE_Y

#define SAVE_Y   (STOP_FLOOR - 20)

The save line, px.

◆ TOP_Y

#define TOP_Y   (PAGE_Y + 8)

The first heading, px.

Function Documentation

◆ box_rect()

gfx_rect_t box_rect ( int i)
static

Row i's value box, at its column's right.

Parameters
ithe row
Returns
the box

◆ col_of()

int col_of ( int i)
static

The column row i is in: THROTTLE OUTPUT's rows on the right.

Parameters
ithe row
Returns
0 left, 1 right

◆ draw_row()

void draw_row ( gfx_canvas_t * c,
int i,
bool safe )
static

Row i: its label, its value box at the column's right and its help line, or the lock's reason, under them.

Parameters
cthe canvas
ithe row
safewhether the pulse rows take a press

◆ motor_endpoints_alert()

const char * motor_endpoints_alert ( endpoints_block_t why)

What the alert band says for a switch to ARMED refused because the pair of Idle pulse and Full pulse is not in force at the IOmcu, by endpoints_block(); NULL for ENDPOINTS_BLOCK_NONE and for a value outside the enum.

◆ motor_screen_keypad()

const ui_keypad_t * motor_screen_keypad ( void )

SETTINGS' keypad, open or closed, for a test to read what it opened with and where its keys are.

Returns
The keypad; never NULL.

◆ motor_screen_keypad_setting()

int motor_screen_keypad_setting ( void )

The setting SETTINGS' keypad types, or -1 while it is closed.

◆ motor_settings_box()

gfx_rect_t motor_settings_box ( int row)

Row row's value box, which a tap opens the keypad on.

◆ motor_settings_heading()

int motor_settings_heading ( int row)

The heading row row sits under, a ui_text_id_t; -1 out of range.

◆ motor_settings_rows()

int motor_settings_rows ( setting_id_t * out,
int max )

SETTINGS' rows in their order, at most max into out (NULL counts them). Returns how many there are.

◆ msp_render()

void msp_render ( gfx_canvas_t * c,
bool safe )

SETTINGS' page in its two columns, or the keypad over it.

Parameters
cthe canvas
safewhether the pulse rows take a press

◆ row_y()

int row_y ( int i)
static

The top of row i: its column's headings above it and its place among the column's rows.

Parameters
ithe row
Returns
its top, px

Variable Documentation

◆ k_heading

const ui_text_id_t k_heading[HD_COUNT]
static
Initial value:
= {
TX_MO_SET_PACK, TX_MO_SET_MOTOR, TX_MO_SET_THROTTLE,
}

◆ k_rows

const struct [struct].k_rows k_rows[]
Initial value:
= {
{ SET_PACK_CELLS, HD_PACK },
{ SET_PACK_MAH, HD_PACK },
{ SET_PACK_MOHM, HD_PACK },
{ SET_MOTOR_POLES, HD_MOTOR },
{ SET_MOTOR_KV, HD_MOTOR },
{ SET_OUT_MIN_US, HD_THROTTLE },
{ SET_OUT_MAX_US, HD_THROTTLE },
{ SET_OUT_RAMP, HD_THROTTLE },
}

◆ p

struct [struct].p p

the page's state