Skip to content

Commit

Permalink
add annotations to motor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccand committed May 2, 2024
1 parent c9b1d04 commit af79389
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions docs/source/nanonav.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,33 +143,33 @@ def enc_pin_high(self, pin):
def calc_duty(self, duty_100):
return int(duty_100 * self.max_duty / 100)

def m1_forward(self, duty_cycle):
self.m1pwm1.duty_u16(min(self.calc_duty(duty_cycle), self.saturated_duty))
self.m1pwm2.duty_u16(0)

def m2_backward(self, duty_cycle):
self.m1pwm1.duty_u16(0)
self.m1pwm2.duty_u16(min(self.calc_duty(duty_cycle), self.saturated_duty))

def m1_signed(self, duty_cycle):
if duty_cycle >= 0:
self.m1_forward(duty_cycle)
else:
self.m2_backward(-duty_cycle)

def m2_forward(self, duty_cycle):
self.m2pwm1.duty_u16(min(self.calc_duty(duty_cycle), self.saturated_duty))
self.m2pwm2.duty_u16(0)

def m2_backward(self, duty_cycle):
self.m2pwm1.duty_u16(0)
self.m2pwm2.duty_u16(min(self.calc_duty(duty_cycle), self.saturated_duty))

def m2_signed(self, duty_cycle):
if duty_cycle >= 0:
self.m2_forward(duty_cycle)
else:
self.m2_backward(-duty_cycle)
def m1_forward(self, speed):
"""
Set Motor 1 to turn forward at speed.
:param speed: The speed to turn Motor 1 forward at. This is a percentage of max speed from 0-100.
"""
pass

def m2_backward(self, speed):
"""
Set Motor 1 to turn backward at speed.
:param speed: The speed to turn Motor 1 backward at. This is a percentage of max speed from 0-100.
"""
pass

def m2_forward(self, speed):
"""
Set Motor 2 to turn forward at speed.
:param speed: The speed to turn Motor 2 forward at. This is a percentage of max speed from 0-100.
"""
pass

def m2_backward(self, speed):
"""
Set Motor 2 to turn backward at speed.
:param speed: The speed to turn Motor 2 backward at. This is a percentage of max speed from 0-100.
"""
pass

def stop(self):
"""
Expand All @@ -187,4 +187,4 @@ def ir_right(self):
"""
Return true if the right IR sensor detects white.
"""
pass
pass

0 comments on commit af79389

Please sign in to comment.