HapticLib
0.7
Haptic Feedback Library for embedded systems
|
Impact Pattern generator function definition More...
#include "hapticLib.h"
Go to the source code of this file.
Functions | |
uint8_t | impactContinuator (pattern_desc *pattern) |
Pattern generator continuator | |
uint8_t | impactPatternGenerator (pattern_desc *pattern) |
Pattern generator initiator |
Variables | |
const uint16_t | rubberImpactPattern [256] |
Hardcoded, Haptic Feedback Pattern of impact on Rubber surface. | |
const uint16_t | woodImpactPattern [256] |
Hardcoded, Haptic Feedback Pattern of impact on Wood surface. | |
const uint16_t | aluminumImpactPattern [256] |
Hardcoded, Haptic Feedback Pattern of impact on Aluminum surface. |
Impact Pattern generator function definition
This is the Impact Pattern Generator function that describe an impact on surface sensation.
Users can choose from three different surface materials and three hit velocity magnitude.
Impact Pattern is based on theoretical research published on paper
and also used in other researches such as the one published on paper
in which authors propose a mathematics model that describe vibrations in impact on various surface materials.
Original model proposed was sinusoidal one:
where:
the amplitude factor depends on impact velocity in a quasi-linear way, so the model can be simplified in
To use this formula as Haptic Pattern Samples Generator some other manipulations are necessary:
This approach ensures non negative samples and avoid discontinuities.
Samples are also scaled to remain in range for the slow pattern implementation; the normal and fast patterns are then runtime generated taking the slow pattern samples multiplied by the velocity parameter.
Graphics of vibration patterns obtained using this formula are reported in figure:
Impact Pattern Generator needs two optional parameters: velocity
and material
, that can be
velocity
:Slow
Normal
Fast
material
:Rubber
Wood
Aluminum
Users must define a structure of impactPatternParameters type to pass these parameters.
This is a sample code snippets that show how impact pattern must be sent:
... haptor_desc *myHaptor = hl_configure(24000000,15,1); impactPatternParameters params; params.velocity = Fast; params.material = Wood; pattern_desc *myImpactPattern = hl_initPattern(Impact, ¶ms); hl_addHaptor(myHaptor,myImpactPattern); hl_startPattern(myImapctPattern); ...
If HL_DEBUG is defined some useful informations are send to USART.
In particular will be send:
No additional notes.
Definition in file impact.c.
uint8_t impactContinuator | ( | pattern_desc * | pattern | ) |
Pattern generator continuator
This function is called back from the patternScheduler() every SystemDesc.samples_delay ms.
At every call, this continuator will point to the next element of the right array of samples.
When reached the last sample the pattern is finished an remove itself from the scheduling patterns.
uint8_t impactPatternGenerator | ( | pattern_desc * | pattern | ) |
Pattern generator initiator
This function is called by the User API Module of HapticLib, when the library user calls hl_startPattern().
The first task for the pattern generator initiator is to validate the user provided inputs, this cannot be done anywhere else.
This pattern initiator then sets up all the status parameters.
If the pattern accept user parameters, the status setting can be based on the user provided parameters.
The last duty of this function is to put the pattern continuator up for scheduling ( setting pattern->continuator =
&impactContinuator;
), so the next time patternScheduler() will check for active patterns, it will find this pattern.
[out] | pattern | A pattern_desc* holding the reference to the running pattern instance to work with. Through this reference, the continuator can extract the user and status parameters in order to execute the haptic pattern. |
0 | Success |
1 | Error |
const uint16_t aluminumImpactPattern[256] |
Hardcoded, Haptic Feedback Pattern of impact on Aluminum surface.
The aluminumImpactPattern describe a vibration in response to impact on Aluminum. (256 samples)
Defined as const to store it in flash memory.
const uint16_t rubberImpactPattern[256] |
Hardcoded, Haptic Feedback Pattern of impact on Rubber surface.
The rubberImpactPattern describe a vibration in response to impact on Rubber. (256 samples)
Defined as const to store it in flash memory.
const uint16_t woodImpactPattern[256] |
Hardcoded, Haptic Feedback Pattern of impact on Wood surface.
The woodImpactPattern describe a vibration in response to impact on Wood. (256 samples)
Defined as const to store it in flash memory.