mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/driver_sm_pwm_01c: initial import
This commit is contained in:
parent
240c016143
commit
a886c311e8
8
tests/driver_sm_pwm_01c/Makefile
Normal file
8
tests/driver_sm_pwm_01c/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
BOARD ?= samr21-xpro
|
||||
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += progress_bar
|
||||
USEMODULE += sm_pwm_01c
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
3
tests/driver_sm_pwm_01c/Makefile.ci
Normal file
3
tests/driver_sm_pwm_01c/Makefile.ci
Normal file
@ -0,0 +1,3 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l011k4
|
||||
#
|
27
tests/driver_sm_pwm_01c/README.md
Normal file
27
tests/driver_sm_pwm_01c/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Test Application for the Amphenol SM_PWM_01C infrared dust sensor
|
||||
|
||||
## About
|
||||
|
||||
This is a simple test application for the SM_PWM_01C driver.
|
||||
|
||||
## Expected result
|
||||
|
||||
If everything works then you should see the progress bar vary if dust
|
||||
concentration changes in the room, or manually block the infrared inputs
|
||||
to force a change.
|
||||
|
||||
Overly exaggerated values (blocked infrared sensor) can be seen here:
|
||||
|
||||
```
|
||||
# main(): This is RIOT! (Version: 2021.04-devel-1044-gfd36c-HEAD)
|
||||
# sm_pwm_01c driver test application
|
||||
# starting weighted average PM2.5 and PM10 measurements
|
||||
#
|
||||
# PM2.5 level: 1272 ug/m3|███████████ |
|
||||
# PM10 level: 490 ug/m3|████ |
|
||||
````
|
||||
|
||||
## Details
|
||||
|
||||
By default a moving average over a 30s window is returned ad the
|
||||
read value. The progress bar is updated every 200ms.
|
6
tests/driver_sm_pwm_01c/app.config.test
Normal file
6
tests/driver_sm_pwm_01c/app.config.test
Normal file
@ -0,0 +1,6 @@
|
||||
# this file enables modules defined in Kconfig. Do not use this file for
|
||||
# application configuration. This is only needed during migration.
|
||||
CONFIG_MODULE_SM_PWM_01C=y
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_MODULE_ZTIMER_USEC=y
|
||||
CONFIG_MODULE_PROGRESS_BAR=y
|
61
tests/driver_sm_pwm_01c/main.c
Normal file
61
tests/driver_sm_pwm_01c/main.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
* @file
|
||||
* @brief Test application for SM_PWM_01C driver
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ztimer.h"
|
||||
|
||||
#include "sm_pwm_01c.h"
|
||||
#include "sm_pwm_01c_params.h"
|
||||
|
||||
#include "progress_bar.h"
|
||||
|
||||
static progress_bar_t progress_bar_list[2];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
sm_pwm_01c_t dev;
|
||||
|
||||
puts("sm_pwm_01c driver test application");
|
||||
if (sm_pwm_01c_init(&dev, &sm_pwm_01c_params[0]) != 0) {
|
||||
puts("init device [ERROR]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
puts("starting weighted average PM2.5 and PM10 measurements\n");
|
||||
sm_pwm_01c_start(&dev);
|
||||
progress_bar_prepare_multi(2);
|
||||
|
||||
while (1) {
|
||||
ztimer_sleep(ZTIMER_USEC, 200 * US_PER_MS);
|
||||
sm_pwm_01c_data_t data;
|
||||
sm_pwm_01c_read_data(&dev, &data);
|
||||
sprintf(progress_bar_list[0].prefix,
|
||||
"%s %4d ug/m3", "PM2.5 level:",
|
||||
data.mc_pm_2p5);
|
||||
sprintf(progress_bar_list[1].prefix, "%s %4d ug/m3", "PM10 level:",
|
||||
data.mc_pm_10);
|
||||
progress_bar_list[0].value = data.mc_pm_2p5 >
|
||||
3000 ? 100 : (data.mc_pm_2p5 * 100) / 3000;
|
||||
progress_bar_list[1].value = data.mc_pm_10 >
|
||||
3000 ? 100 : (data.mc_pm_10 * 100) / 3000;
|
||||
progress_bar_update_multi(progress_bar_list, 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user