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

The numeric keypad for a number of the settings schema. See ui_setting_keypad.h. More...

#include "ui_setting_keypad.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "link_pages.h"
#include "outputs.h"
#include "ui_text.h"

Enumerations

enum  why_t {
  WHY_NONE = 0 , WHY_OFF_GAP , WHY_SDA , WHY_TAP ,
  WHY_IDLE_GAP , WHY_FULL_GAP , WHY_PDMINI , WHY_NO_ROW
}
 Why ui_setting_keypad_takes() refuses v for id. More...

Functions

int ui_setting_keypad_decimals (setting_id_t id)
 The digits the keypad takes after the point for id.
bool ui_setting_keypad_offered (setting_id_t id)
 Whether a tap on the value of id opens the keypad.
bool ui_setting_keypad_signed (setting_id_t id)
 Whether the keypad of id carries the +/- key.
void ui_setting_keypad_open (ui_keypad_t *k, gfx_rect_t area, setting_id_t id)
 Open k over area for setting id.
static why_t why_refused (setting_id_t id, float v)
 Sort v for id into taken or the rule that refuses it.
bool ui_setting_keypad_takes (setting_id_t id, float v)
 Whether settings_set() takes v for id as a value the - and.
static const char * pins_taken (bool(*valid)(int), char *buf, size_t n)
 The GPIOs valid takes, in rising order with one space between, cut at the last pin that fits whole.
const char * ui_setting_keypad_sda_pins (char *buf, size_t n)
 The GPIOs Sensor SDA can have, from settings_sense_sda_valid().
const char * ui_setting_keypad_tap_pins (char *buf, size_t n)
 The GPIOs Tap pin can have, from settings_tap_pin_valid().
const char * ui_setting_keypad_why (setting_id_t id, float v, char *buf, size_t n)
 The line a setting's keypad shows in place of the range after refusing v inside it.
ui_setkey_result_t ui_setting_keypad_ok (ui_keypad_t *k, setting_id_t id, float v)
 Take the value an OK on k handed back for id.

Detailed Description

The numeric keypad for a number of the settings schema. See ui_setting_keypad.h.

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ why_t

enum why_t

Why ui_setting_keypad_takes() refuses v for id.

Enumerator
WHY_NONE 

taken

WHY_OFF_GAP 

between 0 and off_below

WHY_SDA 

a Sensor SDA pin the bus cannot have

WHY_TAP 

a Tap pin the module does not bring out

WHY_IDLE_GAP 

an Idle pulse too near Full pulse

WHY_FULL_GAP 

a Full pulse too near Idle pulse

WHY_PDMINI 

the other PD mini pin's GPIO

WHY_NO_ROW 

no such setting

Function Documentation

◆ pins_taken()

const char * pins_taken ( bool(* valid )(int),
char * buf,
size_t n )
static

The GPIOs valid takes, in rising order with one space between, cut at the last pin that fits whole.

Parameters
validThe rule: true for a pin the row takes.
bufWhere the list goes.
nThe size of buf in bytes.
Returns
buf; "" for a NULL or empty buf.

◆ ui_setting_keypad_decimals()

int ui_setting_keypad_decimals ( setting_id_t id)

The digits the keypad takes after the point for id.

Parameters
idThe setting.
Returns
As many as its step has, 0 to 3: 0 for a step of 1 or more, 1 for 0.1, 2 for 0.05, 3 for 0.001; 0 for an id out of range.

◆ ui_setting_keypad_offered()

bool ui_setting_keypad_offered ( setting_id_t id)

Whether a tap on the value of id opens the keypad.

Parameters
idThe setting.
Returns
True for a number (SET_TYPE_INT or SET_TYPE_FLOAT) that is not derived (settings_derived()) and not held (settings_held()): the rows that draw - and + keys. False for a switch, a choice and an id out of range.

◆ ui_setting_keypad_ok()

ui_setkey_result_t ui_setting_keypad_ok ( ui_keypad_t * k,
setting_id_t id,
float v )

Take the value an OK on k handed back for id.

