From d963802d5b7a9bf47be56bfd24ed7112a0d5301b Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Wed, 8 Nov 2023 22:03:24 +0000 Subject: [PATCH] Restructured lib directory --- examples/modules/dual_motor/single_stepper.py | 2 +- firmware/PIMORONI_YUKON/uf2-manifest.txt | 3 +-- .../{extras/player.py => devices/audio.py} | 0 .../lx_servos.py => devices/lx_servo.py} | 21 ++++++++++++------- .../{extras => devices}/stepper.py | 0 lib/pimoroni_yukon/modules/audio_amp.py | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) rename lib/pimoroni_yukon/{extras/player.py => devices/audio.py} (100%) rename lib/pimoroni_yukon/{protocols/lx_servos.py => devices/lx_servo.py} (99%) rename lib/pimoroni_yukon/{extras => devices}/stepper.py (100%) diff --git a/examples/modules/dual_motor/single_stepper.py b/examples/modules/dual_motor/single_stepper.py index d1e5e15..aa02331 100644 --- a/examples/modules/dual_motor/single_stepper.py +++ b/examples/modules/dual_motor/single_stepper.py @@ -1,7 +1,7 @@ from pimoroni_yukon import Yukon from pimoroni_yukon import SLOT1 as SLOT from pimoroni_yukon.modules import DualMotorModule -from pimoroni_yukon.extras.stepper import OkayStepper +from pimoroni_yukon.devices.stepper import OkayStepper """ Drive a stepper motor from a Dual Motor Module connected to Slot1. diff --git a/firmware/PIMORONI_YUKON/uf2-manifest.txt b/firmware/PIMORONI_YUKON/uf2-manifest.txt index 0091892..36ca348 100644 --- a/firmware/PIMORONI_YUKON/uf2-manifest.txt +++ b/firmware/PIMORONI_YUKON/uf2-manifest.txt @@ -1,6 +1,5 @@ ../*.py ../lib/*.py ../lib/pimoroni_yukon/*.py -../lib/pimoroni_yukon/extras/*.py +../lib/pimoroni_yukon/devices/*.py ../lib/pimoroni_yukon/modules/*.py -../lib/pimoroni_yukon/protocols/*.py \ No newline at end of file diff --git a/lib/pimoroni_yukon/extras/player.py b/lib/pimoroni_yukon/devices/audio.py similarity index 100% rename from lib/pimoroni_yukon/extras/player.py rename to lib/pimoroni_yukon/devices/audio.py diff --git a/lib/pimoroni_yukon/protocols/lx_servos.py b/lib/pimoroni_yukon/devices/lx_servo.py similarity index 99% rename from lib/pimoroni_yukon/protocols/lx_servos.py rename to lib/pimoroni_yukon/devices/lx_servo.py index 7cc3f63..ff2025c 100644 --- a/lib/pimoroni_yukon/protocols/lx_servos.py +++ b/lib/pimoroni_yukon/devices/lx_servo.py @@ -10,6 +10,13 @@ import pimoroni_yukon.logging as logging from ucollections import namedtuple +""" +Classes and functions for controlling LewanSoul/HiWonder +LX servos (tested on LX-16A and LX-224HV) via Yukon's +Serial Bus Servo module. +""" + + Command = namedtuple("Command", ("value", "length")) # LX Servo Protocol @@ -69,7 +76,7 @@ def checksum(buffer): def send(id, uart, duplexer, command, fmt="", *data): # Create a buffer of the correct length buffer = bytearray(FRAME_HEADER_LENGTH + command.length) - + # Populate the buffer with the required header values and command data struct.pack_into("