Simple LMD18200 Motor Driver Breakout Board Library
Embed:
(wiki syntax)
Show/hide line numbers
LMD18200.cpp
00001 #include "LMD18200.h" 00002 #include <algorithm> 00003 00004 LMD18200::LMD18200(PinName pwm, PinName dir) : speed(pwm), direction(dir){ 00005 speed = 0.0; 00006 direction = 0; 00007 } 00008 00009 void LMD18200::setSpeed(float spd){ 00010 spd = clip(spd, 0.0, 1.0); // Clamp value 00011 speed = spd; // Set PWM Speed 00012 } 00013 00014 void LMD18200::setDirection(int dir){ 00015 direction = dir; 00016 } 00017 00018 /* 00019 Clips value to lower/ uppper 00020 @param value The value to clip 00021 @param lower The mininum allowable value 00022 @param upper The maximum allowable value 00023 @return The resulting clipped value 00024 */ 00025 float LMD18200::clip(float value, float lower, float upper){ 00026 return std::max(lower, std::min(value, upper)); 00027 }
Generated on Thu Jul 14 2022 05:26:28 by
1.7.2