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

The interface's words, one table per language. More...

#include <stddef.h>
#include "servo_str.h"
#include "settings.h"

Go to the source code of this file.

Data Structures

struct  ui_language_t
 A language: its column of ui_text.def. More...

Macros

#define TR(id)

Enumerations

enum  ui_lang_t { UI_LANG_EN = 0 , UI_LANG_DE , UI_LANG_COUNT }
enum  ui_text_id_t { TX_COUNT }
 The screens' strings, TX_<ID> for each UI_TEXT() of ui_text.def.

Functions

void ui_text_set_language (ui_lang_t lang)
ui_lang_t ui_text_language (void)
const char * ui_tr (ui_text_id_t id)
const char * ui_tr_pad (const ui_text_id_t *set, int count, int i, char *buf, size_t n)
const char * ui_tr_in (ui_lang_t lang, ui_text_id_t id)
int ui_text_has (ui_lang_t lang, ui_text_id_t id)
int ui_text_cells (ui_text_id_t id)
const char * ui_text_name (ui_text_id_t id)
const ui_language_t * ui_text_table (ui_lang_t lang)
const char * ui_setting_label (setting_id_t id)
const char * ui_setting_help (setting_id_t id)
const char * ui_setting_category (setting_cat_t cat)
const char * ui_setting_value (setting_id_t id, char *buf, size_t n)
const char * ui_setting_value_of (setting_id_t id, float value, char *buf, size_t n)
const char * ui_setting_option (setting_id_t id, int k)
const char * ui_servo_str (servo_str_t id)
const char *const * ui_servo_table (void)
const char * ui_on_off (int on)
int ui_unit_is_symbol (const char *unit)
 Whether unit is a unit symbol, written with no space after its number: one of k_unit_symbols (ui_text.c), which holds the symbols of tools/check_units.py, alone or followed by a "/" part ("rpm/V", "%/s").
const char * ui_unit_gap (const char *unit)
 What stands between a number and unit: "" before a symbol ("6.00V", "1000.0mΩ", "40s") and before no unit, " " before a word that follows its number. A word that leads (ui_unit_is_prefix(), "GPIO 4") also gets " ".
int ui_unit_is_prefix (const char *unit)
 Whether unit is written before its number: the pin word UI_PIN_WORD, "GPIO", so that a pin reads "GPIO 4" (ui_pin_name()) and not as a count of four GPIOs. Every other unit follows its number.
const char * ui_pin_holder (const char *held_by)
 What holds a reserved pin, in the language showing: the words out_bind.c gives a catalogue's LINK_PIN_* values ("heartbeat", "flash", "debug", "sensor", "in use") from the text table, and any other name ("CAN INT", "CAN") as it is.
void ui_text_trace (ui_text_id_t id)

Variables

const ui_language_t ui_lang_de
 The German tables, as ui_text.h declares them.

Detailed Description

The interface's words, one table per language.

Every string a screen shows in the operator's language has an ID in ui_text.def (shared/text/include), which holds its English and its German side by side. ui_text.c makes a table of each language's column; an entry a language leaves NULL shows the English, so a partial column is a working one. What stays English in every language – ARM, DISARM, STOP, the screen titles, protocol and mode names, units, and the field's own terms – is not in the table at all and is written where it is drawn.

Text is UTF-8; gfx decodes it and draws one cell per code point (gfx.h). A translated format string must convert the same arguments in the same order as its English: test_text holds every table to that.

The language is SET_LANGUAGE, applied by settings_apply_ui() with the theme, so a change on SETUP repaints every screen in the new language on the next frame.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ TR

