#include "./motor.h"
#include "include/config.h"
#include <Arduino.h>


void motorInit()
{
  pinMode(Config::MotorPinSleep, OUTPUT);
  digitalWrite(Config::MotorPinSleep, LOW);

  pinMode(Config::MotorPinPWM, OUTPUT);
  digitalWrite(Config::MotorPinPWM, LOW);

  pinMode(Config::MotorPinDirection, OUTPUT);
  pinMode(Config::MotorPinCurrentSensing, INPUT);
}


void motorStart(MotorDirection direction)
{
  digitalWrite(Config::MotorPinDirection, direction == MotorDirection::Up ? HIGH : LOW);
  digitalWrite(Config::MotorPinSleep, HIGH);
  digitalWrite(Config::MotorPinPWM, HIGH);
}


void motorStop()
{
  digitalWrite(Config::MotorPinPWM, LOW);
  digitalWrite(Config::MotorPinSleep, LOW);
}


bool motorIsOvercurrent()
{
  // TODO: implement motorIsOvercurrent
  return false;
}


