dasd

Dependencies:   BufferedSerial

Committer:
shut
Date:
Fri Jun 07 15:39:06 2019 +0000
Revision:
7:5e59f8a011fd
Parent:
1:dc87724abce8
7-6

Who changed what in which revision?

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