7static const char *
const TAG =
"m5stack_8angle";
12 err = this->
read(
nullptr, 0);
14 ESP_LOGE(TAG,
"I2C error %02X", err);
21 ESP_LOGE(TAG,
"I2C error %02X", err);
30 " Firmware version: %d",
40 return (
float) raw_pos / ((1 << bits) - 1);
44 uint16_t knob_pos = 0;
47 err = this->
read_register(M5STACK_8ANGLE_REGISTER_ANALOG_INPUT_8B + channel, (uint8_t *) &knob_pos, 1);
49 err = this->
read_register(M5STACK_8ANGLE_REGISTER_ANALOG_INPUT_12B + (channel * 2), (uint8_t *) &knob_pos, 2);
51 ESP_LOGE(TAG,
"Invalid number of bits: %d", bits);
void mark_failed()
Mark this component as failed.
ErrorCode read(uint8_t *data, size_t len) const
reads an array of bytes from the device using an I2CBus
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
int32_t read_knob_pos_raw(uint8_t channel, AnalogBits bits=AnalogBits::BITS_8)
float read_knob_pos(uint8_t channel, AnalogBits bits=AnalogBits::BITS_8)
void dump_config() override
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ NO_ERROR
No error found during execution of method.