mirror of
https://github.com/esphome/esphome.git
synced 2026-05-21 11:32:08 +08:00
[codegen] Add cg.int8 type and fix templatable int8 types (#15573)
This commit is contained in:
@@ -79,6 +79,7 @@ from esphome.cpp_types import ( # noqa: F401
|
||||
float_,
|
||||
global_ns,
|
||||
gpio_Flags,
|
||||
int8,
|
||||
int16,
|
||||
int32,
|
||||
int64,
|
||||
|
||||
@@ -169,7 +169,7 @@ async def at581x_settings_to_code(config, action_id, template_arg, args):
|
||||
|
||||
# Radar configuration
|
||||
if frontend_reset := config.get(CONF_HW_FRONTEND_RESET):
|
||||
template_ = await cg.templatable(frontend_reset, args, int)
|
||||
template_ = await cg.templatable(frontend_reset, args, cg.int8)
|
||||
cg.add(var.set_hw_frontend_reset(template_))
|
||||
|
||||
if freq := config.get(CONF_FREQUENCY):
|
||||
|
||||
@@ -159,7 +159,7 @@ async def dfrobot_sen0395_settings_to_code(config, action_id, template_arg, args
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
||||
if factory_reset_config := config.get(CONF_FACTORY_RESET):
|
||||
template_ = await cg.templatable(factory_reset_config, args, int)
|
||||
template_ = await cg.templatable(factory_reset_config, args, cg.int8)
|
||||
cg.add(var.set_factory_reset(template_))
|
||||
|
||||
if CONF_DETECTION_SEGMENTS in config:
|
||||
@@ -200,7 +200,7 @@ async def dfrobot_sen0395_settings_to_code(config, action_id, template_arg, args
|
||||
template_ = template_.total_milliseconds / 1000
|
||||
cg.add(var.set_delay_after_disappear(template_))
|
||||
if CONF_SENSITIVITY in config:
|
||||
template_ = await cg.templatable(config[CONF_SENSITIVITY], args, int)
|
||||
template_ = await cg.templatable(config[CONF_SENSITIVITY], args, cg.int8)
|
||||
cg.add(var.set_sensitivity(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -13,6 +13,7 @@ std_string = std_ns.class_("string")
|
||||
std_string_ref = std_ns.namespace("string &")
|
||||
std_vector = std_ns.class_("vector")
|
||||
std_span = std_ns.class_("span")
|
||||
int8 = global_ns.namespace("int8_t")
|
||||
uint8 = global_ns.namespace("uint8_t")
|
||||
uint16 = global_ns.namespace("uint16_t")
|
||||
uint32 = global_ns.namespace("uint32_t")
|
||||
|
||||
Reference in New Issue
Block a user