NagaokaRoboticsClub_mbedTeam / Mbed OS hayatoShooter

Dependencies:   PID QEI ikarashiMDC recieveController omni

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gakugaku.cpp Source File

gakugaku.cpp

00001 #include "gakugaku.h"
00002 
00003 
00004 gakugaku::gakugaku(Serial* serial_)
00005 {
00006   rscs = new DigitalOut(NC);
00007   swingMotor = new ikarashiMDC(rscs,0,2,SM,serial_);
00008   angleMotor = new ikarashiMDC(rscs,0,3,SM,serial_);
00009   deploy = new DigitalOut(PC_0);
00010 
00011   angleMotor->setSpeed(0);
00012   swingMotor->setSpeed(0);
00013 
00014   anglingSpeed = 0;
00015   swinging = false;
00016   deploy->write(false);
00017 
00018 }
00019 
00020 void gakugaku::update()
00021 {
00022   if (swinging) {
00023       swingMotor->setSpeed(0.5);
00024   } else {
00025       swingMotor->setSpeed(0);
00026   }
00027   angleMotor->setSpeed(anglingSpeed);
00028 }
00029 
00030 void gakugaku::setAnglingSpeed(const double& anglingSpeed_)
00031 {
00032   anglingSpeed=anglingSpeed_;
00033 }
00034 
00035 void gakugaku::toggleSwing()
00036 {
00037   swinging = !swinging;
00038 }
00039 void gakugaku::Deploy()
00040 {
00041   deploy->write(true);
00042   timer.attach(callback(this,&gakugaku::deployStop),2);
00043 }
00044 void gakugaku::deployStop()
00045 {
00046   deploy->write(false);
00047 }