Replace double with float, optimize calculation
This commit is contained in:
@ -87,7 +87,7 @@ static void i2c_send(const uint8_t channel, const byte v) {
|
||||
|
||||
// This is for the MCP4018 I2C based digipot
|
||||
void digipot_i2c_set_current(const uint8_t channel, const float current) {
|
||||
i2c_send(channel, current_to_wiper(MIN(MAX(current, 0.0f), float(DIGIPOT_A4988_MAX_CURRENT))));
|
||||
i2c_send(channel, current_to_wiper(MIN(MAX(current, 0), float(DIGIPOT_A4988_MAX_CURRENT))));
|
||||
}
|
||||
|
||||
void digipot_i2c_init() {
|
||||
|
@ -69,7 +69,7 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
|
||||
|
||||
// Set actual wiper value
|
||||
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
|
||||
i2c_send(addr, addresses[channel & 0x3], current_to_wiper(MIN((float) MAX(current, 0.0f), DIGIPOT_I2C_MAX_CURRENT)));
|
||||
i2c_send(addr, addresses[channel & 0x3], current_to_wiper(MIN((float) MAX(current, 0), DIGIPOT_I2C_MAX_CURRENT)));
|
||||
}
|
||||
|
||||
void digipot_i2c_init() {
|
||||
|
Reference in New Issue
Block a user