Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AndroidSensorSharing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
OpenLicht
AndroidSensorSharing
Commits
715b7ed0
Commit
715b7ed0
authored
7 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
Formatting acceleration and rotation in more dense format.
parent
16185869
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
+22
-6
22 additions, 6 deletions
.../java/de/tudresden/inf/st/sensorsharing/MainActivity.java
with
22 additions
and
6 deletions
mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
+
22
−
6
View file @
715b7ed0
...
...
@@ -191,16 +191,18 @@ public class MainActivity extends AppCompatActivity implements
topic
=
MQTT_TOPIC_POLAR_BRIGHTNESS
;
break
;
case
SUB_KEY_LINEAR_ACCELERATION:
float
[]
accelerationData
=
new
float
[
3
];
writeFloatArray
(
ByteBuffer
.
wrap
(
messageEvent
.
getData
()),
accelerationData
);
updatedValue
=
Arrays
.
toString
(
accelerationData
);
// float[] accelerationData = new float[3];
// writeFloatArray(ByteBuffer.wrap(messageEvent.getData()), accelerationData);
// updatedValue = Arrays.toString(accelerationData);
updatedValue
=
formatByteFloatArray
(
ByteBuffer
.
wrap
(
messageEvent
.
getData
()));
textViewToUpdate
=
findViewById
(
R
.
id
.
value_wear_acceleration
);
topic
=
MQTT_TOPIC_POLAR_ACCELERATION
;
break
;
case
SUB_KEY_ROTATION_VECTOR:
float
[]
rotationData
=
new
float
[
3
];
writeFloatArray
(
ByteBuffer
.
wrap
(
messageEvent
.
getData
()),
rotationData
);
updatedValue
=
Arrays
.
toString
(
rotationData
);
// float[] rotationData = new float[3];
// writeFloatArray(ByteBuffer.wrap(messageEvent.getData()), rotationData);
// updatedValue = Arrays.toString(rotationData);
updatedValue
=
formatByteFloatArray
(
ByteBuffer
.
wrap
(
messageEvent
.
getData
()));
textViewToUpdate
=
findViewById
(
R
.
id
.
value_wear_rotation
);
topic
=
MQTT_TOPIC_POLAR_ROTATION
;
break
;
...
...
@@ -219,6 +221,20 @@ public class MainActivity extends AppCompatActivity implements
}
}
private
String
formatByteFloatArray
(
ByteBuffer
buffer
)
{
StringBuilder
sb
=
new
StringBuilder
();
final
int
length
=
3
;
boolean
notFirst
=
false
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(
notFirst
)
{
sb
.
append
(
" : "
);
}
notFirst
=
true
;
sb
.
append
(
String
.
format
(
Locale
.
getDefault
(),
"%.2f"
,
buffer
.
getFloat
()));
}
return
sb
.
toString
();
}
private
void
writeFloatArray
(
ByteBuffer
input
,
float
[]
output
)
{
for
(
int
i
=
0
;
i
<
output
.
length
;
i
++)
{
output
[
i
]
=
input
.
getFloat
();
...
...
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