Dependencies: mbed TSI MMA8451Q
Diff: main.cpp
- Revision:
- 2:316ddc3b4384
- Parent:
- 1:69b15daf7a7d
diff -r 69b15daf7a7d -r 316ddc3b4384 main.cpp --- a/main.cpp Thu Sep 19 19:36:36 2019 +0000 +++ b/main.cpp Thu Sep 19 20:45:17 2019 +0000 @@ -1,6 +1,6 @@ -/* #include "mbed.h" #include "MMA8451Q.h" +#include "TSISensor.h" #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) PinName const SDA = PTE25; @@ -25,17 +25,30 @@ PwmOut bled(LED3); printf("MMA8451 ID: %d\n", acc.getWhoAmI()); + + TSISensor tsi; + + float percent = 0.5; while (true) { float x, y, z; + float current_percent; + uint8_t distance; + + current_percent = tsi.readPercentage(); + if (current_percent != 0) + { + percent = current_percent; + } + x = abs(acc.getAccX()); y = abs(acc.getAccY()); z = abs(acc.getAccZ()); - rled = 1.0f - x; - gled = 1.0f - y; - bled = 1.0f - z; + rled = 1.0f - x * percent; + gled = 1.0f - y * percent; + bled = 1.0f - z * percent; wait(0.1f); - printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z); + //printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n\r", x, y, z); + //printf("percent: %f\t\tdistance: %d\n\r", percent, distance); } } -*/ \ No newline at end of file