Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Task_Motion_Sensor(void) {
- static int16_t prev_acc_X=0, prev_acc_Y=0, prev_acc_Z=0;
- int16_t acc_X=0, acc_Y=0, acc_Z=0;
- uint8_t rf, gf, bf;
- SET_BIT(DEBUG_TASK_MOTION_SENSOR); // set task motion sensor bit high
- read_full_xyz(&acc_X, &acc_Y, &acc_Z);
- rf = abs(prev_acc_X - acc_X) > ACC_SENSITIVITY ? 1 : 0;
- gf = abs(prev_acc_Y - acc_Y) > ACC_SENSITIVITY ? 1 : 0;
- bf = abs(prev_acc_Z - acc_Z) > ACC_SENSITIVITY ? 1 : 0;
- Control_RGB_LEDs(rf, gf, bf);
- Delay(FLASH_DELAY);
- Control_RGB_LEDs(0, 0, 0);
- Delay(FLASH_DELAY*2);
- prev_acc_X = acc_X;
- prev_acc_Y = acc_Y;
- prev_acc_Z = acc_Z;
- CLEAR_BIT(DEBUG_TASK_MOTION_SENSOR); // set task motion sensor bit low
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement