-
Notifications
You must be signed in to change notification settings - Fork 14
Add property access for setting waveform and slot. #9
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
Comments
yeah that would be more elegant! |
I will do this. |
Awesome. Looks like you're up for #8 also. Please do these as separate PR's. |
Should the |
We may end up removing it or making it "private". But for now, just add what's needed for the new interface. And looking at this again, maybe we just want to do: drv[slot] = effect |
i like drv[slot] = effect, myself. its elegant and easy to understand. |
I'd suggest doing |
OK, I've made branches for the two proposed solutions. The first implements I don't have the DRV2605L board (...yet. I plan to buy one tonight), so I haven't fully tested my changes. |
@caternuson That is what I'm referring to. My point is that not all entries are waveforms, some are pauses. I'm picturing something like: drv.sequence[0] = Effect(1)
drv.sequence[1] = Pause(0.4)
drv.sequence[2] = Effect(10) I'm not exactly sure what @process1183 I don't think your sequence_property code will allow for waits in the current way its written. |
@tannewt I was thinking of something similar. Since it's just a matter of setting the 7th bit, it could be done with: # to set slot 0 to effect 1
drv.sequence[0] = 1
# to set slot 1 to a wait 0.4 secs (actual delay = 10ms * bits[6:0])
drv.sequence[1] = 0x80 | int(0.4 * 100) So your def Pause(secs):
if not 0 <= secs <= 1.27:
raise ValueError("Out of range.")
return 0x80 | int(secs *100) Guess |
@tannewt you're right, my sequence_property code won't allow pauses currently. Out of curiosity, I looked at the current I like the idea of @tannewt, @caternuson, and @ladyada: Are you good on moving forward with the |
I'm fine with deferring adding pauses to another PR and going with @process1183 's sequence_property branch. |
I'm ok doing a follow up PR to support pauses but don't want it to be released as is. Otherwise, people will write code to an API that is going to change. |
I think the future change could be done without breaking if we just don't do anything special for setting an effect. So now and in the future it would be |
What I was thinking was a separate Issue/PR for adding pause support to the existing |
@process1183 I'd rather go straight to the property. I'd deprecate set_waveform in favor of it. Anyone know if there are good names for the effects? It'd be neat to name them if not. |
They have names (see table in datasheet). But not what I would call good names in terms of being easy to remember and use - "Transition Ramp Down Long Sharp 2 - 50% to 0%", for example. |
Ah! Maybe having a separate module to define those would be helpful or at least a link in the docs. Building those names in will take a lot of memory. |
It's linked in the Learn Guide. You're saying also add to RTD docs? Can the separate module (or whatever waveform names helper mechanism) be deferred to another PR? @process1183 Do you want to go ahead and update your PR as you were suggesting here? This sounds like how we want to go with this.
|
@caternuson sure! I'll get that updated and open a PR soon. |
@process1183 no need for a new PR. Just push to the branch for this one and let us know it needs another look. Thanks! @caternuson Yeah, we can wait on the helper names. It just makes it more readable. |
Hi @tannewt, @caternuson, and @ladyada! I've added the Pause and Effect classes and changed the sequence property slots so they only accept one of them ( https://github.com/process1183/Adafruit_CircuitPython_DRV2605/commit/87e03c561ff5fc55558d7f8725e6959c1bf0c982 ). The new behavior works as expected using a Feather M0 Express (CircuitPython 3.0.2) and the Adafruit DRV2605L Haptic Motor Controller + Vibrating Mini Motor Disc. There is one thing left that I don't know how you want to proceed with. In the
Should I add pylint ignores for this, or use a different property name for |
@process1183 looking good. You can add a Can you modify the # to set slot 1 to a wait 0.4 secs
drv.sequence[1] = Pause(0.4) Change the doc strings for the properties to read like variables instead of functions. For example, change this: """Return the pause duration.""" to something like: """The pause duration in seconds.""" You only need to have doc strings for the |
@caternuson, thanks for the feedback! Having the |
@caternuson, The Pause class now uses seconds, the docstrings have been adjusted, and Pylint will ignore the |
@process1183 Cloned your latest and played around with it. I'd say it's time to PR! Specifically, from the thanks! |
PR opened: #11 |
And merged! Thanks for the updated. |
Existing approach uses a setter function:
Change or add a property style access for this. Maybe array access for slot?
The text was updated successfully, but these errors were encountered: