Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
tuning_registry.h
Go to the documentation of this file.
1
/// @file tuning_registry.h
2
/// @brief Table-driven registry of runtime tuning parameters.
3
/// @ingroup hioc_tuning
4
///
5
/// The hub exposes each tuning parameter through Home Assistant `number`/`select`
6
/// entities. Rather than hand-syncing four string-dispatch functions in the hub, this
7
/// registry enumerates every parameter once, as a table row pairing the parameter's
8
/// wire name with getter/setter function pointers over TuningConfig. The hub's
9
/// update/get methods become thin table lookups.
10
///
11
/// @par Adding a tuning parameter
12
/// Add exactly two things and the cross-language sync check (`make tuning-sync`) will
13
/// keep them honest:
14
/// 1. one row in the appropriate table below (`NUMBER_PARAMS` or `SELECT_PARAMS`), and
15
/// 2. one matching entry in `tuning.py` (`_NUMBER_PARAMS` or `_SELECT_OPTIONS`).
16
/// The parameter `name` string must be identical on both sides.
17
18
#pragma once
19
20
#include "
tuning_config.h
"
21
22
#include <string>
23
24
namespace
esphome
{
25
namespace
home_io_control
{
26
27
/// One numeric tuning parameter: its wire name plus accessors over TuningConfig.
28
///
29
/// `get` returns the stored value as a float (for HA slider seeding); `set` writes the
30
/// value back, narrowing to the field's underlying integer type. `applies_to_radio`
31
/// marks parameters whose change must be pushed to the active radio driver immediately.
32
struct
TuningNumberParam
{
33
const
char
*
name
;
///< YAML/HA parameter name (must match tuning.py).
34
float (*
get
)(
const
TuningConfig
&);
///< Read the current value as a float.
35
void (*
set
)(
TuningConfig
&, float);
///< Write a new value (narrowed to the field type).
36
bool
applies_to_radio
;
///< True if changes must be re-applied to the radio.
37
};
38
39
/// One select tuning parameter: its wire name plus string accessors over TuningConfig.
40
///
41
/// `get` returns the current option string (matching the HA dropdown labels). `set`
42
/// parses an option string and returns false when the value is unparseable, so the hub
43
/// can skip the radio re-apply exactly as the original per-parameter logic did.
44
struct
TuningSelectParam
{
45
const
char
*
name
;
///< YAML/HA parameter name (must match tuning.py).
46
std::string (*
get
)(
const
TuningConfig
&);
///< Read the current option string.
47
bool (*
set
)(
TuningConfig
&,
const
std::string &);
///< Parse/apply an option; false if unparseable.
48
bool
applies_to_radio
;
///< True if changes must be re-applied to the radio.
49
};
50
51
/// Look up a numeric tuning parameter by name; returns nullptr if unknown.
52
const
TuningNumberParam
*
find_tuning_number
(
const
std::string &name);
53
54
/// Look up a select tuning parameter by name; returns nullptr if unknown.
55
const
TuningSelectParam
*
find_tuning_select
(
const
std::string &name);
56
57
/// @name Table iteration
58
/// Range accessors over the full parameter tables, for enumeration and tests.
59
/// @{
60
const
TuningNumberParam
*
tuning_number_params_begin
();
61
const
TuningNumberParam
*
tuning_number_params_end
();
62
const
TuningSelectParam
*
tuning_select_params_begin
();
63
const
TuningSelectParam
*
tuning_select_params_end
();
64
/// @}
65
66
}
// namespace home_io_control
67
}
// namespace esphome
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::tuning_number_params_end
const TuningNumberParam * tuning_number_params_end()
Definition
tuning_registry.cpp:261
esphome::home_io_control::tuning_select_params_end
const TuningSelectParam * tuning_select_params_end()
Definition
tuning_registry.cpp:263
esphome::home_io_control::tuning_number_params_begin
const TuningNumberParam * tuning_number_params_begin()
Definition
tuning_registry.cpp:260
esphome::home_io_control::find_tuning_select
const TuningSelectParam * find_tuning_select(const std::string &name)
Look up a select tuning parameter by name; returns nullptr if unknown.
Definition
tuning_registry.cpp:252
esphome::home_io_control::tuning_select_params_begin
const TuningSelectParam * tuning_select_params_begin()
Definition
tuning_registry.cpp:262
esphome::home_io_control::find_tuning_number
const TuningNumberParam * find_tuning_number(const std::string &name)
Look up a numeric tuning parameter by name; returns nullptr if unknown.
Definition
tuning_registry.cpp:244
esphome
Definition
device_registry.cpp:12
esphome::home_io_control::TuningConfig
All runtime tunable parameters for pairing and radio diagnostics.
Definition
tuning_config.h:242
esphome::home_io_control::TuningNumberParam
One numeric tuning parameter: its wire name plus accessors over TuningConfig.
Definition
tuning_registry.h:32
esphome::home_io_control::TuningNumberParam::set
void(*) set(TuningConfig &, float)
Write a new value (narrowed to the field type).
Definition
tuning_registry.h:35
esphome::home_io_control::TuningNumberParam::applies_to_radio
bool applies_to_radio
True if changes must be re-applied to the radio.
Definition
tuning_registry.h:36
esphome::home_io_control::TuningNumberParam::get
float(*) get(const TuningConfig &)
Read the current value as a float.
Definition
tuning_registry.h:34
esphome::home_io_control::TuningNumberParam::name
const char * name
YAML/HA parameter name (must match tuning.py).
Definition
tuning_registry.h:33
esphome::home_io_control::TuningSelectParam
One select tuning parameter: its wire name plus string accessors over TuningConfig.
Definition
tuning_registry.h:44
esphome::home_io_control::TuningSelectParam::set
bool(*) set(TuningConfig &, const std::string &)
Parse/apply an option; false if unparseable.
Definition
tuning_registry.h:47
esphome::home_io_control::TuningSelectParam::name
const char * name
YAML/HA parameter name (must match tuning.py).
Definition
tuning_registry.h:45
esphome::home_io_control::TuningSelectParam::get
std::string(*) get(const TuningConfig &)
Read the current option string.
Definition
tuning_registry.h:46
esphome::home_io_control::TuningSelectParam::applies_to_radio
bool applies_to_radio
True if changes must be re-applied to the radio.
Definition
tuning_registry.h:48
tuning_config.h
Runtime tuning configuration for pairing and radio diagnostics.
components
home_io_control
tuning_registry.h
Generated by
1.18.0