Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the Encoder CPR overridable #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inventorhatmini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class InventorHATMini():

SHUNT_RESISTOR = 0.47

def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, init_motors=True, init_servos=True, init_leds=True, start_muted=False):
def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, encoder_cpr=MMME_CPR, init_motors=True, init_servos=True, init_leds=True, start_muted=False):
""" Initialise inventor hat mini's hardware functions
"""
self.address = address
Expand All @@ -101,7 +101,7 @@ def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, init_motors=True, i
# Setup amplifier enable. This mutes the audio by default
GPIO.setup(self.PI_AMP_EN_PIN, GPIO.OUT, initial=GPIO.LOW if start_muted else GPIO.HIGH)

self.__cpr = MMME_CPR * motor_gear_ratio
self.__cpr = motor_gear_ratio * encoder_cpr
self.__init_motors = init_motors
self.__init_servos = init_servos
self.reinit()
Expand Down