mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 11:37:27 +01:00
i2c_device (#7641)
This commit is contained in:
parent
68844c4869
commit
dd8d25e43f
@ -198,6 +198,7 @@ esphome/components/htu31d/* @betterengineering
|
||||
esphome/components/hydreon_rgxx/* @functionpointer
|
||||
esphome/components/hyt271/* @Philippe12
|
||||
esphome/components/i2c/* @esphome/core
|
||||
esphome/components/i2c_device/* @gabest11
|
||||
esphome/components/i2s_audio/* @jesserockz
|
||||
esphome/components/i2s_audio/media_player/* @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 New Issue
Block a user