Fix for hack that worked around iOS app
Haptics.h@2:4f76784f8968, 2016-02-25 (annotated)
- Committer:
- roysandberg
- Date:
- Thu Feb 25 00:19:46 2016 +0000
- Revision:
- 2:4f76784f8968
- Parent:
- 0:8c0ecbdd3449
On/Off/Twilight Mode
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
roysandberg | 0:8c0ecbdd3449 | 1 | /****************************************************************************** |
roysandberg | 0:8c0ecbdd3449 | 2 | * Haptics.c |
roysandberg | 0:8c0ecbdd3449 | 3 | * |
roysandberg | 0:8c0ecbdd3449 | 4 | * Created on: Dec 16, 2011 |
roysandberg | 0:8c0ecbdd3449 | 5 | * Board: DRV2603EVM-CT RevD |
roysandberg | 0:8c0ecbdd3449 | 6 | * Author: a0866685 |
roysandberg | 0:8c0ecbdd3449 | 7 | * |
roysandberg | 0:8c0ecbdd3449 | 8 | * Description: This file contains the functions for sending haptics waveforms. |
roysandberg | 0:8c0ecbdd3449 | 9 | * Edit this file when changing actuators. |
roysandberg | 0:8c0ecbdd3449 | 10 | * |
roysandberg | 0:8c0ecbdd3449 | 11 | * @TODO - Update this file when changing between actuators types |
roysandberg | 0:8c0ecbdd3449 | 12 | * (ERM, LRA, Piezo) |
roysandberg | 0:8c0ecbdd3449 | 13 | * |
roysandberg | 0:8c0ecbdd3449 | 14 | ******************************************************************************/ |
roysandberg | 0:8c0ecbdd3449 | 15 | |
roysandberg | 0:8c0ecbdd3449 | 16 | #ifndef HAPTICS_H_ |
roysandberg | 0:8c0ecbdd3449 | 17 | #define HAPTICS_H_ |
roysandberg | 0:8c0ecbdd3449 | 18 | |
roysandberg | 0:8c0ecbdd3449 | 19 | #include "mbed.h" |
roysandberg | 0:8c0ecbdd3449 | 20 | |
roysandberg | 0:8c0ecbdd3449 | 21 | //#include "msp430.h" |
roysandberg | 0:8c0ecbdd3449 | 22 | //#include "CTS/structure.h" |
roysandberg | 0:8c0ecbdd3449 | 23 | //#include "timer.h" |
roysandberg | 0:8c0ecbdd3449 | 24 | |
roysandberg | 0:8c0ecbdd3449 | 25 | #define LRA_MODE_OFF 0 |
roysandberg | 0:8c0ecbdd3449 | 26 | #define LRA_MODE_WAVEFORM 1 |
roysandberg | 0:8c0ecbdd3449 | 27 | #define LRA_MODE_DELAYED_WAVEFORM 2 |
roysandberg | 0:8c0ecbdd3449 | 28 | #define LRA_MODE_RAMP_TO_TARGET 3 |
roysandberg | 0:8c0ecbdd3449 | 29 | |
roysandberg | 0:8c0ecbdd3449 | 30 | #define DELAY 250 |
roysandberg | 0:8c0ecbdd3449 | 31 | #define DUMBTICK LRAFREQ_185 // Select the LRA resonant frequency for "dumb" (auto-resonance off) mode |
roysandberg | 0:8c0ecbdd3449 | 32 | |
roysandberg | 0:8c0ecbdd3449 | 33 | // LRA Resonant Frequencies (see DUMBTICK above) |
roysandberg | 0:8c0ecbdd3449 | 34 | #define LRAFREQ_220 18182 // 220Hz |
roysandberg | 0:8c0ecbdd3449 | 35 | #define LRAFREQ_215 18605 // 215Hz |
roysandberg | 0:8c0ecbdd3449 | 36 | #define LRAFREQ_210 19048 // 210Hz |
roysandberg | 0:8c0ecbdd3449 | 37 | #define LRAFREQ_205 19512 // 205Hz |
roysandberg | 0:8c0ecbdd3449 | 38 | #define LRAFREQ_200 20000 // 200Hz |
roysandberg | 0:8c0ecbdd3449 | 39 | #define LRAFREQ_195 20513 // 195Hz |
roysandberg | 0:8c0ecbdd3449 | 40 | #define LRAFREQ_190 21052 // 190Hz |
roysandberg | 0:8c0ecbdd3449 | 41 | #define LRAFREQ_185 21621 // 185Hz |
roysandberg | 0:8c0ecbdd3449 | 42 | #define LRAFREQ_180 22222 // 180Hz |
roysandberg | 0:8c0ecbdd3449 | 43 | #define LRAFREQ_175 22857 // 175Hz |
roysandberg | 0:8c0ecbdd3449 | 44 | #define LRAFREQ_170 23529 // 170Hz |
roysandberg | 0:8c0ecbdd3449 | 45 | #define LRAFREQ_165 24242 // 165Hz |
roysandberg | 0:8c0ecbdd3449 | 46 | #define LRAFREQ_160 25000 // 160Hz |
roysandberg | 0:8c0ecbdd3449 | 47 | #define LRAFREQ_155 15806 // 155Hz |
roysandberg | 0:8c0ecbdd3449 | 48 | #define LRAFREQ_150 26667 // 150Hz |
roysandberg | 0:8c0ecbdd3449 | 49 | #define LRAFREQ_145 27586 // 145Hz |
roysandberg | 0:8c0ecbdd3449 | 50 | |
roysandberg | 0:8c0ecbdd3449 | 51 | // PWM output modes |
roysandberg | 0:8c0ecbdd3449 | 52 | #define LRA_AUTOON 0 // LRA Auto-resonance on |
roysandberg | 0:8c0ecbdd3449 | 53 | #define LRA_AUTOOFF 1 // LRA Auto-resonance off |
roysandberg | 0:8c0ecbdd3449 | 54 | #define ERM 2 // ERM Output Mode |
roysandberg | 0:8c0ecbdd3449 | 55 | |
roysandberg | 0:8c0ecbdd3449 | 56 | extern uint16_t Haptics_dumbModeTick; // Sets the LRA Auto-resonance off frequency (use DUMBTICK above to set frequency) |
roysandberg | 0:8c0ecbdd3449 | 57 | extern uint16_t Haptics_resonantModeTick; |
roysandberg | 0:8c0ecbdd3449 | 58 | |
roysandberg | 0:8c0ecbdd3449 | 59 | // Waveform Structure Type Definition |
roysandberg | 0:8c0ecbdd3449 | 60 | typedef struct Haptics_Waveform { |
roysandberg | 0:8c0ecbdd3449 | 61 | const unsigned char outputMode; // ERM, LRA_AUTOON, or LRA_AUTOOFF (see output modes above) |
roysandberg | 0:8c0ecbdd3449 | 62 | const unsigned char length; // size of array in bytes |
roysandberg | 0:8c0ecbdd3449 | 63 | const unsigned char* volatile data; // pointer to waveform array data (waveform array is in (amplitude, time) pairs |
roysandberg | 0:8c0ecbdd3449 | 64 | } Waveform; |
roysandberg | 0:8c0ecbdd3449 | 65 | |
roysandberg | 0:8c0ecbdd3449 | 66 | /** |
roysandberg | 0:8c0ecbdd3449 | 67 | * Haptics_Init - initialize haptics variables and settings |
roysandberg | 0:8c0ecbdd3449 | 68 | */ |
roysandberg | 0:8c0ecbdd3449 | 69 | void Haptics_Init(void); |
roysandberg | 0:8c0ecbdd3449 | 70 | |
roysandberg | 0:8c0ecbdd3449 | 71 | /** |
roysandberg | 0:8c0ecbdd3449 | 72 | * Haptics_OutputWaveform - control the PWM output pattern |
roysandberg | 0:8c0ecbdd3449 | 73 | * @param struct Waveform - the waveform output type, length in bytes, and data |
roysandberg | 0:8c0ecbdd3449 | 74 | * @TODO - Modify this function to change actuator types (ERM, LRA, Piezo) |
roysandberg | 0:8c0ecbdd3449 | 75 | */ |
roysandberg | 0:8c0ecbdd3449 | 76 | |
roysandberg | 0:8c0ecbdd3449 | 77 | void Haptics_OutputWaveform(const Waveform* waveform); |
roysandberg | 0:8c0ecbdd3449 | 78 | void Haptics_OverrideOutputWaveform(const Waveform* newWaveform); |
roysandberg | 0:8c0ecbdd3449 | 79 | void Haptics_OutputCount(uint16_t count); |
roysandberg | 0:8c0ecbdd3449 | 80 | void Haptics_SetHeartbeatWaveform (int waveformNum); |
roysandberg | 0:8c0ecbdd3449 | 81 | void Haptics_OutputDelayedHeartbeat(uint16_t delay); |
roysandberg | 0:8c0ecbdd3449 | 82 | void Haptics_OutputDelayedWaveform(const Waveform* newWaveform, uint16_t delay); |
roysandberg | 0:8c0ecbdd3449 | 83 | void Haptics_SetRampTarget(float amplitude); |
roysandberg | 0:8c0ecbdd3449 | 84 | void Haptics_Off(); |
roysandberg | 0:8c0ecbdd3449 | 85 | bool isHapticsOff(); |
roysandberg | 0:8c0ecbdd3449 | 86 | |
roysandberg | 2:4f76784f8968 | 87 | void LeavingOffModeHapticResponse(int ledFinalState); |
roysandberg | 2:4f76784f8968 | 88 | void EnteringOffModeHapticResponse(); |
roysandberg | 2:4f76784f8968 | 89 | |
roysandberg | 0:8c0ecbdd3449 | 90 | #endif /* HAPTICS_H_ */ |