Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
EngineController.hpp
Go to the documentation of this file.
1
14
15#ifndef ENGINECONTROLLER_HPP
16#define ENGINECONTROLLER_HPP
17
19#include "enums.hpp"
20#include <QObject>
21#include <atomic>
22
27class EngineController : public QObject {
28 Q_OBJECT
29
30private:
31 const int MAX_ANGLE = 180;
32 const int SERVO_CENTER_PWM = 340;
33 const int SERVO_LEFT_PWM = 340 - 100;
34 const int SERVO_RIGHT_PWM = 340 + 130;
35 const int STEERING_CHANNEL = 0;
36
37 std::atomic<bool> m_running;
38 std::atomic<int> m_current_speed;
39 std::atomic<int> m_current_angle;
41
42 void setDirection(CarDirection newDirection);
43
45
46public:
48 EngineController(int servo_addr, int motor_addr, QObject *parent = nullptr);
50
51 void start();
52 void stop();
53 void set_speed(int speed);
54 void set_steering(int angle);
55
56signals:
57 void directionUpdated(CarDirection newDirection);
58 void steeringUpdated(int newAngle);
59};
60
61#endif // ENGINECONTROLLER_HPP
Definition of the IPeripheralController interface.
Definition of the enums used in the application.
CarDirection
Enum class for the car direction.
Definition enums.hpp:30
EngineController()
Default constructor for the EngineController class.
void stop()
Stops the engine.
void setDirection(CarDirection newDirection)
Sets the direction of the car and emits the directionUpdated signal if the direction has changed.
IPeripheralController * pcontrol
std::atomic< int > m_current_speed
std::atomic< bool > m_running
std::atomic< int > m_current_angle
void steeringUpdated(int newAngle)
CarDirection m_currentDirection
void set_speed(int speed)
Sets the speed of the car.
void start()
Starts the engine.
~EngineController()
Destructor for the EngineController class.
void set_steering(int angle)
Sets the steering angle of the car.
void directionUpdated(CarDirection newDirection)
Interface for the peripheral controller.