Initial commit
This commit is contained in:
commit
b46feebc28
5 changed files with 126 additions and 0 deletions
6
.directory
Normal file
6
.directory
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[Dolphin]
|
||||||
|
Timestamp=2019,1,6,21,10,47
|
||||||
|
Version=4
|
||||||
|
|
||||||
|
[Settings]
|
||||||
|
HiddenFilesShown=true
|
12
AndroidManifest.xml
Normal file
12
AndroidManifest.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="">
|
||||||
|
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26"/>
|
||||||
|
<application android:icon="@drawable/icon" android:label="">
|
||||||
|
<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
105
VMC_Processing_Step2.pde
Normal file
105
VMC_Processing_Step2.pde
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
import ketai.sensors.*;
|
||||||
|
|
||||||
|
KetaiSensor sensor;
|
||||||
|
float fontSize = 130*displayDensity;
|
||||||
|
float accelerometerX, accelerometerY, accelerometerZ, rotationX, rotationY, rotationZ;
|
||||||
|
ArrayList<Integer> valuesAccelX = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> valuesAccelY = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> valuesAccelZ = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> valuesRotX = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> valuesRotY = new ArrayList<Integer>();
|
||||||
|
ArrayList<Integer> valuesRotZ = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
sensor = new KetaiSensor(this);
|
||||||
|
sensor.start();
|
||||||
|
|
||||||
|
|
||||||
|
textAlign(CENTER, CENTER);
|
||||||
|
textSize(fontSize);
|
||||||
|
|
||||||
|
strokeWeight(6);
|
||||||
|
smooth();
|
||||||
|
}
|
||||||
|
|
||||||
|
float mapNum;
|
||||||
|
void draw()
|
||||||
|
{
|
||||||
|
background(78, 93, 75);
|
||||||
|
|
||||||
|
drawGraph(valuesAccelX, height / 2 - fontSize * 4);
|
||||||
|
drawGraph(valuesAccelY, height / 2 - fontSize * 3);
|
||||||
|
drawGraph(valuesAccelZ, height / 2 - fontSize * 2);
|
||||||
|
drawGraph(valuesRotX, height / 2 + fontSize * 3);
|
||||||
|
drawGraph(valuesRotY, height / 2 + fontSize * 4);
|
||||||
|
drawGraph(valuesRotZ, height / 2 + fontSize * 5);
|
||||||
|
|
||||||
|
fill(255);
|
||||||
|
text("Accelerometer:", 0, -fontSize*5.5, width, height);
|
||||||
|
mapNum = mapColor(accelerometerX);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("x: " + nfp(accelerometerX, 1, 3), 0, -fontSize*4, width, height);
|
||||||
|
mapNum = mapColor(accelerometerY);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("y: " + nfp(accelerometerY, 1, 3), 0, -fontSize*3, width, height);
|
||||||
|
mapNum = mapColor(accelerometerZ);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("z: " + nfp(accelerometerZ, 1, 3), 0, -fontSize*2, width, height);
|
||||||
|
fill(255);
|
||||||
|
text("Gyroscope:", 0, fontSize*1.5, width, height);
|
||||||
|
mapNum = mapColor(rotationX);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("x: " + nfp(rotationX, 1, 3), 0, fontSize*3, width, height);
|
||||||
|
mapNum = mapColor(rotationY);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("y: " + nfp(rotationY, 1, 3), 0, fontSize*4, width, height);
|
||||||
|
mapNum = mapColor(rotationZ);
|
||||||
|
fill(mapNum, 255-mapNum, 0);
|
||||||
|
text("z: " + nfp(rotationZ, 1, 3), 0, fontSize*5, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
float mapColor(float in){
|
||||||
|
return map(in, -9.83, 9.83, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawGraph(ArrayList<Integer> values, float margin){
|
||||||
|
float lineWidth = (float) width / (values.size() - 1);
|
||||||
|
for (int i=0; i < values.size() - 1; i++) {
|
||||||
|
line(i * lineWidth, margin + values.get(i), (i + 1) * lineWidth, margin + values.get(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onAccelerometerEvent(float x, float y, float z)
|
||||||
|
{
|
||||||
|
valuesAccelX.add(int(x * 10));
|
||||||
|
while(valuesAccelX.size() > 10)
|
||||||
|
valuesAccelX.remove(0);
|
||||||
|
valuesAccelY.add(int(y * 10));
|
||||||
|
while(valuesAccelY.size() > 10)
|
||||||
|
valuesAccelY.remove(0);
|
||||||
|
valuesAccelZ.add(int(z * 10));
|
||||||
|
while(valuesAccelZ.size() > 10)
|
||||||
|
valuesAccelZ.remove(0);
|
||||||
|
|
||||||
|
accelerometerX = x;
|
||||||
|
accelerometerY = y;
|
||||||
|
accelerometerZ = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onGyroscopeEvent(float x, float y, float z)
|
||||||
|
{
|
||||||
|
valuesRotX.add(int(x * 10));
|
||||||
|
while(valuesRotX.size() > 10)
|
||||||
|
valuesRotX.remove(0);
|
||||||
|
valuesRotY.add(int(y * 10));
|
||||||
|
while(valuesRotY.size() > 10)
|
||||||
|
valuesRotY.remove(0);
|
||||||
|
valuesRotZ.add(int(z * 10));
|
||||||
|
while(valuesRotZ.size() > 10)
|
||||||
|
valuesRotZ.remove(0);
|
||||||
|
|
||||||
|
rotationX = x;
|
||||||
|
rotationY = y;
|
||||||
|
rotationZ = z;
|
||||||
|
}
|
1
code/sketch.properties
Normal file
1
code/sketch.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
component=app
|
2
sketch.properties
Normal file
2
sketch.properties
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
mode=Android
|
||||||
|
mode.id=processing.mode.android.AndroidMode
|
Loading…
Reference in a new issue