/
CompressedSerial.ino
60 lines (53 loc) · 1.05 KB
/
CompressedSerial.ino
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
#define debug 0
//String format #XYZZBB;
//X varies from 0 to o ie 0 to 64
//Y varies from 0 to o ie 0 to 64
//ZZ varies from 00 to oo ie 0 to 4096
//BB varies from 00 to oo Buttons value 12 bit binary ie 1111 1111 1111
//#oo oo oo oo oo oo oo oo;
String s1, s2, s3, s4;
char Str1[3] = "X";
char Str2[3] = "Y";
char Str3[3] = "Z";
char Str4[3] = "B";
char c;
int Buttons; //Digital Buttons
int x = 4095;
int y = 4095;
int z = 4095;
int btn = 0;
int la = 4095;
int lo = 4095;
int al = 4095;
int X, Y, Z; //Analog
boolean buttons[10];
boolean flag = 0;
uint32_t packetCount = 0, last_sent = 0;
void setup() {
Serial.begin(115200);
Serial.println("Ready");
}
void loop() {
if (Serial.available())
{
c = Serial.read();
if (c == '*') flag = 1;
if (c == '+') flag = 0;
DecodeString();
}
if (flag)
{
if (millis() - last_sent >= 200)
{
sendPacket();
last_sent = millis();
}
}
// updateVariables();
}
void updateVariables()
{
x = 0;
y = 0;
z = 0;
}