Skip to main content

This library provides a set of slowdowns for my servo packages.

Project description

This is an automatic translation, may be incorrect in some places.

Smooth Servo Library

This library is a collection of deceleration options for my servo libraries. Since this functionality is not mandatory, I decided to move it to a separate library.

Library features:

  • Allows you to create iterators based on: value, time, regrettable slowdown.

Materials used to create the library:

Compatibility

  • MicroPython 1.19.1
  • Raspberry Pi Pico

On the hardware above the library has been tested and works correctly.

ATTENTION

You use this module at your own risk. I am new to MicroPython programming. So there may be nuances that I did not take into account. If you notice an error or have suggestions for improvement, please write to Issues.

Contents

Installation

  • Install the library via pip (Thonny -> Manage Packages) by name smooth-servo
  • Or manual installation:
    • Download library from GitHub
    • take the smooth_servo folder from the archive.
    • upload to the root of the microcontroller or to the lib folder.

Usage

This library is primarily designed to be used with my servo libraries. But you can also use it in other projects like this:

from smooth_servo import SmoothLinear

# Set parameters
value = 100  # End value the iterator should reach
time_ms = 1000  # Time in milliseconds to reach end value
start_value = 0  # Start value
tick_time_ms = 50  # Time between iterations (used to calculate the number of steps)

# Create an instance of the iterator class
linear = SmoothLinear(value, time_ms, start_value)

# create an iterator with a given time between iterations
iterator = linear.generate(tick_time_ms)

# Use an iterator
for i in iterator:
    print(i)

Documentation

Constructor parameters

Parameter type default description
value int None End value
time_ms int None The time in milliseconds it takes to reach the final value
start_value int 0 Initial value
  • value - cannot be equal to or less than 0.
  • time_ms - cannot be equal to or less than 0.
  • start_value - cannot be greater than value.

Iterator classes

Class Easing type Description
ServoSmoothBase None Base class for iterators
SmoothLinear Linear Linear dependence of value on time.
SmoothEaseIn EaseIn Example
SmoothEaseOut EaseOut Example
SmoothEaseInOut EaseInOut Example
SmoothEaseInQuad EaseInQuad Example
SmoothEaseOutQuad EaseOutQuad Example
SmoothEaseInOutQuad EaseInOutQuad Example
SmoothEaseInCubic EaseInCubic Example
SmoothEaseOutCubic EaseOutCubic Example
SmoothEaseInOutCubic EaseInOutCubic Example
SmoothEaseInQuart EaseInQuart Example
SmoothEaseOutQuart EaseOutQuart Example
SmoothEaseInOutQuart EaseInOutQuart Example
SmoothEaseInQuint EaseInQuint Example
SmoothEaseOutQuint EaseOutQuint Example
SmoothEaseInOutQuint EaseInOutQuint Example
SmoothEaseInExpo EaseInExpo Example
SmoothEaseOutExpo EaseOutExpo Example
SmoothEaseInOutExpo EaseInOutExpo Example
SmoothEaseInCirc EaseInCirc Example
SmoothEaseOutCirc EaseOutCirc Example
SmoothEaseInOutCirc EaseInOutCirc Example
SmoothEaseInBack EaseInBack Example
SmoothEaseOutBack EaseOutBack Example
SmoothEaseInOutBack EaseInOutBack Example

Bugs and feedback

Create an issue when you find bugs. The library is open for revision and your pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smooth_servo-0.0.2.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page