Merge pull request #3903 from luhuadong/develop

[sensor] support GPS/GNSS sensor class
This commit is contained in:
Bernard Xiong 2020-09-12 11:04:22 +08:00 committed by GitHub
commit bfebcac4d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -34,7 +34,8 @@ static char *const sensor_name_str[] =
"step_", /* Step sensor */
"forc_", /* Force sensor */
"dust_", /* Dust sensor */
"eco2_" /* eCO2 sensor */
"eco2_", /* eCO2 sensor */
"gnss_" /* GPS/GNSS sensor */
};
/* Sensor interrupt correlation function */

View File

@ -47,6 +47,7 @@ extern "C" {
#define RT_SENSOR_CLASS_FORCE (13) /* Force sensor */
#define RT_SENSOR_CLASS_DUST (14) /* Dust sensor */
#define RT_SENSOR_CLASS_ECO2 (15) /* eCO2 sensor */
#define RT_SENSOR_CLASS_GNSS (16) /* GPS/GNSS sensor */
/* Sensor vendor types */
@ -84,6 +85,8 @@ extern "C" {
#define RT_SENSOR_UNIT_MN (13) /* Force unit: mN */
#define RT_SENSOR_UNIT_PPM (14) /* Concentration unit: ppm */
#define RT_SENSOR_UNIT_PPB (15) /* Concentration unit: ppb */
#define RT_SENSOR_UNIT_DMS (16) /* Coordinates unit: DMS */
#define RT_SENSOR_UNIT_DD (17) /* Coordinates unit: DD */
/* Sensor communication interface types */
@ -184,6 +187,12 @@ struct sensor_3_axis
rt_int32_t z;
};
struct coordinates
{
double longitude;
double latitude;
};
struct rt_sensor_data
{
rt_uint32_t timestamp; /* The timestamp when the data was received */
@ -193,6 +202,7 @@ struct rt_sensor_data
struct sensor_3_axis acce; /* Accelerometer. unit: mG */
struct sensor_3_axis gyro; /* Gyroscope. unit: mdps */
struct sensor_3_axis mag; /* Magnetometer. unit: mGauss */
struct coordinates coord; /* Coordinates unit: degrees */
rt_int32_t temp; /* Temperature. unit: dCelsius */
rt_int32_t humi; /* Relative humidity. unit: permillage */
rt_int32_t baro; /* Pressure. unit: pascal (Pa) */

View File

@ -34,6 +34,9 @@ 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_GNSS:
LOG_I("num:%3d, lon:%5d, lat:%5d, timestamp:%5d", num, sensor_data->data.coord.longitude, sensor_data->data.coord.latitude, 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;