From 8f2f2328874a63dac52a8823d2d06ec20e12417a Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Wed, 8 May 2019 11:39:57 +0800 Subject: [PATCH] =?UTF-8?q?[sensor]=20=E5=AE=8C=E5=96=84sensor=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复开启 RTC 编译报错的问题。 * 在显示 sensor 数据时添加单位。 --- components/drivers/sensors/sensor.h | 2 +- components/drivers/sensors/sensor_cmd.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/drivers/sensors/sensor.h b/components/drivers/sensors/sensor.h index 4f8ee47eb8..a9b6684457 100755 --- a/components/drivers/sensors/sensor.h +++ b/components/drivers/sensors/sensor.h @@ -19,7 +19,7 @@ extern "C" { #endif #ifdef RT_USING_RTC -#define rt_sensor_get_ts() time() /* API for the sensor to get the timestamp */ +#define rt_sensor_get_ts() time(RT_NULL) /* API for the sensor to get the timestamp */ #else #define rt_sensor_get_ts() rt_tick_get() /* API for the sensor to get the timestamp */ #endif diff --git a/components/drivers/sensors/sensor_cmd.c b/components/drivers/sensors/sensor_cmd.c index 2760892cfe..6babf12db3 100755 --- a/components/drivers/sensors/sensor_cmd.c +++ b/components/drivers/sensors/sensor_cmd.c @@ -24,13 +24,13 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor switch (sensor->info.type) { case RT_SENSOR_CLASS_ACCE: - LOG_I("num:%3d, x:%5d, y:%5d, z:%5d, timestamp:%5d", num, sensor_data->data.acce.x, sensor_data->data.acce.y, sensor_data->data.acce.z, sensor_data->timestamp); + LOG_I("num:%3d, x:%5d, y:%5d, z:%5d mg, timestamp:%5d", num, sensor_data->data.acce.x, sensor_data->data.acce.y, sensor_data->data.acce.z, sensor_data->timestamp); break; case RT_SENSOR_CLASS_GYRO: - LOG_I("num:%3d, x:%8d, y:%8d, z:%8d, timestamp:%5d", num, sensor_data->data.gyro.x, sensor_data->data.gyro.y, sensor_data->data.gyro.z, sensor_data->timestamp); + LOG_I("num:%3d, x:%8d, y:%8d, z:%8d dps, timestamp:%5d", num, sensor_data->data.gyro.x / 1000, sensor_data->data.gyro.y / 1000, sensor_data->data.gyro.z / 1000, sensor_data->timestamp); break; case RT_SENSOR_CLASS_MAG: - LOG_I("num:%3d, x:%5d, y:%5d, z:%5d, timestamp:%5d", num, sensor_data->data.mag.x, sensor_data->data.mag.y, sensor_data->data.mag.z, sensor_data->timestamp); + LOG_I("num:%3d, x:%5d, y:%5d, z:%5d mGauss, timestamp:%5d", num, sensor_data->data.mag.x, sensor_data->data.mag.y, sensor_data->data.mag.z, sensor_data->timestamp); break; case RT_SENSOR_CLASS_HUMI: LOG_I("num:%3d, humi:%3d.%d%%, timestamp:%5d", num, sensor_data->data.humi / 10, sensor_data->data.humi % 10, sensor_data->timestamp); @@ -39,7 +39,7 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor LOG_I("num:%3d, temp:%3d.%dC, timestamp:%5d", num, sensor_data->data.temp / 10, sensor_data->data.temp % 10, sensor_data->timestamp); break; case RT_SENSOR_CLASS_BARO: - LOG_I("num:%3d, press:%5d, timestamp:%5d", num, sensor_data->data.baro, sensor_data->timestamp); + LOG_I("num:%3d, press:%5d pa, timestamp:%5d", num, sensor_data->data.baro, sensor_data->timestamp); break; case RT_SENSOR_CLASS_STEP: LOG_I("num:%3d, step:%5d, timestamp:%5d", num, sensor_data->data.step, sensor_data->timestamp);