diff --git a/project/ble.c b/project/ble.c index 971429ce3fee3c851aef398f4b4b02d4c250fe40..46065199bc1adffbb19635c0aeef5ea01d116910 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 dccc4866c136b30c8e2f26a06f440ad6190e6376..8808eeed5edae5257093e19b543b1a81a2934143 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 949175259edaed352e2407dd38861bbb5a392725..e5b8cae8bd412bd3eee6e7558b63af40e4d9a777 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) {