Replies: 6 comments 3 replies
-
I put a #define USE_NO_SERVO_LIB in my main sketch, and changed line 92 in ServoEasing.h from: This stops the #include <Esp32Servo.h>, and it is working ok. Should I propose a pull request, or is there a more elegant solution? Thanks |
Beta Was this translation helpful? Give feedback.
-
My own. It adapts the code for M5STack's 8Servo peripheral, which connects
via I2C and has an internal STM32F030 driving 8 channels of servos (can
also do i/o, analog, rbg). The code in question is here:
https://github.com/m5stack/M5Unit-8Servo/tree/main/src
David
…On Wed, Aug 28, 2024 at 12:13 AM Armin ***@***.***> wrote:
Which servo class are you using?
—
Reply to this email directly, view it on GitHub
<#95 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDQSXCMHD46LLKIPNMNCLZTV2C5AVCNFSM6AAAAABNHEK6VCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANBXGEZDSMQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hmmm. Let me think about it and get back to you. I could possibly release
it as an Arduino library.
I was thinking of something more general, so you do not need to keep
updating your library. If you have a mechanism to turn off the selection of
libraries, then the user could supply servo library with the same interface
as the <Servo.h> library, and your code can subclass to that. That is how
I am structuring my code, it shares Servo.h and has different
implementation code.
David
…On Wed, Aug 28, 2024 at 12:08 PM Armin ***@***.***> wrote:
I think of including your class into my code and enable it with
USE_M5_STACK_SERVO_EXPANDER.
Or is your code or similar available as a arduino library?
—
Reply to this email directly, view it on GitHub
<#95 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDQSTDDE2SSPQTOLYBYDLZTYN4BAVCNFSM6AAAAABNHEK6VCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANBXHEYDCMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Good idea! |
Beta Was this translation helpful? Give feedback.
-
I cloned your library, and dropped it into my libraries directory.
Recompiling my code gave this:
In file included from
/Users/daveharris/Documents/Arduino/libraries/ServoEasing/src/ServoEasing.h:107,
from
/Users/daveharris/Documents/Arduino/libraries/ServoEasing/src/ServoEasing.hpp:50,
from
/Users/daveharris/Documents/Arduino/Esp32_8ServoUnitWifiGC/Esp32_8ServoUnitWifiGC.ino:22:
/Users/daveharris/Documents/Arduino/libraries/ServoEasing/src/DummyServo.h:39:7:
error: redefinition of 'class Servo'
39 | class Servo
| ^~~~~
In file included from
/Users/daveharris/Documents/Arduino/Esp32_8ServoUnitWifiGC/Esp32_8ServoUnitWifiGC.ino:21:
/Users/daveharris/Documents/Arduino/Esp32_8ServoUnitWifiGC/servo.h:27:7:
note: previous definition of 'class Servo'
27 | class Servo {
I changed it to not include any .h:
#if !defined(USE_PCA9685_SERVO_EXPANDER) || defined(USE_SERVO_LIB)
# if defined(USE_USER_PROVIDED_SERVO_LIB)
/*
* Change the #include <DummyServo.h> to the name of your servo library
include file below.
* This library must be like Servo.h, i.e. it must define a class "Servo"
and implement: attach(pin, min, max), detach() and writeMicroseconds(value).
* As example see DummyServo.h, ESP32Servo.h and Servo_megaTinyCore.h
*/
//#include <DummyServo.h>
And now I just have a Servo.h in my files, and an #include "servo.h" in my
main routine:
#include <Wire.h>
#include <ESP32Servo.h>
#include "servo.h"
#include <ServoEasing.hpp> // great library for getting slow servo action,
including bounces
David
…On Wed, Aug 28, 2024 at 2:45 PM Armin ***@***.***> wrote:
Good idea!
I commited a new version, with a new macro USE_USER_PROVIDED_SERVO_LIB and
a new example DummyServoExample.
Can you test it and give feedback?
Thanks
Armin
—
Reply to this email directly, view it on GitHub
<#95 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDQSUCZQSNT3DMNZ3EZLTZTZAJPAVCNFSM6AAAAABNHEK6VCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANBYGAYTONY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
You should comment out the reference #include <DummyServo>
Then the user can define their own Servo class (similar to DummyServo.h),
and then their sketch looks like:
#define USE_USER_PROVIDED_SERVO_LIB
#include "MyServo.h" // definition of the user's own Servo class definition
#include <ServoEasing.h>
...
That way they do not need to modify your library code, and can upgrade the
library with no changes.
David
…On Thu, Aug 29, 2024 at 5:35 AM Armin ***@***.***> wrote:
Closed #95 <#95> as
resolved.
—
Reply to this email directly, view it on GitHub
<#95>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDQSSOSM3FEUJ35B6DNLTZT4IQ3AVCNFSM6AAAAABNHEK6VCVHI2DSMVQWIX3LMV45UABFIRUXGY3VONZWS33OIV3GK3TUHI5E433UNFTGSY3BORUW63R3GE2DONBTGU3A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Hi --
I want to use servoEasing with an I2C peripheral from M5Stack: https://shop.m5stack.com/products/8-channel-servo-driver-unit-stm32f030
I am using an ESP32 (a M5Stack Atom), so the library is trying to use <ESPServo.h>. I cannot figure out an easy way to stop this, so that I can include my own Servo class.
One method would be to allow a "NO_SERVO_CLASS" that would not include a Servo library at all, and I could include one.
Any clever ideas on how to do this without modifying the library?
Thanks
David
Beta Was this translation helpful? Give feedback.
All reactions