mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 07:58:09 +01:00
pull request fixes
This commit is contained in:
parent
aecc34ecb2
commit
b0030fc0b9
2 changed files with 30 additions and 28 deletions
|
@ -17,6 +17,7 @@
|
|||
TODO: Libretiny? (USE_LIBRETINY)
|
||||
*/
|
||||
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "cc1101.h"
|
||||
#include "cc1101defs.h"
|
||||
|
@ -78,7 +79,7 @@ CC1101::CC1101()
|
|||
void CC1101::set_config_gdo0(InternalGPIOPin* pin)
|
||||
{
|
||||
gdo0_ = pin;
|
||||
|
||||
|
||||
if(gdo2_ == NULL) gdo2_ = pin;
|
||||
}
|
||||
|
||||
|
@ -222,7 +223,7 @@ bool CC1101::reset()
|
|||
//this->disable();
|
||||
this->cs_->digital_write(false);
|
||||
delayMicroseconds(41);
|
||||
|
||||
|
||||
this->send_cmd(CC1101_SRES);
|
||||
|
||||
ESP_LOGD(TAG, "Issued CC1101 reset sequence.");
|
||||
|
@ -292,7 +293,7 @@ void CC1101::write_register_burst(uint8_t reg, uint8_t* buffer, size_t length)
|
|||
bool CC1101::send_data(const uint8_t* data, size_t length)
|
||||
{
|
||||
uint8_t buffer[length];
|
||||
|
||||
|
||||
memcpy(buffer, data, lenght);
|
||||
|
||||
this->send_cmd(CC1101_SIDLE);
|
||||
|
@ -671,7 +672,7 @@ void CC1101::begin_tx()
|
|||
{
|
||||
#ifdef USE_ESP8266
|
||||
#ifdef USE_ARDUINO
|
||||
noInterrupts();
|
||||
noInterrupts(); // NOLINT
|
||||
#else // USE_ESP_IDF
|
||||
portDISABLE_INTERRUPTS()
|
||||
#endif
|
||||
|
@ -686,7 +687,7 @@ void CC1101::end_tx()
|
|||
{
|
||||
#ifdef USE_ESP8266
|
||||
#ifdef USE_ARDUINO
|
||||
interrupts();
|
||||
interrupts(); // NOLINT
|
||||
#else // USE_ESP_IDF
|
||||
portENABLE_INTERRUPTS()
|
||||
#endif
|
||||
|
|
|
@ -16,12 +16,12 @@ CODEOWNERS = ["@gabest11", "@dbuezas", "@nistvan86", "@LSatan"]
|
|||
|
||||
DEPENDENCIES = ["spi"]
|
||||
|
||||
CONF_CC1101_GDO0 = "gdo0"
|
||||
CONF_CC1101_GDO2 = "gdo2"
|
||||
CONF_CC1101_BANDWIDTH = "bandwidth"
|
||||
CONF_CC1101_FREQUENCY = "frequency"
|
||||
CONF_CC1101_RSSI = "rssi"
|
||||
CONF_CC1101_LQI = "lqi"
|
||||
CONF_GDO0 = "gdo0"
|
||||
CONF_GDO2 = "gdo2"
|
||||
CONF_BANDWIDTH = "bandwidth"
|
||||
CONF_FREQUENCY = "frequency"
|
||||
CONF_RSSI = "rssi"
|
||||
CONF_LQI = "lqi"
|
||||
|
||||
cc1101_ns = cg.esphome_ns.namespace("cc1101")
|
||||
CC1101 = cc1101_ns.class_("CC1101", sensor.Sensor, cg.PollingComponent, spi.SPIDevice)
|
||||
|
@ -33,20 +33,20 @@ CONFIG_SCHEMA = (
|
|||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(CC1101),
|
||||
cv.Required(CONF_CC1101_GDO0): pins.gpio_output_pin_schema,
|
||||
cv.Optional(CONF_CC1101_GDO2): pins.gpio_input_pin_schema,
|
||||
cv.Optional(CONF_CC1101_BANDWIDTH, default=200): cv.uint32_t,
|
||||
cv.Optional(CONF_CC1101_FREQUENCY, default=433920): cv.uint32_t,
|
||||
cv.Optional(CONF_CC1101_RSSI): sensor.sensor_schema(
|
||||
cv.Required(CONF_GDO0): pins.gpio_output_pin_schema,
|
||||
cv.Optional(CONF_GDO2): pins.gpio_input_pin_schema,
|
||||
cv.Optional(CONF_BANDWIDTH, default=200): cv.uint32_t,
|
||||
cv.Optional(CONF_FREQUENCY, default=433920): cv.uint32_t,
|
||||
cv.Optional(CONF_RSSI): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_DECIBEL_MILLIWATT,
|
||||
accuracy_decimals=0,
|
||||
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
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,
|
||||
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.end_tx", EndTxAction, CC1101_ACTION_SCHEMA)
|
||||
async def cc1101_action_to_code(config, action_id, template_arg, args):
|
||||
|
@ -67,22 +68,22 @@ async def cc1101_action_to_code(config, action_id, template_arg, args):
|
|||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(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))
|
||||
if CONF_CC1101_GDO2 in config:
|
||||
gdo2 = await cg.gpio_pin_expression(config[CONF_CC1101_GDO2])
|
||||
if CONF_GDO2 in config:
|
||||
gdo2 = await cg.gpio_pin_expression(config[CONF_GDO2])
|
||||
cg.add(var.set_config_gdo2(gdo2))
|
||||
cg.add(var.set_config_bandwidth(config[CONF_CC1101_BANDWIDTH]))
|
||||
cg.add(var.set_config_frequency(config[CONF_CC1101_FREQUENCY]))
|
||||
if CONF_CC1101_RSSI in config:
|
||||
rssi = await sensor.new_sensor(config[CONF_CC1101_RSSI])
|
||||
cg.add(var.set_config_bandwidth(config[CONF_BANDWIDTH]))
|
||||
cg.add(var.set_config_frequency(config[CONF_FREQUENCY]))
|
||||
if CONF_RSSI in config:
|
||||
rssi = await sensor.new_sensor(config[CONF_RSSI])
|
||||
cg.add(var.set_config_rssi_sensor(rssi))
|
||||
if CONF_CC1101_LQI in config:
|
||||
lqi = await sensor.new_sensor(config[CONF_CC1101_LQI])
|
||||
if CONF_LQI in config:
|
||||
lqi = await sensor.new_sensor(config[CONF_LQI])
|
||||
cg.add(var.set_config_lqi_sensor(lqi))
|
||||
|
|
Loading…
Reference in a new issue