From 1a88043b7a3608ae36e2cf2161a8bed012c8062b Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 5 Jan 2019 22:22:45 +0100 Subject: [PATCH] Inital commit --- AndroidManifest.xml | 12 ++++++++ VMC_Processing_Step1.pde | 59 ++++++++++++++++++++++++++++++++++++++++ code/sketch.properties | 1 + sketch.properties | 2 ++ 4 files changed, 74 insertions(+) create mode 100644 AndroidManifest.xml create mode 100644 VMC_Processing_Step1.pde create mode 100644 code/sketch.properties create mode 100644 sketch.properties diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..5dfce5c --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/VMC_Processing_Step1.pde b/VMC_Processing_Step1.pde new file mode 100644 index 0000000..c33972b --- /dev/null +++ b/VMC_Processing_Step1.pde @@ -0,0 +1,59 @@ +import ketai.sensors.*; + +KetaiSensor sensor; +float fontSize = 130*displayDensity; +float accelerometerX, accelerometerY, accelerometerZ, rotationX, rotationY, rotationZ; + +void setup() +{ + sensor = new KetaiSensor(this); + sensor.start(); + textAlign(CENTER, CENTER); + textSize(fontSize); +} + +float mapNum; +void draw() +{ + background(78, 93, 75); + 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 onAccelerometerEvent(float x, float y, float z) +{ + accelerometerX = x; + accelerometerY = y; + accelerometerZ = z; +} + +void onGyroscopeEvent(float x, float y, float z) +{ + rotationX = x; + rotationY = y; + rotationZ = z; +} diff --git a/code/sketch.properties b/code/sketch.properties new file mode 100644 index 0000000..c6c5075 --- /dev/null +++ b/code/sketch.properties @@ -0,0 +1 @@ +component=app diff --git a/sketch.properties b/sketch.properties new file mode 100644 index 0000000..6c0182c --- /dev/null +++ b/sketch.properties @@ -0,0 +1,2 @@ +mode=Android +mode.id=processing.mode.android.AndroidMode