Parameters
kThe keypad that returned UI_KEYPAD_OK.
idThe setting it was opened for.
vThe value it handed back.
Returns
UI_SETKEY_SET after settings_set(id, v); UI_SETKEY_REFUSED for a value ui_setting_keypad_takes() refuses, with k open again, marked and showing ui_setting_keypad_why() in place of the range; UI_SETKEY_LOCKED for a row no longer offered (ui_setting_keypad_offered()).

◆ ui_setting_keypad_open()

void ui_setting_keypad_open ( ui_keypad_t * k,
gfx_rect_t area,
setting_id_t id )

Open k over area for setting id.

Parameters
kThe keypad.
areaWhere it is drawn and hit, in the screen's coordinates.
idThe setting: its label in the language showing as the title, its unit, its value faint behind the entry, its range and ui_setting_keypad_decimals(); signed by ui_setting_keypad_signed(). Nothing opens for an id ui_setting_keypad_offered() refuses.

◆ ui_setting_keypad_sda_pins()

const char * ui_setting_keypad_sda_pins ( char * buf,
size_t n )

The GPIOs Sensor SDA can have, from settings_sense_sda_valid().

Parameters
bufWhere the list goes.
nThe size of buf in bytes.
Returns
buf, holding the pins in rising order with one space between ("0 4 6 14 16 18 20 26" for the Pico header), cut at the last pin that fits whole; "" for a NULL or empty buf.

◆ ui_setting_keypad_signed()

bool ui_setting_keypad_signed ( setting_id_t id)

Whether the keypad of id carries the +/- key.

Parameters
idThe setting.
Returns
True for a number whose range reaches below 0, except a pin (unit "GPIO"), whose one value below 0 is -1, not set, which "-" reaches. No setting of today's schema is signed; SERVO's TRIM, -200 to +200us, is a signed row of its own screen.

◆ ui_setting_keypad_takes()

bool ui_setting_keypad_takes ( setting_id_t id,
float v )

Whether settings_set() takes v for id as a value the - and.

  • keys can reach.
    Parameters
    idThe setting.
    vThe value typed, inside the range the keypad holds it to.
    Returns
    False for a value between 0 and the setting's off_below, a Sensor SDA pin the bus cannot have, a Tap pin the module does not bring out, and a PD mini pin at or above 0 that the other PD mini pin holds; true otherwise.

◆ ui_setting_keypad_tap_pins()

const char * ui_setting_keypad_tap_pins ( char * buf,
size_t n )

The GPIOs Tap pin can have, from settings_tap_pin_valid().

Parameters
bufWhere the list goes.
nThe size of buf in bytes.
Returns
buf, holding the pins in rising order with one space between ("0 1 2 4 5 6 7 13 14 15 16 17 18 19 20 21 22" for the Pico header), cut at the last pin that fits whole; "" for a NULL or empty buf.

◆ ui_setting_keypad_why()

const char * ui_setting_keypad_why ( setting_id_t id,
float v,
char * buf,
size_t n )

The line a setting's keypad shows in place of the range after refusing v inside it.

Parameters
idThe setting.
vThe value typed.
bufWhere a text with numbers in it goes (the off gap's figures, the Sensor SDA pins).
nThe size of buf in bytes; 64 holds every reason. A smaller buf holds the text and as many whole pins as fit.
Returns
NULL for a value ui_setting_keypad_takes() takes; otherwise buf holding KEYPAD_WHY_OFF with the row's off_below, maximum and unit for a value between 0 and off_below, buf holding KEYPAD_WHY_SDA with the pins for a Sensor SDA pin the bus cannot have, KEYPAD_WHY_TAP with the pins for a Tap pin the module does not bring out, and KEYPAD_WHY_PDMINI for the other PD mini pin's GPIO, in the panel's language.

◆ why_refused()

why_t why_refused ( setting_id_t id,
float v )
static

Sort v for id into taken or the rule that refuses it.

Parameters
idThe setting.
vThe value typed.
Returns
WHY_NONE for a value settings_set() takes as typed; the rule that refuses it otherwise.