From d3c0ab203dea28d12da9f30a6b346008f153b093 Mon Sep 17 00:00:00 2001 From: Aapo Torkkeli <aamato@utu.fi> Date: Tue, 12 Nov 2019 12:17:48 +0200 Subject: [PATCH] Proper orientation numbers. --- project/ble.c | 4 ++-- project/imu.c | 22 +++++++++++++++------- project/main.c | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/project/ble.c b/project/ble.c index 971429c..4606519 100644 --- a/project/ble.c +++ b/project/ble.c @@ -124,8 +124,8 @@ APP_TIMER_DEF(send_orientation_timer_id); -extern uint8_t orientation; -uint8_t previous_orientation; +extern uint32_t orientation; +uint32_t previous_orientation; NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/ diff --git a/project/imu.c b/project/imu.c index dccc486..8808eee 100644 --- a/project/imu.c +++ b/project/imu.c @@ -64,7 +64,15 @@ #define NUM_TAPS 58 #define BLOCK_SIZE 28 -extern uint8_t orientation; +#define ORIENTATION_FIVE 500 +#define ORIENTATION_FOUR 400 +#define ORIENTATION_THREE 300 +#define ORIENTATION_TWO 200 +#define ORIENTATION_ONE 100 +#define ORIENTATION_ZERO 0 + + +extern uint32_t orientation; float32_t x_axis; float32_t y_axis; @@ -161,23 +169,23 @@ void calculate_orientation(){ if ( (z_axis_abs > x_axis_abs) && (z_axis_abs > y_axis_abs)) { // base orientation on Z if (z_axis > 0) { - orientation = (uint8_t) 0x0; + orientation = (uint32_t) ORIENTATION_ZERO; } else { - orientation = (uint8_t) 0x1; + orientation = (uint32_t) ORIENTATION_ONE; } } else if ( (y_axis_abs > x_axis_abs) && (y_axis_abs > z_axis_abs)) { // base orientation on Y if (y_axis > 0) { - orientation = (uint8_t) 0x2; + orientation = (uint32_t) ORIENTATION_TWO; } else { - orientation = (uint8_t) 0x3; + orientation = (uint32_t) ORIENTATION_THREE; } } else { // base orientation on X if (x_axis < 0) { - orientation = (uint8_t) 0x4; + orientation = (uint32_t) ORIENTATION_FOUR; } else { - orientation = (uint8_t) 0x5; + orientation = (uint32_t) ORIENTATION_FIVE; } } } diff --git a/project/main.c b/project/main.c index 9491752..e5b8cae 100644 --- a/project/main.c +++ b/project/main.c @@ -5,7 +5,7 @@ #include "imu.h" #include "ble.h" -uint8_t orientation; +uint32_t orientation; int main(void) { -- GitLab