Skip to content

Commit 5f2980d

Browse files
committed
Serial bauds as a parameter
1 parent 844c127 commit 5f2980d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/constants.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @file constants.h
33
* @author José Ángel Sánchez (https://github.com/gelanchez)
44
* @brief Constants used along the program
5-
* @version 1.0.0
6-
* @date 2020-08-22
5+
* @version 1.0.1
6+
* @date 2020-08-28
77
* @copyright GPL-3.0
88
*/
99

@@ -14,6 +14,8 @@
1414

1515
namespace Constants
1616
{
17+
const long serialBaud(9600); // bps for Serial.begin
18+
1719
// MOTORS
1820
// Right motors pins
1921
const uint8_t motorsEnA(6);

src/robot.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @file robot.cpp
33
* @author José Ángel Sánchez (https://github.com/gelanchez)
44
* @brief Library for controling the robot.
5-
* @version 1.0.1
6-
* @date 2020-08-23
5+
* @version 1.0.2
6+
* @date 2020-08-28
77
* @copyright GPL-3.0
88
*/
99

@@ -47,7 +47,7 @@ void RobotControl::restartState()
4747

4848
void RobotControl::begin()
4949
{
50-
Serial.begin(9600); // Can not be inside a constructor
50+
Serial.begin(Constants::serialBaud); // Can not be inside a constructor
5151
m_servo.begin(); // Servo initialization can not be done inside Robot constructor
5252
}
5353

@@ -56,7 +56,6 @@ String RobotControl::getBTData()
5656
String dataBT = "";
5757
while ((Serial.available() > 0) && (dataBT.endsWith("}") == false))
5858
{
59-
6059
dataBT += static_cast<char>(Serial.read());
6160
delay(3);
6261
}
@@ -298,7 +297,6 @@ void RobotControl::lineTrackingMode()
298297
m_state = RobotModeState::OBSTACLE;
299298
}
300299
break;
301-
302300
case RobotModeState::LINELOST:
303301
m_motors.rotateRight(); // Rotate 180 and find the line
304302
delay(Constants::rotate180Time);

0 commit comments

Comments
 (0)