//
#include "Define.h"
//
#ifndef StepperDRV8825_h
#define StepperDRV8825_h
//
enum EStepDirection
{
    sdNegative  = 0,
    sdPositive  = 1
};
//
enum EStepResolution
{
    srFull      = 0,
    srHalf      = 1,
    srQuarter   = 2,
    srEight     = 3,
    srSixteen   = 4,
    srThirtyTwo = 5
};
//
enum EStateStep
{
    ssIdle = 0,
    ssStepHigh = 1,
    ssStepLow = 2
};
//
class CStepperDRV8825
{
    private:
    EStateStep FStateStep;
    int FPinStep, FPinDirection;
    int FPinM0, FPinM1, FPinM2;
    int FPinEnableN;
    bool FOpened;
    long unsigned FMicrosPeriod;
    long unsigned FMicrosPreset;
    long unsigned FStepCount; // only positive!
    long int FDistance; // positive and negative!
    //
    public:
    CStepperDRV8825(int pinstep, int pindirection,
                    int pinm0, int pinm1, int pinm2,
                    int pinenablen);
    //
    EStateStep GetStateStep(void) { return FStateStep; }
    void SetStateStep(EStateStep statestep);
    void SetStepDirection(EStepDirection stepdirection);
    EStepDirection GetStepDirection(void);
    void SetStepResolution(EStepResolution stepresolution);
    EStepResolution GetStepResolution(void);
    void SetDistance(long int preset) { FDistance = preset; }
    long int GetDistance(void) { return FDistance; }
    bool IsOpened(void) { return FOpened; }
    void Enable(void);
    void Disable(void);
    void SetStepLow(void);
    void SetStepHigh(void);
    //
    bool Open(void);
    bool Close(void);
    bool Move(EStepDirection stepdirection,
               EStepResolution stepresolution,
               long unsigned stepperiod,
               long unsigned stepcount);
    bool Halt(void);
    //
    void Execute(void);
};
//
#endif // StepperDRV8825_h
//
