6 namespace m5stack_8angle {
8 static const char *
const TAG =
"m5stack_8angle";
11 ESP_LOGCONFIG(TAG,
"Setting up M5STACK_8ANGLE...");
14 err = this->
read(
nullptr, 0);
16 ESP_LOGE(TAG,
"I2C error %02X...", err);
23 ESP_LOGE(TAG,
"I2C error %02X...", err);
30 ESP_LOGCONFIG(TAG,
"M5STACK_8ANGLE:");
32 ESP_LOGCONFIG(TAG,
" Firmware version: %d ", this->
fw_version_);
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);
const float DATA
For components that import data from directly connected sensors like DHT.
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
No error found during execution of method.
void dump_config() override
float read_knob_pos(uint8_t channel, AnalogBits bits=AnalogBits::BITS_8)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
float get_setup_priority() const override
int32_t read_knob_pos_raw(uint8_t channel, AnalogBits bits=AnalogBits::BITS_8)