feat add sensor device support for sensor framework from Liu_weichao

it is OK
This commit is contained in:
xuedongliang
2022-03-09 09:37:19 +08:00
39 changed files with 1432 additions and 52 deletions
@@ -36,6 +36,8 @@ extern int As830Ch4Init(void);
extern int Tb600bIaq10IaqInit(void);
extern int Tb600bTvoc10TvocInit(void);
extern int Tb600bWqHcho1osInit(void);
extern int QsFxWindDirectionInit(void);
extern int QsFsWindSpeedInit(void);
extern int lv_port_init(void);
@@ -104,6 +106,14 @@ static struct InitDesc sensor_desc[] =
{ "zg09_co2", Zg09Co2Init },
#endif
#ifdef SENSOR_QS_FX
{ "qs_fx_wind_direction", QsFxWindDirectionInit },
#endif
#ifdef SENSOR_QS_FS
{ "qs_fs_wind_speed", QsFsWindSpeedInit },
#endif
#ifdef SENSOR_AS830
{ "ch4_as830", As830Ch4Init },
#endif
@@ -53,6 +53,10 @@ menu "sensor app"
config APPLICATION_SENSOR_CO2_ZG09
bool "Using sensor ZG09 apps"
default n
config APPLICATION_SENSOR_CO2_G8S
bool "Using sensor G8S apps"
default n
endif
menuconfig APPLICATION_SENSOR_PM1_0
@@ -122,7 +126,36 @@ menu "sensor app"
endif
endif
menuconfig APPLICATION_SENSOR_WINDDIRECTION
bool "Using sensor wind direction apps"
default n
if APPLICATION_SENSOR_WINDDIRECTION
config APPLICATION_SENSOR_WINDDIRECTION_QS_FX
bool "Using sensor QS-FX apps"
default n
endif
menuconfig APPLICATION_SENSOR_WINDSPEED
bool "Using sensor wind speed apps"
default n
if APPLICATION_SENSOR_WINDSPEED
config APPLICATION_SENSOR_WINDSPEED_QS_FS
bool "Using sensor QS-FS apps"
default n
endif
menuconfig APPLICATION_SENSOR_ALTITUDE
bool "Using sensor altitude apps"
default n
if APPLICATION_SENSOR_ALTITUDE
config APPLICATION_SENSOR_ALTITUDE_BMP180
bool "Using sensor BMP180 apps"
default n
endif
endif
endmenu
@@ -74,6 +74,10 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES += co2_zg09.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_G8S), y)
SRC_FILES += co2_g8s.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
SRC_FILES += pm1_0_ps5308.c
endif
@@ -98,6 +102,18 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES += temperature_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_WINDDIRECTION_QS_FX), y)
SRC_FILES += winddirection_qs_fx.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_WINDSPEED_QS_FS), y)
SRC_FILES += windspeed_qs_fs.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_ALTITUDE_BMP180), y)
SRC_FILES += altitude_bmp180.c
endif
include $(KERNEL_ROOT)/compiler.mk
endif
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file altitude_bmp180.c
* @brief BMP180 altitude example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.23
*/
#include <user_api.h>
#include <sensor.h>
/**
* @description: Read a altitude
* @return 0
*/
void AltitudeBmp180(void)
{
int32 altitude;
struct SensorQuantity *p_altitude = SensorQuantityFind(SENSOR_QUANTITY_BMP180_ALTITUDE, SENSOR_QUANTITY_ALTITUDE);
SensorQuantityOpen(p_altitude);
altitude = SensorQuantityRead(p_altitude);
printf("Altitude Pressure : %d Pa\n", altitude);
PrivTaskDelay(1000);
SensorQuantityClose(p_altitude);
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file co2_g8s.c
* @brief G8S CO2 example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.23
*/
#include <user_api.h>
#include <sensor.h>
/**
* @description: Read a CO2
* @return 0
*/
void Co2G8s(void)
{
struct SensorQuantity *co2 = SensorQuantityFind(SENSOR_QUANTITY_G8S_CO2, SENSOR_QUANTITY_CO2);
SensorQuantityOpen(co2);
printf("CO2 : %d ppm\n", SensorQuantityRead(co2));
SensorQuantityClose(co2);
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file winddirection_qs_fx.c
* @brief qs-fx wind direction example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <transform.h>
#include <sensor.h>
/**
* @description: Read a wind direction
* @return 0
*/
void WindDirectionQsFx(void)
{
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
SensorQuantityOpen(wind_direction);
PrivTaskDelay(2000);
uint16 result = SensorQuantityRead(wind_direction);
printf("wind direction : %d degree\n", result);
SensorQuantityClose(wind_direction);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindDirectionQsFx, WindDirectionQsFx, WindDirectionQsFx function);
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file windspeed_qs_fs.c
* @brief qs-fx wind direction example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <transform.h>
#include <sensor.h>
/**
* @description: Read a wind speed
* @return 0
*/
void WindSpeedQsFs(void)
{
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
SensorQuantityOpen(wind_speed);
PrivTaskDelay(2000);
uint16 result = SensorQuantityRead(wind_speed);
printf("wind speed : %d.%d m/s\n", result/10, result%10);
SensorQuantityClose(wind_speed);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindSpeedQsFs, WindSpeedQsFs, WindSpeedQsFs function);