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

SETUP > SENSORS: the INA3221 parts' rows of the schema, their migration from the one INA3221 of 0.21, and the map they make. See settings_sensors.h. More...

#include "settings_sensors.h"
#include "settings_opts.h"
#include <math.h>
#include <stddef.h>
#include <string.h>

Macros

#define WATCH_OPTS   .options = settings_opts_watch, .option_count = (uint8_t)SENS_W_COUNT
 A WATCHES row's options: list watch of ui_text.def.
#define AT(id)
#define N_ROWS   (SET_INA_CH_LAST - SET_INA_FIT_0 + 1)
#define FIT_ROW(a)
#define CH_ROWS(a, ch, watch_def)
#define PART_ROWS(a, w1)

Functions

bool settings_sensors_row (setting_id_t id)
const setting_def_t * settings_sensors_def (setting_id_t id)
int settings_sensors_part (setting_id_t id)
uint16_t settings_sensors_watch_code (int option)
void settings_sensors_unset (float *values)
static int seed (float *values, setting_id_t id, float v)
int settings_sensors_migrate (float *values)
int settings_sensors_watch_option (uint16_t code)
 The WATCHES option of a SENSE_MAP WATCH value.
uint16_t settings_sensors_limit_ma (int c)
 Channel c's LIMIT as SENSE_LIMIT's LIMIT_MA takes it.
uint16_t settings_sensors_dmohm (int c)
 A channel's shunt as the map carries it.
uint8_t settings_sensors_fast (void)
uint8_t settings_sensors_fitted (void)
uint16_t settings_sensors_meter_dmohm (void)
 The shunt of the channel the servo rail's meter reads.
static bool watches_target (uint16_t code, int target)
void settings_sensors_map (settings_sensors_map_t *m)

Variables

static const setting_def_t k_rows [N_ROWS]
static const setting_def_t k_kept [4]

Detailed Description

SETUP > SENSORS: the INA3221 parts' rows of the schema, their migration from the one INA3221 of 0.21, and the map they make. See settings_sensors.h.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ AT

#define AT ( id)
Value:
((int)(id) - (int)SET_INA_FIT_0)

◆ CH_ROWS

#define CH_ROWS ( a,
ch,
watch_def )
Value:
[AT(SET_INA_W(3 * (a) + (ch) - 1))] = { \
"ina_w_" #a #ch, "", \
SET_CAT_SENSORS, SET_TYPE_ENUM, 0, 0, 1, (watch_def), WATCH_OPTS, \
0.0f }, \
[AT(SET_INA_SH(3 * (a) + (ch) - 1))] = { \
"ina_sh_" #a #ch, "mΩ", \
SET_CAT_SENSORS, SET_TYPE_FLOAT, 0.0f, 1000.0f, 0.1f, 100.0f, \
NULL, 0, 5.0f }, \
[AT(SET_INA_LIM(3 * (a) + (ch) - 1))] = { \
"ina_lim_" #a #ch, "mA", \
SET_CAT_SENSORS, SET_TYPE_INT, 0, 32767, 10, 0, NULL, 0, 10.0f }
@ SET_CAT_SENSORS
Definition settings.h:33
#define WATCH_OPTS
A WATCHES row's options: list watch of ui_text.def.
Definition settings_sensors.c:18
#define SET_INA_LIM(c)
Channel c's LIMIT row, 0 to 11.
Definition settings_sensors.h:65

◆ FIT_ROW

#define FIT_ROW ( a)
Value:
[AT(SET_INA_FIT(a))] = { \
"ina_fit_" #a, "", \
SET_CAT_SENSORS, SET_TYPE_BOOL, 0, 1, 1, 0, NULL, 0, 0.0f }
#define SET_INA_FIT(a)
The row ids: part a's FITTED, channel c's WATCHES, SHUNT and LIMIT. a is 0 to 3, c 0 to 11.
Definition settings_sensors.h:61

◆ PART_ROWS

#define PART_ROWS ( a,
w1 )
Value:
CH_ROWS(a, 1, w1), CH_ROWS(a, 2, SENS_W_NONE), CH_ROWS(a, 3, SENS_W_NONE)

Function Documentation

◆ settings_sensors_def()

