Skip to content
Snippets Groups Projects
Commit b4bbb33e authored by jhierck laptop's avatar jhierck laptop
Browse files

Added some variables to add clarity

parent 747299f0
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ print(GPIO.VERSION)
class Encoder:
PULSES_PER_ROTATION = 40 # How many edges you would detect in a full rotation
WHEEL_DIAMETER = 6 # TODO: Move this into another file which holds constants like this
def __init__(self, name, encoder_pin: int):
"""Initialize some stuff"""
self.name = name
......@@ -50,7 +53,7 @@ class Encoder:
def get_speed(self) -> float:
"""Convert pulse speed to cm/s"""
pulse_per_second = self.get_current_pulse_speed()
return pulse_per_second * (6 * 2 * math.pi) / 40
return pulse_per_second * (self.WHEEL_DIAMETER * 2 * math.pi) / self.PULSES_PER_ROTATION
def init_callback(self):
"""Initialize the interrupt"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment