Tiago Correia / Mbed OS SRA2020-2021

Dependencies:   BufferedSerial

Committer:
yaaqobhpt
Date:
Wed May 05 14:14:28 2021 +0000
Revision:
2:faef6636d456
Parent:
0:c25c4b67b6a1
dada

Who changed what in which revision?

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