Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GPN_BadgeLasertag
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian
GPN_BadgeLasertag
Commits
64513d12
Commit
64513d12
authored
7 years ago
by
OleL
Browse files
Options
Downloads
Patches
Plain Diff
Ahh nicht mehr viel Zeit !!1 (*rennt panisch im Kreis*)
parent
de1488bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GPN_BadgeLasertag.ino
+10
-10
10 additions, 10 deletions
GPN_BadgeLasertag.ino
GameClient.cpp
+17
-1
17 additions, 1 deletion
GameClient.cpp
with
27 additions
and
11 deletions
GPN_BadgeLasertag.ino
+
10
−
10
View file @
64513d12
...
@@ -139,7 +139,6 @@ String recv_ir() {
...
@@ -139,7 +139,6 @@ String recv_ir() {
pixels
.
setPixelColor
(
1
,
pixels
.
Color
(
0
,
0
,
0
));
pixels
.
setPixelColor
(
1
,
pixels
.
Color
(
0
,
0
,
0
));
pixels
.
show
();
pixels
.
show
();
}
}
uint8_t
checksum
=
'X'
;
if
(
stringCompleted
)
{
if
(
stringCompleted
)
{
uint8_t
checksum
=
buf
[
1
];
uint8_t
checksum
=
buf
[
1
];
dataCompleted
=
true
;
dataCompleted
=
true
;
...
@@ -159,6 +158,7 @@ String recv_ir() {
...
@@ -159,6 +158,7 @@ String recv_ir() {
checksumRec
+=
buf
[
0
]
+
buf
[
1
]
+
buf
[
2
]
+
buf
[
3
];
checksumRec
+=
buf
[
0
]
+
buf
[
1
]
+
buf
[
2
]
+
buf
[
3
];
Serial
.
printf
(
"->:
\n\t
0: %c
\n\t
1: %c
\n\t
2: %c
\n\t
3: %c
\n
"
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
]);
Serial
.
printf
(
"->:
\n\t
0: %c
\n\t
1: %c
\n\t
2: %c
\n\t
3: %c
\n
"
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
]);
if
(
buf
[
0
]
==
'\n'
||
buf
[
1
]
==
'\n'
||
buf
[
2
]
==
'\n'
||
buf
[
3
]
==
'\n'
)
{
if
(
buf
[
0
]
==
'\n'
||
buf
[
1
]
==
'\n'
||
buf
[
2
]
==
'\n'
||
buf
[
3
]
==
'\n'
)
{
stringCompleted
=
true
;
stringCompleted
=
true
;
Serial
.
printf
(
"string complete %s
\n
"
,
received
.
c_str
());
Serial
.
printf
(
"string complete %s
\n
"
,
received
.
c_str
());
//done = true; //isValidIp(received.substring(1, received.length() - 2));
//done = true; //isValidIp(received.substring(1, received.length() - 2));
...
@@ -167,34 +167,34 @@ String recv_ir() {
...
@@ -167,34 +167,34 @@ String recv_ir() {
irrecv
.
resume
();
// Prepare for the next value
irrecv
.
resume
();
// Prepare for the next value
}
}
delay
(
0
);
delay
(
0
);
ui
->
dispatchInput
(
badge
.
getJoystickState
());
//Allow canceling
//
}
}
badge
.
setGPIO
(
IR_EN
,
HIGH
);
badge
.
setGPIO
(
IR_EN
,
LOW
);
return
received
;
return
received
;
}
}
void
joinGame
()
{
void
joinGame
()
{
ui
->
closeCurrent
();
ui
->
closeCurrent
();
ui
->
draw
();
ui
->
draw
();
#ifdef DEBUG
#ifdef DEBUG
Serial
.
printf
(
"Join Otter
\n
"
);
Serial
.
printf
(
"Join Otter
\n
"
);
#endif
#endif
String
irinput
=
recv_ir
();
String
irinput
=
recv_ir
();
#ifdef DEBUG
Serial
.
printf
(
"-->
\n\t
%s
\n
<--"
,
irinput
.
c_str
());
#endif
String
ip
;
String
ip
;
ip
=
irinput
.
substring
(
1
,
irinput
.
length
()
-
2
);
ip
=
irinput
.
substring
(
1
,
irinput
.
length
()
-
1
);
Serial
.
printf
(
"Received ip: %s"
,
ip
.
c_str
());
unsigned
short
firstA
=
ip
.
indexOf
(
'a'
);
Serial
.
printf
(
"firstA: %d
\n
"
,
firstA
);
ip
=
ip
.
substring
(
firstA
,
ip
.
length
());
Serial
.
printf
(
"Received ip: >%s<
\n
"
,
ip
.
c_str
());
client
=
new
GameClient
(
ui
,
&
badge
,
player
);
client
=
new
GameClient
(
ui
,
&
badge
,
player
);
client
->
joinGame
(
ip
);
client
->
joinGame
(
ip
);
#ifdef DEBUG
#ifdef DEBUG
Serial
.
printf
(
"Join - Ende
\n
"
);
Serial
.
printf
(
"Join - Ende
\n
"
);
#endif
#endif
}
}
void
loop
()
{
void
loop
()
{
...
...
This diff is collapsed.
Click to expand it.
GameClient.cpp
+
17
−
1
View file @
64513d12
...
@@ -41,12 +41,28 @@ void GameClient::joinGame(String ip) {
...
@@ -41,12 +41,28 @@ void GameClient::joinGame(String ip) {
badge
->
setVibrator
(
true
);
badge
->
setVibrator
(
true
);
delay
(
200
);
delay
(
200
);
badge
->
setVibrator
(
false
);
badge
->
setVibrator
(
false
);
playerList
->
addMenuItem
(
new
MenuItem
(
player
->
getNickname
(),
[]()
{}));
playerList
->
addMenuItem
(
new
MenuItem
(
player
->
getNickname
(),
[]()
{}));
ui
->
dispatchInput
(
badge
->
getJoystickState
());
ui
->
open
(
playerList
);
ui
->
open
(
playerList
);
client
->
connect
(
ip
.
c_str
(),
SERVER_PORT
);
ui
->
draw
();
Serial
.
printf
(
"Conn data:
\n\t
ip: %s
\n\t
port: %d
\n
"
,
ip
.
c_str
(),
SERVER_PORT
);
//client->connect(ip.c_str(), SERVER_PORT);
Serial
.
printf
(
"Trying to conncet!
\n
"
);
if
(
!
client
->
connect
(
"192.168.42.175"
,
4803
)){
Serial
.
printf
(
"Connect failed!
\n
"
);
}
Serial
.
printf
(
"client->connect
\n
"
);
client
->
print
(
player
->
getNickname
());
client
->
print
(
player
->
getNickname
());
Serial
.
printf
(
"client->print nickname
\n
"
);
client
->
flush
();
client
->
flush
();
Serial
.
printf
(
"client->flush"
);
Serial
.
printf
(
"Receiving"
);
String
recv
=
client
->
readStringUntil
(
'\n'
);
String
recv
=
client
->
readStringUntil
(
'\n'
);
Serial
.
printf
(
"RECV: %s"
,
recv
.
c_str
());
Serial
.
printf
(
"RECV: %s"
,
recv
.
c_str
());
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment