Dependencies:   BufferedSerial

Committer:
ccpjboss
Date:
Thu May 27 08:53:19 2021 +0000
Revision:
0:0d3a25d4697e
tet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ccpjboss 0:0d3a25d4697e 1 /** @file */
ccpjboss 0:0d3a25d4697e 2 #ifndef ROBOT_H_
ccpjboss 0:0d3a25d4697e 3 #define ROBOT_H_
ccpjboss 0:0d3a25d4697e 4
ccpjboss 0:0d3a25d4697e 5 #include "mbed.h"
ccpjboss 0:0d3a25d4697e 6
ccpjboss 0:0d3a25d4697e 7 extern int16_t countsLeft;
ccpjboss 0:0d3a25d4697e 8 extern int16_t countsRight;
ccpjboss 0:0d3a25d4697e 9
ccpjboss 0:0d3a25d4697e 10 /** \brief Sets the speed for both motors.
ccpjboss 0:0d3a25d4697e 11 *
ccpjboss 0:0d3a25d4697e 12 * \param leftSpeed A number from -300 to 300 representing the speed and
ccpjboss 0:0d3a25d4697e 13 * direction of the left motor. Values of -300 or less result in full speed
ccpjboss 0:0d3a25d4697e 14 * reverse, and values of 300 or more result in full speed forward.
ccpjboss 0:0d3a25d4697e 15 * \param rightSpeed A number from -300 to 300 representing the speed and
ccpjboss 0:0d3a25d4697e 16 * direction of the right motor. Values of -300 or less result in full speed
ccpjboss 0:0d3a25d4697e 17 * reverse, and values of 300 or more result in full speed forward. */
ccpjboss 0:0d3a25d4697e 18 void setSpeeds(int16_t leftSpeed, int16_t rightSpeed);
ccpjboss 0:0d3a25d4697e 19
ccpjboss 0:0d3a25d4697e 20 /** \brief Sets the speed for the left motor.
ccpjboss 0:0d3a25d4697e 21 *
ccpjboss 0:0d3a25d4697e 22 * \param speed A number from -300 to 300 representing the speed and
ccpjboss 0:0d3a25d4697e 23 * direction of the left motor. Values of -300 or less result in full speed
ccpjboss 0:0d3a25d4697e 24 * reverse, and values of 300 or more result in full speed forward. */
ccpjboss 0:0d3a25d4697e 25 void setLeftSpeed(int16_t speed);
ccpjboss 0:0d3a25d4697e 26
ccpjboss 0:0d3a25d4697e 27 /** \brief Sets the speed for the right motor.
ccpjboss 0:0d3a25d4697e 28 *
ccpjboss 0:0d3a25d4697e 29 * \param speed A number from -300 to 300 representing the speed and
ccpjboss 0:0d3a25d4697e 30 * direction of the right motor. Values of -300 or less result in full speed
ccpjboss 0:0d3a25d4697e 31 * reverse, and values of 300 or more result in full speed forward. */
ccpjboss 0:0d3a25d4697e 32 void setRightSpeed(int16_t speed);
ccpjboss 0:0d3a25d4697e 33
ccpjboss 0:0d3a25d4697e 34 /*! Returns the number of counts that have been detected from the both
ccpjboss 0:0d3a25d4697e 35 * encoders. These counts start at 0. Positive counts correspond to forward
ccpjboss 0:0d3a25d4697e 36 * movement of the wheel of the Romi, while negative counts correspond
ccpjboss 0:0d3a25d4697e 37 * to backwards movement.
ccpjboss 0:0d3a25d4697e 38 *
ccpjboss 0:0d3a25d4697e 39 * The count is returned as a signed 16-bit integer. When the count goes
ccpjboss 0:0d3a25d4697e 40 * over 32767, it will overflow down to -32768. When the count goes below
ccpjboss 0:0d3a25d4697e 41 * -32768, it will overflow up to 32767. */
ccpjboss 0:0d3a25d4697e 42 void getCounts();
ccpjboss 0:0d3a25d4697e 43
ccpjboss 0:0d3a25d4697e 44 /*! This function is just like getCounts() except it also clears the
ccpjboss 0:0d3a25d4697e 45 * counts before returning. If you call this frequently enough, you will
ccpjboss 0:0d3a25d4697e 46 * not have to worry about the count overflowing. */
ccpjboss 0:0d3a25d4697e 47 void getCountsAndReset();
ccpjboss 0:0d3a25d4697e 48
ccpjboss 0:0d3a25d4697e 49 #endif /* ROBOT_H_ */