-
Notifications
You must be signed in to change notification settings - Fork 14
Add functionality to set the Real-Time Playback value #34
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
Conversation
Hello :) first, thank you for the add!!. Hopefully, I would be able to test over the weekend. However, in the meantime, just one comment. As you would need to put the device in RTP mode before using this function, I think it would be a good idea to document it either in the documentation and/or with an example, maybe something equivalent to this? Adafruit_CircuitPython_DRV2605/adafruit_drv2605.py Lines 201 to 209 in 2200f21
Also, it would be good to create it as a property, so users could do something like real_time_value = xxxxx Let me know thanks :) |
Thanks for the input. Both are good suggestions. I reworked the PR accordingly. One change that may need explanation is allowing input values from -127 to 255. I did so since:
Oddness occurs if the user READS a value outside 0-127 since the register is always read as unsigned. Without complicating the reading routine by also reading and checking the |
Thanks for the changes. I agree with you, it is indeed difficult to take into account all the corner cases, I think we are covering the default behaviour, verifying the value. and the note do a good job both explaining and refering to the datasheet for more information. will test probably probably later, just want to test the change on hardware :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks 👍🏼
Test
tested with Adafruit CircuitPython 8.0.2 on 2023-02-14; Adafruit Feather RP2040 with rp2040
and the following test script
import time
import board
import adafruit_drv2605
# Initialize I2C bus and DRV2605 module.
i2c = board.I2C()
drv = adafruit_drv2605.DRV2605(i2c)
print("Start real-time playback")
print("Mode value before:", drv.mode)
print("real time value before:", drv.realtime_value)
drv.realtime_value = 0
print("real time value after:", drv.realtime_value)
drv.mode = adafruit_drv2605.MODE_REALTIME
print("Mode value after:", drv.mode)
print("Buzz the motor briefly at 50% and 100% amplitude")
print("real time value before:", drv.realtime_value)
drv.realtime_value = 64
print("real time value after:", drv.realtime_value)
time.sleep(0.5)
print("real time value before:", drv.realtime_value)
drv.realtime_value = 127
print("real time value after:", drv.realtime_value)
time.sleep(0.5)
print("Stop real-time playback")
drv.realtime_value = 0
print("Mode value before:", drv.mode)
drv.mode = adafruit_drv2605.MODE_INTTRIG
print("Mode value after:", drv.mode)
Results
Start real-time playback
Mode value before: 0
real time value before: 0
real time value after: 0
Mode value after: 5
Buzz the motor briefly at 50% and 100% amplitude
real time value before: 0
real time value after: 64
real time value before: 64
real time value after: 127
Stop real-time playback
Mode value before: 5
Mode value after: 0
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO08X to 1.1.10 from 1.1.9: > Merge pull request adafruit/Adafruit_CircuitPython_BNO08x#39 from xenomorpheus/main > Add upload url to release action > Add .venv to .gitignore Updating https://github.com/adafruit/Adafruit_CircuitPython_DRV2605 to 1.3.0 from 1.2.8: > Merge pull request adafruit/Adafruit_CircuitPython_DRV2605#34 from kriswilk/patch-1 > Add upload url to release action > Add .venv to .gitignore Updating https://github.com/adafruit/Adafruit_CircuitPython_LC709203F to 2.2.11 from 2.2.10: > Merge pull request adafruit/Adafruit_CircuitPython_LC709203F#23 from edanidzerda/main > Add upload url to release action Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 9.0.2 from 9.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_BLE#183 from brentyi/main > Add upload url to release action > Add .venv to .gitignore Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.26.0 from 2.24.0: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#184 from Neradoc/fix-multiple-lines-in-bitmaplabel > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#186 from Neradoc/fix-bitmap-label-anchored-position Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_GFX Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
This PR adds the ability to set the output value in Real-Time Playback mode. A port of this function from the DRV2605(L) Arduino library.
Closes #33