8 static const char *
const TAG =
"select";
46 const auto *
name = parent->get_name().c_str();
47 const auto &traits = parent->traits;
48 auto options = traits.get_options();
51 ESP_LOGW(TAG,
"'%s' - SelectCall performed without selecting an operation",
name);
55 ESP_LOGW(TAG,
"'%s' - Cannot perform SelectCall, select has no options",
name);
59 std::string target_value;
62 ESP_LOGD(TAG,
"'%s' - Setting",
name);
64 ESP_LOGW(TAG,
"'%s' - No option value set for SelectCall",
name);
70 ESP_LOGW(TAG,
"'%s' - No index value set for SelectCall",
name);
74 ESP_LOGW(TAG,
"'%s' - Index value %zu out of bounds",
name, this->
index_.
value());
86 if (!parent->has_state()) {
89 auto index = parent->index_of(parent->state);
90 if (index.has_value()) {
94 target_value =
options[use_index];
97 target_value =
options[index.value() - 1];
99 target_value =
options[index.value() + 1];
111 ESP_LOGW(TAG,
"'%s' - Option %s is not a valid option",
name, target_value.c_str());
115 ESP_LOGD(TAG,
"'%s' - Set selected option to: %s",
name, target_value.c_str());
116 parent->control(target_value);
value_type const & value() const
SelectCall & select_next(bool cycle)
SelectCall & with_cycle(bool cycle)
SelectCall & set_index(size_t index)
SelectOperation operation_
SelectCall & select_last()
SelectCall & with_option(const std::string &option)
SelectCall & with_operation(SelectOperation operation)
SelectCall & with_index(size_t index)
SelectCall & select_previous(bool cycle)
optional< size_t > index_
SelectCall & select_first()
Implementation of SPI Controller mode.
optional< std::string > option_
SelectCall & set_option(const std::string &option)