Skip to content

Add support for Teensy PWMServo.h#20

Open
natekfl wants to merge 2 commits intoEvanBottango:mainfrom
natekfl:main
Open

Add support for Teensy PWMServo.h#20
natekfl wants to merge 2 commits intoEvanBottango:mainfrom
natekfl:main

Conversation

@natekfl
Copy link
Copy Markdown

@natekfl natekfl commented Aug 30, 2025

No description provided.

Copy link
Copy Markdown
Owner

@EvanBottango EvanBottango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea on license of pwm servo? Also see comments on the us to deg conversion

#ifdef ESP32
#include <ESP32Servo.h>
#elif defined(CORE_TEENSY)
#include <PWMServo.h>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure out the license on this library? It doesn't have a license file at https://github.com/PaulStoffregen/PWMServo

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its LGPL. Look at the comment header in the PWMServo.h file.

if (currentSignal != targetSignal)
{
#ifdef CORE_TEENSY
servo.write(180 * (targetSignal - 544) / 1856);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things give me misgivings here:

  1. 544 and 1856 are pretty magic number-y? Maybe a define?

  2. I get what you're doing with the lerp to convert us to angle. But I'm sad that this is 10x less resolution in us pulse length than directly writing us. Especially since this will just eventually go back to us pulse length on the backend. I guess this is more of a critique of the library than you, but it makes me have reservation of suggesting it as the default. By my math with the defaults here, 1 deg == about 10us.

A possible mitigation would be to scale the values at attach and then resultantly the lerp as well?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind to scaling, realized that was a dumb idea 2 mins later. I'm not sure there's a way to get back the lost resolution when the only call is to write between 0 and 180 deg.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it's frustrating that PWMTeensy doesn't have a writeMicroseconds call available. Should this be something that requires the user to change BottangoArduinoConfig.h, rather than a default for the teensy family of devices?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay, ya this should be an option to enable (off by default) in the config file, rather than just on.

Also, looks like "TEENSYDUINO" is the more appropriate guard than CORE_TEENSY?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll work on moving it to a configurable option!

As for the guards, CORE_TEENSY is the more common one used within Teensy internal libraries. The difference is TEENSYDUINO is provided from compiler flags, and CORE_TEENSY is provided from Arduino.h. But in the context of the Bottango driver, either would work.

@natekfl
Copy link
Copy Markdown
Author

natekfl commented Jan 12, 2026

Dang, I really did just forget about this PR, huh? That's my bad and I apologize. I have added the guard to BottangoArduinoConfig.h like we talked about :)

@natekfl natekfl requested a review from EvanBottango February 17, 2026 04:29
@natekfl
Copy link
Copy Markdown
Author

natekfl commented Feb 22, 2026

@EvanBottango any update on this?

@EvanBottango
Copy link
Copy Markdown
Owner

@natekfl Hi, sorry for the slowness here. I am still working on a major update and have been for a while, and will work to merge these changes into that branch once it's close to done. I'll also take a look at your changes asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants