#include "system/includes.h" /*#include "btcontroller_config.h"*/ #include "btstack/btstack_task.h" #include "app_config.h" #include "app_action.h" #include "asm/pwm_led.h" #include "tone_player.h" #include "ui_manage.h" #include "gpio.h" #include "app_main.h" #include "asm/charge.h" #include "update.h" #include "app_power_manage.h" #include "audio_config.h" #include "app_charge.h" #include "bt_profile_cfg.h" #include "dev_manager/dev_manager.h" #include "update_loader_download.h" #include "LIS2DH12.h" #define xlog(format, ...) printf("[%s] " format, __func__, ##__VA_ARGS__) u16 xtell_i2c_test_id; u16 print_motion_data_id; // Task to print motion data periodically void print_motion_data_task(void) { motion_data_t current_motion; axis_info_xtell current_accel; // Get the latest motion data get_motion_data(¤t_motion); current_accel = get_current_accel_mss(); xlog("--- Motion Data ---\n"); xlog("Accel (m/s^2): X=%.2f, Y=%.2f, Z=%.2f\n", current_accel.x, current_accel.y, current_accel.z); xlog("Velo (m/s): X=%.2f, Y=%.2f, Z=%.2f\n", current_motion.velocity.x, current_motion.velocity.y, current_motion.velocity.z); xlog("Dist (m): X=%.2f, Y=%.2f, Z=%.2f\n", current_motion.distance.x, current_motion.distance.y, current_motion.distance.z); xlog("-------------------\n"); } void create_process(u16* pid,char* name, void *priv, void (*func)(void *priv), u32 msec){ xlog("1 name=%s, pid =%d\n",name,*pid); if (*pid != 0) return; *pid = sys_timer_add(priv, func, msec); xlog("2 name=%s, pid =%d\n",name,*pid); } void xtell_main(void){ soft_iic_init(0); // 引脚选择在demo_cf.h中 extern u8 LIS2DH12_Config(void); LIS2DH12_Config(); // This task runs every 200ms to perform the calculations create_process(&xtell_i2c_test_id, "xtell_i2c_test",NULL, xtell_i2c_test, SAMPLING_PERIOD_S*1000); // This task runs every 1000ms to print the results create_process(&print_motion_data_id, "print_motion_data_task", NULL, print_motion_data_task, 1000); }