arduino stuffs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef MOTOR_H
#define MOTOR_H

#include "motor_utils.h"

struct Motor {
  int pin;
  int brake_pin;
  int speed_pin;

  inline void forward(int8_t speed) {
    motor_utils::set(pin, brake_pin, speed_pin, HIGH, speed);
  }
  inline void backward(int8_t speed) {
    motor_utils::set(pin, brake_pin, speed_pin, LOW, speed);
  }
  inline void brake() { motor_utils::brake(brake_pin, speed_pin); }

  inline void begin() {
    pinMode(pin, OUTPUT);
    pinMode(brake_pin, OUTPUT);
  }

  Motor(const uint8_t _pin, const uint8_t _brake_pin,
        const uint8_t _speed_pin) {
    pin = _pin;
    brake_pin = _brake_pin;
    speed_pin = _speed_pin;
  }
};
#endif