Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Driving FFB Servo's through PCA9685 #98

Open
wants to merge 7 commits into
base: proto5
Choose a base branch
from

Conversation

Roastlawyer
Copy link

Allows connecting and driving your FFB servo's through a PCA9685 I2C board instead of needing them directly connected to the ESP/Arduino, allowing you to control all your servo's using only two pins.

I setup the PCA code to follow the input format of the ESP32Servo and Servo.h libraries, allowing the servo commands to be passed to the PCA without changes.

Update Branch to latest Proto 5 Firmware.
@Roastlawyer Roastlawyer marked this pull request as ready for review April 12, 2023 06:06
Copy link
Member

@danwillm danwillm left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a couple of comments.

firmware/lucidgloves-firmware/_main.ino Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/PCA9685Servo.hpp Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/PCA9685Servo.hpp Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/_main.ino Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/AdvancedConfig.h Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/AdvancedConfig.h Outdated Show resolved Hide resolved
Allow Driving FFB Servo's through PCA9685

Allows connecting and driving your FFB servo's through a PCA9685 I2C board instead of needing them directly connected to the ESP/Arduino, allowing you to control all your servo's using only two pins.

I setup the PCA code to follow the input format of the ESP32Servo and Servo.h libraries, allowing the servo commands to be passed to the PCA without changes.

Edit when squashing commits

Cleanup of changes AdvancedConfig.h, & Lucidgloves-firmware.ino

Remove unneeded include of "advancedConfig.h" in _main.ino

Moved PCA9685 related defines in AdvancedConfig.h to only actually be defined if they where going to be accessed. Did the same for I2C in lucidgloves-firmware.ino as it is currently only used for this.

Moves the PCA9685 initialization out of _main.ino and into the preexisting "setupServoHaptics" function in haptics.ino.

This eliminated the need for any changes to _main.ino to implement PCA9685 support
@Roastlawyer Roastlawyer force-pushed the LucidGloves_Proto5_Firmware branch 2 times, most recently from 9c9225a to 85cd6f0 Compare June 5, 2023 11:46
The function itself was moved into its own file for I2C to make it easier if someone else needs I2C support for other hardware in the future.

Currently it's still called in the haptics.ino with the PCA9685 setup code as that is the only thing to use it.
@Roastlawyer Roastlawyer force-pushed the LucidGloves_Proto5_Firmware branch from 85cd6f0 to cfe87da Compare June 5, 2023 11:47
@Roastlawyer
Copy link
Author

Well, I moved the I2C struct into its own file as a normal function. Doing so fixed the compile error by indirectly #including AdvancedConfig.h in haptics.ino (and also wire.h which I had missed before) Either way. It now compiles and from what I can tell fully works again.

Roastlawyer and others added 2 commits June 6, 2023 22:03
Changes servo code to derive from a new abstract IServo class that can be easily expanded on to make addition of future servo library support easier.

+ minor cleanup of extra spaces and lines in I2C.h & PCA9685Servo.ino
Moves the function & method declarations out of PCA9685.hpp and into their own .cpp file.

Code mostly by danwillm.

Co-Authored-By: danwillm <[email protected]>
@Roastlawyer
Copy link
Author

Alright, I think that's everything from your original comments done.

@Roastlawyer Roastlawyer requested a review from danwillm June 7, 2023 08:22
…) class

The previous version of the PCA initialization code was being called before I2C was initialized, was being reran for each of the 5 servo objects, & wasn't acknowledging the configured I2C pins.

This commit redoes it to be run as part of a subfunction within InitServoInterface() just as I2C initialization is.
Recombines PCA9685Servo.cpp & PCA9685Servo.hpp into a single .ino file so that #if statements can be used to prevent PCA code from being compiled & included when not actually using a PCA board.
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