1531 lines
49 KiB
C
1531 lines
49 KiB
C
/*----------------------------------------------------------------------------
|
||
* Copyright (c) Fenda Technologies Co., Ltd. 2021. All rights reserved.
|
||
*
|
||
* Description: sql_fit.c
|
||
*
|
||
* Author: saimen
|
||
*
|
||
* Create: 2024-06-08
|
||
*--------------------------------------------------------------------------*/
|
||
|
||
#include "sys_typedef.h"
|
||
#include "sys_config.h"
|
||
#include "linux/crc32.h"
|
||
#include "sql_fit.h"
|
||
|
||
#include <stdlib.h> //测试
|
||
// #include <string.h>
|
||
#include <time.h> //测试
|
||
|
||
/**********************************************************************************************************************
|
||
* DEFINE
|
||
*/
|
||
#define ENABLE_STATIC_PRINT false
|
||
#define static_print_error(...) sys_sql_log_e(__VA_ARGS__) //错误信息打印一般常开
|
||
#define static_print_warn(...) sys_sql_log_w(__VA_ARGS__) //警告信息打印一般常开
|
||
#if ENABLE_STATIC_PRINT
|
||
#define static_print_debug(...) sys_sql_log_d(__VA_ARGS__)
|
||
#else
|
||
#define static_print_debug(...)
|
||
#endif
|
||
|
||
|
||
#define FILE_VERSION_FIT 1
|
||
#define FILE_PATH_FIT "/system/sql_fit.bin"
|
||
|
||
|
||
//健康数据:用户信息,健康配置信息,天数据。
|
||
typedef struct {
|
||
uint16_t weight; //体重: kg * 10
|
||
uint8_t gender; //性别: 0=男; 1=女
|
||
uint8_t age; //年龄
|
||
uint8_t height; //身高: cm
|
||
char name[32]; //用户昵称
|
||
} user_info_t;
|
||
|
||
typedef struct {
|
||
uint8_t bright_screen_sw; //抬腕亮屏开关: 0=关闭, 1=开启
|
||
uint8_t switch_screen_sw; //翻腕切屏开关: 0=关闭, 1=开启
|
||
uint8_t sedentary_remind_sw; //久坐提醒开关: 0=关闭, 1=开启
|
||
uint8_t sleep_measure_sw; //睡眠测量开关: 0=关闭, 1=开启
|
||
uint8_t hr_cont_measure_sw; //心率连续测量开关: 0=关闭, 1=开启
|
||
uint8_t spo2_cont_measure_sw; //血氧连续测量开关: 0=关闭, 1=开启
|
||
uint8_t stress_cont_measure_sw; //压力连续测量开关: 0=关闭, 1=开启
|
||
uint32_t goal_sleep_time_th; //目标睡眠时长阈值: min
|
||
uint32_t goal_step_th; //目标步数阈值: step
|
||
uint8_t hr_upper_remind_sw; //心率过高提醒开关: 0=关闭, 1=开启
|
||
uint8_t hr_upper_remind_th; //心率过高提醒阈值: bpm
|
||
uint8_t hr_lower_remind_sw; //心率过低提醒开关: 0=关闭, 1=开启
|
||
uint8_t hr_lower_remind_th; //心率过低提醒阈值: bpm
|
||
uint8_t spo2_lower_remind_sw; //血氧过低提醒开关: 0=关闭, 1=开启
|
||
uint8_t spo2_lower_remind_th; //血氧过低提醒阈值: [0~100]%
|
||
|
||
// 四叶草数据
|
||
uint8_t goalTaskNum; //目标任务数
|
||
uint8_t currentTaskNum; //当前任务数
|
||
uint8_t goalStandNum; //目标站立次数
|
||
uint8_t currentStandNum; //当前站立次数
|
||
uint16_t goalCalorieNum; //目标卡路里消耗: kcal
|
||
uint16_t currentCalorieNum; //当前卡路里消耗: kcal
|
||
uint8_t goalStrengthTime; //目标强度训练时长: min
|
||
uint8_t currentStrengthTime; //当前强度训练时长: min
|
||
uint16_t goalStepNum; //目标步数: step
|
||
uint16_t currentStepNum; //当前步数: step
|
||
uint16_t goalDrinkNum; //目标喝水次数
|
||
uint16_t currentDrinkNum; //当前喝水次数
|
||
uint16_t currentSleepTime; //当前睡眠时长: min
|
||
uint16_t goalSleepTime; //目标睡眠时长: min
|
||
uint8_t goalMedicineNum; //目标吃药次数
|
||
uint8_t currentMedicineNum; //当前吃药次数
|
||
uint8_t curBloodPressureMeasurTime; //当前血压测量次数
|
||
uint8_t goalBloodPressureMeasurTime; //目标血压测量次数
|
||
uint16_t curEarlySleepTime; //当前早睡时间: min
|
||
uint16_t goalEarlySleepTime; //目标早睡时间: min
|
||
bool sleepEarly; //是否早睡
|
||
bool custom123; //自定义123开关
|
||
bool prayToBuddha; //是否礼佛
|
||
bool religious; //是否礼拜
|
||
bool pray; //是否祈祷
|
||
bool hascustomtask; //是否有自定义任务
|
||
custom_task_t customTask[CUSTOM_TASK_NUM];//自定义任务 CUSTOM_TASK_NUM个
|
||
|
||
uint8_t heartRateRemindValue[5]; //心率提醒选择下标
|
||
int timeRemindValue; //时间提醒选择下标
|
||
int distRemindValue; //单段提醒距离选择下标
|
||
uint8_t hand_up_flag; //抬手标志
|
||
|
||
} health_cfg_t;
|
||
|
||
typedef struct {
|
||
uint32_t timestamp; //时间戳,表示属于哪一天
|
||
uint64_t hr_last_time; //心率最近测量时间: timestamp
|
||
uint8_t hr_last_val; //心率最近测量值: bpm
|
||
uint8_t hr_max; //心率最大值: bpm
|
||
uint8_t hr_min; //心率最小值: bpm
|
||
uint8_t hr_resting; //静息心率: bpm
|
||
uint32_t spo2_last_time; //血氧最近测量时间: timestamp
|
||
uint8_t spo2_last_val; //血氧最近测量值: [0~100]%
|
||
uint8_t spo2_max; //血氧最大值: [0~100]%
|
||
uint8_t spo2_min; //血氧最小值: [0~100]%
|
||
uint32_t stress_last_time; //压力最近测量时间: timestamp
|
||
uint8_t stress_last_val; //压力最近测量值: [0~100]%
|
||
uint8_t stress_max; //压力最大值: [0~100]%
|
||
uint8_t stress_min; //压力最小值: [0~100]%
|
||
uint8_t cadence_step; //步频(XXX步/分钟)
|
||
uint32_t total_step; //总步数: step
|
||
uint32_t total_calorie; //总热量: kcal
|
||
uint32_t total_distance; //总距离: m
|
||
uint32_t last_step; //上一次步数: step
|
||
uint32_t last_calorie; //上一次热量: kcal
|
||
uint32_t last_distance; //上一次距离: m
|
||
int8_t last_measure_time; //最近一次测量时间: hour
|
||
uint32_t total_exercise_time; //总运动时长: min
|
||
uint32_t total_sport_time; //总运动时长: s
|
||
sleep_total_data_t sleep_total_data; //总睡眠数据
|
||
} health_day_data_t;
|
||
|
||
#pragma pack(4) //alignment 4 bytes
|
||
typedef struct {
|
||
uint32_t init_flag:8; //标记模块是否初始化。=0 无效数据;=1 正常数据;=2 恢复数据。
|
||
uint32_t version:8; //结构体版本
|
||
|
||
user_info_t user_info;
|
||
health_cfg_t health_cfg;
|
||
health_day_data_t health_day[7];
|
||
|
||
uint8_t hr_day_array[HR_DAY_MAX_NUM]; //心率一天的数据,每5分钟记录一次
|
||
uint8_t spo2_day_array[SPO2_DAY_MAX_NUM]; //血氧一天的数据,每1小时记录一次
|
||
uint8_t stress_day_array[STRESS_DAY_MAX_NUM]; //压力一天的数据,每1小时记录一次
|
||
uint32_t step_day_array[DAILYDATA_DAY_MAX_NUM]; //步数一天的数据,每1小时记录一次
|
||
uint16_t calorie_day_array[DAILYDATA_DAY_MAX_NUM]; //热量一天的数据,每1小时记录一次
|
||
uint16_t distance_day_array[DAILYDATA_DAY_MAX_NUM]; //距离一天的数据,每1小时记录一次
|
||
uint16_t exertime_day_array[DAILYDATA_DAY_MAX_NUM]; //运动时长一天的数据,每1小时记录一次
|
||
uint8_t stress_record_day; //记录压力记录的天数
|
||
uint8_t* stress_week_data[7]; //压力周数据
|
||
|
||
uint8_t sport_popup_flag_arry[3]; //运动弹窗标志
|
||
//uint8_t revs[1]; //保证8字节对齐
|
||
uint32_t crc32;
|
||
} sql_fit_t;
|
||
#pragma pack()
|
||
|
||
sql_fit_t g_sql_fit;
|
||
static bool g_sql_fit_need_save = false;
|
||
|
||
/**********************************************************************************************************************
|
||
* 固定接口
|
||
*/
|
||
|
||
//清空当天运动数据
|
||
void sql_fit_clear_cur_data(uint8_t week_day)
|
||
{
|
||
|
||
//清除当天的运动统计数据
|
||
memset(&g_sql_fit.health_day[week_day], 0, sizeof(health_day_data_t));
|
||
g_sql_fit.health_day[week_day].hr_max = 0;
|
||
g_sql_fit.health_day[week_day].hr_min = 255;
|
||
g_sql_fit.health_day[week_day].spo2_max = 0;
|
||
g_sql_fit.health_day[week_day].spo2_min = 100;
|
||
g_sql_fit.health_day[week_day].spo2_last_val = 0; //血氧最近测量值: [0~100]%
|
||
g_sql_fit.health_day[week_day].stress_max = 0;
|
||
g_sql_fit.health_day[week_day].stress_min = 100;
|
||
g_sql_fit.health_day[week_day].last_measure_time = -1;
|
||
|
||
//清除天运动健康明细数据。
|
||
for(int i=0; i<HR_DAY_MAX_NUM; i++) g_sql_fit.hr_day_array[i] = 0; //初始化血氧数组
|
||
for(int i=0; i<SPO2_DAY_MAX_NUM; i++) g_sql_fit.spo2_day_array[i] = 0; //初始化血氧数组
|
||
for(int i=0; i< STRESS_DAY_MAX_NUM; i++) g_sql_fit.stress_day_array[i] = 0; //初始化压力数组
|
||
for(int i=0; i< DAILYDATA_DAY_MAX_NUM; i++)
|
||
{
|
||
g_sql_fit.step_day_array[i] = 0;
|
||
g_sql_fit.calorie_day_array[i] = 0;
|
||
g_sql_fit.exertime_day_array[i] = 0;
|
||
g_sql_fit.distance_day_array[i] = 0;
|
||
}
|
||
|
||
g_sql_fit.stress_week_data[week_day] = NULL;
|
||
|
||
//清空当天四叶草数据
|
||
g_sql_fit.health_cfg.currentTaskNum = 0;
|
||
g_sql_fit.health_cfg.currentStandNum = 0;
|
||
g_sql_fit.health_cfg.currentCalorieNum = 0;
|
||
g_sql_fit.health_cfg.currentStrengthTime = 0;
|
||
g_sql_fit.health_cfg.currentStepNum = 0;
|
||
g_sql_fit.health_cfg.currentDrinkNum = 0;
|
||
g_sql_fit.health_cfg.currentMedicineNum = 0;
|
||
g_sql_fit_need_save = true;
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* @brief 重置运动健康数据.
|
||
* @return int|返回结果,0=成功.
|
||
*/
|
||
static int sql_fit_restore(void)
|
||
{
|
||
uint8_t i;
|
||
int ret = RET_SUCCESS;
|
||
|
||
static_print_warn("sql_fit_restore()\r\n");
|
||
memset((uint8_t*)&g_sql_fit, 0, sizeof(sql_fit_t));
|
||
g_sql_fit.version = FILE_VERSION_FIT;
|
||
g_sql_fit.init_flag = 1;
|
||
|
||
strcpy(g_sql_fit.user_info.name, "TH18A_LEFUN");
|
||
g_sql_fit.user_info.weight = 600; //体重: kg * 10
|
||
g_sql_fit.user_info.gender = 0; //性别: 0=男; 1=女
|
||
g_sql_fit.user_info.age = 27; //年龄
|
||
g_sql_fit.user_info.height = 175; //身高: cm
|
||
|
||
g_sql_fit.health_cfg.bright_screen_sw = 1; //抬腕亮屏开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.switch_screen_sw = 0; //翻腕切屏开关: 0=关闭, 1=开启
|
||
|
||
g_sql_fit.health_cfg.sedentary_remind_sw = 1; //久坐提醒开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.sleep_measure_sw = 1; //睡眠测量开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.hr_cont_measure_sw = 0; //心率连续测量开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.spo2_cont_measure_sw = 0; //血氧连续测量开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.stress_cont_measure_sw = 0; //压力连续测量开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.goal_sleep_time_th = 480; //目标睡眠时长阈值: min
|
||
g_sql_fit.health_cfg.goal_step_th = 10000; //目标步数阈值: step
|
||
g_sql_fit.health_cfg.hr_upper_remind_sw = 0; //心率过高提醒开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.hr_upper_remind_th = 0; //心率过高提醒阈值
|
||
g_sql_fit.health_cfg.hr_lower_remind_sw = 0; //心率过低提醒开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.hr_lower_remind_th = 0; //心率过低提醒阈值
|
||
g_sql_fit.health_cfg.spo2_lower_remind_sw = 0; //血氧过低提醒开关: 0=关闭, 1=开启
|
||
g_sql_fit.health_cfg.spo2_lower_remind_th = 0; //血氧过低提醒阈值
|
||
|
||
for (int i=0; i<7; i++) {
|
||
g_sql_fit.health_day[i].hr_max = 0;
|
||
g_sql_fit.health_day[i].hr_min = 255;
|
||
g_sql_fit.health_day[i].spo2_max = 0;
|
||
g_sql_fit.health_day[i].spo2_min = 100;
|
||
g_sql_fit.health_day[i].spo2_last_val = 0; //血氧最近测量值: [0~100]%
|
||
g_sql_fit.health_day[i].stress_max = 0;
|
||
g_sql_fit.health_day[i].stress_min = 100;
|
||
g_sql_fit.health_day[i].last_measure_time = -1;
|
||
}
|
||
|
||
for(int i=0; i<SPO2_DAY_MAX_NUM; i++) g_sql_fit.spo2_day_array[i] = 0; //初始化血氧数组
|
||
|
||
g_sql_fit.stress_record_day = 0;
|
||
for(int i=0; i< STRESS_DAY_MAX_NUM; i++) g_sql_fit.stress_day_array[i] = 0; //初始化压力数组
|
||
for (int i = 0; i < 7; i++) {g_sql_fit.stress_week_data[i] = NULL;}
|
||
|
||
//初始化运动弹窗标志:0=不需要弹窗,1=需要弹窗/i = 0 表示距离弹窗,1 表示时间弹窗 ,2 表示卡路里弹窗...
|
||
for(int i=0; i< 3; i++) g_sql_fit.sport_popup_flag_arry[i] = 0;
|
||
//心率测试
|
||
// for(int i=0; i<288; i++) g_sql_fit.hr_day_array[i] = 155;
|
||
// g_sql_fit.hr_day_array[50] = 70;
|
||
// g_sql_fit.hr_day_array[60] = 80;
|
||
// g_sql_fit.hr_day_array[150] = 180;
|
||
|
||
//每日数据测试
|
||
// srand(time(NULL));
|
||
// for (int i=0; i<DAILYDATA_DAY_MAX_NUM; i++) {
|
||
// g_sql_fit.step_day_array[i] = rand() % 12;
|
||
// g_sql_fit.calorie_day_array[i] = rand() % 6;
|
||
// g_sql_fit.exertime_day_array[i] = rand() % 4;
|
||
// g_sql_fit.distance_day_array[i] = rand() % 8;
|
||
// }
|
||
// g_sql_fit.health_day[week_day].deep_sleep_time = 20520;
|
||
// g_sql_fit.health_day[week_day].light_sleep_time = 10260;
|
||
// for (int i=0; i<7; i++) {
|
||
// g_sql_fit.deep_sleep_time_array[i] = rand() % 8001;
|
||
// g_sql_fit.light_sleep_time_array[i] = rand() % 10001;
|
||
// }
|
||
|
||
// 四叶草数据初始化
|
||
g_sql_fit.health_cfg.goalTaskNum = 7;
|
||
g_sql_fit.health_cfg.currentTaskNum = 0;
|
||
g_sql_fit.health_cfg.goalStandNum = 200;
|
||
g_sql_fit.health_cfg.currentStandNum = 0;
|
||
g_sql_fit.health_cfg.goalCalorieNum = 200;
|
||
g_sql_fit.health_cfg.currentCalorieNum = 0;
|
||
g_sql_fit.health_cfg.goalStrengthTime = 35;
|
||
g_sql_fit.health_cfg.currentStrengthTime = 0;
|
||
g_sql_fit.health_cfg.goalStepNum = 2000;
|
||
g_sql_fit.health_cfg.currentStepNum = 0;
|
||
g_sql_fit.health_cfg.goalDrinkNum = 6;
|
||
g_sql_fit.health_cfg.currentDrinkNum = 0;
|
||
g_sql_fit.health_cfg.goalMedicineNum = 2;
|
||
g_sql_fit.health_cfg.currentMedicineNum = 0;
|
||
g_sql_fit.health_cfg.sleepEarly = false;
|
||
g_sql_fit.health_cfg.custom123 = false;
|
||
g_sql_fit.health_cfg.prayToBuddha = false;
|
||
g_sql_fit.health_cfg.religious = false;
|
||
g_sql_fit.health_cfg.pray = false;
|
||
|
||
g_sql_fit.health_cfg.heartRateRemindValue[0] = 0; //心率提醒选择下标
|
||
g_sql_fit.health_cfg.heartRateRemindValue[1] = 0; //心率提醒选择下标
|
||
g_sql_fit.health_cfg.heartRateRemindValue[2] = 0; //心率提醒选择下标
|
||
g_sql_fit.health_cfg.heartRateRemindValue[3] = 0; //心率提醒选择下标
|
||
g_sql_fit.health_cfg.heartRateRemindValue[4] = 1; //心率提醒选择下标
|
||
g_sql_fit.health_cfg.timeRemindValue = 30*60; //时间提醒选择下标
|
||
g_sql_fit.health_cfg.distRemindValue = 1000; //单段提醒距离选择下标
|
||
|
||
// 睡眠数据测试
|
||
// for (int i=0; i<7; i++) {
|
||
// g_sql_fit.health_day[i].sleep_total_data.mins_deep_sleep = (3+i)*60+20;
|
||
// g_sql_fit.health_day[i].sleep_total_data.mins_light_sleep = (8-i)*60+30;
|
||
// }
|
||
|
||
g_sql_fit_need_save = false;
|
||
return ret;
|
||
}
|
||
|
||
/**
|
||
* @brief 初始化运动健康数据.
|
||
* @return int|返回结果,0=成功.
|
||
*/
|
||
int sql_fit_init(void)
|
||
{
|
||
int ret = RET_SUCCESS;
|
||
uint32_t ui32_crc;
|
||
|
||
static_print_warn("[%s],sizeof(sql_fit_t) = %d\r\n", FILE_PATH_FIT, sizeof(sql_fit_t));
|
||
ui32_crc = Crc32Part(0, (const char *)&g_sql_fit, sizeof(sql_fit_t) - 4);
|
||
if (ui32_crc != g_sql_fit.crc32 || g_sql_fit.version != FILE_VERSION_FIT) {
|
||
sql_fit_restore();
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
/**
|
||
* @brief 获取运动健康数据信息.
|
||
* @output len|数据长度, path|数据文件路径.
|
||
* @return void*|数据指针.
|
||
*/
|
||
void* sql_fit_get_info(uint32_t *len, char **path)
|
||
{
|
||
g_sql_fit.crc32 = Crc32Part(0,(const char *)&g_sql_fit, sizeof(g_sql_fit) - 4);
|
||
*len = sizeof(g_sql_fit);
|
||
*path = (char*)FILE_PATH_FIT;
|
||
|
||
return &g_sql_fit;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置运动健康数据存储标志.
|
||
* @input value|数据存储标志,0=不需要存储,1=需要存储.
|
||
* @return void
|
||
*/
|
||
void sql_fit_set_save_flag(uint8_t value)
|
||
{
|
||
g_sql_fit_need_save = value;
|
||
}
|
||
|
||
/**
|
||
* @brief 获取运动健康数据存储标志.
|
||
* @return uint8_t|数据存储标志,0=不需要存储,1=需要存储.
|
||
*/
|
||
uint8_t sql_fit_get_save_flag(void)
|
||
{
|
||
return g_sql_fit_need_save;
|
||
}
|
||
|
||
|
||
|
||
/**********************************************************************************************************************
|
||
* 用户信息接口
|
||
*/
|
||
|
||
void sql_fit_set_user_gender(uint8_t gender)
|
||
{
|
||
static_print_debug("sql_fit_set_user_gender()");
|
||
if(g_sql_fit.user_info.gender != gender) {
|
||
g_sql_fit.user_info.gender = gender;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_user_gender(void)
|
||
{
|
||
return g_sql_fit.user_info.gender;
|
||
}
|
||
|
||
void sql_fit_set_user_weight(uint8_t weight)
|
||
{
|
||
static_print_debug("sql_fit_set_user_weight()");
|
||
if(g_sql_fit.user_info.weight != weight) {
|
||
g_sql_fit.user_info.weight = weight;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_user_weight(void)
|
||
{
|
||
return g_sql_fit.user_info.weight;
|
||
}
|
||
|
||
void sql_fit_set_user_height(uint8_t height)
|
||
{
|
||
static_print_debug("sql_fit_set_user_height()");
|
||
if(g_sql_fit.user_info.height != height) {
|
||
g_sql_fit.user_info.height = height;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_user_height(void)
|
||
{
|
||
return g_sql_fit.user_info.height;
|
||
}
|
||
|
||
void sql_fit_set_user_age(uint8_t age)
|
||
{
|
||
static_print_debug("sql_fit_set_user_age()");
|
||
if(g_sql_fit.user_info.age != age) {
|
||
g_sql_fit.user_info.age = age;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_user_age(void)
|
||
{
|
||
return g_sql_fit.user_info.age;
|
||
}
|
||
|
||
void sql_fit_set_user_name(const char *name)
|
||
{
|
||
static_print_debug("sql_fit_set_user_name()");
|
||
if(strcmp(g_sql_fit.user_info.name, name) != 0) {
|
||
strncpy_s(g_sql_fit.user_info.name, 32 , name, strlen(name));
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_get_user_name(char * name)
|
||
{
|
||
strncpy_s(name, 32 , g_sql_fit.user_info.name, strlen(g_sql_fit.user_info.name));
|
||
}
|
||
|
||
void sql_fit_set_hr_max(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_hr_max()");
|
||
if(g_sql_fit.health_day[week_day].hr_max != value) {
|
||
g_sql_fit.health_day[week_day].hr_max = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_hr_max(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_max;
|
||
}
|
||
|
||
void sql_fit_set_hr_min(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_hr_min()");
|
||
if(g_sql_fit.health_day[week_day].hr_min != value) {
|
||
g_sql_fit.health_day[week_day].hr_min = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_hr_min(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_min;
|
||
}
|
||
|
||
void sql_fit_set_last_hr(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_last_hr()");
|
||
if(g_sql_fit.health_day[week_day].hr_last_val != value) {
|
||
g_sql_fit.health_day[week_day].hr_last_val = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_last_hr(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_last_val;
|
||
}
|
||
|
||
void sql_fit_set_last_hr_timestamp(uint64_t timestamp, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_hr_max()");
|
||
if(g_sql_fit.health_day[week_day].hr_last_time != timestamp) {
|
||
g_sql_fit.health_day[week_day].hr_last_time = timestamp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint64_t sql_fit_get_last_hr_timestamp(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_last_time;
|
||
}
|
||
|
||
void sql_fit_set_hr_curdata(uint32_t index, uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_hr_curdata()");
|
||
if(index >= HR_DAY_MAX_NUM) {
|
||
static_print_error("index over HR_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.hr_day_array[index] != value) {
|
||
g_sql_fit.hr_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_hr_daydata(uint8_t** array)
|
||
{
|
||
*array = g_sql_fit.hr_day_array;
|
||
return HR_DAY_MAX_NUM;
|
||
}
|
||
|
||
/*血氧数据接口*/
|
||
uint8_t sql_fit_get_spo2_min(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].spo2_min;
|
||
}
|
||
|
||
void sql_fit_set_last_spo2(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_last_spo2()");
|
||
if(g_sql_fit.health_day[week_day].spo2_last_val != value) {
|
||
g_sql_fit.health_day[week_day].spo2_last_val = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_last_spo2(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].spo2_last_val;
|
||
}
|
||
|
||
uint8_t sql_fit_get_spo2_max(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].spo2_max;
|
||
}
|
||
|
||
void sql_fit_set_spo2_max(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_spo2_max()");
|
||
if(g_sql_fit.health_day[week_day].spo2_max != value) {
|
||
g_sql_fit.health_day[week_day].spo2_max = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_set_spo2_min(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_spo2_min()");
|
||
if(g_sql_fit.health_day[week_day].spo2_min != value) {
|
||
g_sql_fit.health_day[week_day].spo2_min = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_spo2_daydata(uint8_t** array)
|
||
{
|
||
*array = g_sql_fit.spo2_day_array;
|
||
return SPO2_DAY_MAX_NUM;
|
||
}
|
||
|
||
void sql_fit_set_spo2_curdata(uint32_t index, uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_spo2_curdata()");
|
||
if(index >= SPO2_DAY_MAX_NUM) {
|
||
static_print_error("index over SPO2_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.spo2_day_array[index] != value) {
|
||
g_sql_fit.spo2_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
int8_t sql_fit_get_spo2_curdata(uint8_t week_day) //获取当前血氧值
|
||
{
|
||
return g_sql_fit.health_day[week_day].spo2_last_val;
|
||
}
|
||
|
||
// 压力数据接口
|
||
uint8_t sql_fit_get_stress_record_day(void)
|
||
{
|
||
return g_sql_fit.stress_record_day;
|
||
}
|
||
|
||
void sql_fit_set_stress_record_day(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_stress_record_day()");
|
||
if(g_sql_fit.stress_record_day != value) {
|
||
g_sql_fit.stress_record_day = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_reset_stress_day_arry(uint8_t day)//重置一天的压力数据,并且将当天数据保存到周数据中
|
||
{
|
||
for (uint8_t i = 0; i < STRESS_DAY_MAX_NUM; i++ )
|
||
{
|
||
g_sql_fit.stress_day_array[i] = 0;
|
||
}
|
||
g_sql_fit.stress_week_data[day] = g_sql_fit.stress_day_array;
|
||
}
|
||
|
||
uint8_t sql_fit_get_stress_min(uint8_t week_day)
|
||
{
|
||
uint8_t stress_min = 100;
|
||
for (uint8_t i = 0; i < STRESS_DAY_MAX_NUM; i++ )
|
||
{
|
||
if (g_sql_fit.stress_day_array[i] < stress_min && g_sql_fit.stress_day_array[i] != 0)
|
||
{
|
||
stress_min = g_sql_fit.stress_day_array[i];
|
||
}
|
||
}
|
||
|
||
g_sql_fit.health_day[week_day].stress_min = stress_min;
|
||
return g_sql_fit.health_day[week_day].stress_min;
|
||
}
|
||
|
||
uint8_t sql_fit_get_stress_max(uint8_t week_day)
|
||
{
|
||
uint8_t stress_max = 0;
|
||
for (uint8_t i = 0; i < STRESS_DAY_MAX_NUM; i++ )
|
||
{
|
||
if (g_sql_fit.stress_day_array[i] > stress_max)
|
||
{
|
||
stress_max = g_sql_fit.stress_day_array[i];
|
||
}
|
||
}
|
||
|
||
g_sql_fit.health_day[week_day].stress_max = stress_max;
|
||
return g_sql_fit.health_day[week_day].stress_max;
|
||
}
|
||
|
||
void sql_fit_set_stress_max(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_stress_max()");
|
||
if(g_sql_fit.health_day[week_day].stress_max != value) {
|
||
g_sql_fit.health_day[week_day].stress_max = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_set_last_stress(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_last_stress()");
|
||
if(g_sql_fit.health_day[week_day].stress_last_val != value) {
|
||
g_sql_fit.health_day[week_day].stress_last_val = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_last_stress(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].stress_last_val;
|
||
}
|
||
|
||
void sql_fit_set_stress_min(uint8_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_stress_min()");
|
||
if(g_sql_fit.health_day[week_day].stress_min != value) {
|
||
g_sql_fit.health_day[week_day].stress_min = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_set_stress_curdata(uint32_t index, uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_stress_curdata()");
|
||
if(index > STRESS_DAY_MAX_NUM) {
|
||
static_print_error("index over stress_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.stress_day_array[index] != value) {
|
||
g_sql_fit.stress_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_sterss_daydata(uint8_t** array)
|
||
{
|
||
*array = g_sql_fit.stress_day_array;
|
||
return STRESS_DAY_MAX_NUM;
|
||
}
|
||
|
||
// 四叶草数据接口
|
||
void sql_fit_set_goalTaskNum_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalTaskNum_data()");
|
||
if(g_sql_fit.health_cfg.goalTaskNum != value) {
|
||
g_sql_fit.health_cfg.goalTaskNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_goalTaskNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalTaskNum;
|
||
}
|
||
|
||
void sql_fit_set_currentTaskNum_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentTaskNum_data()");
|
||
if(g_sql_fit.health_cfg.currentTaskNum != value) {
|
||
g_sql_fit.health_cfg.currentTaskNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_currentTaskNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentTaskNum;
|
||
}
|
||
|
||
void sql_fit_set_goalStandNum_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalStandNum_data()");
|
||
if(g_sql_fit.health_cfg.goalStandNum != value) {
|
||
g_sql_fit.health_cfg.goalStandNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_goalStandNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalStandNum;
|
||
}
|
||
|
||
void sql_fit_set_currentStandNum_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentStandNum_data()");
|
||
if(g_sql_fit.health_cfg.currentStandNum != value) {
|
||
g_sql_fit.health_cfg.currentStandNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_currentStandNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentStandNum;
|
||
}
|
||
|
||
void sql_fit_set_goalCalorieNum_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalCalorieNum_data()");
|
||
if(g_sql_fit.health_cfg.goalCalorieNum != value) {
|
||
g_sql_fit.health_cfg.goalCalorieNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_goalCalorieNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalCalorieNum;
|
||
}
|
||
|
||
void sql_fit_set_currentCalorieNum_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentCalorieNum_data()");
|
||
if(g_sql_fit.health_cfg.currentCalorieNum != value) {
|
||
g_sql_fit.health_cfg.currentCalorieNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_currentCalorieNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentCalorieNum;
|
||
}
|
||
|
||
void sql_fit_set_goalStrengthTime_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalStrengthTime_data()");
|
||
if(g_sql_fit.health_cfg.goalStrengthTime != value) {
|
||
g_sql_fit.health_cfg.goalStrengthTime = value;
|
||
g_sql_fit_need_save =true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_goalStrengthTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalStrengthTime;
|
||
}
|
||
|
||
void sql_fit_set_currentStrengthTime_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentStrengthTime_data()");
|
||
if(g_sql_fit.health_cfg.currentStrengthTime != value) {
|
||
g_sql_fit.health_cfg.currentStrengthTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_currentStrengthTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentStrengthTime;
|
||
}
|
||
|
||
void sql_fit_set_goalStepNum_data(uint32_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalStepNum_data()");
|
||
if(g_sql_fit.health_cfg.goalStepNum != value) {
|
||
g_sql_fit.health_cfg.goalStepNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_goalStepNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalStepNum;
|
||
}
|
||
|
||
void sql_fit_set_currentStepNum_data(uint32_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentStepNum_data()");
|
||
if(g_sql_fit.health_cfg.currentStepNum != value) {
|
||
g_sql_fit.health_cfg.currentStepNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_currentStepNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentStepNum;
|
||
}
|
||
|
||
void sql_fit_set_goalDrinkNum_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalDrinkNum_data()");
|
||
if(g_sql_fit.health_cfg.goalDrinkNum != value) {
|
||
g_sql_fit.health_cfg.goalDrinkNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_goalDrinkNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalDrinkNum;
|
||
}
|
||
|
||
void sql_fit_set_currentDrinkNum_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentDrinkNum_data()");
|
||
if(g_sql_fit.health_cfg.currentDrinkNum != value) {
|
||
g_sql_fit.health_cfg.currentDrinkNum = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_currentDrinkNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentDrinkNum;
|
||
}
|
||
|
||
void sql_fit_set_currentSleepTime_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_currentSleepTime_data()");
|
||
if(g_sql_fit.health_cfg.currentSleepTime != value) {
|
||
g_sql_fit.health_cfg.currentSleepTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_currentSleepTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentSleepTime;
|
||
}
|
||
|
||
void sql_fit_set_goalSleepTime_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalSleepTime_data()");
|
||
if(g_sql_fit.health_cfg.goalSleepTime != value) {
|
||
g_sql_fit.health_cfg.goalSleepTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_goalSleepTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalSleepTime;
|
||
}
|
||
|
||
uint8_t sql_fit_get_goalMedicineNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalMedicineNum;
|
||
}
|
||
|
||
uint8_t sql_fit_get_currentMedicineNum_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.currentMedicineNum;
|
||
}
|
||
|
||
void sql_fit_set_curBloodPressureMeasurTime_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_curBloodPressureMeasurTime_data()");
|
||
if(g_sql_fit.health_cfg.curBloodPressureMeasurTime != value){
|
||
g_sql_fit.health_cfg.curBloodPressureMeasurTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_curBloodPressureMeasurTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.curBloodPressureMeasurTime;
|
||
}
|
||
|
||
void sql_fit_set_goalBloodPressureMeasurTime_data(uint8_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_curBloodPressureMeasurTime_data()");
|
||
if(g_sql_fit.health_cfg.goalBloodPressureMeasurTime != value){
|
||
g_sql_fit.health_cfg.goalBloodPressureMeasurTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_goalBloodPressureMeasurTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalBloodPressureMeasurTime;
|
||
}
|
||
|
||
void sql_fit_set_curEarlySleepTime_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_curEarlySleepTime_data()");
|
||
if(g_sql_fit.health_cfg.curEarlySleepTime != value){
|
||
g_sql_fit.health_cfg.curEarlySleepTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_curEarlySleepTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.curEarlySleepTime;
|
||
}
|
||
|
||
void sql_fit_set_goalEarlySleepTime_data(uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_goalEarlySleepTime_data()");
|
||
if(g_sql_fit.health_cfg.goalEarlySleepTime != value){
|
||
g_sql_fit.health_cfg.goalEarlySleepTime = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_goalEarlySleepTime_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goalEarlySleepTime;
|
||
}
|
||
|
||
void sql_fit_set_sleepEarly_data(bool value)
|
||
{
|
||
static_print_debug("sql_fit_set_sleepEarly_data()");
|
||
g_sql_fit.health_cfg.sleepEarly = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
bool sql_fit_get_sleepEarly_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.sleepEarly;
|
||
}
|
||
|
||
bool sql_fit_get_custom123_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.custom123;
|
||
}
|
||
|
||
bool sql_fit_get_prayToBuddha_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.prayToBuddha;
|
||
}
|
||
|
||
bool sql_fit_get_religious_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.religious;
|
||
}
|
||
|
||
bool sql_fit_get_pray_data(void)
|
||
{
|
||
return g_sql_fit.health_cfg.pray;
|
||
}
|
||
|
||
void sql_fit_set_total_sleep_daydata(sleep_total_data_t data, uint8_t week_day)
|
||
{
|
||
if (week_day >= 7) return;
|
||
g_sql_fit.health_day[week_day].sleep_total_data = data;
|
||
g_sql_fit_need_save = true;
|
||
|
||
}
|
||
|
||
sleep_total_data_t sql_fit_get_total_sleep_daydata(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].sleep_total_data;
|
||
}
|
||
|
||
void sql_fit_set_has_custom_task(bool value)
|
||
{
|
||
static_print_debug("sql_fit_set_has_custom_task()");
|
||
if(g_sql_fit.health_cfg.hascustomtask != value){
|
||
g_sql_fit.health_cfg.hascustomtask = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
}
|
||
|
||
bool sql_fit_get_has_custom_task(void)
|
||
{
|
||
return g_sql_fit.health_cfg.hascustomtask;
|
||
}
|
||
|
||
void sql_fit_set_custom_task(uint8_t index, char * task_name, bool is_punch_clock,uint16_t redmind_time)
|
||
{
|
||
static_print_debug("sql_fit_set_custom_task()");
|
||
if(index >= CUSTOM_TASK_NUM) {
|
||
static_print_error("index over CUSTOM_TASK_NUM");
|
||
return;
|
||
}
|
||
|
||
if(task_name != NULL){
|
||
strncpy(g_sql_fit.health_cfg.customTask[index].custom_task_name, task_name, strlen(task_name));
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
if(g_sql_fit.health_cfg.customTask[index].iscustomtaskpunchClock != is_punch_clock){
|
||
g_sql_fit.health_cfg.customTask[index].iscustomtaskpunchClock = is_punch_clock;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
if(g_sql_fit.health_cfg.customTask[index].custom_task_reminder_time != redmind_time) {
|
||
g_sql_fit.health_cfg.customTask[index].custom_task_reminder_time = redmind_time;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_custom_task(custom_task_t ** array)
|
||
{
|
||
*array = g_sql_fit.health_cfg.customTask;
|
||
return CUSTOM_TASK_NUM;
|
||
}
|
||
|
||
void sql_fit_set_step_curdata(uint16_t index, uint32_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_step_curdata()");
|
||
if(index > DAILYDATA_DAY_MAX_NUM) {
|
||
static_print_error("index over DAILYDATA_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.step_day_array[index] != value) {
|
||
g_sql_fit.step_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
for (int i = 0; i < DAILYDATA_DAY_MAX_NUM; i++) {
|
||
printf("step_day_array[%d] = %d\r\n", i, g_sql_fit.step_day_array[i]);
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_step_daydata(uint32_t** array)
|
||
{
|
||
*array = g_sql_fit.step_day_array;
|
||
return DAILYDATA_DAY_MAX_NUM;
|
||
}
|
||
|
||
uint32_t sql_fit_get_step_curdata_in_hour(uint8_t hour)
|
||
{
|
||
return g_sql_fit.step_day_array[hour];
|
||
}
|
||
|
||
void sql_fit_set_calorie_curdata(uint16_t index, uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_calorie_curdata()");
|
||
if(index > DAILYDATA_DAY_MAX_NUM) {
|
||
static_print_error("index over DAILYDATA_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.calorie_day_array[index] != value) {
|
||
g_sql_fit.calorie_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_calorie_curdata_in_hour(uint8_t hour)
|
||
{
|
||
return g_sql_fit.calorie_day_array[hour];
|
||
}
|
||
|
||
uint16_t sql_fit_get_calorie_daydata(uint16_t** array)
|
||
{
|
||
*array = g_sql_fit.calorie_day_array;
|
||
return DAILYDATA_DAY_MAX_NUM;
|
||
}
|
||
|
||
uint32_t sql_fit_get_distance_curdata_in_hour(uint8_t hour)
|
||
{
|
||
return g_sql_fit.distance_day_array[hour];
|
||
}
|
||
|
||
void sql_fit_set_distance_curdata(uint16_t index, uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_distance_curdata()");
|
||
if(index > DAILYDATA_DAY_MAX_NUM) {
|
||
static_print_error("index over DAILYDATA_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.distance_day_array[index] != value) {
|
||
g_sql_fit.distance_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_distance_daydata(uint16_t** array)
|
||
{
|
||
*array = g_sql_fit.distance_day_array;
|
||
return DAILYDATA_DAY_MAX_NUM;
|
||
}
|
||
|
||
void sql_fit_set_exertime_curdata(uint16_t index, uint16_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_exertime_curdata()");
|
||
if(index > DAILYDATA_DAY_MAX_NUM) {
|
||
static_print_error("index over DAILYDATA_DAY_MAX_NUM");
|
||
return;
|
||
}
|
||
|
||
if(g_sql_fit.exertime_day_array[index] != value) {
|
||
g_sql_fit.exertime_day_array[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint16_t sql_fit_get_exertime_daydata(uint16_t** array)
|
||
{
|
||
*array = g_sql_fit.exertime_day_array;
|
||
return DAILYDATA_DAY_MAX_NUM;
|
||
}
|
||
|
||
void sql_fit_set_day_cadence_step(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_day_cadence_step()");
|
||
if(g_sql_fit.health_day[week_day].cadence_step != value) {
|
||
g_sql_fit.health_day[week_day].cadence_step = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_cadence_step(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].cadence_step;
|
||
}
|
||
|
||
void sql_fit_set_day_step(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_day_step()");
|
||
if(g_sql_fit.health_day[week_day].total_step != value) {
|
||
g_sql_fit.health_day[week_day].total_step = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_day_step(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].total_step;
|
||
}
|
||
|
||
void sql_fit_set_day_calorie(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_day_calorie()");
|
||
if(g_sql_fit.health_day[week_day].total_calorie != value) {
|
||
g_sql_fit.health_day[week_day].total_calorie = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_day_calorie(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].total_calorie;
|
||
}
|
||
|
||
void sql_fit_set_day_distance(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_day_distance()");
|
||
if(g_sql_fit.health_day[week_day].total_distance != value) {
|
||
g_sql_fit.health_day[week_day].total_distance = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_day_distance(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].total_distance;
|
||
}
|
||
|
||
void sql_fit_set_day_exercise_time(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_day_exercise_time()");
|
||
if(g_sql_fit.health_day[week_day].total_exercise_time != value) {
|
||
g_sql_fit.health_day[week_day].total_exercise_time = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_day_exercise_time(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].total_exercise_time;
|
||
}
|
||
|
||
|
||
/**********************************************************************************************************************
|
||
* 健康控制接口
|
||
*/
|
||
void sql_fit_set_goal_step_th(uint32_t goal_step_th)
|
||
{
|
||
if(g_sql_fit.health_cfg.goal_step_th != goal_step_th) {
|
||
g_sql_fit.health_cfg.goal_step_th = goal_step_th;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_goal_step_th(void)
|
||
{
|
||
return g_sql_fit.health_cfg.goal_step_th;
|
||
}
|
||
|
||
void sql_fit_set_switch_bright_screen(uint8_t sw)
|
||
{
|
||
if(g_sql_fit.health_cfg.bright_screen_sw != sw) {
|
||
g_sql_fit.health_cfg.bright_screen_sw = sw;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_switch_bright_screen(void)
|
||
{
|
||
return g_sql_fit.health_cfg.bright_screen_sw;
|
||
}
|
||
|
||
void sql_fit_set_switch_sedentary_remind_sw(uint8_t sw)
|
||
{
|
||
if(g_sql_fit.health_cfg.sedentary_remind_sw != sw) {
|
||
g_sql_fit.health_cfg.sedentary_remind_sw = sw;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_switch_sedentary_remind_sw(void)
|
||
{
|
||
return g_sql_fit.health_cfg.sedentary_remind_sw;
|
||
}
|
||
/**********************************************************************************************************************
|
||
* 健康天数据接口
|
||
*/
|
||
void sql_fit_set_hr_last_val(uint8_t value, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].hr_last_val != value) {
|
||
g_sql_fit.health_day[week_day].hr_last_val = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_hr_last_val(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_last_val;
|
||
}
|
||
|
||
void sql_fit_set_hr_last_time(uint32_t timestamp, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].hr_last_time != timestamp) {
|
||
g_sql_fit.health_day[week_day].hr_last_time = timestamp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_hr_last_time(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].hr_last_time;
|
||
}
|
||
|
||
void sql_fit_clear_health_day_data(uint8_t week_day)
|
||
{
|
||
memset(&(g_sql_fit.health_day[week_day]), 0, sizeof(health_day_data_t));
|
||
g_sql_fit.health_day[week_day].hr_min = 255;
|
||
g_sql_fit.health_day[week_day].spo2_min = 100;
|
||
g_sql_fit.health_day[week_day].stress_min = 100;
|
||
}
|
||
|
||
uint8_t sql_fit_get_heart_rate_arry(uint8_t** array)
|
||
{
|
||
*array = g_sql_fit.health_cfg.heartRateRemindValue;
|
||
return 5;
|
||
}
|
||
|
||
void sql_fit_reset_sport_heart_rate_arry(void)
|
||
{
|
||
for(int i=0; i< 4; i++)
|
||
{
|
||
g_sql_fit.health_cfg.heartRateRemindValue[i] = 0;
|
||
}
|
||
|
||
g_sql_fit.health_cfg.heartRateRemindValue[4] = 1;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
|
||
void sql_fit_set_sport_heart_rate_remind_value(int index, int value)
|
||
{
|
||
printf("line 1106 sql_fit_set_sport_heart_rate_remind_value index:%d value:%d\n", index, value);
|
||
if( g_sql_fit.health_cfg.heartRateRemindValue[index] != value) {
|
||
g_sql_fit.health_cfg.heartRateRemindValue[index] = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
void sql_fit_set_sport_time_remind_value(int value)
|
||
{
|
||
int value_tmp = 0;
|
||
switch (value)
|
||
{
|
||
case 0:
|
||
value_tmp = 10*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
value_tmp = 20*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
value_tmp = 30*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
value_tmp = 40*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
value_tmp = 50*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 5:
|
||
value_tmp = 60*60;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
value_tmp = 99999;
|
||
if( g_sql_fit.health_cfg.timeRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.timeRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
int sql_fit_get_sport_time_remind_value(void)
|
||
{
|
||
return g_sql_fit.health_cfg.timeRemindValue;
|
||
}
|
||
|
||
void sql_fit_set_sport_dist_remind_value(int value)
|
||
{
|
||
int value_tmp = 0;
|
||
switch (value)
|
||
{
|
||
case 0:
|
||
value_tmp = 500;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 1:
|
||
value_tmp = 1000;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 2:
|
||
value_tmp = 2000;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 3:
|
||
value_tmp = 3000;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
case 4:
|
||
value_tmp = 4000;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
value_tmp = 9999;
|
||
if( g_sql_fit.health_cfg.distRemindValue != value_tmp) {
|
||
g_sql_fit.health_cfg.distRemindValue = value_tmp;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
int sql_fit_get_sport_dist_remind_value(void)
|
||
{
|
||
return g_sql_fit.health_cfg.distRemindValue;
|
||
}
|
||
|
||
void sql_fit_set_total_sport_time(uint32_t value, uint8_t week_day)
|
||
{
|
||
static_print_debug("sql_fit_set_total_sport_time()");
|
||
if(g_sql_fit.health_day[week_day].total_sport_time != value) {
|
||
g_sql_fit.health_day[week_day].total_sport_time = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_total_sport_time(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].total_sport_time;
|
||
}
|
||
|
||
void sql_fit_set_hand_up_flag(uint32_t value)
|
||
{
|
||
static_print_debug("sql_fit_set_total_sport_time()");
|
||
if(g_sql_fit.health_cfg.hand_up_flag != value) {
|
||
g_sql_fit.health_cfg.hand_up_flag = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_hand_up_flag(void)
|
||
{
|
||
return g_sql_fit.health_cfg.hand_up_flag;
|
||
}
|
||
|
||
uint32_t sql_fit_get_last_step(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].last_step;
|
||
}
|
||
|
||
void sql_fit_set_last_step(uint32_t value, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].last_step != value) {
|
||
g_sql_fit.health_day[week_day].last_step = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_last_calorie(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].last_calorie;
|
||
}
|
||
|
||
void sql_fit_set_last_calorie(uint32_t value, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].last_calorie != value) {
|
||
g_sql_fit.health_day[week_day].last_calorie = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint32_t sql_fit_get_last_distance(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].last_distance;
|
||
}
|
||
|
||
void sql_fit_set_last_distance(uint32_t value, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].last_distance != value) {
|
||
g_sql_fit.health_day[week_day].last_distance = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
uint8_t sql_fit_get_last_measure_time(uint8_t week_day)
|
||
{
|
||
return g_sql_fit.health_day[week_day].last_measure_time;
|
||
}
|
||
|
||
void sql_fit_set_last_measure_time(int8_t value, uint8_t week_day)
|
||
{
|
||
if(g_sql_fit.health_day[week_day].last_measure_time != value) {
|
||
g_sql_fit.health_day[week_day].last_measure_time = value;
|
||
g_sql_fit_need_save = true;
|
||
}
|
||
}
|
||
|
||
|