// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved


// This software makes use of tools and libraries obtained from open source projects or released for

// use by relevant hardware manufactures. However, this software is NOT a part of any open source project.

// It is released only on a "need to know" basis for beta testers of the "RiceCNC Interpolation Engine".

// Recipents of this source code must respect the confidential nature of this software and prevent any

// distribution that could result in counterfeit copies of the "RiceCNC Interpolation Engine".


// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved

#ifndef Spindle_h

#define Spindle_h


#include "Energia.h"

class OutputPin;

class PwmOutputPin;

class Machine;


class Spindle {

     Machine*     machine;


     struct {

          uint     spindleOn     : 1;

          uint     spindleCCW     : 1;

          uint     pulseOn          : 1; } flags;

     

     float          setScaledSpeed;

     char          useAxis;

  

     // independent mode

     int32_t               pwmFrequency;    // PWM

     PwmOutputPin*     runPin;

     OutputPin*          directionPin;


     void          setAxisSpeed();


     public:


    Spindle(

          Machine*     myMachine,

          char*          data,

          String*          msgPtr );

    ~Spindle();

  

     uint32_t     onDelayMs;

     uint32_t     offDelayMs;


     bool          isValid();


    void        setSpindleDirection(     bool );

    void        setSpindleOn(               bool );

    void        setSpindleSpeed(          float scaledSpeed );

    bool          counterClockwise();

    bool          running(); };


#endif