-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrols.h
More file actions
67 lines (54 loc) · 1.37 KB
/
controls.h
File metadata and controls
67 lines (54 loc) · 1.37 KB
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
57
58
59
60
61
62
63
64
65
66
67
#ifndef CONTROLS_H
#define CONTROLS_H
#include "gl.h"
/*
* Outputs x, y, z controls for the
* DREAM'S DON'T DIE Moonwalker Brain Machine Interface
* to have spatial awareness of the device
*
* Author: William Pan <williampan@cs.stanford.edu>
* Date: Mar 28, 2023
*/
typedef struct {
signed int min_x;
signed int max_x;
signed int min_y;
signed int max_y;
} control_limits_t;
typedef struct {
signed short accel_x;
signed short accel_y;
signed short accel_z;
} control_accel_t;
typedef struct {
signed short gyro_x;
signed short gyro_y;
signed short gyro_z;
} control_gyro_t;
typedef struct {
float pitch_x;
float roll_y;
} control_angles_t;
typedef struct {
enum { EMG_INACTIVE, EMG_ACTIVE } action;
signed int x;
signed int y;
color_t color;
control_limits_t limits;
signed int sensitivity;
signed int threshold;
} control_action_t;
void controls_init(void);
void set_limits(signed int screen_x, signed int screen_y);
void set_location(signed int screen_x, signed int screen_y);
void set_sensitivity_threshold(signed int sensitivity, signed int threshold);
void calibrate(void);
int clear_accel(void);
int clear_gyro(void);
void control_read_accel(void);
void ontrol_read_gyro(void);
void control_read_angles(void);
void control_read_action(control_action_t *ctrl);
control_action_t control_get_action(void);
void control_action_loop(void);
#endif