DRV8830/Texas Instruments H-Bridge Voltage-Controlled Motor Driver library for Brushed DC Motor
Dependents: NucleoF401_motor_test_simple Frequency_Counter_w_GPS_1PPS Nucleo_ACM1602_I2C_DC_Angle Frequency_Cntr_1PPS_F746ZG
Diff: DRV8830.cpp
- Revision:
- 3:98a9369ed390
- Parent:
- 1:a9b58bc85be0
- Child:
- 4:323a62f5fff3
--- a/DRV8830.cpp Thu Nov 27 21:41:21 2014 +0000 +++ b/DRV8830.cpp Tue Dec 23 23:28:54 2014 +0000 @@ -83,14 +83,14 @@ uint8_t pwm_rate = 0; uint8_t dt[2]; - if (speed == 0.0 ){ + if (speed == 0.0f ){ pwm_rate = DRV8830_V_MIN; direction = DRV8830_FREE; - } else if (speed > 0.0){ + } else if (speed > 0.0f){ pwm_rate = (uint8_t)(DRV8830_V_RANGE * speed) + DRV8830_V_MIN; direction = DRV8830_CW; - } else if (speed < 0.0){ - speed *= -1; + } else if (speed < 0.0f){ + speed *= -1.0f; pwm_rate = (uint8_t)(DRV8830_V_RANGE * speed) + DRV8830_V_MIN; direction = DRV8830_CCW; }