MakerToolbox
The MakerToolbox module provides a collection of tools for working with various electronic hardware. The goal of this module is to simplify setting up and interfacing with hardware while developing maker projects.
Imports
from MakerToolbox import *
GPIO Interfaces
The following classes can be used to interface with GPIO. Each class manages the logic for setting up GPIO depending on the hardware it represents.
RPi4 - Raspberry Pi Model 4 (B)
The RPi4 class provides a simple interface for configuring GPIO inputs and outputs for a Raspberry Pi 4 board.
class RPi4:
@staticmethod def output_pin(pin: int) -> OutputPin
@staticmethod def input_pin(pin: int) -> InputPin
@staticmethod def pwm_pin(pin: int, frequency: int) -> PWMPin
@staticmethod def cleanup()
RPi3 - Raspberry Pi Model 3 (A/B/B+)
The RPi3 class provides a simple interface for configuring GPIO inputs and outputs for a Raspberry Pi 3 board.
class RPi3:
@staticmethod def output_pin(pin: int) -> OutputPin
@staticmethod def input_pin(pin: int) -> InputPin
@staticmethod def pwm_pin(pin: int, frequency: int) -> PWMPin
@staticmethod def cleanup()
Hardware
The following classes provide interfaces for controlling various pieces of hardware.
BasicStepperDriver
The BasicStepperDriver provides a simple interface for controlling a stepper motor using only a stp and dir pin.
class BasicStepperDriver:
def __init__(self, stp_pin: OutputPin, dir_pin: OutputPin)
def step(self, delay: float)
def set_direction(self, value: bool)
def get_direction(self) -> bool:
ULN2003
The ULN2003 class provides a simple interface for controlling a ULN2003 stepper motor driver.
class ULN2003:
def __init__(self, in1: OutputPin, in2: OutputPin, in3: OutputPin, in4: OutputPin, default_delay: float = 0.003)
def step(self, delay: float)
def set_direction(self, value: bool)
def get_direction(self) -> bool:
DCMotorDriver
The DCMotorDriver class provides a simple interface for controlling a DC motor using a motor driver module.
class DCMotorDriver:
def __init__(self, pwm: PWMPin, dir_a: OutputPin, dir_b: OutputPin, initial_speed: float = 0.5)
def set_speed(self, speed: float)
def stop(self)
Machines
The following classes represent 'machines' (collections of hardware) and provide methods for controlling them. Hardware
CoreXY
The CoreXY class provides a high-level interface for controlling a CoreXY motion system. See: https://en.wikipedia.org/wiki/CoreXY
class CoreXY:
def __init__(self, stepper_a: BasicStepperDriver, stepper_b: BasicStepperDriver)
def step_together(self, steps: int, delay_func: callable = None)
@staticmethod def step_single(stepper: BasicStepperDriver, steps: int, delay_func: callable = None)
def north(self, steps: int, delay_func: callable = None)
def south(self, steps: int, delay_func: callable = None)
def east(self, steps: int, delay_func: callable = None)
def west(self, steps: int, delay_func: callable = None)
def north_west(self, steps: int, delay_func: callable = None)
def north_east(self, steps: int, delay_func: callable = None)
def south_west(self, steps: int, delay_func: callable = None)
def south_east(self, steps: int, delay_func: callable = None)
Utility
The following classes provide generic utility.
XYPosition
The XYPosition class defines a coordinate in space. Modeled as a vector.
class XYPosition:
def __init__(self, x: int, y: int)
Algorithms
The following are implementations of different algorithms.
Paths
compute_discrete_xy_path_differentials
Computes a discrete path between two positions relative to the start position.
compute_discrete_xy_path_differentials(start: XYPosition, end: XYPosition) -> List[XYPosition]
Examples
from MakerToolbox import BasicStepperDriver, RPi4
# Move a stepper motor one direction and then the opposite direction.
stepper: BasicStepperDriver = BasicStepperDriver(RPi4.output_pin(1), RPi4.output_pin(2))
stepper.set_direction(True)
for _ in range(200):
stepper.step()
stepper.set_direction(False)
for _ in range(200):
stepper.step()
Metadata
Release files for MakerToolbox 0.0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| makertoolbox-0.0.19.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| makertoolbox-0.0.19-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.1 kB
Release files / makertoolbox-0.0.19.tar.gz
| Download URL | makertoolbox-0.0.19.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47cebf26b102b8f835b7ed8d32f0a8c5a633fa5d259b14d45a6d78930cd064ef
|
|
BLAKE2b-256 checksum How to use checksums |
f0d90a2e59a7266d38ee9a0d33e1c99dc67e178b49f04616d9c5c82096a22c81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|
Release files / makertoolbox-0.0.19-py3-none-any.whl
| Download URL | makertoolbox-0.0.19-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f68b7be4062dad83a934c80757754b3cb9a7b7047136d8504b5048409cd1c0ba
|
|
BLAKE2b-256 checksum How to use checksums |
3518f5cb18512201f5abc18b72bd186b65920d287fc4c705bc7aaac62615db23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|