Skip to content

Commit 47b1809

Browse files
authored
Merge pull request #62 from kattni/rotary-update
Update names.
2 parents 5e53ccb + a866571 commit 47b1809

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

adafruit_seesaw/seesaw.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,19 @@ def set_pwm_freq(self, pin, freq):
369369
else:
370370
raise ValueError("Invalid PWM pin")
371371

372-
def get_encoder_pos(self, encoder=0):
373-
"""Read the current position of the encoder"""
372+
def encoder_position(self, encoder=0):
373+
"""The current position of the encoder"""
374374
buf = bytearray(4)
375375
self.read(_ENCODER_BASE, _ENCODER_POSITION + encoder, buf)
376376
return struct.unpack(">i", buf)[0]
377377

378-
def set_encoder_pos(self, pos, encoder=0):
378+
def set_encoder_position(self, pos, encoder=0):
379379
"""Set the current position of the encoder"""
380380
cmd = struct.pack(">i", pos)
381381
self.write(_ENCODER_BASE, _ENCODER_POSITION + encoder, cmd)
382382

383-
def get_encoder_delta(self, encoder=0):
384-
"""Read the change in encoder position since it was last read"""
383+
def encoder_delta(self, encoder=0):
384+
"""The change in encoder position since it was last read"""
385385
buf = bytearray(4)
386386
self.read(_ENCODER_BASE, _ENCODER_DELTA + encoder, buf)
387387
return struct.unpack(">i", buf)[0]

examples/seesaw_rotary_simpletest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
button = DigitalIO(seesaw, 24)
1414
button_held = False
1515

16-
last_pos = seesaw.get_encoder_pos()
16+
last_position = seesaw.encoder_position()
1717

1818
while True:
1919

2020
# read position of the rotary encoder
21-
pos = seesaw.get_encoder_pos()
22-
if pos != last_pos:
23-
last_pos = pos
24-
print(f"Position: {pos}")
21+
position = seesaw.encoder_position()
22+
if position != last_position:
23+
last_position = position
24+
print("Position: {}".format(position))
2525

2626
if not button.value and not button_held:
2727
button_held = True

0 commit comments

Comments
 (0)