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.
main.cpp
- Committer:
- seyfrid_L
- Date:
- 2017-10-09
- Revision:
- 0:179836d5c9f5
- Child:
- 1:d77819d695e3
File content as of revision 0:179836d5c9f5:
#include "mbed.h"
#include "MMA8451Q.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
#define XYZ_DATA_CFG (0x04<<1)
#define FF_MT_CFG (0x38<<1)
#define FF_MT_SRC 0x07
Serial terminal(USBTX,USBRX);
float xAxis;
float yAxis;
float zAxis;
int freefall (){
if ((FF_MT_SRC >> 0x07) & 1){
//zavolaj obsluhu prerusenia
return 0;
}
return 1;
}
int main(void) {
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
terminal.printf("x y z\n\r");
while(true){
xAxis = acc.getAccX();
yAxis = acc.getAccY();
zAxis = acc.getAccZ();
wait(2.0);
terminal.printf("%1.2f, %1.2f, %1.2f,\n\r", xAxis, yAxis, zAxis);
}
}