Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q TSI USBDevice mbed
Fork of FRDM_MMA8451Q by
Revision 8:ffab051c58b5, committed 2013-05-17
- Comitter:
- vsluiter
- Date:
- Fri May 17 15:14:03 2013 +0000
- Parent:
- 7:70775be9f474
- Commit message:
- Working demo with mouse, rgb and fader. Board should be powered on 'KL25Z-USB'
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Fri May 17 15:14:03 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Fri May 17 15:14:03 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#354942d2fa38
--- a/main.cpp Tue Feb 19 23:46:45 2013 +0000
+++ b/main.cpp Fri May 17 15:14:03 2013 +0000
@@ -1,18 +1,32 @@
#include "mbed.h"
+#include "TSISensor.h"
#include "MMA8451Q.h"
+#include "USBMouse.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
int main(void) {
+ USBMouse mouse;
+ float pct_tsi = 0;
+ TSISensor tsi;
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
PwmOut rled(LED_RED);
PwmOut gled(LED_GREEN);
PwmOut bled(LED_BLUE);
-
+ rled.period_ms(2);
+ bled.period_ms(2);
+ gled.period_ms(2);
while (true) {
- rled = 1.0 - abs(acc.getAccX());
- gled = 1.0 - abs(acc.getAccY());
- bled = 1.0 - abs(acc.getAccZ());
- wait(0.1);
+ float accs[3];
+ float pct_tsi_t;
+ pct_tsi_t = tsi.readPercentage();
+ pct_tsi = pct_tsi_t == 0 && pct_tsi > 0.1 ? pct_tsi : pct_tsi_t;
+ acc.getAccAllAxis(accs);
+ rled = 1.0 - (abs(accs[0])*pct_tsi);
+ gled = 1.0 - (abs(accs[1])*pct_tsi);
+ bled = 1.0 - (abs(accs[2])*pct_tsi);
+ mouse.move(accs[0]*10,accs[1]*-10);
+ wait(0.001);
}
}
