Skip to content

Commit 9d0fc99

Browse files
committed
Clean up imports and fix flip_dir logic
Move the re import to the module top in XRPLib/encoder.py and remove the redundant local import. In XRPLib/motor.py, replace the expression flip_dir ^ True with the clearer and correct not flip_dir for NanoXRP, ensuring proper boolean inversion and improving readability.
1 parent 1f012ac commit 9d0fc99

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

XRPLib/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import rp2
55
import time
66
from sys import implementation
7+
import re
78

89
class Encoder:
910
if "NanoXRP" in implementation._machine:
@@ -53,7 +54,6 @@ def _get_pin_id(self, pin):
5354
# String representation is usually "Pin(GPIO16, mode=IN)" or "Pin(16)"
5455
# We look for the numeric part associated with the GPIO.
5556
s = str(pin)
56-
import re
5757
match = re.search(r'(\d+)', s)
5858
if match:
5959
return int(match.group(1))

XRPLib/motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DualPWMMotor:
5858
def __init__(self, in1_pwm_forward: int|str, in2_pwm_backward: int|str, flip_dir:bool=False):
5959

6060
if "NanoXRP" in implementation._machine:
61-
self.flip_dir = flip_dir ^ True
61+
self.flip_dir = not flip_dir
6262
else:
6363
self.flip_dir = flip_dir
6464

0 commit comments

Comments
 (0)