タコ 腕

Dependencies:   2017NHKpin_config FEP ikarashiMDC

Fork of NHK2017_octopus2 by NagaokaRoboticsClub_mbedTeam

bot/elevator/elevator.cpp

Committer:
number_key
Date:
2017-11-23
Revision:
54:857390145ac4
Parent:
49:69a7235d837a
Child:
55:ccf2ac8f6f32

File content as of revision 54:857390145ac4:

#include "elevator.h"

Elevator::Elevator(DigitalOut* RS485Controller, Serial* RS485) :
  elevatorMotor(RS485Controller, 1, 2, SM, RS485),
  limit(LIMIT4, LIMIT5),
  debugSerial(USBTX, USBRX, 115200)
{
	elevatorMotor.braking = true;
}

void Elevator::move(float speed)
{
  if(speed*limit.getPosition() < 0)    speed = 0;
  if(speed*limit.getPosition() > 0)    limit.resetPosition();
	elevatorMotor.setSpeed(speed);
}

void Elevator::stop()
{
  elevatorMotor.setSpeed(0);
}

void Elevator::debugPrint()
{
  debugSerial.printf("elevator:%d\r\f",limit.getPosition());
}