Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
stepper-inl.hpp
1 /*
2  Title --- motor/stepper-inl.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_MOTOR_STEPPER_INL_HPP_
23 #define _RPI_HW_MOTOR_STEPPER_INL_HPP_
24 
25 namespace rpihw { // Begin main namespace
26 
27 namespace motor { // Begin motors namespace
28 
29 inline void
30 stepper::setSteps( size_t steps ) {
31 
32  // Set the number of steps per revolution
33  m_steps = steps;
34 }
35 
36 inline size_t
38 
39  // Return the number of steps per revolution
40  return m_steps;
41 }
42 
43 inline void
44 stepper::setSpeed( double rpm ) {
45 
46  // Set the motor speed in rotations per minute
47  m_rpm = math::abs( rpm );
48 }
49 
50 inline double
52 
53  // Return the motor speed in rotations per minute
54  return m_rpm;
55 }
56 
57 inline void
59 
60  // Set the motor direction
61  m_direction = direction;
62 }
63 
64 inline Direction
66 
67  // Return the current motor direction
68  return m_direction;
69 }
70 
71 } // End of motors namespace
72 
73 } // End of main namespace
74 
75 #endif /* _RPI_HW_MOTOR_STEPPER_INL_HPP_ */
void setSpeed(double rpm)
Sets the motor speed in rotations per minute (RPMs).
Definition: stepper-inl.hpp:44
void setDirection(Direction direction)
Sets the motor direction.
Definition: stepper-inl.hpp:58
Direction
Directions of the rotation.
Definition: stepper.hpp:45
double m_rpm
Motor speed in rotations per minute (RPMs).
Definition: stepper.hpp:153
size_t getSteps() const
Returns the number of steps per revolution.
Definition: stepper-inl.hpp:37
T abs(T x)
Returns the absolute value of x.
Definition: math.hpp:46
Direction getDirection() const
Returns the current motor direction.
Definition: stepper-inl.hpp:65
size_t m_steps
Number of steps per revolution.
Definition: stepper.hpp:156
double getSpeed() const
Returns the motor speed in rotations per minute (RPMs).
Definition: stepper-inl.hpp:51
Direction m_direction
Motor direction.
Definition: stepper.hpp:150
void setSteps(size_t steps)
Sets the number of steps per revolution.
Definition: stepper-inl.hpp:30