Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DDC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GOKA HARSHITH
DDC
Commits
fe37890b
Commit
fe37890b
authored
Jun 19, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate algorithm and android code
parent
5f927c00
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
7 deletions
+170
-7
.idea/vcs.xml
.idea/vcs.xml
+6
-0
app/src/main/java/com/example/harshith/ddc/Live.java
app/src/main/java/com/example/harshith/ddc/Live.java
+42
-0
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+122
-7
No files found.
.idea/vcs.xml
0 → 100644
View file @
fe37890b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/src/main/java/com/example/harshith/ddc/Live.java
0 → 100644
View file @
fe37890b
package
com.example.harshith.ddc
;
import
java.util.Scanner
;
/**
* Created by harshith on 18/6/16.
*/
public
class
Live
{
int
reading
[];
int
sensors
=
11
;
public
Live
(){
reading
=
new
int
[
sensors
];
}
public
Live
(
Live
staticLive
){
reading
=
new
int
[
staticLive
.
sensors
];
for
(
int
i
=
0
;
i
<
sensors
;
i
++)
{
reading
[
i
]
=
staticLive
.
reading
[
i
];
}
}
public
void
updateConsole
(){
Scanner
scan
=
new
Scanner
(
System
.
in
).
useDelimiter
(
"\\s"
);
for
(
int
i
=
0
;
i
<
sensors
;
i
++)
{
reading
[
i
]
=
scan
.
nextInt
();
}
}
public
void
update
(
int
[]
readings
){
reading
=
readings
;
}
public
void
print
(){
for
(
int
i
=
0
;
i
<
sensors
;
i
++)
{
System
.
out
.
print
(
reading
[
i
]
+
" "
);
}
System
.
out
.
print
(
'\n'
);
}
}
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
fe37890b
...
...
@@ -20,6 +20,7 @@ public class ReceiveDataThread extends Thread {
public
int
readStatus
;
private
StringBuilder
stringBuilder
=
null
;
int
[]
readings
;
Gesture
[]
a
;
public
ReceiveDataThread
(
BluetoothSocket
bluetoothSocket
,
Handler
handler
,
GlobalClass
globalClass
)
{
this
.
bluetoothSocket
=
bluetoothSocket
;
...
...
@@ -27,6 +28,45 @@ public class ReceiveDataThread extends Thread {
this
.
globalClass
=
globalClass
;
stringBuilder
=
new
StringBuilder
();
a
=
new
Gesture
[
8
];
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
a
[
i
]
=
new
StaticGesture
();
}
int
[]
hand
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
int
q
=
0
;
q
=
0
;
hand
=
new
int
[]
{
0
,
0
,
0
,
0
,
0
,
8
,
8
,
8
,
8
,
8
,
8
};
// neutral
a
[
q
].
updateFrame
(
hand
);
q
=
1
;
hand
=
new
int
[]
{
1
,
1
,
0
,
0
,
0
,
8
,
8
,
8
,
8
,
1
,
8
};
// voice search
a
[
q
].
updateFrame
(
hand
);
q
=
2
;
hand
=
new
int
[]
{
1
,
0
,
1
,
1
,
1
,
8
,
8
,
8
,
8
,
1
,
8
};
// tap
a
[
q
].
updateFrame
(
hand
);
q
=
3
;
hand
=
new
int
[]
{
0
,
1
,
1
,
1
,
0
,
8
,
8
,
8
,
8
,
1
,
8
};
// call
a
[
q
].
updateFrame
(
hand
);
q
=
4
;
hand
=
new
int
[]
{
0
,
0
,
1
,
1
,
1
,
8
,
8
,
8
,-
1
,
8
,
8
};
// cam open
a
[
q
].
updateFrame
(
hand
);
q
=
5
;
hand
=
new
int
[]
{
0
,
0
,
0
,
1
,
1
,
8
,
8
,
8
,-
1
,
8
,
8
};
// cam click
a
[
q
].
updateFrame
(
hand
);
q
=
6
;
hand
=
new
int
[]
{
1
,
0
,
1
,
1
,
0
,
8
,
8
,
8
,
8
,
1
,
8
};
// music open
a
[
q
].
updateFrame
(
hand
);
q
=
7
;
hand
=
new
int
[]
{
0
,
0
,
1
,
1
,
0
,
8
,
8
,
8
,
8
,
1
,
8
};
// music play
a
[
q
].
updateFrame
(
hand
);
}
public
void
setProcessHandler
(
Handler
processHandler
)
{
...
...
@@ -43,20 +83,95 @@ public class ReceiveDataThread extends Thread {
byte
[]
buffer
=
new
byte
[
64
];
int
bytes
=
-
1
;
bytes
=
inputStream
.
read
(
buffer
);
readStatus
=
Constants
.
READ_STATUS_OK
;
String
readMessage
=
new
String
(
buffer
,
0
,
bytes
);
stringBuilder
.
append
(
readMessage
);
convert
();
// ProcessThread processThread = new ProcessThread(globalClass);
// processThread.start();
//
// processHandler = globalClass.getProcessHandler();
Live
staticLive
=
new
Live
();
int
no
=
50
;
//StaticLive.print();
int
count
=
0
;
int
gestActive
=
-
1
;
boolean
stay
=
true
;
while
(
true
)
{
bytes
=
inputStream
.
read
(
buffer
);
readMessage
=
new
String
(
buffer
,
0
,
bytes
);
String
readMessage
=
new
String
(
buffer
,
0
,
bytes
);
stringBuilder
.
append
(
readMessage
);
convert
();
int
endOfLineIndex
=
stringBuilder
.
indexOf
(
"~"
);
if
(
endOfLineIndex
>
0
)
{
int
startOfLineIndex
=
stringBuilder
.
indexOf
(
"#"
);
if
(
startOfLineIndex
>
endOfLineIndex
||
startOfLineIndex
==
-
1
)
{
startOfLineIndex
=
0
;
}
else
if
(
startOfLineIndex
==
0
)
{
startOfLineIndex
=
1
;
}
String
dataIn
=
stringBuilder
.
substring
(
startOfLineIndex
,
endOfLineIndex
);
String
[]
readingStrings
=
dataIn
.
split
(
"\\+"
);
readings
=
new
int
[
readingStrings
.
length
];
for
(
int
i
=
0
;
i
!=
readingStrings
.
length
;
i
++)
{
try
{
readings
[
i
]
=
Integer
.
valueOf
(
readingStrings
[
i
]);
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NullPointerException
e
)
{
}
}
String
testConvert
=
""
;
for
(
int
reading
:
readings
)
{
testConvert
+=
" "
+
reading
;
}
L
.
m
(
testConvert
);
stringBuilder
.
delete
(
0
,
endOfLineIndex
+
2
);
if
(
count
==
no
){
L
.
m
(
"Gesture "
+
gestActive
+
" is activated"
);
count
=
0
;
gestActive
=
-
1
;
//if( str.equals("n") ) { stay = false; break; }
}
if
(
count
<
no
){
if
(
readings
.
length
==
11
)
{
staticLive
.
update
(
readings
);
}
}
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
if
(
a
[
i
].
isInFrame
(
staticLive
)){
if
(
gestActive
==
i
){
count
++;
continue
;
}
else
{
gestActive
=
i
;
count
=
1
;
continue
;
}
}
}
// int[] flex = new int[5];
// for (int i = 0; i != 5; i++) {
// try {
// flex[i] = readings[i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
//
// int[] mpu = new int[6];
// for (int i = 0; i != 6; i++) {
// try {
// mpu[i] = readings[5 + i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
}
// if(processHandler != null) {
// processHandler.obtainMessage(1, readings).sendToTarget();
// }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment