54 void setup()
override;
59 void set_pid(int32_t p, int32_t i, int32_t d) {
71 SUB_TEXT_SENSOR(status)
76 void control_command(
float value) {
78 this->command_number_->publish_state(
value);
83 void control_direction(
size_t index) {
85 this->direction_select_->publish_state(index);
98 return this->
read_bytes(reg,
reinterpret_cast<uint8_t *
>(
value),
sizeof(T));
101 return this->
write_bytes(reg,
reinterpret_cast<const uint8_t *
>(&
value),
sizeof(T));
122#ifdef USE_TEXT_SENSOR
BedjetMode mode
BedJet operating mode.
This class simplifies creating components that periodically check a state.
This Class provides the methods to read/write bytes from/to an i2c device.
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
Hub for one M5Stack M5Unit-BLDC brushless motor driver.
Direction current_direction_
bool direction_change_pending_
uint8_t direction_change_polls_
SUB_SENSOR(rpm) SUB_SENSOR(frequency) SUB_TEXT_SENSOR(status) SUB_NUMBER(command) void control_command(float value)
The PWM duty number in open loop, the target RPM number in closed loop.
void finish_direction_change_()
const uint8_t pole_pairs_
void dump_config() override
static constexpr uint32_t DIRECTION_CHANGE_POLL_ID
const Direction initial_direction_
const bool save_to_flash_
bool write_direction_raw_(Direction direction)
void set_pid(int32_t p, int32_t i, int32_t d)
PID gains as the device stores them, each multiplied by 100.
const MotorModel motor_model_
const ControlMode control_mode_
bool write_direction(Direction direction)
bool write_reg_(uint8_t reg, const T &value)
ESPPreferenceObject save_pref_
SUB_SELECT(direction) void control_direction(size_t index)
bool write_command_raw_(float value)
bool read_reg_(uint8_t reg, T *value)
bool read_command_raw_(float *value)
bool write_command(float value)
Send the PWM duty (open loop) or target RPM (closed loop).
M5StackUnitBldc(ControlMode mode, Direction initial_direction, MotorModel model, uint8_t pole_pairs, bool save_to_flash)
@ CONTROL_MODE_CLOSED_LOOP