pull request fixes

This commit is contained in:
Gábor Poczkodi 2024-02-28 13:26:03 +01:00
parent aecc34ecb2
commit b0030fc0b9
2 changed files with 30 additions and 28 deletions

View file

@ -17,6 +17,7 @@
TODO: Libretiny? (USE_LIBRETINY) TODO: Libretiny? (USE_LIBRETINY)
*/ */
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "cc1101.h" #include "cc1101.h"
#include "cc1101defs.h" #include "cc1101defs.h"
@ -671,7 +672,7 @@ void CC1101::begin_tx()
{ {
#ifdef USE_ESP8266 #ifdef USE_ESP8266
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
noInterrupts(); noInterrupts(); // NOLINT
#else // USE_ESP_IDF #else // USE_ESP_IDF
portDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
#endif #endif
@ -686,7 +687,7 @@ void CC1101::end_tx()
{ {
#ifdef USE_ESP8266 #ifdef USE_ESP8266
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
interrupts(); interrupts(); // NOLINT
#else // USE_ESP_IDF #else // USE_ESP_IDF
portENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
#endif #endif

View file

@ -16,12 +16,12 @@ CODEOWNERS = ["@gabest11", "@dbuezas", "@nistvan86", "@LSatan"]
DEPENDENCIES = ["spi"] DEPENDENCIES = ["spi"]
CONF_CC1101_GDO0 = "gdo0" CONF_GDO0 = "gdo0"
CONF_CC1101_GDO2 = "gdo2" CONF_GDO2 = "gdo2"
CONF_CC1101_BANDWIDTH = "bandwidth" CONF_BANDWIDTH = "bandwidth"
CONF_CC1101_FREQUENCY = "frequency" CONF_FREQUENCY = "frequency"
CONF_CC1101_RSSI = "rssi" CONF_RSSI = "rssi"
CONF_CC1101_LQI = "lqi" CONF_LQI = "lqi"
cc1101_ns = cg.esphome_ns.namespace("cc1101") cc1101_ns = cg.esphome_ns.namespace("cc1101")
CC1101 = cc1101_ns.class_("CC1101", sensor.Sensor, cg.PollingComponent, spi.SPIDevice) CC1101 = cc1101_ns.class_("CC1101", sensor.Sensor, cg.PollingComponent, spi.SPIDevice)
@ -33,20 +33,20 @@ CONFIG_SCHEMA = (
cv.Schema( cv.Schema(
{ {
cv.GenerateID(): cv.declare_id(CC1101), cv.GenerateID(): cv.declare_id(CC1101),
cv.Required(CONF_CC1101_GDO0): pins.gpio_output_pin_schema, cv.Required(CONF_GDO0): pins.gpio_output_pin_schema,
cv.Optional(CONF_CC1101_GDO2): pins.gpio_input_pin_schema, cv.Optional(CONF_GDO2): pins.gpio_input_pin_schema,
cv.Optional(CONF_CC1101_BANDWIDTH, default=200): cv.uint32_t, cv.Optional(CONF_BANDWIDTH, default=200): cv.uint32_t,
cv.Optional(CONF_CC1101_FREQUENCY, default=433920): cv.uint32_t, cv.Optional(CONF_FREQUENCY, default=433920): cv.uint32_t,
cv.Optional(CONF_CC1101_RSSI): sensor.sensor_schema( cv.Optional(CONF_RSSI): sensor.sensor_schema(
unit_of_measurement=UNIT_DECIBEL_MILLIWATT, unit_of_measurement=UNIT_DECIBEL_MILLIWATT,
accuracy_decimals=0, accuracy_decimals=0,
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
state_class=STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
), ),
cv.Optional(CONF_CC1101_LQI): sensor.sensor_schema( cv.Optional(CONF_LQI): sensor.sensor_schema(
unit_of_measurement=UNIT_EMPTY, unit_of_measurement=UNIT_EMPTY,
accuracy_decimals=0, accuracy_decimals=0,
state_class = STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
), ),
} }
) )
@ -60,6 +60,7 @@ CC1101_ACTION_SCHEMA = maybe_simple_id(
} }
) )
@automation.register_action("cc1101.begin_tx", BeginTxAction, CC1101_ACTION_SCHEMA) @automation.register_action("cc1101.begin_tx", BeginTxAction, CC1101_ACTION_SCHEMA)
@automation.register_action("cc1101.end_tx", EndTxAction, CC1101_ACTION_SCHEMA) @automation.register_action("cc1101.end_tx", EndTxAction, CC1101_ACTION_SCHEMA)
async def cc1101_action_to_code(config, action_id, template_arg, args): async def cc1101_action_to_code(config, action_id, template_arg, args):
@ -73,16 +74,16 @@ async def to_code(config):
await cg.register_component(var, config) await cg.register_component(var, config)
await spi.register_spi_device(var, config) await spi.register_spi_device(var, config)
gdo0 = await cg.gpio_pin_expression(config[CONF_CC1101_GDO0]) gdo0 = await cg.gpio_pin_expression(config[CONF_GDO0])
cg.add(var.set_config_gdo0(gdo0)) cg.add(var.set_config_gdo0(gdo0))
if CONF_CC1101_GDO2 in config: if CONF_GDO2 in config:
gdo2 = await cg.gpio_pin_expression(config[CONF_CC1101_GDO2]) gdo2 = await cg.gpio_pin_expression(config[CONF_GDO2])
cg.add(var.set_config_gdo2(gdo2)) cg.add(var.set_config_gdo2(gdo2))
cg.add(var.set_config_bandwidth(config[CONF_CC1101_BANDWIDTH])) cg.add(var.set_config_bandwidth(config[CONF_BANDWIDTH]))
cg.add(var.set_config_frequency(config[CONF_CC1101_FREQUENCY])) cg.add(var.set_config_frequency(config[CONF_FREQUENCY]))
if CONF_CC1101_RSSI in config: if CONF_RSSI in config:
rssi = await sensor.new_sensor(config[CONF_CC1101_RSSI]) rssi = await sensor.new_sensor(config[CONF_RSSI])
cg.add(var.set_config_rssi_sensor(rssi)) cg.add(var.set_config_rssi_sensor(rssi))
if CONF_CC1101_LQI in config: if CONF_LQI in config:
lqi = await sensor.new_sensor(config[CONF_CC1101_LQI]) lqi = await sensor.new_sensor(config[CONF_LQI])
cg.add(var.set_config_lqi_sensor(lqi)) cg.add(var.set_config_lqi_sensor(lqi))