Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
PeripheralController.hpp
Go to the documentation of this file.
1
16
17#ifndef PERIPHERALCONTROLLER_HPP
18#define PERIPHERALCONTROLLER_HPP
19
21#include <QDebug>
22#include <QObject>
23#include <cmath>
24#include <fcntl.h>
25#include <linux/i2c-dev.h>
26#include <sys/ioctl.h>
27#include <unistd.h>
28
34{
35private:
40
41public:
42 PeripheralController(int servo_addr, int motor_addr);
43 ~PeripheralController() override;
44 int i2c_smbus_write_byte_data(int file, uint8_t command, uint8_t value) override;
45 int i2c_smbus_read_byte_data(int file, uint8_t command) override;
46 virtual void write_byte_data(int fd, int reg, int value) override;
47 virtual int read_byte_data(int fd, int reg) override;
48 void set_servo_pwm(int channel, int on_value, int off_value) override;
49 void set_motor_pwm(int channel, int value) override;
50 void init_servo() override;
51 void init_motors() override;
52
53};
54
55#endif // PERIPHERALCONTROLLER_HPP
Definition of the IPeripheralController interface.
Interface for the peripheral controller.
void init_motors() override
Initializes the motor controllers.
void init_servo() override
Initializes the servo controller.
~PeripheralController() override
Destructor for the PeripheralController class.
void set_servo_pwm(int channel, int on_value, int off_value) override
Sets the PWM of a servo motor.
int i2c_smbus_read_byte_data(int file, uint8_t command) override
Reads a byte of data from a specific register.
void set_motor_pwm(int channel, int value) override
Sets the PWM value for a motor.
virtual void write_byte_data(int fd, int reg, int value) override
Writes a byte of data to a specific register.
virtual int read_byte_data(int fd, int reg) override
Reads a byte of data from a specific register.
PeripheralController(int servo_addr, int motor_addr)
Constructor for the PeripheralController class.
int i2c_smbus_write_byte_data(int file, uint8_t command, uint8_t value) override
Writes a byte of data to a specific register.