const setting_def_t * settings_sensors_def ( setting_id_t id)

The schema row of id: a SENSORS row, or one of the four kept keys of 0.21; NULL for any other id.

◆ settings_sensors_dmohm()

uint16_t settings_sensors_dmohm ( int c)

A channel's shunt as the map carries it.

Parameters
cthe channel
Returns
the shunt in 0.1mOhm; 0 off

◆ settings_sensors_fast()

uint8_t settings_sensors_fast ( void )

settings_sensors_map()'s FAST: the channel watching the servo tester's target, LINK_SM_FAST_NONE for none.

◆ settings_sensors_fitted()

uint8_t settings_sensors_fitted ( void )

The fitted parts: bit a for 0x40 + a.

◆ settings_sensors_limit_ma()

uint16_t settings_sensors_limit_ma ( int c)

Channel c's LIMIT as SENSE_LIMIT's LIMIT_MA takes it.

Parameters
cthe channel, 0 to 11.
Returns
the limit, mA, at most 32767; 0 for none and for a c out of range.

◆ settings_sensors_map()

void settings_sensors_map ( settings_sensors_map_t * m)

The map the values in force make, into m. FAST is the lowest channel with a shunt on a fitted part that watches the servo tester's target: an output, OUT 1 to OUT 8, while the target is OUTPUTS, and PORT n while it is programming port n (SET_SERVO_TARGET n).

◆ settings_sensors_meter_dmohm()

uint16_t settings_sensors_meter_dmohm ( void )

The shunt of the channel the servo rail's meter reads.

Returns
FAST's shunt, else the one-part frame's (settings_sensors_map_t), in 0.1mOhm; 0 for no part fitted

◆ settings_sensors_migrate()

int settings_sensors_migrate ( float * values)

After the store is read and its values coerced: every SENSORS value still NAN seeded from the old INA3221 keys and the servo tester's target, as the file comment says. Returns how many were seeded.

◆ settings_sensors_part()

int settings_sensors_part ( setting_id_t id)

The part, 0 to 3, a SENSORS row belongs to; -1 for any other id.

◆ settings_sensors_row()

bool settings_sensors_row ( setting_id_t id)

Whether id is a SENSORS row.

◆ settings_sensors_unset()

void settings_sensors_unset ( float * values)

Before the store is read: every SENSORS value set to NAN, a value no store holds, so settings_sensors_migrate() can tell a key the store did not have. values is the model's array of SETTING_COUNT.

◆ settings_sensors_watch_code()

uint16_t settings_sensors_watch_code ( int option)

The SENSE_MAP WATCH value of WATCHES option option; NONE for one out of range.

◆ settings_sensors_watch_option()

int settings_sensors_watch_option ( uint16_t code)

The WATCHES option of a SENSE_MAP WATCH value.

Parameters
codea SENSE_MAP WATCH value.
Returns
the option, SENS_W_*; SENS_W_NONE for a value no option has.

Variable Documentation

◆ k_kept

const setting_def_t k_kept[4]
static
Initial value:
= {
{
"ina3221_en", "",
SET_CAT_COUNT, SET_TYPE_BOOL, 0, 1, 1, 0, NULL, 0, 0.0f },
{
"ina3221_adr", "",
SET_CAT_COUNT, SET_TYPE_ENUM, 0, 0, 1, 0, settings_opts_old_addr, 4, 0.0f },
{
"ina3221_mohm", "mΩ",
SET_CAT_COUNT, SET_TYPE_FLOAT, 5.0f, 1000.0f, 0.1f, 100.0f, NULL, 0, 0.0f },
{
"ina3221_ch", "",
SET_CAT_COUNT, SET_TYPE_ENUM, 0, 0, 1, 0, settings_opts_old_ch, 2, 0.0f },
}

◆ k_rows

const setting_def_t k_rows[N_ROWS]
static
Initial value:
= {
FIT_ROW(0), FIT_ROW(1), FIT_ROW(2), FIT_ROW(3),
PART_ROWS(0, SENS_W_OUT_1),
PART_ROWS(1, SENS_W_NONE),
PART_ROWS(2, SENS_W_NONE),
PART_ROWS(3, SENS_W_NONE),
}
@ SENS_W_OUT_1
Definition settings_sensors.h:70