Add change i2c address and allow multi conf for TB6612FNG (#5492)

This commit is contained in:
Christian
2023-10-16 20:47:35 +01:00
committed by Jesse Hills
parent 52e8a2e9e4
commit 97d624114d
2 changed files with 34 additions and 2 deletions
@@ -84,8 +84,7 @@ class GroveMotorDriveTB6612FNG : public Component, public i2c::I2CDevice {
*************************************************************/
void set_i2c_addr(uint8_t addr);
/*************************************************************
Description
/***********************************change_address
Drive a motor.
Parameter
chl: MOTOR_CHA or MOTOR_CHB
@@ -204,5 +203,13 @@ class GROVETB6612FNGMotorNoStandbyAction : public Action<Ts...>, public Parented
void play(Ts... x) override { this->parent_->not_standby(); }
};
template<typename... Ts>
class GROVETB6612FNGMotorChangeAddressAction : public Action<Ts...>, public Parented<GroveMotorDriveTB6612FNG> {
public:
TEMPLATABLE_VALUE(uint8_t, address)
void play(Ts... x) override { this->parent_->set_i2c_addr(this->address_.value(x...)); }
};
} // namespace grove_tb6612fng
} // namespace esphome