Telescope Control Library

Dependents:   PushToGo-F429

Revision:
0:6cb2eaf8b133
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StepOut.h	Sun Aug 19 05:21:20 2018 +0000
@@ -0,0 +1,53 @@
+/*
+ * ControllablePWMOut.h
+ *
+ *  Created on: 2018Äê2ÔÂ9ÈÕ
+ *      Author: caoyuan9642
+ */
+
+#ifndef TELESCOPE_STEPOUT_H_
+#define TELESCOPE_STEPOUT_H_
+
+#include "mbed.h"
+
+class StepOut: protected PwmOut
+{
+public:
+
+	StepOut(PinName pin) :
+			PwmOut(pin), stepCount(0), freq(1), status(IDLE)
+	{
+		// Stop the output
+		this->period(1);
+		this->write(0);
+		tim.start();
+	}
+	virtual ~StepOut()
+	{
+		// Stop the PWM Output
+		this->write(0);
+	}
+
+	void start();
+	void stop();
+
+	double setFrequency(double frequency);
+	void resetCount();
+	int64_t getCount();
+
+private:
+	typedef enum
+	{
+		IDLE = 0, STEPPING
+	} stepstatus_t;
+
+	int64_t stepCount;
+	double freq;
+	stepstatus_t status;
+	Timer tim;
+
+};
+
+#endif /* TELESCOPE_STEPOUT_H_ */
+
+