update button handling
This commit is contained in:
		
							parent
							
								
									51a5e6fc28
								
							
						
					
					
						commit
						b631a44abb
					
				
					 6 changed files with 133 additions and 52 deletions
				
			
		
							
								
								
									
										18
									
								
								stepper.h
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								stepper.h
									
										
									
									
									
								
							|  | @ -11,14 +11,15 @@ private: | |||
|     const uint8_t _pinC; | ||||
| 	const uint8_t _pinD; | ||||
|      | ||||
|     static constexpr uint8_t acceleration = 5; | ||||
| 	static constexpr uint8_t speedFloor = 50; | ||||
|     static constexpr uint8_t acceleration = 1; | ||||
| 	static constexpr uint16_t speedFloor = 0xEF00; | ||||
| 	 | ||||
| 	bool endlessMove = false; | ||||
| 	bool endlessDriection = true; | ||||
|      | ||||
|     bool endlessDriection = true; | ||||
| 	bool halfCurrent = false; | ||||
| 	 | ||||
|     uint16_t _speed = speedFloor; | ||||
|     uint8_t _targetSpeed = 220; | ||||
|     uint16_t _targetSpeed = 220; | ||||
| 	uint8_t _stepInterval = 0; | ||||
|      | ||||
|     uint16_t _tickCounter = 0; | ||||
|  | @ -27,16 +28,19 @@ private: | |||
|     int32_t _targetStep = 0; | ||||
|      | ||||
|     void step(bool direction); | ||||
| 	void setOutputs(); | ||||
| 	void disableOutputs(); | ||||
| 	 | ||||
|      | ||||
| public: | ||||
|      | ||||
|     Stepper( volatile uint8_t * const port, const uint8_t pinA, const uint8_t pinB, const uint8_t pinC, const uint8_t pinD): _port(port), _pinA(pinA), _pinB(pinB), _pinC(pinC), _pinD(pinD){} | ||||
|     void tick(); | ||||
|     void moveTo(const int32_t step); | ||||
|     void moveRelative(const int16_t dist); | ||||
|     void setSpeed(const uint8_t speed); | ||||
|     void setSpeed(const uint16_t speed); | ||||
|     uint32_t isAt(); | ||||
| 	void setHalfCurrent(bool current); | ||||
|     bool isStoped(); | ||||
| 	void setEndlesMove(bool endless, bool direction = true); | ||||
| 	void shutdown(); | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue