smartknob icon indicating copy to clipboard operation
smartknob copied to clipboard

Haptic effect examples in firmware

Open rubenfrolic opened this issue 2 years ago • 1 comments

Awesome project with an abundance of information! But as we speak there is not much documentation (yet) from a firmware perspective. Going through the code and understanding what's happening is quite a task since there are many functionalities built-in.

I was wondering if it would be possible to include some more basic examples of purely the haptic part. It would be great to have an isolated example of this, so it's relatively easy to play with these effects and a brushless motor, even if you don't have the full smart-knob setup. This would enable more people to spin-off their own projects and different applications.

rubenfrolic avatar Sep 07 '22 09:09 rubenfrolic

That's a great idea. In the meantime, generally speaking, the core haptic feedback code is fairly well contained within motor_task.cpp: https://github.com/scottbez1/smartknob/blob/e35319af6d4223d03087177da39b63936b2836fb/firmware/src/motor_task.cpp

It could definitely use some cleanup to make things more clear, but there's a big chunk of code that handles one-time calibration (to automatically measure the number of poles in the motor and the physical orientation of the motor's phases relative to the angle sensor) and then the rest is the main loop which checks for messages requesting to change which haptic mode it should be in or whether it should play a haptic "click", and otherwise calculates the motor torque based on the current position and haptic configuration. That has a few sections:

scottbez1 avatar Oct 03 '22 15:10 scottbez1