基本クラス
Dependents: 300_PS3com Quadrifoglio_PS3COM
Diff: Master.cpp
- Revision:
- 0:e2da5742a718
- Child:
- 1:60319e61775d
diff -r 000000000000 -r e2da5742a718 Master.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Master.cpp Sat Jun 11 13:24:51 2022 +0000 @@ -0,0 +1,54 @@ +#include "Master.h" + +Master::Master() : + pc(USBTX, USBRX, 115200) + ,shot(kicker) + ,drib(ESCpin) +{ + motor[0] = new KohiMD(PA_15); + motor[1] = new KohiMD(PA_6); + motor[2] = new KohiMD(PA_7); + motor[3] = new KohiMD(PB_6); + shot.setkickperiod(2.0); + shot.setoutputtime(0.1); + drib.setspeed(0.0); +} + +void Master::SetPS3Address(bool *button_, uint8_t *trigger_, uint8_t *stick_) +{ + button = button_; + stick = stick_; + trigger = trigger_; +} + +void Master::PS3Com() +{ + for(int i=0; i < 4; i++) { + if (button[i+4]) { + pwm = 0.5; + } else if (button[i+4+4]){ + pwm = -0.5; + } else { + pwm = 0; + } +// md[i].setSpeed(pwm); + SetValueMotor(i, 0.2); + } + if (button[2]) Shot(); + if (button[3]) Dribble(0.6); +} + +void Master::Shot() +{ + shot.outPut(); +} + +void Master::Dribble(float power) +{ + drib.setspeed(power); +} + +void Master::SetValueMotor(int num, double val) +{ + motor[num]->setSpeed(val); +} \ No newline at end of file