Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Spindle.h « Tools « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 69eb30dddef8758a96336eb23032f4b378d3dbb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Spindle.h
 *
 *  Created on: Mar 21, 2018
 *      Author: Christian
 */

#ifndef SPINDLE_H
#define SPINDLE_H

#include <RepRapFirmware.h>
#include <Hardware/IoPorts.h>
#include <ObjectModel/ObjectModel.h>
#include <General/NamedEnum.h>

NamedEnum(SpindleState, uint8_t, unconfigured, stopped, forward, reverse);

class Spindle INHERIT_OBJECT_MODEL
{
private:
	void SetRpm(const uint32_t rpm) noexcept;

	PwmPort pwmPort, onOffPort, reverseNotForwardPort;
	uint32_t currentRpm, configuredRpm, minRpm, maxRpm;
	PwmFrequency frequency;
	SpindleState state;

protected:
	DECLARE_OBJECT_MODEL

public:
	Spindle() noexcept;

	GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException);

	uint32_t GetCurrentRpm() const noexcept { return currentRpm; }
	uint32_t GetMinRpm() const noexcept { return minRpm; }
	uint32_t GetMaxRpm() const noexcept { return maxRpm; }
	uint32_t GetRpm() const noexcept { return configuredRpm; }
	bool IsValidRpm(const uint32_t rpm) const noexcept { return rpm >= minRpm && rpm <= maxRpm; }
	void SetConfiguredRpm(const uint32_t rpm, const bool updateCurrentRpm) noexcept;
	SpindleState GetState() const noexcept { return state; }
	void SetState(const SpindleState newState) noexcept;
};

#endif