mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
i2c_device (#7641)
Some checks are pending
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Some checks are pending
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
This commit is contained in:
parent
68844c4869
commit
dd8d25e43f
10 changed files with 110 additions and 0 deletions
|
@ -198,6 +198,7 @@ esphome/components/htu31d/* @betterengineering
|
||||||
esphome/components/hydreon_rgxx/* @functionpointer
|
esphome/components/hydreon_rgxx/* @functionpointer
|
||||||
esphome/components/hyt271/* @Philippe12
|
esphome/components/hyt271/* @Philippe12
|
||||||
esphome/components/i2c/* @esphome/core
|
esphome/components/i2c/* @esphome/core
|
||||||
|
esphome/components/i2c_device/* @gabest11
|
||||||
esphome/components/i2s_audio/* @jesserockz
|
esphome/components/i2s_audio/* @jesserockz
|
||||||
esphome/components/i2s_audio/media_player/* @jesserockz
|
esphome/components/i2s_audio/media_player/* @jesserockz
|
||||||
esphome/components/i2s_audio/microphone/* @jesserockz
|
esphome/components/i2s_audio/microphone/* @jesserockz
|
||||||
|
|
26
esphome/components/i2c_device/__init__.py
Normal file
26
esphome/components/i2c_device/__init__.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.components import i2c
|
||||||
|
from esphome.const import CONF_ID
|
||||||
|
|
||||||
|
DEPENDENCIES = ["i2c"]
|
||||||
|
CODEOWNERS = ["@gabest11"]
|
||||||
|
MULTI_CONF = True
|
||||||
|
|
||||||
|
i2c_device_ns = cg.esphome_ns.namespace("i2c_device")
|
||||||
|
|
||||||
|
I2CDeviceComponent = i2c_device_ns.class_(
|
||||||
|
"I2CDeviceComponent", cg.Component, i2c.I2CDevice
|
||||||
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
|
{
|
||||||
|
cv.GenerateID(CONF_ID): cv.declare_id(I2CDeviceComponent),
|
||||||
|
}
|
||||||
|
).extend(i2c.i2c_device_schema(None))
|
||||||
|
|
||||||
|
|
||||||
|
async def to_code(config):
|
||||||
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
await cg.register_component(var, config)
|
||||||
|
await i2c.register_i2c_device(var, config)
|
17
esphome/components/i2c_device/i2c_device.cpp
Normal file
17
esphome/components/i2c_device/i2c_device.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include "i2c_device.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/hal.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace i2c_device {
|
||||||
|
|
||||||
|
static const char *const TAG = "i2c_device";
|
||||||
|
|
||||||
|
void I2CDeviceComponent::dump_config() {
|
||||||
|
ESP_LOGCONFIG(TAG, "I2CDevice");
|
||||||
|
LOG_I2C_DEVICE(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace i2c_device
|
||||||
|
} // namespace esphome
|
18
esphome/components/i2c_device/i2c_device.h
Normal file
18
esphome/components/i2c_device/i2c_device.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/components/i2c/i2c.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace i2c_device {
|
||||||
|
|
||||||
|
class I2CDeviceComponent : public Component, public i2c::I2CDevice {
|
||||||
|
public:
|
||||||
|
void dump_config() override;
|
||||||
|
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace i2c_device
|
||||||
|
} // namespace esphome
|
8
tests/components/i2c_device/test.esp32-ard.yaml
Normal file
8
tests/components/i2c_device/test.esp32-ard.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 16
|
||||||
|
sda: 17
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
8
tests/components/i2c_device/test.esp32-c3-ard.yaml
Normal file
8
tests/components/i2c_device/test.esp32-c3-ard.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 5
|
||||||
|
sda: 4
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
8
tests/components/i2c_device/test.esp32-c3-idf.yaml
Normal file
8
tests/components/i2c_device/test.esp32-c3-idf.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 5
|
||||||
|
sda: 4
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
8
tests/components/i2c_device/test.esp32-idf.yaml
Normal file
8
tests/components/i2c_device/test.esp32-idf.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 16
|
||||||
|
sda: 17
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
8
tests/components/i2c_device/test.esp8266-ard.yaml
Normal file
8
tests/components/i2c_device/test.esp8266-ard.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 5
|
||||||
|
sda: 4
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
8
tests/components/i2c_device/test.rp2040-ard.yaml
Normal file
8
tests/components/i2c_device/test.rp2040-ard.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
i2c:
|
||||||
|
- id: i2c_i2c
|
||||||
|
scl: 5
|
||||||
|
sda: 4
|
||||||
|
|
||||||
|
i2c_device:
|
||||||
|
id: i2cdev
|
||||||
|
address: 0x2C
|
Loading…
Reference in a new issue