forked from zachrudder/MEAM-5100-Final-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvive510.h
56 lines (44 loc) · 997 Bytes
/
vive510.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* header for MEAM510 hacks for vive interface
* May 2021
* Use at your own risk
*
*/
#ifndef VIVE510
#define VIVE510
#include <arduino.h>
// vive status errors
#define VIVE_NO_SIGNAL 0
#define VIVE_SYNC_ONLY 1
#define VIVE_RECEIVING 2
#define KTYPE 2
#define JTYPE 1
class Vive510
{
private:
volatile uint32_t m_usRising ; // updated by interrupts
volatile uint32_t m_usFalling ;
uint16_t m_xCoord;
uint16_t m_yCoord;
int m_vivestatus = 0;
int m_pin; // signal input pin
int m_sweepWidth=50;
int m_pulseType; // 1 is J, 2 is K
uint32_t m_lastFalling;
int m_spurious;
int isJPulse(uint32_t pulsewidth);
int isKPulse(uint32_t pulsewidth);
void processPulse();
public:
Vive510(int pin);
uint16_t xCoord();
uint16_t yCoord();
uint32_t sync(int);
int status();
void stop();
void start();
void begin();
void begin(int);
void IRAM_ATTR pulseISR(uint32_t); // need public for global interrupt Arduino hack
};
#endif