mcu_hi3321_watch/tjd/ui/app/motion_sensing_game/TjdUiAppMSGameModel.cpp
2025-05-26 20:15:20 +08:00

64 lines
1.9 KiB
C++

#include "TjdUiAppMSGameModel.h"
#include "TjdUiAppMSGamePresenter.h"
#include "ble_api.h"
#include "service_gsensor.h"
#include "sys_config.h"
#include "gsensor_port.h"
#define ENABLE_PRINT_INFO 1
#if ENABLE_PRINT_INFO
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) // 一般信息打印宏控制
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) // 警告信息打印一般常开
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) // 错误信息打印一般常开
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__) // 调试信息打印一般常开
#else
#define static_print_info(...)
#define static_print_warn(...)
#define static_print_error(...)
#define static_print_debug(...)
#endif
namespace TJD {
GsensorData &TjdUiAppMSGameModel::GetGsensorData(void)
{
gsensor_xyz_info xyzInfo = {};
uint8_t count = tjd_service_gs_get_fifo_count(GSEN_SERVICE_PRODUCTION);
if (count == 0) {
return data_;
}
tjd_service_gs_get_xyz_fifo(GSEN_SERVICE_PRODUCTION, &xyzInfo, 1);
data_.x = xyzInfo.gsensor_x.raw_data;
data_.y = xyzInfo.gsensor_y.raw_data;
data_.z = xyzInfo.gsensor_z.raw_data;
return data_;
};
bool TjdUiAppMSGameModel::UploadGsensorData(const game_data_struct &data)
{
uint8_t retData[6]={0};
int16_t x_axis = data.X_Move_Distance;
int16_t y_axis = data.Y_Move_Distance;
int16_t z_axis = data.Speed_Throw;
retData[0] = x_axis >> 8 & 0x00ff;
retData[1] = x_axis & 0x00ff;
retData[2] = y_axis >>8 & 0x00ff;
retData[3] = y_axis & 0x00ff;
retData[4] = z_axis >> 8 & 0x00ff;
retData[5] = z_axis & 0x00ff;
tjd_msgame_send_gesensor_data(retData,sizeof(retData));
return true;
}
void TjdUiAppMSGameModel::EnterMsGameEvent(void)
{
// TODO: 通知App进入体感游戏模式
}
void TjdUiAppMSGameModel::ExitMsGameEvent(void)
{
// TODO: 通知App退出体感游戏模式
}
} // namespace TJD