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

Test Pattern generator function definition More...

#include "hapticLib.h"

Go to the source code of this file.

Functions

uint8_t testContinuator (pattern_desc *pattern)
 Test Pattern generator continuator
uint8_t testPatternGenerator (pattern_desc *pattern)
 Test Pattern generator initiator

Detailed Description

Test Pattern generator function definition

Implementation code of the Test Pattern.

Introduction

This pattern reproduce two linear ramp from 0% to 100% duty-cycle.

Theory

Simple pattern with sawtooth profile.

Optional Parameters

No optional parameters.

Usage Examples

Here is a typical usage scenario for the Test Pattern:

                ...
                haptor_desc *myHaptor = hl_configure(24000000,15,1);

                pattern_desc *myTestPattern = hl_initPattern(Test,NULL);

                hl_addHaptor(myHaptor, myTestPattern);

                hl_startPattern(myTestPattern);
                ...

A condensed version of the same code is the follow:

                ...
                haptor_desc *myHaptor = hl_configure(24000000,15,1);

                hl_startPattern(hl_addHaptor(myHaptor, hl_initPattern(Test,NULL) ) );
                ...
Note:
This shortcut is valid and can be used only for single haptor pattern.

Debugging Details

testPatternGenerator doesn't need optional parameter, just pass a NULL. If any are passed, an error occurs and if HL_DEBUG is defined this error will be sent on UART.

Additional Notes

No additional notes.

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

Definition in file test.c.


Function Documentation

uint8_t testContinuator ( pattern_desc pattern)

Test Pattern generator continuator

This function is called back from the SysTick_Handler every SystemDesc.samples_delay ms.

At every call, this continuator will calculate the next value of PWM duty-cycle.

After two positive ramps the pattern is finished and remove itself from the scheduling patterns.

Definition at line 100 of file test.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.