8static const char *
const TAG =
"as7341";
16 ESP_LOGCONFIG(TAG,
" Read ID: 0x%X",
id);
17 if ((
id & 0xFC) != (AS7341_CHIP_ID << 2)) {
24 ESP_LOGE(TAG,
" Power on failed!");
37 ESP_LOGCONFIG(TAG,
"AS7341:");
40 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
42 LOG_UPDATE_INTERVAL(
this);
49 LOG_SENSOR(
" ",
"F1", this->
f1_);
50 LOG_SENSOR(
" ",
"F2", this->
f2_);
51 LOG_SENSOR(
" ",
"F3", this->
f3_);
52 LOG_SENSOR(
" ",
"F4", this->
f4_);
53 LOG_SENSOR(
" ",
"F5", this->
f5_);
54 LOG_SENSOR(
" ",
"F6", this->
f6_);
55 LOG_SENSOR(
" ",
"F7", this->
f7_);
56 LOG_SENSOR(
" ",
"F8", this->
f8_);
57 LOG_SENSOR(
" ",
"Clear", this->
clear_);
58 LOG_SENSOR(
" ",
"NIR", this->
nir_);
64 if (this->
f1_ !=
nullptr) {
67 if (this->
f2_ !=
nullptr) {
70 if (this->
f3_ !=
nullptr) {
73 if (this->
f4_ !=
nullptr) {
76 if (this->
f5_ !=
nullptr) {
79 if (this->
f6_ !=
nullptr) {
82 if (this->
f7_ !=
nullptr) {
85 if (this->
f8_ !=
nullptr) {
88 if (this->
clear_ !=
nullptr) {
91 if (this->
nir_ !=
nullptr) {
124 bool low_success = this->
read_bytes_16(AS7341_CH0_DATA_L, data, 6);
129 bool high_sucess = this->
read_bytes_16(AS7341_CH0_DATA_L, &data[6], 6);
131 return low_success && high_sucess;
148 uint8_t data = command << 3;
203 uint16_t timeout = 1000;
204 for (uint16_t time = 0; time < timeout; time++) {
218 uint16_t timeout = 1000;
219 for (uint16_t time = 0; time < timeout; time++) {
241 bool bit = (data & (1 << bit_position)) > 0;
256 data |= (1 << bit_position);
263 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)
uint16_t swap_bytes(uint16_t data)
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(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool read_byte_16(uint8_t a_register, uint16_t *data)
bool read_bytes_16(uint8_t a_register, uint16_t *data, uint8_t len)
bool write_byte_16(uint8_t a_register, uint16_t data) const
void publish_state(float state)
Publish a new state to the front-end.
@ AS7341_SMUX_CMD_WRITE
Write SMUX configuration from RAM to SMUX chain.
Providing packet encoding functions for exchanging data with a remote host.
void HOT delay(uint32_t ms)