#define TR ( id)
Value:
ui_tr(TX_##id)
const char * ui_tr(ui_text_id_t id)
Definition ui_text.c:173

Enumeration Type Documentation

◆ ui_lang_t

enum ui_lang_t

In SET_LANGUAGE's order.

Function Documentation

◆ ui_on_off()

const char * ui_on_off ( int on)

ON or OFF in the language showing.

◆ ui_pin_holder()

const char * ui_pin_holder ( const char * held_by)

What holds a reserved pin, in the language showing: the words out_bind.c gives a catalogue's LINK_PIN_* values ("heartbeat", "flash", "debug", "sensor", "in use") from the text table, and any other name ("CAN INT", "CAN") as it is.

Parameters
held_byan outbind_pin_t's held_by, or NULL
Returns
the text to show; "" for NULL

◆ ui_servo_str()

const char * ui_servo_str ( servo_str_t id)

The servo test's words for the screen and the report, in the language showing. servo_str() stays English: it writes the CSV, which tools read.

◆ ui_servo_table()

const char *const * ui_servo_table ( void )

The servo table to hand a run for its report: NULL is English.

◆ ui_setting_option()

const char * ui_setting_option ( setting_id_t id,
int k )

Option k of an enum setting; "?" for one out of range.

◆ ui_setting_value()

const char * ui_setting_value ( setting_id_t id,
char * buf,
size_t n )

As settings_value_text(), with ON, OFF and the options translated.

◆ ui_setting_value_of()

const char * ui_setting_value_of ( setting_id_t id,
float value,
char * buf,
size_t n )

As ui_setting_value(), for value rather than the value in force.

◆ ui_text_cells()

int ui_text_cells ( ui_text_id_t id)

The cells id may take where it is drawn, from ui_text.def, or 0 when the fit check measures it on a rendered screen instead.

◆ ui_text_has()

int ui_text_has ( ui_lang_t lang,
ui_text_id_t id )

Whether lang's own table has id, rather than falling back.

◆ ui_text_name()

const char * ui_text_name ( ui_text_id_t id)

The ID's name without the TX_ prefix, for the host's checks; "" on the panel, which carries no names.

◆ ui_text_set_language()

void ui_text_set_language ( ui_lang_t lang)

Show lang from now on; one out of range is English.

◆ ui_text_table()

const ui_language_t * ui_text_table ( ui_lang_t lang)

The table of lang; NULL for English.

◆ ui_text_trace()

void ui_text_trace ( ui_text_id_t id)

Defined by the fit check's harness: id was looked up.

◆ ui_tr()

const char * ui_tr ( ui_text_id_t id)

id in the language showing; "" for an ID out of range.

◆ ui_tr_in()

const char * ui_tr_in ( ui_lang_t lang,
ui_text_id_t id )

id in lang, falling back to English as ui_tr() does.

◆ ui_tr_pad()

const char * ui_tr_pad ( const ui_text_id_t * set,
int count,
int i,
char * buf,
size_t n )

Entry i of set in the language showing, padded with spaces to the cells of the longest entry of set, into buf. For a label one of several replaces in place: each lays out the same width, so one repaints over another without a clear.

◆ ui_unit_gap()

const char * ui_unit_gap ( const char * unit)

What stands between a number and unit: "" before a symbol ("6.00V", "1000.0mΩ", "40s") and before no unit, " " before a word that follows its number. A word that leads (ui_unit_is_prefix(), "GPIO 4") also gets " ".

Parameters
unitthe unit, or NULL
Returns
"" or " "

◆ ui_unit_is_prefix()

int ui_unit_is_prefix ( const char * unit)

Whether unit is written before its number: the pin word UI_PIN_WORD, "GPIO", so that a pin reads "GPIO 4" (ui_pin_name()) and not as a count of four GPIOs. Every other unit follows its number.

Parameters
unitthe unit, or NULL
Returns
1 for a pin word, else 0

◆ ui_unit_is_symbol()

int ui_unit_is_symbol ( const char * unit)

Whether unit is a unit symbol, written with no space after its number: one of k_unit_symbols (ui_text.c), which holds the symbols of tools/check_units.py, alone or followed by a "/" part ("rpm/V", "%/s").

Parameters
unitthe unit, UTF-8 ("mΩ"); NULL or "" is none
Returns
1 for a symbol ("V", "S", a battery's cell count), 0 for a word ("GPIO"), none or NULL