Merge pull request #3413 from luhuadong/patch1

[Sensor] Add vendor info and sensor types for cmd
This commit is contained in:
Bernard Xiong 2020-03-04 11:44:25 +08:00 committed by GitHub
commit b3d196392c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 5 deletions

View File

@ -7,6 +7,7 @@
* Date Author Notes
* 2019-01-31 flybreak first version
* 2019-07-16 WillianChan Increase the output of sensor information
* 2020-02-22 luhuadong Add vendor info and sensor types for cmd
*/
#include "sensor.h"
@ -33,24 +34,42 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
case RT_SENSOR_CLASS_MAG:
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_TEMP:
LOG_I("num:%3d, temp:%3d.%d C, timestamp:%5d", num, sensor_data->data.temp / 10, sensor_data->data.temp % 10, 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);
break;
case RT_SENSOR_CLASS_TEMP:
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 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);
case RT_SENSOR_CLASS_LIGHT:
LOG_I("num:%3d, light:%5d lux, timestamp:%5d", num, sensor_data->data.light, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_PROXIMITY:
LOG_I("num:%3d, distance:%5d, timestamp:%5d", num, sensor_data->data.proximity, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_HR:
LOG_I("num:%3d, heart rate:%5d bpm, timestamp:%5d", num, sensor_data->data.hr, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_TVOC:
LOG_I("num:%3d, tvoc:%5d ppb, timestamp:%5d", num, sensor_data->data.tvoc, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_NOISE:
LOG_I("num:%3d, noise:%5d, timestamp:%5d", num, sensor_data->data.noise, 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);
break;
case RT_SENSOR_CLASS_FORCE:
LOG_I("num:%3d, force:%5d, timestamp:%5d", num, sensor_data->data.force, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_DUST:
LOG_I("num:%3d, dust:%5d ug/m3, timestamp:%5d", num, sensor_data->data.dust, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_ECO2:
LOG_I("num:%3d, eco2:%5d ppm, timestamp:%5d", num, sensor_data->data.eco2, sensor_data->timestamp);
break;
default:
break;
}
@ -301,6 +320,15 @@ static void sensor(int argc, char **argv)
case RT_SENSOR_VENDOR_DALLAS:
rt_kprintf("vendor :Dallas\n");
break;
case RT_SENSOR_VENDOR_ASAIR:
rt_kprintf("vendor :Asair\n");
break;
case RT_SENSOR_VENDOR_SHARP:
rt_kprintf("vendor :Sharp\n");
break;
case RT_SENSOR_VENDOR_SENSIRION:
rt_kprintf("vendor :Sensirion\n");
break;
}
rt_kprintf("model :%s\n", info.model);
switch (info.unit)