12 if (!this->
check_chip_id(
this, AS7341_ID, AS7341_CHIP_ID << 2, 0xFC))
29 ESP_LOGCONFIG(TAG,
"AS7341:");
31 LOG_UPDATE_INTERVAL(
this);
38 LOG_SENSOR(
" ",
"F1", this->
f1_);
39 LOG_SENSOR(
" ",
"F2", this->
f2_);
40 LOG_SENSOR(
" ",
"F3", this->
f3_);
41 LOG_SENSOR(
" ",
"F4", this->
f4_);
42 LOG_SENSOR(
" ",
"F5", this->
f5_);
43 LOG_SENSOR(
" ",
"F6", this->
f6_);
44 LOG_SENSOR(
" ",
"F7", this->
f7_);
45 LOG_SENSOR(
" ",
"F8", this->
f8_);
46 LOG_SENSOR(
" ",
"Clear", this->
clear_);
47 LOG_SENSOR(
" ",
"NIR", this->
nir_);
53 if (this->
f1_ !=
nullptr) {
56 if (this->
f2_ !=
nullptr) {
59 if (this->
f3_ !=
nullptr) {
62 if (this->
f4_ !=
nullptr) {
65 if (this->
f5_ !=
nullptr) {
68 if (this->
f6_ !=
nullptr) {
71 if (this->
f7_ !=
nullptr) {
74 if (this->
f8_ !=
nullptr) {
77 if (this->
clear_ !=
nullptr) {
80 if (this->
nir_ !=
nullptr) {
120 return low_success && high_sucess;
137 uint8_t data = command << 3;
192 uint16_t timeout = 1000;
193 for (uint16_t time = 0; time < timeout; time++) {
207 uint16_t timeout = 1000;
208 for (uint16_t time = 0; time < timeout; time++) {
230 bool bit = (data & (1 << bit_position)) > 0;
245 data |= (1 << bit_position);
252 data &= ~(1 << bit_position);
void mark_failed()
Mark this component as failed.
bool setup_atime(uint8_t atime)
uint16_t channel_readings_[12]
bool setup_gain(AS7341Gain gain)
bool read_register_bit(uint8_t address, uint8_t bit_position)
void dump_config() override
void configure_smux_low_channels()
bool clear_register_bit(uint8_t address, uint8_t bit_position)
bool enable_power(bool enable)
bool read_channels(uint16_t *data)
bool set_smux_command(AS7341SmuxCommand command)
void configure_smux_high_channels()
bool setup_astep(uint16_t astep)
void set_smux_low_channels(bool enable)
bool enable_spectral_measurement(bool enable)
bool set_register_bit(uint8_t address, uint8_t bit_position)
bool write_register_bit(uint8_t address, bool value, uint8_t bit_position)
bool write_byte_16_le(uint8_t a_register, uint16_t data) const
Write a 16-bit value least significant byte first.
bool check_chip_id(Component *component, uint8_t a_register, uint8_t expected, uint8_t mask=0xFF)
Read the 8-bit ID at a_register and accept it when it matches expected in the bits set in mask.
bool read_bytes_16_le(uint8_t a_register, uint16_t *data, uint8_t len)
Read len 16-bit values stored least significant byte first; no conversion is compiled on little-endia...
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool read_byte_16_le(uint8_t a_register, uint16_t *data)
Read a 16-bit value stored least significant byte first.
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "as7341")
@ AS7341_SMUX_CMD_WRITE
Write SMUX configuration from RAM to SMUX chain.
void HOT delay(uint32_t ms)