Add all supported number components
This commit is contained in:
parent
274ff30d9c
commit
290900747c
|
@ -10,21 +10,49 @@ CODEOWNERS = ["@sqozz"]
|
||||||
|
|
||||||
tw7100Number = tw7100_ns.class_("tw7100Number", number.Number, cg.Component)
|
tw7100Number = tw7100_ns.class_("tw7100Number", number.Number, cg.Component)
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
numbers = [
|
||||||
{
|
("VOL","mdi:volume-high"),
|
||||||
cv.GenerateID(): cv.use_id(tw7100),
|
("VKEYSTONE",""),
|
||||||
cv.Optional("VOL"): number.number_schema(
|
("HKEYSTONE",""),
|
||||||
tw7100Number
|
("BRIGHT","mdi:brightness-7"),
|
||||||
),
|
("CONTRAST","mdi:contrast"),
|
||||||
}
|
("DENSITY",""),
|
||||||
)
|
("TINT",""),
|
||||||
|
("CTEMP","mdi:format-color-fill"),
|
||||||
|
("FCOLOR","mdi:account"),
|
||||||
|
("NRS",""),
|
||||||
|
("MPEGNRS",""),
|
||||||
|
("OFFSETR","mdi:alpha-r-box-outline"),
|
||||||
|
("OFFSETG","mdi:alpha-g-box-outline"),
|
||||||
|
("OFFSETB","mdi:alpha-b-box-outline"),
|
||||||
|
("GAINR","mdi:alpha-r-circle-outline"),
|
||||||
|
("GAING","mdi:alpha-g-circle-outline"),
|
||||||
|
("GAINB","mdi:alpha-b-circle-outline"),
|
||||||
|
("SHRF","mdi:format-line-weight"),
|
||||||
|
("SHRS","mdi:image-filter-center-focus"),
|
||||||
|
("DERANGE","mdi:magnify-expand"),
|
||||||
|
("DESTRENGTH","mdi:magnify-plus-outline")
|
||||||
|
]
|
||||||
|
|
||||||
|
schema={cv.GenerateID(): cv.use_id(tw7100)}
|
||||||
|
for number_name,icon in numbers:
|
||||||
|
schema.update({cv.Optional(number_name): number.number_schema(tw7100Number, icon=icon)})
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = cv.Schema(schema)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
parent = await cg.get_variable(config[CONF_ID])
|
parent = await cg.get_variable(config[CONF_ID])
|
||||||
|
|
||||||
if "VOL" in config:
|
for number_name,icon in numbers:
|
||||||
number_ = await number.new_number(config["VOL"], min_value=0, max_value=255, step=1)
|
if number_name in config:
|
||||||
cg.add(number_.set_cmd("VOL"))
|
number_ = await number.new_number(config[number_name], min_value=0, max_value=255, step=1)
|
||||||
|
cg.add(number_.set_cmd(number_name))
|
||||||
cg.add(number_.set_tw7100_parent(parent))
|
cg.add(number_.set_tw7100_parent(parent))
|
||||||
cg.add(parent.set_set_volume(number_))
|
cg.add(getattr(parent, "set_set_{}".format(number_name.lower()))(number_))
|
||||||
|
|
||||||
|
#if "VOL" in config:
|
||||||
|
# number_ = await number.new_number(config["VOL"], min_value=0, max_value=255, step=1)
|
||||||
|
# cg.add(number_.set_cmd("VOL"))
|
||||||
|
# cg.add(number_.set_tw7100_parent(parent))
|
||||||
|
# cg.add(parent.set_set_volume(number_))
|
||||||
|
|
|
@ -9,9 +9,6 @@ namespace tw7100 {
|
||||||
|
|
||||||
void tw7100Number::setup() {
|
void tw7100Number::setup() {
|
||||||
static const char *const TAG = "tw7100Number::setup()";
|
static const char *const TAG = "tw7100Number::setup()";
|
||||||
if (cmd_ == "VOL") {
|
|
||||||
ESP_LOGV(TAG, "setup VOL");
|
|
||||||
}
|
|
||||||
ESP_LOGV(TAG, "setup done");
|
ESP_LOGV(TAG, "setup done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +22,8 @@ void tw7100Number::control(float value) {
|
||||||
static const char *const TAG = "tw7100Number::control()";
|
static const char *const TAG = "tw7100Number::control()";
|
||||||
|
|
||||||
std::string param;
|
std::string param;
|
||||||
if (cmd_ == "VOL") {
|
|
||||||
param = std::to_string((int)value);
|
param = std::to_string((int)value);
|
||||||
ESP_LOGV(TAG, "VOL: %s (from %i)", param, (int)value);
|
ESP_LOGV(TAG, "%s: %s (from %i)", cmd_, param, (int)value);
|
||||||
}
|
|
||||||
|
|
||||||
if (param.length() > 0 && state != value) {
|
if (param.length() > 0 && state != value) {
|
||||||
parent_->push_cmd(cmd_, param);
|
parent_->push_cmd(cmd_, param);
|
||||||
|
|
91
tw7100.cpp
91
tw7100.cpp
|
@ -17,9 +17,9 @@ std::map<int, std::string> sourcelist;
|
||||||
std::vector<std::string> pwr_off_query_cmds{ "PWR?", "LAMP?" };
|
std::vector<std::string> pwr_off_query_cmds{ "PWR?", "LAMP?" };
|
||||||
std::vector<std::string> pwr_on_query_cmds{
|
std::vector<std::string> pwr_on_query_cmds{
|
||||||
// Projection screen adjustment settings
|
// Projection screen adjustment settings
|
||||||
/*
|
|
||||||
"VKEYSTONE?",
|
"VKEYSTONE?",
|
||||||
"HKEYSTONE?",
|
"HKEYSTONE?",
|
||||||
|
/*
|
||||||
"QC?",
|
"QC?",
|
||||||
"CORRECTMET?",
|
"CORRECTMET?",
|
||||||
"ASPECT?",
|
"ASPECT?",
|
||||||
|
@ -32,14 +32,15 @@ std::vector<std::string> pwr_on_query_cmds{
|
||||||
// Source/Input/Resolution settings
|
// Source/Input/Resolution settings
|
||||||
"SOURCE?",
|
"SOURCE?",
|
||||||
// Image settings
|
// Image settings
|
||||||
/*
|
|
||||||
"BRIGHT?",
|
"BRIGHT?",
|
||||||
"CONTRAST?",
|
"CONTRAST?",
|
||||||
"DENSITY?",
|
"DENSITY?",
|
||||||
"TINT?",
|
"TINT?",
|
||||||
"CTEMP?",
|
"CTEMP?",
|
||||||
"FCOLOR?",
|
"FCOLOR?",
|
||||||
|
/*
|
||||||
"CMODE?",
|
"CMODE?",
|
||||||
|
*/
|
||||||
"NRS?",
|
"NRS?",
|
||||||
"MPEGNRS?",
|
"MPEGNRS?",
|
||||||
"OFFSETR?",
|
"OFFSETR?",
|
||||||
|
@ -48,13 +49,17 @@ std::vector<std::string> pwr_on_query_cmds{
|
||||||
"GAINR?",
|
"GAINR?",
|
||||||
"GAING?",
|
"GAING?",
|
||||||
"GAINB?",
|
"GAINB?",
|
||||||
|
/*
|
||||||
"GAMMA?",
|
"GAMMA?",
|
||||||
"CSEL?",
|
"CSEL?",
|
||||||
"4KENHANCE?",
|
"4KENHANCE?",
|
||||||
"IMGPRESET?",
|
"IMGPRESET?",
|
||||||
|
*/
|
||||||
"SHRF?",
|
"SHRF?",
|
||||||
"SHRS?",
|
"SHRS?",
|
||||||
"DERANGE?",
|
"DERANGE?",
|
||||||
|
"DESTRENGTH?",
|
||||||
|
/*
|
||||||
"MCFI?",
|
"MCFI?",
|
||||||
"CLRSPACE?",
|
"CLRSPACE?",
|
||||||
"DYNRANGE?",
|
"DYNRANGE?",
|
||||||
|
@ -251,8 +256,88 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
|
||||||
mute_switch_->publish_state(value_string == "ON");
|
mute_switch_->publish_state(value_string == "ON");
|
||||||
} else if (cmd == "VOL") {
|
} else if (cmd == "VOL") {
|
||||||
int value = std::stoi(value_string);
|
int value = std::stoi(value_string);
|
||||||
volume_number_->publish_state(value);
|
|
||||||
ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str());
|
ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str());
|
||||||
|
volume_number_->publish_state(value);
|
||||||
|
} else if (cmd == "VKEYSTONE") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating vkeystone number with value %s", value_string.c_str());
|
||||||
|
vkeystone_number_->publish_state(value);
|
||||||
|
} else if (cmd == "HKEYSTONE") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating hkeystone number with value %s", value_string.c_str());
|
||||||
|
hkeystone_number_->publish_state(value);
|
||||||
|
} else if (cmd == "BRIGHT") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating brightness number with value %s", value_string.c_str());
|
||||||
|
brightness_number_->publish_state(value);
|
||||||
|
} else if (cmd == "CONTRAST") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating contrast number with value %s", value_string.c_str());
|
||||||
|
contrast_number_->publish_state(value);
|
||||||
|
} else if (cmd == "DENSITY") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating density number with value %s", value_string.c_str());
|
||||||
|
density_number_->publish_state(value);
|
||||||
|
} else if (cmd == "TINT") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating tint number with value %s", value_string.c_str());
|
||||||
|
tint_number_->publish_state(value);
|
||||||
|
} else if (cmd == "CTEMP") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating ctemp number with value %s", value_string.c_str());
|
||||||
|
ctemp_number_->publish_state(value);
|
||||||
|
} else if (cmd == "FCOLOR") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating fcolor number with value %s", value_string.c_str());
|
||||||
|
fcolor_number_->publish_state(value);
|
||||||
|
} else if (cmd == "NRS") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating nrs number with value %s", value_string.c_str());
|
||||||
|
nrs_number_->publish_state(value);
|
||||||
|
} else if (cmd == "MPRGNRS") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating mprgngs number with value %s", value_string.c_str());
|
||||||
|
mpegnrs_number_->publish_state(value);
|
||||||
|
} else if (cmd == "OFFSETR") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating offsetr number with value %s", value_string.c_str());
|
||||||
|
offsetr_number_->publish_state(value);
|
||||||
|
} else if (cmd == "OFFSETG") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating offsetg number with value %s", value_string.c_str());
|
||||||
|
offsetg_number_->publish_state(value);
|
||||||
|
} else if (cmd == "OFFSETB") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating offsetb number with value %s", value_string.c_str());
|
||||||
|
oggsetb_number_->publish_state(value);
|
||||||
|
} else if (cmd == "GAINR") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating gainr number with value %s", value_string.c_str());
|
||||||
|
gainr_number_->publish_state(value);
|
||||||
|
} else if (cmd == "GAING") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating gaing number with value %s", value_string.c_str());
|
||||||
|
gaing_number_->publish_state(value);
|
||||||
|
} else if (cmd == "GAINB") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating gainb number with value %s", value_string.c_str());
|
||||||
|
gainb_number_->publish_state(value);
|
||||||
|
} else if (cmd == "SHRF") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating shrf number with value %s", value_string.c_str());
|
||||||
|
shrf_number_->publish_state(value);
|
||||||
|
} else if (cmd == "SHRS") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating shrs number with value %s", value_string.c_str());
|
||||||
|
shrs_number_->publish_state(value);
|
||||||
|
} else if (cmd == "DERANGE") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating derange number with value %s", value_string.c_str());
|
||||||
|
derange_number_->publish_state(value);
|
||||||
|
} else if (cmd == "DESTRENGTH") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
ESP_LOGV(TAG, "updating destrength number with value %s", value_string.c_str());
|
||||||
|
destrength_number_->publish_state(value);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());
|
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
43
tw7100.h
43
tw7100.h
|
@ -46,7 +46,28 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
||||||
void set_set_mute(switch_::Switch *switch_) { this->mute_switch_ = switch_; }
|
void set_set_mute(switch_::Switch *switch_) { this->mute_switch_ = switch_; }
|
||||||
void set_set_source(tw7100::tw7100Select *source_) { this->source_select_ = source_; }
|
void set_set_source(tw7100::tw7100Select *source_) { this->source_select_ = source_; }
|
||||||
void set_set_luminance(tw7100::tw7100Select *luminance_) { this->luminance_select_ = luminance_; }
|
void set_set_luminance(tw7100::tw7100Select *luminance_) { this->luminance_select_ = luminance_; }
|
||||||
void set_set_volume(tw7100::tw7100Number *number_) { this->volume_number_ = number_; }
|
void set_set_vol(tw7100::tw7100Number *number_) { this->volume_number_ = number_; }
|
||||||
|
void set_set_vkeystone(tw7100::tw7100Number *number_) { this->vkeystone_number_ = number_; }
|
||||||
|
void set_set_hkeystone(tw7100::tw7100Number *number_) { this->hkeystone_number_ = number_; }
|
||||||
|
void set_set_bright(tw7100::tw7100Number *number_) { this->brightness_number_ = number_; }
|
||||||
|
void set_set_contrast(tw7100::tw7100Number *number_) { this->contrast_number_ = number_; }
|
||||||
|
void set_set_density(tw7100::tw7100Number *number_) { this->density_number_ = number_; }
|
||||||
|
void set_set_tint(tw7100::tw7100Number *number_) { this->tint_number_ = number_; }
|
||||||
|
void set_set_ctemp(tw7100::tw7100Number *number_) { this->ctemp_number_ = number_; }
|
||||||
|
void set_set_fcolor(tw7100::tw7100Number *number_) { this->fcolor_number_ = number_; }
|
||||||
|
void set_set_nrs(tw7100::tw7100Number *number_) { this->nrs_number_ = number_; }
|
||||||
|
void set_set_mpegnrs(tw7100::tw7100Number *number_) { this->mpegnrs_number_ = number_; }
|
||||||
|
void set_set_offsetr(tw7100::tw7100Number *number_) { this->offsetr_number_ = number_; }
|
||||||
|
void set_set_offsetg(tw7100::tw7100Number *number_) { this->offsetg_number_ = number_; }
|
||||||
|
void set_set_offsetb(tw7100::tw7100Number *number_) { this->oggsetb_number_ = number_; }
|
||||||
|
void set_set_gainr(tw7100::tw7100Number *number_) { this->gainr_number_ = number_; }
|
||||||
|
void set_set_gaing(tw7100::tw7100Number *number_) { this->gaing_number_ = number_; }
|
||||||
|
void set_set_gainb(tw7100::tw7100Number *number_) { this->gainb_number_ = number_; }
|
||||||
|
void set_set_shrf(tw7100::tw7100Number *number_) { this->shrf_number_ = number_; }
|
||||||
|
void set_set_shrs(tw7100::tw7100Number *number_) { this->shrs_number_ = number_; }
|
||||||
|
void set_set_derange(tw7100::tw7100Number *number_) { this->derange_number_ = number_; }
|
||||||
|
void set_set_destrength(tw7100::tw7100Number *number_) { this->destrength_number_ = number_; }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
binary_sensor::BinarySensor *powered_{nullptr};
|
binary_sensor::BinarySensor *powered_{nullptr};
|
||||||
|
@ -62,6 +83,26 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
||||||
tw7100::tw7100Select *source_select_{nullptr};
|
tw7100::tw7100Select *source_select_{nullptr};
|
||||||
tw7100::tw7100Select *luminance_select_{nullptr};
|
tw7100::tw7100Select *luminance_select_{nullptr};
|
||||||
tw7100::tw7100Number *volume_number_{nullptr};
|
tw7100::tw7100Number *volume_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *vkeystone_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *hkeystone_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *brightness_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *contrast_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *density_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *tint_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *ctemp_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *fcolor_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *nrs_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *mpegnrs_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *offsetr_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *offsetg_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *oggsetb_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *gainr_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *gaing_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *gainb_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *shrf_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *shrs_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *derange_number_{nullptr};
|
||||||
|
tw7100::tw7100Number *destrength_number_{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tw7100
|
} // namespace tw7100
|
||||||
|
|
Loading…
Reference in a new issue