HapticLib  0.7
Haptic Feedback Library for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hl_patterns.c File Reference

Pattern Generator Module definitions More...

#include "hapticLib.h"

Go to the source code of this file.

Macros

#define HL_SYSTEM_FILE
 Used to indicate this module is a System one.

Functions

uint8_t genericPatternGenerator (pattern_desc *)
 Pattern generator initiator
uint8_t testPatternGenerator (pattern_desc *)
 Test Pattern generator initiator
uint8_t impactPatternGenerator (pattern_desc *)
 Pattern generator initiator
uint8_t constantPatternGenerator (pattern_desc *)
 Pattern generator initiator
void patternScheduler (void)
 Updates all the active patterns' progress.
void cleanList (haptor_desc *haptor)
 Utility function to clean the pattern list of haptors.
uint16_t dutyConverter (uint16_t duty, haptor_desc *haptor)
 Utility function to convert duty-cycles.

Variables

system_desc SystemDesc
 Global variable to describe the haptic system.
pattern_initiator patternMap [Num_Patterns_Available]
 Pattern Generators Functions Map.

Detailed Description

Pattern Generator Module definitions

hl_patterns.c is part of the Pattern Generator Module of HapticLib.

This file lists of all the pattern generators initiators, and uses them to fill the patternMap array.

The technique used by HapticLib make it possible to decouple the User API Module and the Pattern Generator Module.

See also:
Please refer to the HapticLib Developer documentation page.

The User API Module only knows the signature of a generic pattern generator function (that is always the same) regardless of what the actual function will be.

Authors:
Leonardo Guardati
Silvio Vallorani
Version:
v0.7
Date:
2012

Definition in file hl_patterns.c.


Macro Definition Documentation

#define HL_SYSTEM_FILE

Used to indicate this module is a System one.

Declaring this symbol, some internal data structures will be available to the module.

Definition at line 57 of file hl_patterns.c.


Function Documentation

void cleanList ( haptor_desc haptor)

Utility function to clean the pattern list of haptors.

This function holds the frequently used code to free the haptor list form the attached pattern.

Parameters:
[out]haptorThe haptor_desc * hold by activeHaptorList inside pattern_desc structure.

Definition at line 131 of file hl_patterns.c.

uint8_t constantPatternGenerator ( 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 =&constantContinuator;), so the next time patternScheduler() will check for active patterns, it will find this pattern.

Warning:
If the initiator doesn't set the continuator up for scheduling, the pattern will never start, and for HapticLib, the haptor is free to receive other patterns.
Parameters:
[out]patternA pattern_desc* holding the running instance of the pattern being started.
Returns:
uint8_t The result is returned to indicate success or error.
Return values:
0Success
1Error

Definition at line 184 of file constant.c.

uint16_t dutyConverter ( uint16_t  duty,
haptor_desc haptor 
)

Utility function to convert duty-cycles.

Given the absolute duty-cycle (0-65535) and the haptor this function will return the actual duty cycle honoring min_duty and max_duty values of the haptor.

Parameters:
[in]dutyA uint16_t value representing the absolute duty cycle.
[out]haptorA haptor_desc * holding the reference to the haptor for which the duty has to be scaled.
Returns:
uint16_t the scaled value of the duty cycle.

Definition at line 163 of file hl_patterns.c.

uint8_t genericPatternGenerator ( 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.

The 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 =&genericContinuator;), so the next time patternScheduler() will check for active patterns, it will find this pattern.

Warning:
If the initiator doesn't set the continuator up for scheduling, the pattern will never start, and for HapticLib, the haptor is free to receive other patterns.
Parameters:
[out]patternA pattern_desc* holding the running instance of the pattern being started.
Returns:
uint8_t The result is returned to indicate success or error.
Return values:
0Success
1Error

Definition at line 272 of file generic.c.

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.

Warning:
If the initiator doesn't set the continuator up for scheduling, the pattern will never start, and for HapticLib, the haptor is free to receive other patterns.
Parameters:
[out]patternA 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.
Returns:
uint8_t The result is returned to indicate success or error.
Return values:
0Success
1Error

Definition at line 431 of file impact.c.

void patternScheduler ( void  )

Updates all the active patterns' progress.

patternScheduler() checks for all the patterns configured in the system. If the pattern is running, its continuator is called.

patternScheduler() is called by the Platform Specific Module ( for example in the STM32VLDISCOVERY platform, SysTick_Handler() is the caller).

See also:
Please refer to the Developer Guide page to know the internal details of how HapticLib multi-haptor technique works.

Definition at line 100 of file hl_patterns.c.

uint8_t testPatternGenerator ( pattern_desc pattern)

Test Pattern generator initiator

This function is called by the User API Module of HapticLib, when the library user calls hl_sendPattern().

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 =&testContinuator;), so the next time patternScheduler() will check for active patterns, it will find this pattern.

Warning:
If the initiator doesn't set the continuator up for scheduling, the pattern will never start, and for HapticLib, the haptor is free to receive other patterns.
Note:
This pattern doesn't need user parameters, and check for this parameter to be NULL.
Parameters:
[out]patternA 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.
Returns:
uint8_t The result is returned to indicate success or error.
Return values:
0Success
1Error

Definition at line 189 of file test.c.


Variable Documentation

Initial value:

Pattern Generators Functions Map.

This array contains the addresses of all the pattern generator initiator functions.

The index of the array locate the specific pattern using one of the Pattern Generator Functions Index Names defined in the pattern_name enumeration type definition. (e.g. Test, Impact)

Definition at line 79 of file hl_patterns.c.

system_desc SystemDesc

Global variable to describe the haptic system.

The Library uses this global variable to describe the system and to keep track of the haptic devices' status and active patterns' progress at any time.

Note:
The library user doesn't need to access this variable.

The SystemDesc variable holds a lot of informations, and its members allow the system to access almost all the informations needed.

See also:
Please refer to the Developer Guide page for details.

Definition at line 70 of file hapticLib.c.