2#ifndef CHASSIS_MOTOR_H_
3#define CHASSIS_MOTOR_H_
14struct Motor : mbed::NonCopyable<Motor> {
18 Motor(
const PinName pinA,
const PinName pinB) : outA_{pinA}, outB_{pinB} {
26 void set_pwm(
const float power) {
36 printf(
"%d\t%d\t",
int(pwm_[0] * 100),
int(pwm_[1] * 100));
42 float operator=(
const float val) {
64 Motor(
const int pinA,
const int pinB) : pin_{pinA, pinB} {
65 pinMode(pinA, OUTPUT);
66 pinMode(pinB, OUTPUT);
68 Motor(
const Motor&) =
delete;
69 Motor(Motor&&) =
delete;
72 void set_pwm(
const int power) {
73 pwm_[0] = power > 0 ? power : 0;
74 pwm_[1] = power > 0 ? 0 : -power;
78 analogWrite(pin_[0], pwm_[0]);
79 analogWrite(pin_[1], pwm_[1]);
83 Serial.print(pwm_[0]);
85 Serial.print(pwm_[1]);
91 int operator=(
const int val) {