I2CMotor/src/I2CMotor.h

31 lines
694 B
C++

#ifndef I2C_MOTOR_H
#define I2C_MOTOR_H
#include <Arduino.h>
#include <Wire.h>
class I2CMotor {
public:
I2CMotor();
I2CMotor(uint8_t sda = 8, uint8_t scl = 3, uint32_t freq = 100000);
void begin();
bool found();
uint8_t address();
String identify();
void setDeviceName(const char* newname);
void setMinMax(uint8_t min_pwm, uint8_t max_pwm);
void setMotorDirection(uint8_t motor, uint8_t dir);
void setMotorSpeed(uint8_t motor, uint8_t speed_percent);
void emergencyStop();
private:
uint8_t sda_, scl_;
uint32_t freq_;
uint8_t slave_addr_;
uint8_t scanForMotorController();
String queryIdentification(uint8_t addr);
};
#endif