![](/media/cache/group/IMG_1289.JPG.50x50_q85.jpg)
Test program for MMA8451Q
main.cpp@1:61ac5dab9c3e, 2017-04-28 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Apr 28 02:01:43 2017 +0000
- Revision:
- 1:61ac5dab9c3e
- Parent:
- 0:b9f8aeb1c46b
- Child:
- 2:d6d06dc2ab11
Title print added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:b9f8aeb1c46b | 1 | #include "mbed.h" |
Rhyme | 0:b9f8aeb1c46b | 2 | #include "MMA8451Q.h" |
Rhyme | 0:b9f8aeb1c46b | 3 | #include "MSS.h" |
Rhyme | 0:b9f8aeb1c46b | 4 | |
Rhyme | 0:b9f8aeb1c46b | 5 | MMA8451Q *acc = 0 ; |
Rhyme | 0:b9f8aeb1c46b | 6 | |
Rhyme | 0:b9f8aeb1c46b | 7 | int main() { |
Rhyme | 0:b9f8aeb1c46b | 8 | int16_t ix, iy, iz ; |
Rhyme | 0:b9f8aeb1c46b | 9 | float fx, fy, fz ; |
Rhyme | 0:b9f8aeb1c46b | 10 | |
Rhyme | 1:61ac5dab9c3e | 11 | #if 0 // for FRDM-KL25Z ONBOARDSENSOR |
Rhyme | 0:b9f8aeb1c46b | 12 | acc = new MMA8451Q(PTE25, PTE24, 0x1D) ; |
Rhyme | 0:b9f8aeb1c46b | 13 | #endif |
Rhyme | 1:61ac5dab9c3e | 14 | #if 1 // for MSU MMA8451Q on MSS |
Rhyme | 0:b9f8aeb1c46b | 15 | acc = new MMA8451Q(PIN_SDA, PIN_SCL, 0x1C) ; |
Rhyme | 0:b9f8aeb1c46b | 16 | #endif |
Rhyme | 1:61ac5dab9c3e | 17 | |
Rhyme | 1:61ac5dab9c3e | 18 | printf("=== test MMA8451Q for %s (%s) ===\n", BOARD_NAME, __DATE__) ; |
Rhyme | 0:b9f8aeb1c46b | 19 | |
Rhyme | 0:b9f8aeb1c46b | 20 | while(1) { |
Rhyme | 0:b9f8aeb1c46b | 21 | ix = acc->getRawX() ; |
Rhyme | 0:b9f8aeb1c46b | 22 | iy = acc->getRawY() ; |
Rhyme | 0:b9f8aeb1c46b | 23 | iz = acc->getRawZ() ; |
Rhyme | 0:b9f8aeb1c46b | 24 | fx = acc->getAccX() ; |
Rhyme | 0:b9f8aeb1c46b | 25 | fy = acc->getAccY() ; |
Rhyme | 0:b9f8aeb1c46b | 26 | fz = acc->getAccZ() ; |
Rhyme | 1:61ac5dab9c3e | 27 | printf("X = %6d [ %.2f ], Y = %6d [ %.2f ], Z = %6d [ %.2f ]\n", |
Rhyme | 0:b9f8aeb1c46b | 28 | ix, fx, iy, fy, iz, fz ) ; |
Rhyme | 0:b9f8aeb1c46b | 29 | wait(0.2) ; |
Rhyme | 0:b9f8aeb1c46b | 30 | } |
Rhyme | 0:b9f8aeb1c46b | 31 | } |