Demo from Seeed Studio's H3LIS331DL repository.
Dependencies: C12832 H3LIS331DL mbed
Code ported from Seeed Studio's H3LIS331DL repository.
License
The MIT License (MIT) Copyright (c) 2013 Seeed Technology Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Diff: main.cpp
- Revision:
- 0:b9d6b582470b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 08 22:26:21 2014 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "H3LIS331DL.h" +#include "C12832.h" + +//please get these value by running H3LIS331DL_AdjVal +#define VAL_X_AXIS 128 +#define VAL_Y_AXIS 61 +#define VAL_Z_AXIS 303 + +H3LIS331DL h3lis(p28, p27); +Serial pc(USBTX, USBRX); // tx, rx +C12832 lcd(p5, p7, p6, p8, p11); + +int main() { + h3lis.init(); + h3lis.importPara(VAL_X_AXIS,VAL_Y_AXIS,VAL_Z_AXIS); + + while(1) { + double accel[3] = {0.0, 0.0, 0.0}; + + h3lis.getAcceleration(accel); + pc.printf("X %1.3f Y %1.3f Z %1.3f\n", accel[0], accel[1], accel[2]); + lcd.printf("X %1.3f Y %1.3f Z %1.3f ", accel[0], accel[1], accel[2]); + lcd.locate(0,0); + wait_ms(100); + } +}