For Rotaryencoder and Motor

Dependencies:   arrc_mbed

Dependents:  

Committer:
m2130
Date:
Mon Sep 12 02:11:41 2022 +0000
Revision:
1:9e7d6d72e352
Parent:
0:b1487fd792c9
kk;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m2130 0:b1487fd792c9 1 #include "motor.hpp"
m2130 0:b1487fd792c9 2
m2130 0:b1487fd792c9 3 Motor::Motor(PinName MP, PinName MM): mp(MP), mm(MM){
m2130 0:b1487fd792c9 4 mp.period_us(2048);
m2130 0:b1487fd792c9 5 mm.period_us(2048);
m2130 0:b1487fd792c9 6 }
m2130 0:b1487fd792c9 7
m2130 0:b1487fd792c9 8 void Motor::out(double pwm){
m2130 0:b1487fd792c9 9 if(pwm > 0.0){
m2130 0:b1487fd792c9 10 mp = pwm > 0.5 ? 0.5 : pwm;
m2130 0:b1487fd792c9 11 mm = 0.0;
m2130 0:b1487fd792c9 12 }
m2130 0:b1487fd792c9 13 else if(pwm == 0){
m2130 0:b1487fd792c9 14 mp = 0.0;
m2130 0:b1487fd792c9 15 mm = 0.0;
m2130 0:b1487fd792c9 16 }
m2130 0:b1487fd792c9 17 else{
m2130 0:b1487fd792c9 18 mp = 0.0;
m2130 0:b1487fd792c9 19 mm = -pwm > 0.5 ? 0.5 : -pwm;
m2130 0:b1487fd792c9 20 }
m2130 0:b1487fd792c9 21 }