The MakerToolbox module provides a collection of tools for working with various electronic hardware.
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file makertoolbox-0.0.19.tar.gz.
File metadata
- Download URL: makertoolbox-0.0.19.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47cebf26b102b8f835b7ed8d32f0a8c5a633fa5d259b14d45a6d78930cd064ef
|
|
| MD5 |
39726127a2b5e51b6f4da416c84ecb51
|
|
| BLAKE2b-256 |
f0d90a2e59a7266d38ee9a0d33e1c99dc67e178b49f04616d9c5c82096a22c81
|
File details
Details for the file makertoolbox-0.0.19-py3-none-any.whl.
File metadata
- Download URL: makertoolbox-0.0.19-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f68b7be4062dad83a934c80757754b3cb9a7b7047136d8504b5048409cd1c0ba
|
|
| MD5 |
a359a527241f13f610960dc540d1092d
|
|
| BLAKE2b-256 |
3518f5cb18512201f5abc18b72bd186b65920d287fc4c705bc7aaac62615db23
|