-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKontrolMux.ino
186 lines (143 loc) · 3.48 KB
/
KontrolMux.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//#include <Adafruit_GFX.h>
//#include <RGBmatrixPanel.h>
//#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr
//#define CLK 11 // USE THIS ON ARDUINO MEGA
//#define OE 9
//#define LAT 10
//#define A A0
//#define B A1
//#define C A2
//#define D A3
//RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true, 64);
//
//
//uint16_t myRED = matrix.Color333(7,0,0);
//uint16_t myGREEN = matrix.Color333(0,7,0);
//uint16_t myBLUE = matrix.Color333(0,0,7);
//uint16_t myWHITE = matrix.Color333(7, 7,7);
int A_1 = 4;
int B_1 = 5;
String data;
String dt[20];
boolean parsing = false;
int minLength = 0;
char heading[15], win[15];
float d_head;
float d_win;
String s_heading;
float f_heading=0;
String dataku;
int textX1 = 14;
int8_t ball[3][4] = {
{ 3, 0, 1, 1 }, // Initial X,Y pos & velocity for 3 bouncy balls
{ 17, 15, 1, -1 },
{ 27, 4, -1, 1 }
};
static const uint16_t PROGMEM ballcolor[3] = {
0x0080, // Green=1
0x0002, // Blue=1
0x1000 // Red=1
};
void setup() {
// put your setup code here, to run once:
Serial.begin(4800);
Serial1.begin(4800);
pinMode( A_1, OUTPUT);
pinMode( B_1, OUTPUT);
digitalWrite(A_1,LOW);
digitalWrite(B_1, LOW);
// matrix.begin();
// matrix.setTextWrap(false); // Allow text to run off right edge
// matrix.setTextSize(1);
}
void loop() {
// put your main code here, to run repeatedly:
if (parsing) {
parsingdata();
// display_data();
data = "";
parsing = false;
}
}
void serialEvent1() {
while (Serial1.available()) {
char inChar = (char)Serial1.read();
data += inChar;
if (inChar == '\n') {
parsing = true;
}
}
}
void parsingdata()
{
int j = 0;
int k = 0;
dt[j] = "";
int minLength;
if (data.length() > 70) {
minLength = 20;
}
else {
minLength = 0;
}
for (k = 1; k < data.length() - minLength ; k++) {
if ((data[k] == '$') || (data[k] == ',' ) || (data[k] == '*' ) ) {
j++;
dt[j] = "";
}
else {
dt[j] = dt[j] + data[k];
}
}
if (dt[0].charAt(4)=='T') {
//dt[1].toCharArray(heading,15);
d_head=dt[1].toFloat();
digitalWrite(A_1, HIGH);
digitalWrite(B_1, LOW);
}
else if (dt[0].charAt(4) == 'V') {
Serial.println(data);
//dt[1].toCharArray(win,15);
//d_win = dt[1].toFloat();
digitalWrite(A_1, LOW);
digitalWrite(B_1, LOW);
}
else if (dt[0] == "GPRMC" ) {
Serial.println(data);
digitalWrite(A_1, HIGH);
digitalWrite(B_1, HIGH);
}
else if (dt[0] == "WIMWV" ) {
Serial.println(data);
digitalWrite(A_1, LOW);
digitalWrite(B_1, LOW);
}
}
/*
void display_data(){
matrix.fillScreen(matrix.Color333(0, 0, 0));
matrix.setCursor(3,1);
matrix.setTextColor(myWHITE);
matrix.setFont();
matrix.print("SPD:");
//heading
matrix.setCursor(3,12);
matrix.setFont();
matrix.setTextColor(myWHITE);
matrix.print("HDG:");
matrix.setCursor(27,12);
matrix.setTextColor(myWHITE);
matrix.setFont();
matrix.print(d_head);
//speed
matrix.setCursor(3,22);
matrix.setTextColor(myWHITE);
matrix.setFont();
matrix.print("WIN:");
matrix.setCursor(27,22);
matrix.setTextColor(myWHITE);
matrix.setFont();
matrix.print(d_win);
matrix.swapBuffers(false);
}
*/