[components][sensor]增加电源检测类型

This commit is contained in:
CYFS 2024-09-11 07:54:03 +08:00 committed by GitHub
parent 240172609c
commit cb0b5b05ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 4 deletions

View File

@ -53,6 +53,9 @@ extern "C" {
#define RT_SENSOR_CLASS_IAQ (19) /* IAQ sensor. */
#define RT_SENSOR_CLASS_ETOH (20) /* EtOH sensor. */
#define RT_SENSOR_CLASS_BP (21) /* Blood Pressure */
#define RT_SENSOR_CLASS_VOLTAGE (22) /* Voltage sensor */
#define RT_SENSOR_CLASS_CURRENT (23) /* Current sensor */
#define RT_SENSOR_CLASS_POWER (24) /* Power sensor */
/* Sensor vendor types */
@ -95,6 +98,9 @@ extern "C" {
#define RT_SENSOR_UNIT_DD (17) /* Coordinates unit: DD */
#define RT_SENSOR_UNIT_MGM3 (18) /* Concentration unit: mg/m3 */
#define RT_SENSOR_UNIT_MMHG (19) /* Blood Pressure unit: mmHg */
#define RT_SENSOR_UNIT_MV (20) /* Voltage unit: mV */
#define RT_SENSOR_UNIT_MA (21) /* Current unit: mA */
#define RT_SENSOR_UNIT_MW (22) /* Power unit: mW */
/* Sensor communication interface types */
#define RT_SENSOR_INTF_I2C (1 << 0)
@ -233,6 +239,9 @@ struct rt_sensor_data
rt_uint32_t iaq; /* IAQ sensor. unit: 1 */
rt_uint32_t etoh; /* EtOH sensor. unit: ppm */
struct sensor_bp bp; /* BloodPressure. unit: mmHg */
float mv; /* Voltage sensor. unit: mv */
float ma; /* Current sensor. unit: ma */
float mw; /* Power sensor. unit: mw */
} data;
};

View File

@ -40,7 +40,10 @@ static char *const sensor_name_str[] =
"spo2_", /* SpO2 sensor */
"iaq_", /* IAQ sensor */
"etoh_", /* EtOH sensor */
"bp_" /* Blood Pressure */
"bp_", /* Blood Pressure */
"volt_", /* Voltage sensor */
"curr_", /* Current sensor */
"pow_" /* Power sensor */
};
/* Sensor interrupt correlation function */

View File

@ -83,6 +83,15 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
case RT_SENSOR_CLASS_BP:
LOG_I("num:%3d, bp.sbp:%5d mmHg, bp.dbp:%5d mmHg, timestamp:%5d", num, sensor_data->data.bp.sbp, sensor_data->data.bp.dbp, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_VOLTAGE:
LOG_I("num:%3d, voltage:%5d mV, timestamp:%5d", num, sensor_data->data.mv, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_CURRENT:
LOG_I("num:%3d, current:%5d mA, timestamp:%5d", num, sensor_data->data.ma, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_POWER:
LOG_I("num:%3d, power:%5d mW, timestamp:%5d", num, sensor_data->data.mv, sensor_data->timestamp);
break;
default:
break;
}
@ -302,7 +311,7 @@ static int sensor(int argc, char **argv)
rt_kprintf(" sodr <var> Set output date rate to var\n");
rt_kprintf(" read [num] Read [num] times sensor\n");
rt_kprintf(" num default 5\n");
return ;
return -RT_EINVAL;
}
else if (!strcmp(argv[1], "info"))
{
@ -418,6 +427,15 @@ static int sensor(int argc, char **argv)
case RT_SENSOR_UNIT_MMHG:
rt_kprintf("unit :mmHg\n");
break;
case RT_SENSOR_UNIT_MV:
rt_kprintf("unit :mV\n");
break;
case RT_SENSOR_UNIT_MA:
rt_kprintf("unit :mA\n");
break;
case RT_SENSOR_UNIT_MW:
rt_kprintf("unit :mW\n");
break;
}
rt_kprintf("range_max :%d\n", info.range_max);
rt_kprintf("range_min :%d\n", info.range_min);