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: BSP_B-L475E-IOT01
Revision 2:4cfbd0da7242, committed 2018-12-06
- Comitter:
- vicara
- Date:
- Thu Dec 06 16:38:26 2018 +0000
- Parent:
- 1:288cdb94027a
- Commit message:
- fixed
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 06 15:54:33 2018 +0000
+++ b/main.cpp Thu Dec 06 16:38:26 2018 +0000
@@ -66,14 +66,27 @@
led3 = led3_status;
}
+
+bool is_board_horizontal(int16_t pDataXYZ[3]) {
+ return (pDataXYZ[2] < 1030 && pDataXYZ[2] > 950) || (pDataXYZ[2] < -950 && pDataXYZ[2] > -1030);
+}
+
+bool is_board_vertical_short(int16_t pDataXYZ[3]) {
+ return (pDataXYZ[0] < -950 && pDataXYZ[0] > -1030) || (pDataXYZ[0] < 1030 && pDataXYZ[0] > 950);
+}
+
+bool is_board_vertical_long(int16_t pDataXYZ[3]) {
+ return (pDataXYZ[1] < 1030 && pDataXYZ[1] > 950) || (pDataXYZ[1] < -950 && pDataXYZ[1] > -1030);
+}
+
void write_positions_on_file() {
int16_t pDataXYZ[3] = {0};
BSP_ACCELERO_AccGetXYZ(pDataXYZ);
- if ((pDataXYZ[0] < -950 && pDataXYZ[0] > -1030) || (pDataXYZ[0] < 1030 && pDataXYZ[0] > 950)) {
+ if (is_board_vertical_short(pDataXYZ)) {
fprintf(f, "%d\n", 0);
- } else if ((pDataXYZ[1] < 1030 && pDataXYZ[1] > 950) || (pDataXYZ[1] < -950 && pDataXYZ[1] > -1030)) {
+ } else if (is_board_vertical_long(pDataXYZ)) {
fprintf(f, "%d\n", 1);
- } else if ((pDataXYZ[2] < 1030 && pDataXYZ[2] > 950) || (pDataXYZ[2] < -950 && pDataXYZ[2] > -1030)) {
+ } else if (is_board_horizontal(pDataXYZ)) {
fprintf(f, "%d\n", 2);
} else {
fprintf(f, "%d\n", -1);
@@ -142,17 +155,7 @@
printf("ACCELERO_Z = %d\n\n", pDataXYZ[2]);
}
-bool is_board_horizontal() {
- return (pDataXYZ[2] < 1030 && pDataXYZ[2] > 950) || (pDataXYZ[2] < -950 && pDataXYZ[2] > -1030);
-}
-bool is_board_vertical_short() {
- return (pDataXYZ[0] < -950 && pDataXYZ[0] > -1030) || (pDataXYZ[0] < 1030 && pDataXYZ[0] > 950);
-}
-
-bool is_board_vertical_long() {
- return (pDataXYZ[1] < 1030 && pDataXYZ[1] > 950) || (pDataXYZ[1] < -950 && pDataXYZ[1] > -1030);
-}
void ticker_attach() {
queue.call(write_positions_on_file);