#pragma once

#include <Arduino.h>
#include <vector>
//#include "ESP32MotorControl.h"
#include "Cdrv8833.h"

#include <ESP32Servo.h> //by Kevin Harrington

#include "config.h"

#define RIGHT_MOTOR 1
#define LEFT_MOTOR 0
#define ARM_MOTOR 2


#define SERVOSTEP 10
#define SERVOMIN  50
#define SERVOMAX 180

#define BUCKETTIMER 10

struct MOTOR_PINS
{
  int pinIN1;
  int pinIN2;    
};

//general functions
void setupmotors();
void loop_motors();

void drivemotor(uint8_t num, int dirspeed);


//Servo functions
void bucketTilt(int bucketServoValue);
void auxControl(int auxServoValue);
void AbsBucketTilt(int bucketServoValue);



class motor: public Cdrv8833
{
  const uint8_t motorindex = 0;

  public:
  
  uint8_t m_index;
  int prevsetpoint = 0;

  

  void drive(int dirspeed);
  void setindex(uint8_t index)
  {
    m_index = index;
  }
};