From ee89576f83ebbd59e4faddcecb7eccbc95455db2 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:11:08 -0400 Subject: [PATCH 01/13] samples: sensors: remove dps310 sensor sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/dps310/CMakeLists.txt | 8 ----- samples/sensor/dps310/README.rst | 45 ---------------------------- samples/sensor/dps310/app.overlay | 18 ----------- samples/sensor/dps310/prj.conf | 4 --- samples/sensor/dps310/sample.yaml | 12 -------- samples/sensor/dps310/src/main.c | 36 ---------------------- 6 files changed, 123 deletions(-) delete mode 100644 samples/sensor/dps310/CMakeLists.txt delete mode 100644 samples/sensor/dps310/README.rst delete mode 100644 samples/sensor/dps310/app.overlay delete mode 100644 samples/sensor/dps310/prj.conf delete mode 100644 samples/sensor/dps310/sample.yaml delete mode 100644 samples/sensor/dps310/src/main.c diff --git a/samples/sensor/dps310/CMakeLists.txt b/samples/sensor/dps310/CMakeLists.txt deleted file mode 100644 index ba8f86184416..000000000000 --- a/samples/sensor/dps310/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -project(dps310) -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/dps310/README.rst b/samples/sensor/dps310/README.rst deleted file mode 100644 index fae1ef99e709..000000000000 --- a/samples/sensor/dps310/README.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. _dps310: - -DPS310 Temperature and Pressure Sensor -###################################### - -Overview -******** - -This sample application periodically reads temperature and pressure data from -the first available device that implements SENSOR_CHAN_AMBIENT_TEMP and -SENSOR_CHAN_PRESS. This sample checks the sensor in polling mode (without -interrupt trigger). - -Building and Running -******************** - -This sample application uses an DPS310 sensor connected to a board via I2C. -Connect the sensor pins according to the connection diagram given in the -`dps310 datasheet`_ at page 18 figure 7. - -Build and flash this sample (for example, for the nrf52840dk_nrf52840 board) -using these commands: - -.. zephyr-app-commands:: - :zephyr-app: samples/sensors/dps310 - :board: nrf52840dk_nrf52840 - :goals: flash - :compact: - -Sample Output -============= -To check output of this sample, any serial console program can be used. -This example uses ``picocom`` on the serial port ``/dev/ttyUSB0``: - -.. code-block:: console - - $ sudo picocom -D /dev/ttyUSB0 - -.. code-block:: console - - temp: 23.774363; press: 97.354728 - temp: 23.777492; press: 97.353904 - temp: 23.784646; press: 97.354064 - -.. _dps310 datasheet: https://www.infineon.com/dgdl/Infineon-DPS310-DataSheet-v01_01-EN.pdf?fileId=5546d462576f34750157750826c42242 diff --git a/samples/sensor/dps310/app.overlay b/samples/sensor/dps310/app.overlay deleted file mode 100644 index aa866af3834a..000000000000 --- a/samples/sensor/dps310/app.overlay +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2019 Infineon Technologies AG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * A DPS310 attached to the Arduino I2C pins - */ - -&arduino_i2c { - DPS310@77 { - status = "okay"; - compatible = "infineon,dps310"; - reg = <0x77>; - label = "DPS310"; - }; -}; diff --git a/samples/sensor/dps310/prj.conf b/samples/sensor/dps310/prj.conf deleted file mode 100644 index ccd4003e152e..000000000000 --- a/samples/sensor/dps310/prj.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_DPS310=y diff --git a/samples/sensor/dps310/sample.yaml b/samples/sensor/dps310/sample.yaml deleted file mode 100644 index 051b18c6dc0e..000000000000 --- a/samples/sensor/dps310/sample.yaml +++ /dev/null @@ -1,12 +0,0 @@ -sample: - name: DP310 Sensor sample -tests: - sample.sensor.dps310: - harness: console - tags: sensors - depends_on: i2c arduino_i2c - harness_config: - type: one_line - regex: - - "temp: (.*); press: (.*);" - fixture: fixture_i2c_dps310 diff --git a/samples/sensor/dps310/src/main.c b/samples/sensor/dps310/src/main.c deleted file mode 100644 index e594176f6901..000000000000 --- a/samples/sensor/dps310/src/main.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019 Infineon Technologies AG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -void main(void) -{ - printk("Hello DPS310\n"); - const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, infineon_dps310))); - - if (dev == NULL) { - printk("Could not get DPS310 device\n"); - return; - } - - printk("dev %p name %s\n", dev, dev->name); - - while (1) { - struct sensor_value temp, press; - - sensor_sample_fetch(dev); - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); - sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press); - - printk("temp: %d.%06d; press: %d.%06d\n", - temp.val1, abs(temp.val2), press.val1, press.val2); - - k_sleep(K_MSEC(1000)); - } -} From e584efdb191cc982a0ca7aab5b1f450e0b9bd933 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:11:47 -0400 Subject: [PATCH 02/13] samples: sensor: remove thermometer sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/thermometer/CMakeLists.txt | 8 ---- samples/sensor/thermometer/README.txt | 22 ----------- samples/sensor/thermometer/prj.conf | 3 -- samples/sensor/thermometer/sample.yaml | 8 ---- samples/sensor/thermometer/src/main.c | 48 ----------------------- 5 files changed, 89 deletions(-) delete mode 100644 samples/sensor/thermometer/CMakeLists.txt delete mode 100644 samples/sensor/thermometer/README.txt delete mode 100644 samples/sensor/thermometer/prj.conf delete mode 100644 samples/sensor/thermometer/sample.yaml delete mode 100644 samples/sensor/thermometer/src/main.c diff --git a/samples/sensor/thermometer/CMakeLists.txt b/samples/sensor/thermometer/CMakeLists.txt deleted file mode 100644 index fa78fa5e610c..000000000000 --- a/samples/sensor/thermometer/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(thermometer) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/thermometer/README.txt b/samples/sensor/thermometer/README.txt deleted file mode 100644 index aca938a1acf0..000000000000 --- a/samples/sensor/thermometer/README.txt +++ /dev/null @@ -1,22 +0,0 @@ -Title: Thermometer - -Description: - -A simple thermometer example - --------------------------------------------------------------------------------- - -Building and Running Project: - -This project writes the temperature to the console once per second. -It can be built and executed on bbc_microbit as follows: - - make - -Sample Output: - -Thermometer Example! -arm temp device is 0x20000184, name is TEMP_0 -Temperature is 29.5C -Temperature is 29.5C -Temperature is 29.5C diff --git a/samples/sensor/thermometer/prj.conf b/samples/sensor/thermometer/prj.conf deleted file mode 100644 index ebf29e3dda27..000000000000 --- a/samples/sensor/thermometer/prj.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_SENSOR=y -CONFIG_STDOUT_CONSOLE=y -CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/samples/sensor/thermometer/sample.yaml b/samples/sensor/thermometer/sample.yaml deleted file mode 100644 index 1b8ba099dff3..000000000000 --- a/samples/sensor/thermometer/sample.yaml +++ /dev/null @@ -1,8 +0,0 @@ -sample: - name: Temperature Sensor -tests: - sample.sensor.thermometer: - tags: sensors - harness: sensor - integration_platforms: - - frdm_k64f diff --git a/samples/sensor/thermometer/src/main.c b/samples/sensor/thermometer/src/main.c deleted file mode 100644 index 3a632ce99b99..000000000000 --- a/samples/sensor/thermometer/src/main.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016 ARM Ltd. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -void main(void) -{ - const struct device *temp_dev; - - printf("Thermometer Example! %s\n", CONFIG_ARCH); - - temp_dev = device_get_binding("TEMP_0"); - if (!temp_dev) { - printf("error: no temp device\n"); - return; - } - - printf("temp device is %p, name is %s\n", - temp_dev, temp_dev->name); - - while (1) { - int r; - struct sensor_value temp_value; - - r = sensor_sample_fetch(temp_dev); - if (r) { - printf("sensor_sample_fetch failed return: %d\n", r); - break; - } - - r = sensor_channel_get(temp_dev, SENSOR_CHAN_AMBIENT_TEMP, - &temp_value); - if (r) { - printf("sensor_channel_get failed return: %d\n", r); - break; - } - - printf("Temperature is %gC\n", - sensor_value_to_double(&temp_value)); - - k_sleep(K_MSEC(1000)); - } -} From aa26f1aa60d9b72c92d6ca8146bcc0578e93f425 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:18:23 -0400 Subject: [PATCH 03/13] samples: sensor: remove TI HDC1080 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/ti_hdc/CMakeLists.txt | 9 --- samples/sensor/ti_hdc/README.rst | 81 ------------------- .../ti_hdc/boards/nucleo_l496zg.overlay | 15 ---- samples/sensor/ti_hdc/prj.conf | 5 -- samples/sensor/ti_hdc/sample.yaml | 10 --- samples/sensor/ti_hdc/src/main.c | 40 --------- 6 files changed, 160 deletions(-) delete mode 100644 samples/sensor/ti_hdc/CMakeLists.txt delete mode 100644 samples/sensor/ti_hdc/README.rst delete mode 100644 samples/sensor/ti_hdc/boards/nucleo_l496zg.overlay delete mode 100644 samples/sensor/ti_hdc/prj.conf delete mode 100644 samples/sensor/ti_hdc/sample.yaml delete mode 100644 samples/sensor/ti_hdc/src/main.c diff --git a/samples/sensor/ti_hdc/CMakeLists.txt b/samples/sensor/ti_hdc/CMakeLists.txt deleted file mode 100644 index e6d7591ff5c9..000000000000 --- a/samples/sensor/ti_hdc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(ti_hdc) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/ti_hdc/README.rst b/samples/sensor/ti_hdc/README.rst deleted file mode 100644 index c60cd00497a2..000000000000 --- a/samples/sensor/ti_hdc/README.rst +++ /dev/null @@ -1,81 +0,0 @@ -.. _ti_hdc_sample: - -TI_HDC Sample -############## - -Description -*********** - -This sample application periodically takes Temperature and Humidity -using the ti_hdc sensor driver. The result is written to the console. - -Requirements -************ - -This sample needs a compatible sensor like HDC1010 or HDC1080 -connected to the target board's I2C connector. - -Example Breakout Boards: - -* Pmod HYGRO: Humidity and Temperature Sensor Breakout board - - -Wiring -****** - -This sample is tested with the STM32L496ZG nucleo and the Pmod HYGRO -Temp/RH breakout board. - -The sensor operates at 3.3V and uses I2C to communicate with the board. - -External Wires: - -* Breakout **GND** pin <--> Nucleo **GND** pin -* Breakout **VCC** pin <--> Nucleo **3V3** pin -* Breakout **SDA** pin <--> Nucleo **CN7-D14** pin -* Breakout **SCL** pin <--> Nucleo **CN7-D15** pin - -Building and Running -******************** - -This sample builds one application for the HDC1080 sensor. -Build/Flash Steps: - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/ti_hdc/ - :board: nucleo_l496zg - :goals: build flash - :compact: - -Sample Output -************* -.. code-block:: console - - Running on arm! - Dev 0x20001160 name HDC1080 is ready! - Fetching... - Raw Temp = 25144, Temp = 23.305053 C, Raw RH = 32292, RH = 49.273681 % - Fetching... - Raw Temp = 25148, Temp = 23.315124 C, Raw RH = 32424, RH = 49.475097 % - ... - -Build Testing -************** - -.. code-block:: bash - - $ZEPHYR_BASE/scripts/twister -T $ZEPHYR_BASE/samples/sensor/ti_hdc/ -p nucleo_l496zg --device-testing --device-serial /dev/ttyACM0 -t build - -Target Testing -************** - -.. code-block:: bash - - $ZEPHYR_BASE/scripts/twister -T $ZEPHYR_BASE/samples/sensor/ti_hdc/ -p nucleo_l496zg --device-testing --device-serial /dev/ttyACM0 -t target - - -References -********** - -.. _Nucleo STM32L496ZG board: https://www.st.com/en/evaluation-tools/nucleo-l496zg.html -.. _HDC1080 Breakout board: https://store.digilentinc.com/pmod-hygro-digital-humidity-and-temperature-sensor/ diff --git a/samples/sensor/ti_hdc/boards/nucleo_l496zg.overlay b/samples/sensor/ti_hdc/boards/nucleo_l496zg.overlay deleted file mode 100644 index f09f5d82c0ed..000000000000 --- a/samples/sensor/ti_hdc/boards/nucleo_l496zg.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2019 Centaur Analytics, Inc - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&arduino_i2c { - - ti_hdc: ti_hdc@40 { - compatible = "ti,hdc","ti,hdc1080"; - reg = <0x40>; - label = "HDC1080"; - }; - -}; diff --git a/samples/sensor/ti_hdc/prj.conf b/samples/sensor/ti_hdc/prj.conf deleted file mode 100644 index 456d5328aa5a..000000000000 --- a/samples/sensor/ti_hdc/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ASSERT=y # validation -CONFIG_I2C=y -CONFIG_GPIO=y -CONFIG_SENSOR=y -CONFIG_TI_HDC=y diff --git a/samples/sensor/ti_hdc/sample.yaml b/samples/sensor/ti_hdc/sample.yaml deleted file mode 100644 index aeddcb129aea..000000000000 --- a/samples/sensor/ti_hdc/sample.yaml +++ /dev/null @@ -1,10 +0,0 @@ -sample: - name: TI HDC Humidity/Temperature Sensor -tests: - sample.sensor.ti_hdc: - harness: sensor - platform_allow: reel_board nucleo_l496zg - integration_platforms: - - reel_board - tags: sensors - depends_on: i2c diff --git a/samples/sensor/ti_hdc/src/main.c b/samples/sensor/ti_hdc/src/main.c deleted file mode 100644 index 50e40af7a5d1..000000000000 --- a/samples/sensor/ti_hdc/src/main.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019 Centaur Analytics - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include -#include -#include - -void main(void) -{ - printk("Running on %s!\n", CONFIG_ARCH); - const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_hdc))); - - __ASSERT(dev != NULL, "Failed to get device binding"); - - printk("Dev %p name %s is ready!\n", dev, dev->name); - - struct sensor_value temp, humidity; - - while (1) { - /* take a sample */ - printk("Fetching...\n"); - sensor_sample_fetch(dev); - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); - sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity); - - /* print the result */ - printk("Temp = %d.%06d C, RH = %d.%06d %%\n", - temp.val1, temp.val2, humidity.val1, humidity.val2); - - /* wait for the next sample */ - k_sleep(K_SECONDS(10)); - } -} From d4c3a5fd52f7eb06eed737d72775abbb7f645c4f Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:19:27 -0400 Subject: [PATCH 04/13] samples: sensor: remove th02 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/th02/CMakeLists.txt | 8 -- samples/sensor/th02/README.rst | 41 ------- samples/sensor/th02/boards/frdm_k64f.overlay | 13 --- samples/sensor/th02/prj.conf | 9 -- samples/sensor/th02/sample.yaml | 8 -- samples/sensor/th02/src/main.c | 106 ------------------- 6 files changed, 185 deletions(-) delete mode 100644 samples/sensor/th02/CMakeLists.txt delete mode 100644 samples/sensor/th02/README.rst delete mode 100644 samples/sensor/th02/boards/frdm_k64f.overlay delete mode 100644 samples/sensor/th02/prj.conf delete mode 100644 samples/sensor/th02/sample.yaml delete mode 100644 samples/sensor/th02/src/main.c diff --git a/samples/sensor/th02/CMakeLists.txt b/samples/sensor/th02/CMakeLists.txt deleted file mode 100644 index 75d7d52aa8f6..000000000000 --- a/samples/sensor/th02/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(th02) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/th02/README.rst b/samples/sensor/th02/README.rst deleted file mode 100644 index b8d7c67b067c..000000000000 --- a/samples/sensor/th02/README.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. _th02-sample: - -TH02: Temperature and Humidity Monitor -###################################### - -Overview -******** -This sample periodically reads temperature and humidity from the Grove -Temperature & Humidity Sensor (TH02) and display the results on the Grove LCD -display. - - -Requirements -************ - -This sample uses the TH02 sensor and the grove LCD display. Both devices are -controlled using the I2C interface. - -More details about the sensor and the display can be found here: - -- `Grove Temperature And Humidity`_ -- `Grove LCD Module`_ - -Wiring -****** - -The easiest way to get this wired is to use the Grove shield and connect both -devices to I2C. No additional wiring is required. Depending on the board you are -using you might need to connect two 10K ohm resistors to SDL and and SDA (I2C). -The LCD display requires 5 volts, so the voltage switch on the shield needs to -be on 5v. - - -References -********** - - - TH02: http://www.datasheetspdf.com/mobile/748107/TH02.html - - -.. _Grove LCD Module: http://wiki.seeed.cc/Grove-LCD_RGB_Backlight/ -.. _Grove Temperature And Humidity: http://wiki.seeed.cc/Grove-TemptureAndHumidity_Sensor-High-Accuracy_AndMini-v1.0/ diff --git a/samples/sensor/th02/boards/frdm_k64f.overlay b/samples/sensor/th02/boards/frdm_k64f.overlay deleted file mode 100644 index 1037b44a8046..000000000000 --- a/samples/sensor/th02/boards/frdm_k64f.overlay +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2019, Linaro Ltd. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&i2c0 { - th02@40 { - compatible = "hoperf,th02"; - reg = <0x40>; - label = "TH02"; - }; -}; diff --git a/samples/sensor/th02/prj.conf b/samples/sensor/th02/prj.conf deleted file mode 100644 index 7ec5020c37f7..000000000000 --- a/samples/sensor/th02/prj.conf +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_TH02=y -CONFIG_LOG=n -CONFIG_SENSOR_LOG_LEVEL_DBG=y -CONFIG_GROVE_LCD_RGB=y -CONFIG_DISPLAY=y -CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/samples/sensor/th02/sample.yaml b/samples/sensor/th02/sample.yaml deleted file mode 100644 index 6131b520b54b..000000000000 --- a/samples/sensor/th02/sample.yaml +++ /dev/null @@ -1,8 +0,0 @@ -sample: - name: TH02 Temperature and Humidity Monitor -tests: - sample.sensor.th02: - harness: sensor - tags: sensors - depends_on: i2c - filter: dt_compat_enabled("hoperf,th02") diff --git a/samples/sensor/th02/src/main.c b/samples/sensor/th02/src/main.c deleted file mode 100644 index 4d2d6a8ee4ff..000000000000 --- a/samples/sensor/th02/src/main.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016 Intel Corporation. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include - -#ifdef CONFIG_GROVE_LCD_RGB -#include -#include -#include -#endif - -struct channel_info { - int chan; - char *dev_name; -}; - -/* change device names if you want to use different sensors */ -static struct channel_info info[] = { - { SENSOR_CHAN_AMBIENT_TEMP, "TH02" }, - { SENSOR_CHAN_HUMIDITY, "TH02" }, -}; - -void main(void) -{ - const struct device *dev[ARRAY_SIZE(info)]; - struct sensor_value val[ARRAY_SIZE(info)]; - unsigned int i; - int rc; - - for (i = 0U; i < ARRAY_SIZE(info); i++) { - dev[i] = device_get_binding(info[i].dev_name); - if (dev[i] == NULL) { - printk("Failed to get \"%s\" device\n", - info[i].dev_name); - return; - } - } - -#ifdef CONFIG_GROVE_LCD_RGB - const struct device *glcd; - - glcd = device_get_binding(GROVE_LCD_NAME); - if (glcd == NULL) { - printk("Failed to get Grove LCD\n"); - return; - } - - /* configure LCD */ - glcd_function_set(glcd, GLCD_FS_ROWS_2 | GLCD_FS_DOT_SIZE_LITTLE | - GLCD_FS_8BIT_MODE); - glcd_display_state_set(glcd, GLCD_DS_DISPLAY_ON); -#endif - - while (1) { - /* fetch sensor samples */ - for (i = 0U; i < ARRAY_SIZE(info); i++) { - rc = sensor_sample_fetch(dev[i]); - if (rc) { - printk("Failed to fetch sample for device %s (%d)\n", - info[i].dev_name, rc); - } - } - - for (i = 0U; i < ARRAY_SIZE(info); i++) { - rc = sensor_channel_get(dev[i], info[i].chan, &val[i]); - if (rc) { - printk("Failed to get data for device %s (%d)\n", - info[i].dev_name, rc); - continue; - } - } - -#ifdef CONFIG_GROVE_LCD_RGB - char row[16]; - - /* clear LCD */ - (void)memset(row, ' ', sizeof(row)); - glcd_cursor_pos_set(glcd, 0, 0); - glcd_print(glcd, row, sizeof(row)); - glcd_cursor_pos_set(glcd, 0, 1); - glcd_print(glcd, row, sizeof(row)); - - /* display temperature on LCD */ - glcd_cursor_pos_set(glcd, 0, 0); - sprintf(row, "T:%.1f%cC", sensor_value_to_double(val), - 223 /* degree symbol */); - glcd_print(glcd, row, strlen(row)); - - /* display himidity on LCD */ - glcd_cursor_pos_set(glcd, 17 - strlen(row), 0); - sprintf(row, "RH:%.0f%c", sensor_value_to_double(val + 1), - 37 /* percent symbol */); - glcd_print(glcd, row, strlen(row)); - -#endif - - k_sleep(K_MSEC(2000)); - } -} From 1a271d9e2a1112e62edbc296d262ab37e23834f5 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:24:55 -0400 Subject: [PATCH 05/13] samples: sensor: remove ms5837 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/ms5837/CMakeLists.txt | 8 --- samples/sensor/ms5837/README.rst | 52 ------------------- .../ms5837/boards/nrf52840dk_nrf52840.overlay | 15 ------ samples/sensor/ms5837/prj.conf | 8 --- samples/sensor/ms5837/sample.yaml | 10 ---- samples/sensor/ms5837/src/main.c | 51 ------------------ 6 files changed, 144 deletions(-) delete mode 100644 samples/sensor/ms5837/CMakeLists.txt delete mode 100644 samples/sensor/ms5837/README.rst delete mode 100644 samples/sensor/ms5837/boards/nrf52840dk_nrf52840.overlay delete mode 100644 samples/sensor/ms5837/prj.conf delete mode 100644 samples/sensor/ms5837/sample.yaml delete mode 100644 samples/sensor/ms5837/src/main.c diff --git a/samples/sensor/ms5837/CMakeLists.txt b/samples/sensor/ms5837/CMakeLists.txt deleted file mode 100644 index fecd283e07ed..000000000000 --- a/samples/sensor/ms5837/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(ms5837) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/ms5837/README.rst b/samples/sensor/ms5837/README.rst deleted file mode 100644 index 03bf40dc188b..000000000000 --- a/samples/sensor/ms5837/README.rst +++ /dev/null @@ -1,52 +0,0 @@ -.. _ms5837-sample: - -MS5837 Sensor Sample -#################### - -Overview -******** - -This sample application retrieves the pressure and temperature from a MS5837 -sensor every 10 seconds, and prints this information to the UART console. - -Requirements -************ - -- `nRF52840 Preview development kit`_ -- MS5837 sensor - -Wiring -****** - -The nrf52840 Preview development kit should be connected as follows to the -MS5837 sensor. - -+-------------+----------+ -| | nrf52840 | | MS5837 | -| | Pin | | Pin | -+=============+==========+ -| P0.3 | SCL | -+-------------+----------+ -| P0.31 | SDA | -+-------------+----------+ - -Building and Running -******************** - -Build this sample using the following commands: - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/ms5837 - :board: nrf52840dk_nrf52840 - :goals: build - :compact: - -See :ref:`nrf52840dk_nrf52840` on how to flash the build. - -References -********** - -.. target-notes:: - -.. _MS5837 Sensor: http://www.te.com/usa-en/product-CAT-BLPS0017.html?q=&type=products&samples=N&q2=ms5837 -.. _nRF52840 Preview development kit: http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK diff --git a/samples/sensor/ms5837/boards/nrf52840dk_nrf52840.overlay b/samples/sensor/ms5837/boards/nrf52840dk_nrf52840.overlay deleted file mode 100644 index 2efc01cda87e..000000000000 --- a/samples/sensor/ms5837/boards/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2018 Jan Van Winkel - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&i2c1 { - status = "okay"; - clock-frequency = ; - ms5837@76 { - compatible = "meas,ms5837"; - reg = <0x76>; - label = "MS5837"; - }; -}; diff --git a/samples/sensor/ms5837/prj.conf b/samples/sensor/ms5837/prj.conf deleted file mode 100644 index 70612c0d92e1..000000000000 --- a/samples/sensor/ms5837/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_LOG=y -CONFIG_LOG_BACKEND_SHOW_COLOR=y -CONFIG_LOG_DEFAULT_LEVEL=1 -CONFIG_LOG_OVERRIDE_LEVEL=1 -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_MS5837=y diff --git a/samples/sensor/ms5837/sample.yaml b/samples/sensor/ms5837/sample.yaml deleted file mode 100644 index 59adc486e646..000000000000 --- a/samples/sensor/ms5837/sample.yaml +++ /dev/null @@ -1,10 +0,0 @@ -sample: - description: TBD - name: TBD -tests: - sample.sensor.ms5837: - build_only: true - platform_allow: nrf52840dk_nrf52840 - integration_platforms: - - nrf52840dk_nrf52840 - tags: sensors diff --git a/samples/sensor/ms5837/src/main.c b/samples/sensor/ms5837/src/main.c deleted file mode 100644 index a158306cfd82..000000000000 --- a/samples/sensor/ms5837/src/main.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018 Jan Van Winkel - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -#include -LOG_MODULE_REGISTER(main); - -void main(void) -{ - struct sensor_value oversampling_rate = { 8192, 0 }; - const struct device *dev = DEVICE_DT_GET_ANY(meas_ms5837); - - if (dev == NULL) { - LOG_ERR("Could not find MS5837 device, aborting test."); - return; - } - if (!device_is_ready(dev)) { - LOG_ERR("MS5837 device %s is not ready, aborting test.", - dev->name); - return; - } - - if (sensor_attr_set(dev, SENSOR_CHAN_ALL, SENSOR_ATTR_OVERSAMPLING, - &oversampling_rate) != 0) { - LOG_ERR("Could not set oversampling rate of %d " - "on MS5837 device, aborting test.", - oversampling_rate.val1); - return; - } - - while (1) { - struct sensor_value temp; - struct sensor_value press; - - sensor_sample_fetch(dev); - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); - sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press); - - printf("Temperature: %d.%06d, Pressure: %d.%06d\n", temp.val1, - temp.val2, press.val1, press.val2); - - k_sleep(K_MSEC(10000)); - } -} From 32a1e1a56a058279d3cbff03d7cbaf15f66590ab Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:28:28 -0400 Subject: [PATCH 06/13] samples: sensor: remove MAX6675 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/max6675/CMakeLists.txt | 9 ---- samples/sensor/max6675/README.rst | 45 ----------------- .../max6675/boards/nucleo_f030r8.overlay | 14 ------ samples/sensor/max6675/prj.conf | 4 -- samples/sensor/max6675/sample.yaml | 14 ------ samples/sensor/max6675/src/main.c | 50 ------------------- 6 files changed, 136 deletions(-) delete mode 100644 samples/sensor/max6675/CMakeLists.txt delete mode 100644 samples/sensor/max6675/README.rst delete mode 100644 samples/sensor/max6675/boards/nucleo_f030r8.overlay delete mode 100644 samples/sensor/max6675/prj.conf delete mode 100644 samples/sensor/max6675/sample.yaml delete mode 100644 samples/sensor/max6675/src/main.c diff --git a/samples/sensor/max6675/CMakeLists.txt b/samples/sensor/max6675/CMakeLists.txt deleted file mode 100644 index 628e373bdbc5..000000000000 --- a/samples/sensor/max6675/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2021 Teslabs Engineering S.L. -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(max6675) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/max6675/README.rst b/samples/sensor/max6675/README.rst deleted file mode 100644 index 3ef6b4188b85..000000000000 --- a/samples/sensor/max6675/README.rst +++ /dev/null @@ -1,45 +0,0 @@ -MAX6675 K-thermocouple to digital converter -########################################### - -Overview -******** - -This is a sample application to read an external MAX6675 -cold-junction-compensated K-thermocouple to digital converter. - -Requirements -************ - -- MAX6675 wired to your board SPI bus -- K-thermocouple connected to MAX6675 T+/T- inputs - -References -********** - - - MAX6675: https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf - -Building and Running -******************** - -This sample can be built with any board that supports SPI. A sample overlay is -provided for the NUCLEO-F030R8 board. - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/max6675 - :board: nucleo_f030r8 - :goals: build - :compact: - -Sample Output -============= - -The application will read and print sensor temperature every second. Note that -temperature fetch will fail if the K-thermocouple is not connected. This is -because MAX6675 is able to detect if the K-thermocouple is connected or not. - -.. code-block:: console - - Temperature: 25.25 C - Temperature: 25.50 C - - diff --git a/samples/sensor/max6675/boards/nucleo_f030r8.overlay b/samples/sensor/max6675/boards/nucleo_f030r8.overlay deleted file mode 100644 index 5b0321eb187f..000000000000 --- a/samples/sensor/max6675/boards/nucleo_f030r8.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2021 Teslabs Engineering S.L. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&arduino_spi { - max6675@0 { - compatible = "maxim,max6675"; - reg = <0>; - spi-max-frequency = <4300000>; - label = "MAX6675"; - }; -}; diff --git a/samples/sensor/max6675/prj.conf b/samples/sensor/max6675/prj.conf deleted file mode 100644 index b11b19061f22..000000000000 --- a/samples/sensor/max6675/prj.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_CBPRINTF_FP_SUPPORT=y -CONFIG_SPI=y -CONFIG_SENSOR=y -CONFIG_MAX6675=y diff --git a/samples/sensor/max6675/sample.yaml b/samples/sensor/max6675/sample.yaml deleted file mode 100644 index 686a2ddd396e..000000000000 --- a/samples/sensor/max6675/sample.yaml +++ /dev/null @@ -1,14 +0,0 @@ -sample: - name: MAX6675 K-thermocouple to digital converter -tests: - sample.sensor.max6675: - tags: sensors - harness: console - depends_on: spi - harness_config: - type: multi_line - ordered: true - regex: - - "Temperature: ([0-9\\.]+) C" - fixture: fixture_spi_max6675 - filter: dt_compat_enabled("maxim,max6675") diff --git a/samples/sensor/max6675/src/main.c b/samples/sensor/max6675/src/main.c deleted file mode 100644 index 4f53763c6d53..000000000000 --- a/samples/sensor/max6675/src/main.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Teslabs Engineering S.L. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include -#include -#include - -/** - * @file Sample app using the MAX6675 cold-junction-compensated K-thermocouple - * to digital converter. - * - * This app will read and display the sensor temperature every second. - */ - -void main(void) -{ - const struct device *dev; - struct sensor_value val; - - dev = device_get_binding(DT_LABEL(DT_INST(0, maxim_max6675))); - if (dev == NULL) { - printf("Could not obtain MAX6675 device\n"); - return; - } - - while (1) { - int ret; - - ret = sensor_sample_fetch_chan(dev, SENSOR_CHAN_AMBIENT_TEMP); - if (ret < 0) { - printf("Could not fetch temperature (%d)\n", ret); - return; - } - - ret = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &val); - if (ret < 0) { - printf("Could not get temperature (%d)\n", ret); - return; - } - - printf("Temperature: %.2f C\n", sensor_value_to_double(&val)); - - k_sleep(K_MSEC(1000)); - } -} From 484165bee0ceb5fd9fd723b5319e13a2d02ac259 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 10:34:01 -0400 Subject: [PATCH 07/13] samples: sensor: remove grove sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- .../sensor/grove_temperature/CMakeLists.txt | 8 -- .../boards/nrf52dk_nrf52832.overlay | 13 --- samples/sensor/grove_temperature/prj.conf | 6 -- samples/sensor/grove_temperature/sample.yaml | 13 --- samples/sensor/grove_temperature/src/main.c | 84 ------------------- 5 files changed, 124 deletions(-) delete mode 100644 samples/sensor/grove_temperature/CMakeLists.txt delete mode 100644 samples/sensor/grove_temperature/boards/nrf52dk_nrf52832.overlay delete mode 100644 samples/sensor/grove_temperature/prj.conf delete mode 100644 samples/sensor/grove_temperature/sample.yaml delete mode 100644 samples/sensor/grove_temperature/src/main.c diff --git a/samples/sensor/grove_temperature/CMakeLists.txt b/samples/sensor/grove_temperature/CMakeLists.txt deleted file mode 100644 index 01706e9a631a..000000000000 --- a/samples/sensor/grove_temperature/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(grove_temperature) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/grove_temperature/boards/nrf52dk_nrf52832.overlay b/samples/sensor/grove_temperature/boards/nrf52dk_nrf52832.overlay deleted file mode 100644 index 4e849598a6b4..000000000000 --- a/samples/sensor/grove_temperature/boards/nrf52dk_nrf52832.overlay +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/ { - ntc { - label = "GTS"; - compatible = "grove,temperature"; - io-channels = <&arduino_adc 0>; - }; -}; diff --git a/samples/sensor/grove_temperature/prj.conf b/samples/sensor/grove_temperature/prj.conf deleted file mode 100644 index 0ba9cf35c005..000000000000 --- a/samples/sensor/grove_temperature/prj.conf +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG_ADC=y -CONFIG_SENSOR=y -CONFIG_GROVE_TEMPERATURE_SENSOR=y -CONFIG_NEWLIB_LIBC=y -CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y -CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/samples/sensor/grove_temperature/sample.yaml b/samples/sensor/grove_temperature/sample.yaml deleted file mode 100644 index c51eb0dd8033..000000000000 --- a/samples/sensor/grove_temperature/sample.yaml +++ /dev/null @@ -1,13 +0,0 @@ -common: - filter: TOOLCHAIN_HAS_NEWLIB == 1 -sample: - name: Grove Temperature Sensor -tests: - sample.sensor.grove_temperature: - min_flash: 33 - tags: drivers sensor grove temperature - platform_allow: nrf52dk_nrf52832 - integration_platforms: - - nrf52dk_nrf52832 - harness: grove - depends_on: adc diff --git a/samples/sensor/grove_temperature/src/main.c b/samples/sensor/grove_temperature/src/main.c deleted file mode 100644 index a7f539836194..000000000000 --- a/samples/sensor/grove_temperature/src/main.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -#ifdef CONFIG_GROVE_LCD_RGB -#include -#include -#include -#endif - -#define SLEEP_TIME K_MSEC(1000) - -void main(void) -{ - const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_temperature))); - struct sensor_value temp; - int read; - - if (dev == NULL) { - printf("device not found. aborting test.\n"); - return; - } -#ifdef CONFIG_GROVE_LCD_RGB - const struct device *glcd; - - glcd = device_get_binding(GROVE_LCD_NAME); - if (glcd == NULL) { - printf("Failed to get Grove LCD\n"); - return; - } - - /* configure LCD */ - glcd_function_set(glcd, GLCD_FS_ROWS_2 | GLCD_FS_DOT_SIZE_LITTLE | - GLCD_FS_8BIT_MODE); - glcd_display_state_set(glcd, GLCD_DS_DISPLAY_ON); -#endif - - while (1) { - - read = sensor_sample_fetch(dev); - if (read) { - printk("sample fetch error\n"); - continue; - } - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); -#ifdef CONFIG_GROVE_LCD_RGB - char row[16]; - - /* clear LCD */ - (void)memset(row, ' ', sizeof(row)); - glcd_cursor_pos_set(glcd, 0, 0); - glcd_print(glcd, row, sizeof(row)); - glcd_cursor_pos_set(glcd, 0, 1); - glcd_print(glcd, row, sizeof(row)); - - /* display temperature on LCD */ - glcd_cursor_pos_set(glcd, 0, 0); -#ifdef CONFIG_NEWLIB_LIBC_FLOAT_PRINTF - sprintf(row, "T:%.2f%cC", - sensor_value_to_double(&temp), - 223 /* degree symbol */); -#else - sprintf(row, "T:%d%cC", temp.val1, - 223 /* degree symbol */); -#endif - glcd_print(glcd, row, strlen(row)); - -#endif - -#ifdef CONFIG_NEWLIB_LIBC_FLOAT_PRINTF - printf("Temperature: %.2f C\n", sensor_value_to_double(&temp)); -#else - printk("Temperature: %d\n", temp.val1); -#endif - k_sleep(SLEEP_TIME); - } -} From c3d7dee19d05d92590a767c799ab600fbbeeffb2 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 11:19:03 -0400 Subject: [PATCH 08/13] samples: sensor: remove LPS22HB sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/lps22hb/CMakeLists.txt | 8 ---- samples/sensor/lps22hb/README.rst | 49 ----------------------- samples/sensor/lps22hb/prj.conf | 5 --- samples/sensor/lps22hb/sample.yaml | 14 ------- samples/sensor/lps22hb/src/main.c | 57 --------------------------- 5 files changed, 133 deletions(-) delete mode 100644 samples/sensor/lps22hb/CMakeLists.txt delete mode 100644 samples/sensor/lps22hb/README.rst delete mode 100644 samples/sensor/lps22hb/prj.conf delete mode 100644 samples/sensor/lps22hb/sample.yaml delete mode 100644 samples/sensor/lps22hb/src/main.c diff --git a/samples/sensor/lps22hb/CMakeLists.txt b/samples/sensor/lps22hb/CMakeLists.txt deleted file mode 100644 index 483acf0bdf4d..000000000000 --- a/samples/sensor/lps22hb/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(lps22hb) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/lps22hb/README.rst b/samples/sensor/lps22hb/README.rst deleted file mode 100644 index efbc20ca0093..000000000000 --- a/samples/sensor/lps22hb/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -.. _lps22hb: - -LPS22HB: Temperature and Humidity Monitor -######################################### - -Overview -******** -This sample periodically reads pressure from the LPS22HB MEMS pressure -sensor and displays it on the console. - - -Requirements -************ - -This sample uses the LPS22HB sensor controlled using the I2C interface. - -References -********** - -- LPS22HB: http://www.st.com/en/mems-and-sensors/lps22hb.html - -Building and Running -******************** - -This project outputs sensor data to the console. It requires an LPS22HB -sensor, which is present on the disco_l475_iot1 board. - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/lps22hb - :board: disco_l475_iot1 - :goals: build - :compact: - -Sample Output -============= - -.. code-block:: console - - Observation:1 - Pressure:98.7 kPa - Temperature:22.5 C - Observation:2 - Pressure:98.7 kPa - Temperature:22.5 C - Observation:3 - Pressure:98.7 kPa - Temperature:22.5 C - - diff --git a/samples/sensor/lps22hb/prj.conf b/samples/sensor/lps22hb/prj.conf deleted file mode 100644 index d52e2d4b67b8..000000000000 --- a/samples/sensor/lps22hb/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_LPS22HB=y -CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/samples/sensor/lps22hb/sample.yaml b/samples/sensor/lps22hb/sample.yaml deleted file mode 100644 index eedeff23e119..000000000000 --- a/samples/sensor/lps22hb/sample.yaml +++ /dev/null @@ -1,14 +0,0 @@ -sample: - name: LPS22HB Temperature and Humidity Monitor -tests: - sample.sensor.lps22hb: - harness: console - tags: sensors - depends_on: i2c lps22hb - harness_config: - type: multi_line - ordered: yes - regex: - - "Temperature: (.*)" - - "Relative Humidity: (.*)" - fixture: fixture_i2c_lps22hb diff --git a/samples/sensor/lps22hb/src/main.c b/samples/sensor/lps22hb/src/main.c deleted file mode 100644 index d76f375d7daa..000000000000 --- a/samples/sensor/lps22hb/src/main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 Linaro Limited - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include - -static void process_sample(const struct device *dev) -{ - static unsigned int obs; - struct sensor_value pressure, temp; - - if (sensor_sample_fetch(dev) < 0) { - printf("Sensor sample update error\n"); - return; - } - - if (sensor_channel_get(dev, SENSOR_CHAN_PRESS, &pressure) < 0) { - printf("Cannot read LPS22HB pressure channel\n"); - return; - } - - if (sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp) < 0) { - printf("Cannot read LPS22HB temperature channel\n"); - return; - } - - ++obs; - printf("Observation:%u\n", obs); - - /* display pressure */ - printf("Pressure:%.1f kPa\n", sensor_value_to_double(&pressure)); - - /* display temperature */ - printf("Temperature:%.1f C\n", sensor_value_to_double(&temp)); - -} - -void main(void) -{ - const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); - - if (dev == NULL) { - printf("Could not get LPS22HB device\n"); - return; - } - - while (true) { - process_sample(dev); - k_sleep(K_MSEC(2000)); - } -} From 6762ca3c96842bb53df6b344ac38300992aeff98 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 13:33:23 -0400 Subject: [PATCH 09/13] samples: sensor: remove ENS210 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/ens210/CMakeLists.txt | 11 --------- samples/sensor/ens210/README.rst | 34 --------------------------- samples/sensor/ens210/ens210.overlay | 15 ------------ samples/sensor/ens210/prj.conf | 3 --- samples/sensor/ens210/sample.yaml | 8 ------- samples/sensor/ens210/src/main.c | 35 ---------------------------- 6 files changed, 106 deletions(-) delete mode 100644 samples/sensor/ens210/CMakeLists.txt delete mode 100644 samples/sensor/ens210/README.rst delete mode 100644 samples/sensor/ens210/ens210.overlay delete mode 100644 samples/sensor/ens210/prj.conf delete mode 100644 samples/sensor/ens210/sample.yaml delete mode 100644 samples/sensor/ens210/src/main.c diff --git a/samples/sensor/ens210/CMakeLists.txt b/samples/sensor/ens210/CMakeLists.txt deleted file mode 100644 index 96a8a6b6e35a..000000000000 --- a/samples/sensor/ens210/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) - -set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ens210.overlay") - -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(ens210) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/ens210/README.rst b/samples/sensor/ens210/README.rst deleted file mode 100644 index 57ee2e868d9a..000000000000 --- a/samples/sensor/ens210/README.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. _ens210: - -ams ens210 Relative Humidity and Temperature Sensor -################################################### - -Overview -******** - -This sample application demonstrates how to use the ams ens210 sensor to -measure the ambient temperature and relative humidity. - -Building and Running -******************** - -This sample application uses the sensor connected to the i2c stated in the -ens210.overlay file. -Flash the binary to a board of choice with a sensor connected. -For example build for a nucleo_f446re board: - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/ens210 - :board: nucleo_f446re - :goals: build flash - :compact: - -Sample Output -============= - -.. code-block:: console - - device is 0x20001174, name is ENS210 - Temperature: 28.28881222 C; Humidity: 25.25689737% - Temperature: 28.28912472 C; Humidity: 25.25799105% - Temperature: 28.28959347 C; Humidity: 25.25760045% diff --git a/samples/sensor/ens210/ens210.overlay b/samples/sensor/ens210/ens210.overlay deleted file mode 100644 index 6d6d0e26a718..000000000000 --- a/samples/sensor/ens210/ens210.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2018 Alexander Wachter - * SPDX-License-Identifier: Apache-2.0 - */ - -&arduino_i2c { - status = "okay"; - clock-frequency = ; - - ens210: ens210@43 { - compatible = "ams,ens210"; - reg = <0x43>; - label = "ENS210"; - }; -}; diff --git a/samples/sensor/ens210/prj.conf b/samples/sensor/ens210/prj.conf deleted file mode 100644 index 6842996e3de7..000000000000 --- a/samples/sensor/ens210/prj.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_ENS210=y diff --git a/samples/sensor/ens210/sample.yaml b/samples/sensor/ens210/sample.yaml deleted file mode 100644 index 66b37178eaf5..000000000000 --- a/samples/sensor/ens210/sample.yaml +++ /dev/null @@ -1,8 +0,0 @@ -sample: - description: Demonstration of the AMS Temperature and Humidity Sensor driver - name: ENS210 sample -tests: - sample.sensor.ens210: - harness: sensor - tags: samples - depends_on: i2c arduino_i2c diff --git a/samples/sensor/ens210/src/main.c b/samples/sensor/ens210/src/main.c deleted file mode 100644 index 884846fb841f..000000000000 --- a/samples/sensor/ens210/src/main.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018 Alexander Wachter - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -void main(void) -{ - const struct device *dev; - struct sensor_value temperature, humidity; - - dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ens210))); - if (!dev) { - printk("Failed to get device binding"); - return; - } - - printk("device is %p, name is %s\n", dev, dev->name); - - while (1) { - sensor_sample_fetch(dev); - sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity); - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temperature); - printk("Temperature: %d.%06d C; Humidity: %d.%06d%%\n", - temperature.val1, temperature.val2, - humidity.val1, humidity.val2); - - k_sleep(K_MSEC(1000)); - } -} From ad653152a9ae19e15131eec87b9432731bc115da Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 30 May 2021 13:33:34 -0400 Subject: [PATCH 10/13] samples: sensor: remove BME680 sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/bme680/CMakeLists.txt | 12 ----- samples/sensor/bme680/README.rst | 53 ------------------- .../boards/adafruit_feather_nrf52840.overlay | 17 ------ .../bme680/boards/nrf52840dk_nrf52840.overlay | 13 ----- samples/sensor/bme680/prj.conf | 5 -- samples/sensor/bme680/sample.yaml | 9 ---- samples/sensor/bme680/src/main.c | 33 ------------ 7 files changed, 142 deletions(-) delete mode 100644 samples/sensor/bme680/CMakeLists.txt delete mode 100644 samples/sensor/bme680/README.rst delete mode 100644 samples/sensor/bme680/boards/adafruit_feather_nrf52840.overlay delete mode 100644 samples/sensor/bme680/boards/nrf52840dk_nrf52840.overlay delete mode 100644 samples/sensor/bme680/prj.conf delete mode 100644 samples/sensor/bme680/sample.yaml delete mode 100644 samples/sensor/bme680/src/main.c diff --git a/samples/sensor/bme680/CMakeLists.txt b/samples/sensor/bme680/CMakeLists.txt deleted file mode 100644 index 9198f51fd1f4..000000000000 --- a/samples/sensor/bme680/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright (c) 2018 Bosch Sensortec GmbH -# -# SPDX-License-Identifier: Apache-2.0 -# - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(bme680) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/bme680/README.rst b/samples/sensor/bme680/README.rst deleted file mode 100644 index c070cf64f4cc..000000000000 --- a/samples/sensor/bme680/README.rst +++ /dev/null @@ -1,53 +0,0 @@ -.. _bme680: - -BME680: Integrated environmental sensor -##################################################### - -Description -*********** - -This sample application periodically (every 3s) measures the ambient temperature -in degrees Celsius, atmospheric pressure in kilopascal, relative humidity in percentage, -and gas sensor resistance in ohms. The result is written to the console. - -References -********** - - - BME680: https://www.bosch-sensortec.com/bst/products/all_products/bme680 - -Wiring -******* - -This sample uses the BME680 sensor controlled using the I2C interface. -Connect Supply: **VDD**, **VDDIO**, **GND** and Interface: **SDA**, **SCL**. -The supply voltage can be in the 1.8V to 3.6V range. -Depending on the baseboard used, the **SDA** and **SCL** lines require Pull-Up -resistors. - -Building and Running -******************** - -This project outputs sensor data to the console. It requires a BME680 -sensor. It should work with any platform featuring a I2C peripheral interface. -It does not work on QEMU. -In this example below the :ref:`nrf52840dk_nrf52840` board is used. - - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/bme680 - :board: nrf52840dk_nrf52840 - :goals: build flash - -Sample Output -============= - -.. code-block:: console - - Device 0x20002b74 name is BME680 - T: 23.988877; P: 97.648568; H: 53.689533; G: 1035.211466 - T: 24.168500; P: 97.648866; H: 53.565966; G: 1046.677896 - T: 24.336533; P: 97.648596; H: 53.353663; G: 1058.656533 - T: 24.589696; P: 97.648366; H: 53.958864; G: 1072.155863 - T: 24.856631; P: 97.648322; H: 53.553669; G: 1096.448788 - - diff --git a/samples/sensor/bme680/boards/adafruit_feather_nrf52840.overlay b/samples/sensor/bme680/boards/adafruit_feather_nrf52840.overlay deleted file mode 100644 index 081e0351e944..000000000000 --- a/samples/sensor/bme680/boards/adafruit_feather_nrf52840.overlay +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2020, Patrick Moffitt - * - * SPDX-License-Identifier: Apache-2.0 - * - * i2c interface for the Feather nRF52840 Express and the - * Adafruit BME680. - */ - -&i2c0 { - compatible = "nordic,nrf-twi"; - bme680: bme680@77 { - compatible = "bosch,bme680"; - reg = <0x77>; - label = "BME680"; - }; -}; diff --git a/samples/sensor/bme680/boards/nrf52840dk_nrf52840.overlay b/samples/sensor/bme680/boards/nrf52840dk_nrf52840.overlay deleted file mode 100644 index c98ce3411f9b..000000000000 --- a/samples/sensor/bme680/boards/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2020, Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&i2c0 { - bme680@76 { - compatible = "bosch,bme680"; - reg = <0x76>; - label = "BME680"; - }; -}; diff --git a/samples/sensor/bme680/prj.conf b/samples/sensor/bme680/prj.conf deleted file mode 100644 index bd2a9059fdfe..000000000000 --- a/samples/sensor/bme680/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_I2C=y -CONFIG_SENSOR=y -CONFIG_BME680=y - diff --git a/samples/sensor/bme680/sample.yaml b/samples/sensor/bme680/sample.yaml deleted file mode 100644 index 566aeac14c99..000000000000 --- a/samples/sensor/bme680/sample.yaml +++ /dev/null @@ -1,9 +0,0 @@ -sample: - name: BME680 Sensor sample -tests: - sample.sensor.bme680: - harness: sensor - tags: samples sensor - integration_platforms: - - nrf52840dk_nrf52840 - platform_allow: nrf52840dk_nrf52840 adafruit_feather_nrf52840 diff --git a/samples/sensor/bme680/src/main.c b/samples/sensor/bme680/src/main.c deleted file mode 100644 index ecfc29319f0c..000000000000 --- a/samples/sensor/bme680/src/main.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018 Bosch Sensortec GmbH - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -void main(void) -{ - const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, bosch_bme680))); - struct sensor_value temp, press, humidity, gas_res; - - printf("Device %p name is %s\n", dev, dev->name); - - while (1) { - k_sleep(K_MSEC(3000)); - - sensor_sample_fetch(dev); - sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); - sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press); - sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity); - sensor_channel_get(dev, SENSOR_CHAN_GAS_RES, &gas_res); - - printf("T: %d.%06d; P: %d.%06d; H: %d.%06d; G: %d.%06d\n", - temp.val1, temp.val2, press.val1, press.val2, - humidity.val1, humidity.val2, gas_res.val1, - gas_res.val2); - } -} From c08894415fcae3d6697fe72d0a88c92070c522a4 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 1 Jun 2021 19:02:22 -0400 Subject: [PATCH 11/13] samples: sensor: remove DHT sample Opt for a unified sample for temperature sensors and remove this one as it duplicated the same functionality with limited hardware support. Signed-off-by: Anas Nashif --- samples/sensor/dht/CMakeLists.txt | 12 ---- samples/sensor/dht/README.rst | 45 ------------ .../dht/boards/nrf52dk_nrf52832.overlay | 15 ---- samples/sensor/dht/prj.conf | 15 ---- samples/sensor/dht/sample.yaml | 17 ----- samples/sensor/dht/src/main.c | 71 ------------------- 6 files changed, 175 deletions(-) delete mode 100644 samples/sensor/dht/CMakeLists.txt delete mode 100644 samples/sensor/dht/README.rst delete mode 100644 samples/sensor/dht/boards/nrf52dk_nrf52832.overlay delete mode 100644 samples/sensor/dht/prj.conf delete mode 100644 samples/sensor/dht/sample.yaml delete mode 100644 samples/sensor/dht/src/main.c diff --git a/samples/sensor/dht/CMakeLists.txt b/samples/sensor/dht/CMakeLists.txt deleted file mode 100644 index b22515e422f5..000000000000 --- a/samples/sensor/dht/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright (c) 2019 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: Apache-2.0 -# - -cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(dht) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/sensor/dht/README.rst b/samples/sensor/dht/README.rst deleted file mode 100644 index 20fc3276215c..000000000000 --- a/samples/sensor/dht/README.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. _dht: - -DHT: Aosong DHT Digital-output Humidity and Temperature Sensor -############################################################## - -Description -*********** - -This sample application periodically (0.5 Hz) measures the ambient -temperature and humidity. The result is written to the console. - -Wiring -******* - -This sample uses an external breakout for the sensor. A devicetree -overlay must be provided to identify the sensor variant and the GPIO -used to control the sensor. - -Building and Running -******************** - -After providing a devicetree overlay that specifies the sensor location, -build this sample app using: - -.. zephyr-app-commands:: - :zephyr-app: samples/sensor/dht - :board: nrf52dk_nrf52832 - :goals: build flash - -Sample Output -============= - -.. code-block:: console - - *** Booting Zephyr OS build zephyr-v2.1.0-329-g38418b26c4cc *** - [0:00:00.027]: 20.0 Cel ; 48.7 %RH - [0:00:02.053]: 19.8 Cel ; 48.7 %RH - [0:00:04.079]: 20.0 Cel ; 48.7 %RH - [0:00:06.105]: 19.8 Cel ; 48.7 %RH - [0:00:08.130]: 20.0 Cel ; 48.8 %RH - [0:00:10.156]: 20.1 Cel ; 48.8 %RH - [0:00:12.182]: 19.7 Cel ; 48.7 %RH - [0:00:14.207]: 20.0 Cel ; 48.8 %RH - - diff --git a/samples/sensor/dht/boards/nrf52dk_nrf52832.overlay b/samples/sensor/dht/boards/nrf52dk_nrf52832.overlay deleted file mode 100644 index 910c41abfe13..000000000000 --- a/samples/sensor/dht/boards/nrf52dk_nrf52832.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/ { - dht22 { - compatible = "aosong,dht"; - status = "okay"; - label = "DHT22"; - dio-gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - dht22; - }; -}; diff --git a/samples/sensor/dht/prj.conf b/samples/sensor/dht/prj.conf deleted file mode 100644 index cdddc2442ffe..000000000000 --- a/samples/sensor/dht/prj.conf +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2019 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: Apache-2.0 -# - -CONFIG_SENSOR=y -CONFIG_GPIO=y -CONFIG_DHT=y - -# Need float format support -CONFIG_NEWLIB_LIBC=y -CONFIG_NEWLIB_LIBC_NANO=n -CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y -CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/samples/sensor/dht/sample.yaml b/samples/sensor/dht/sample.yaml deleted file mode 100644 index 74f346bd31dd..000000000000 --- a/samples/sensor/dht/sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (c) 2019 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: Apache-2.0 -# - -common: - filter: TOOLCHAIN_HAS_NEWLIB == 1 -sample: - name: DHT Sensor Sample -tests: - sample.sensor.dht: - build_only: true - platform_allow: nrf52dk_nrf52832 - integration_platforms: - - nrf52dk_nrf52832 - tags: sensors diff --git a/samples/sensor/dht/src/main.c b/samples/sensor/dht/src/main.c deleted file mode 100644 index 922a2a2c2ca1..000000000000 --- a/samples/sensor/dht/src/main.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -static const char *now_str(void) -{ - static char buf[16]; /* ...HH:MM:SS.MMM */ - uint32_t now = k_uptime_get_32(); - unsigned int ms = now % MSEC_PER_SEC; - unsigned int s; - unsigned int min; - unsigned int h; - - now /= MSEC_PER_SEC; - s = now % 60U; - now /= 60U; - min = now % 60U; - now /= 60U; - h = now; - - snprintf(buf, sizeof(buf), "%u:%02u:%02u.%03u", - h, min, s, ms); - return buf; -} - -void main(void) -{ - const char *const label = DT_LABEL(DT_INST(0, aosong_dht)); - const struct device *dht22 = device_get_binding(label); - - if (!dht22) { - printf("Failed to find sensor %s\n", label); - return; - } - - while (true) { - int rc = sensor_sample_fetch(dht22); - - if (rc != 0) { - printf("Sensor fetch failed: %d\n", rc); - break; - } - - struct sensor_value temperature; - struct sensor_value humidity; - - rc = sensor_channel_get(dht22, SENSOR_CHAN_AMBIENT_TEMP, - &temperature); - if (rc == 0) { - rc = sensor_channel_get(dht22, SENSOR_CHAN_HUMIDITY, - &humidity); - } - if (rc != 0) { - printf("get failed: %d\n", rc); - break; - } - - printf("[%s]: %.1f Cel ; %.1f %%RH\n", - now_str(), - sensor_value_to_double(&temperature), - sensor_value_to_double(&humidity)); - k_sleep(K_SECONDS(2)); - } -} From 2dd7907f76db45b6aa9bab8393e228c2de8491f3 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 18 May 2021 14:10:42 -0400 Subject: [PATCH 12/13] samples: sensor: add unified environment sensing sample Merge all sensor samples into one. Signed-off-by: Anas Nashif --- cmake/compiler/gcc/compiler_flags.cmake | 2 + samples/sensor/env_sensing/CMakeLists.txt | 19 ++ samples/sensor/env_sensing/Kconfig | 163 ++++++++++++++ samples/sensor/env_sensing/README.rst | 36 +++ samples/sensor/env_sensing/prj.conf | 4 + samples/sensor/env_sensing/sample.yaml | 15 ++ .../env_sensing/sensor_overlay/bme280.overlay | 20 ++ .../sensor_overlay/bme280_spi.overlay | 18 ++ .../env_sensing/sensor_overlay/bme680.overlay | 14 ++ .../env_sensing/sensor_overlay/dps310.overlay | 18 ++ .../env_sensing/sensor_overlay/ens210.overlay | 15 ++ .../sensor_overlay/hdc1080.overlay | 15 ++ .../env_sensing/sensor_overlay/hts221.overlay | 14 ++ .../sensor_overlay/lps22hb-press.overlay | 12 + .../sensor_overlay/lps22hh.overlay | 14 ++ .../sensor_overlay/max6675.overlay | 14 ++ .../sensor_overlay/mcp9808.overlay | 14 ++ .../env_sensing/sensor_overlay/ms5837.overlay | 15 ++ .../env_sensing/sensor_overlay/sht3xd.overlay | 14 ++ .../env_sensing/sensor_overlay/th02.overlay | 13 ++ samples/sensor/env_sensing/src/disp.h | 17 ++ samples/sensor/env_sensing/src/grove_lcd.c | 70 ++++++ samples/sensor/env_sensing/src/lvgl.c | 151 +++++++++++++ samples/sensor/env_sensing/src/main.c | 170 ++++++++++++++ samples/sensor/env_sensing/src/resources.h | 211 ++++++++++++++++++ 25 files changed, 1068 insertions(+) create mode 100644 samples/sensor/env_sensing/CMakeLists.txt create mode 100644 samples/sensor/env_sensing/Kconfig create mode 100644 samples/sensor/env_sensing/README.rst create mode 100644 samples/sensor/env_sensing/prj.conf create mode 100644 samples/sensor/env_sensing/sample.yaml create mode 100644 samples/sensor/env_sensing/sensor_overlay/bme280.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/bme680.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/dps310.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/ens210.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/hts221.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/max6675.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/ms5837.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay create mode 100644 samples/sensor/env_sensing/sensor_overlay/th02.overlay create mode 100644 samples/sensor/env_sensing/src/disp.h create mode 100644 samples/sensor/env_sensing/src/grove_lcd.c create mode 100644 samples/sensor/env_sensing/src/lvgl.c create mode 100644 samples/sensor/env_sensing/src/main.c create mode 100644 samples/sensor/env_sensing/src/resources.h diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index f0e92c7f74f7..3e5b2fc23556 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -3,6 +3,7 @@ list(APPEND CXX_EXCLUDED_OPTIONS -Werror=implicit-int -Wold-style-definition -Wno-pointer-sign + -Wno-attributes ) ######################################################## @@ -32,6 +33,7 @@ set_compiler_property(PROPERTY warning_base -Wformat-security -Wno-format-zero-length -Wno-main + -Wno-attributes ) check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) diff --git a/samples/sensor/env_sensing/CMakeLists.txt b/samples/sensor/env_sensing/CMakeLists.txt new file mode 100644 index 000000000000..da0ab7a8f570 --- /dev/null +++ b/samples/sensor/env_sensing/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) + +if(DEFINED SENSOR) + set(DTC_OVERLAY_FILE sensor_overlay/${SENSOR}.overlay) +else() + set(DTC_OVERLAY_FILE sensor_overlay/bme680.overlay) +endif() + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(env_sensing) + + +FILE(GLOB app_sources src/main.c) + +target_sources(app PRIVATE ${app_sources}) +target_sources_ifdef(CONFIG_SAMPLE_DISPLAY_GROVE app PRIVATE src/grove_lcd.c) +target_sources_ifdef(CONFIG_SAMPLE_DISPLAY_LVGL app PRIVATE src/lvgl.c) diff --git a/samples/sensor/env_sensing/Kconfig b/samples/sensor/env_sensing/Kconfig new file mode 100644 index 000000000000..90384c8f7f49 --- /dev/null +++ b/samples/sensor/env_sensing/Kconfig @@ -0,0 +1,163 @@ +# Copyright (c) 2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +choice + prompt "Select Display" + default SAMPLE_DISPLAY_NONE + +config SAMPLE_DISPLAY_NONE + bool "No Display" + +config SAMPLE_DISPLAY_GROVE + bool "Grove LCD Display" + select GROVE_LCD_RGB + select DISPLAY + +config SAMPLE_DISPLAY_LVGL + bool "LVGL Display" + select LVGL + select DISPLAY + select LVGL_USE_LABEL + select LVGL_USE_CONT + select LVGL_USE_BTN + select LVGL_FONT_MONTSERRAT_14 + select LVGL_FONT_MONTSERRAT_16 + select LVGL_FONT_MONTSERRAT_18 + select LVGL_FONT_MONTSERRAT_22 + select LVGL_USE_IMG + select LVGL_USE_LINEMETER + select LVGL_USE_PAGE + +endchoice + + +if LVGL +config HEAP_MEM_POOL_SIZE + default 16384 + +config MAIN_STACK_SIZE + default 2048 + +endif + +if GROVE_LCD_RGB +config GROVE_LCD_RGB_I2C_MASTER_DEV_NAME + default "I2C_0" + +endif + + +config HAS_TEMPERATURE + bool + +config HAS_HUMIDITY + bool + +config HAS_PRESSURE + bool + +config HAS_GAS + bool + +config SAMPLE_SENSOR_TRIGGER + bool "Enable Trigger" + +choice + prompt "Select Sensor" + default SAMPLE_SENSOR_BME680 + +config SAMPLE_SENSOR_BME680 + bool "BME680" + select BME680 + select HAS_TEMPERATURE + select HAS_HUMIDITY + select HAS_PRESSURE + select HAS_GAS + +config SAMPLE_SENSOR_TH02 + bool "TH02" + select TH02 + select HAS_TEMPERATURE + +config SAMPLE_SENSOR_SI7006 + bool "SI7006" + select SI7006 + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_DHT + bool "DHT" + select DHT + select GPIO + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_LPS22HB + bool "LPS22HB" + select LPS22HB + select HAS_TEMPERATURE + select HAS_PRESSURE + +config SAMPLE_SENSOR_LPS22HH + bool "LPS22HH" + select LPS22HH + select HAS_TEMPERATURE + select HAS_PRESSURE + +config SAMPLE_SENSOR_MS5837 + bool "MS5837" + select MS5837 + select HAS_TEMPERATURE + select HAS_PRESSURE + +config SAMPLE_SENSOR_HDC1080 + bool "HDC1080" + select TI_HDC + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_ENS210 + bool "ENS210" + select ENS210 + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_DPS310 + bool "DPS310" + select DPS310 + select HAS_TEMPERATURE + +config SAMPLE_SENSOR_MCP9808 + bool "MCP9808" + select MCP9808 + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_HTS221 + bool "HTS221" + select HTS221 + select HAS_TEMPERATURE + select HAS_HUMIDITY + +config SAMPLE_SENSOR_BME280 + bool "BME 280" + select BME280 + select HAS_TEMPERATURE + select HAS_HUMIDITY + select HAS_PRESSURE + +config SAMPLE_SENSOR_TMP007 + bool "TMP007" + select TMP007 + select HAS_TEMPERATURE + +config SAMPLE_SENSOR_SHT3XD + bool "SHT3XD" + select SHT3XD + select HAS_HUMIDITY + select SHT3XD_TRIGGER if SAMPLE_SENSOR_TRIGGER + +endchoice + + +source "Kconfig.zephyr" diff --git a/samples/sensor/env_sensing/README.rst b/samples/sensor/env_sensing/README.rst new file mode 100644 index 000000000000..9fd7e5eb8e04 --- /dev/null +++ b/samples/sensor/env_sensing/README.rst @@ -0,0 +1,36 @@ +.. _env_sensing: + +Environment Sensing +#################### + +Overview +******** + +TBD + +Requirements +************ + +TBD + +References +********** + + +Building and Running +******************** + + This project outputs sensor data to the console. It requires an HTS221 + sensor, which is present on the disco_l475_iot1 board. + +.. zephyr-app-commands:: + :zephyr-app: samples/sensor/env_sensing + :board: disco_l475_iot1 + :goals: build + :compact: + +Sample Output +============= + + +TBD diff --git a/samples/sensor/env_sensing/prj.conf b/samples/sensor/env_sensing/prj.conf new file mode 100644 index 000000000000..924d933f5749 --- /dev/null +++ b/samples/sensor/env_sensing/prj.conf @@ -0,0 +1,4 @@ +CONFIG_I2C=y +CONFIG_SENSOR=y +CONFIG_CBPRINTF_FP_SUPPORT=y +CONFIG_LVGL_USE_THEME_MATERIAL=y diff --git a/samples/sensor/env_sensing/sample.yaml b/samples/sensor/env_sensing/sample.yaml new file mode 100644 index 000000000000..0bf130253cc8 --- /dev/null +++ b/samples/sensor/env_sensing/sample.yaml @@ -0,0 +1,15 @@ +sample: + name: Environmnt Sensing Application +tests: + sample.sensor.env_sensing: + harness: console + tags: sensors + depends_on: arduino_i2c + integration_platforms: + - frdm_k64f + harness_config: + type: multi_line + ordered: yes + regex: + - "Temperature: (.*)" + - "Relative Humidity: (.*)" diff --git a/samples/sensor/env_sensing/sensor_overlay/bme280.overlay b/samples/sensor/env_sensing/sensor_overlay/bme280.overlay new file mode 100644 index 000000000000..95a8fadd82b5 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/bme280.overlay @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Example configuration of a BME280 device on an Arduino I2C bus. + * + * Device address 0x77 is assumed. Your device may have a different + * address; check your device documentation if unsure. + */ +&arduino_i2c { + status = "okay"; + bme280@77 { + compatible = "bosch,bme280"; + reg = <0x77>; + label = "BME280_I2C"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay b/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay new file mode 100644 index 000000000000..c368ceb1d293 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Example configuration of a BME280 device on an Arduino SPI bus. */ + +&arduino_spi { + status = "okay"; + cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; + bme280@0 { + compatible = "bosch,bme280"; + reg = <0>; + label = "BME280_SPI"; + spi-max-frequency = <1000000>; /* conservatively set to 1MHz */ + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/bme680.overlay b/samples/sensor/env_sensing/sensor_overlay/bme680.overlay new file mode 100644 index 000000000000..1a8a765a3375 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/bme680.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019, Linaro Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + status = "okay"; + bme680@77 { + compatible = "bosch,bme680"; + reg = <0x77>; + label = "BME680"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/dps310.overlay b/samples/sensor/env_sensing/sensor_overlay/dps310.overlay new file mode 100644 index 000000000000..aa866af3834a --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/dps310.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 Infineon Technologies AG + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * A DPS310 attached to the Arduino I2C pins + */ + +&arduino_i2c { + DPS310@77 { + status = "okay"; + compatible = "infineon,dps310"; + reg = <0x77>; + label = "DPS310"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/ens210.overlay b/samples/sensor/env_sensing/sensor_overlay/ens210.overlay new file mode 100644 index 000000000000..6d6d0e26a718 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/ens210.overlay @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Alexander Wachter + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + status = "okay"; + clock-frequency = ; + + ens210: ens210@43 { + compatible = "ams,ens210"; + reg = <0x43>; + label = "ENS210"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay b/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay new file mode 100644 index 000000000000..f09f5d82c0ed --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2019 Centaur Analytics, Inc + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + + ti_hdc: ti_hdc@40 { + compatible = "ti,hdc","ti,hdc1080"; + reg = <0x40>; + label = "HDC1080"; + }; + +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/hts221.overlay b/samples/sensor/env_sensing/sensor_overlay/hts221.overlay new file mode 100644 index 000000000000..1b9fc300cb6e --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/hts221.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + + hts221@5f { + compatible = "st,hts221"; + reg = <0x5f>; + label = "HTS221"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay b/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay new file mode 100644 index 000000000000..a77a0dee06e3 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2021 Intel Corporation + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + lps22hb-press@5d { + compatible = "st,lps22hb-press"; + reg = <0x5d>; + label = "LPS22HB"; + }; +} diff --git a/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay b/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay new file mode 100644 index 000000000000..dfc1d601b0df --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + lps22hh@5d { + compatible = "st,lps22hh"; + reg = <0x5d>; + drdy-gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>; /* D6 */ + label = "LPS22HH"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/max6675.overlay b/samples/sensor/env_sensing/sensor_overlay/max6675.overlay new file mode 100644 index 000000000000..5b0321eb187f --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/max6675.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2021 Teslabs Engineering S.L. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_spi { + max6675@0 { + compatible = "maxim,max6675"; + reg = <0>; + spi-max-frequency = <4300000>; + label = "MAX6675"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay b/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay new file mode 100644 index 000000000000..fe06ef6ae496 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019, Linaro Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + mcp9808@18 { + compatible = "microchip,mcp9808"; + reg = <0x18>; + int-gpios = <&gpioc 16 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "MCP9808"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay b/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay new file mode 100644 index 000000000000..13b431d7971d --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + status = "okay"; + clock-frequency = ; + ms5837@76 { + compatible = "meas,ms5837"; + reg = <0x76>; + label = "MS5837"; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay b/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay new file mode 100644 index 000000000000..63798af105c4 --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 Peter Bigot Consulting, LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { /* SDA PTE25, SCL PTE24, ALERT PTE26 */ + sht3xd@44 { + compatible = "sensirion,sht3xd"; + reg = <0x44>; + label = "SHT3XD"; + alert-gpios = <&gpioe 26 GPIO_ACTIVE_HIGH>; + }; +}; diff --git a/samples/sensor/env_sensing/sensor_overlay/th02.overlay b/samples/sensor/env_sensing/sensor_overlay/th02.overlay new file mode 100644 index 000000000000..a107e22789cf --- /dev/null +++ b/samples/sensor/env_sensing/sensor_overlay/th02.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2019, Linaro Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + th02@40 { + compatible = "hoperf,th02"; + reg = <0x40>; + label = "TH02"; + }; +}; diff --git a/samples/sensor/env_sensing/src/disp.h b/samples/sensor/env_sensing/src/disp.h new file mode 100644 index 000000000000..f47b40c56ea9 --- /dev/null +++ b/samples/sensor/env_sensing/src/disp.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ENV_DISPLAY_H_ +#define ENV_DISPLAY_H_ + +void init_display(void); +void reset_display(void); +void update_display(struct sensor_value temp, + struct sensor_value hum, + struct sensor_value press, + struct sensor_value gas); + +#endif diff --git a/samples/sensor/env_sensing/src/grove_lcd.c b/samples/sensor/env_sensing/src/grove_lcd.c new file mode 100644 index 000000000000..1de17dec600b --- /dev/null +++ b/samples/sensor/env_sensing/src/grove_lcd.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include +#include +#include +#include + +#include "disp.h" + +#include +LOG_MODULE_DECLARE(main); + +extern const struct device *display; + +void init_display(void) +{ + + display = device_get_binding(GROVE_LCD_NAME); + if (display == NULL) { + LOG_ERR("Failed to get Grove LCD"); + return NULL; + } + + /* configure LCD */ + glcd_function_set(display, GLCD_FS_ROWS_2 | GLCD_FS_DOT_SIZE_LITTLE | + GLCD_FS_8BIT_MODE); + glcd_display_state_set(display, GLCD_DS_DISPLAY_ON); +} + +void reset_display(void) +{ + char row[16]; + + /* clear LCD */ + (void)memset(row, ' ', sizeof(row)); + glcd_cursor_pos_set(display, 0, 0); + glcd_print(display, row, sizeof(row)); + glcd_cursor_pos_set(display, 0, 1); + glcd_print(display, row, sizeof(row)); +} + + +void update_display(struct sensor_value temp, + struct sensor_value hum, + struct sensor_value press, + struct sensor_value gas) +{ + + char row[16]; + + glcd_cursor_pos_set(display, 0, 0); +#if CONFIG_HAS_TEMPERATURE + snprintk(row, sizeof(row), "T: %.1f%cC", sensor_value_to_double(&temp), + 223 /* degree symbol */); + glcd_print(display, row, strlen(row)); +#endif +#if CONFIG_HAS_HUMIDITY + glcd_cursor_pos_set(display, 0, 1); + snprintk(row, sizeof(row), "H: %.1f%%", + sensor_value_to_double(&hum)); + glcd_print(display, row, strlen(row)); +#endif +} diff --git a/samples/sensor/env_sensing/src/lvgl.c b/samples/sensor/env_sensing/src/lvgl.c new file mode 100644 index 000000000000..f76e7769d5b7 --- /dev/null +++ b/samples/sensor/env_sensing/src/lvgl.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2021 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include "resources.h" +#include + +extern const struct device *display; +extern const struct device *sensor_dev; + +#include +LOG_MODULE_DECLARE(main); + +lv_obj_t *temp_value_label; +lv_obj_t *humid_value_label; +lv_obj_t *pres_value_label; +lv_obj_t *LogOutput; + +lv_obj_t *city_label; +lv_obj_t *rain_meter; +lv_obj_t *rain_static; +lv_obj_t *temp_label; +lv_obj_t *pressure_label; +lv_obj_t *humidity_label; + +void init_display(void) +{ + lv_obj_t *img1; + const char *location; + static lv_style_t large_style; + + display = device_get_binding(CONFIG_LVGL_DISPLAY_DEV_NAME); + + if (display == NULL) { + LOG_ERR("Display device not found."); + return; + } + + lv_theme_t *th = + lv_theme_material_init(LV_COLOR_BLACK, LV_COLOR_WHITE, LV_THEME_MATERIAL_FLAG_DARK, + &lv_font_montserrat_14, &lv_font_montserrat_16, + &lv_font_montserrat_18, &lv_font_montserrat_22); + + lv_theme_set_act(th); + img1 = lv_img_create(lv_scr_act(), NULL); + city_label = lv_label_create(lv_scr_act(), NULL); + rain_meter = lv_linemeter_create(lv_scr_act(), NULL); + rain_static = lv_label_create(lv_scr_act(), NULL); + temp_label = lv_label_create(lv_scr_act(), NULL); + pressure_label = lv_label_create(lv_scr_act(), NULL); + humidity_label = lv_label_create(lv_scr_act(), NULL); + temp_value_label = lv_label_create(lv_scr_act(), NULL); + humid_value_label = lv_label_create(lv_scr_act(), NULL); + pres_value_label = lv_label_create(lv_scr_act(), NULL); + + + lv_style_init(&large_style); + lv_style_set_text_font(&large_style, LV_STATE_DEFAULT, lv_theme_get_font_title()); + + lv_img_set_src(img1, &cloudy); + lv_obj_set_x(img1, 20); + lv_obj_set_y(img1, 120); + lv_obj_set_style_local_image_recolor_opa(img1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, 255); + lv_obj_set_style_local_image_recolor(img1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, + LV_COLOR_WHITE); + + lv_obj_add_style(city_label, LV_LABEL_PART_MAIN, &large_style); + lv_obj_set_x(city_label, 115); + lv_obj_set_y(city_label, 10); + lv_obj_set_height(city_label, 20); + lv_obj_set_width(city_label, 50); + lv_label_set_text(city_label, location); + + lv_obj_set_x(rain_meter, 15); + lv_obj_set_y(rain_meter, 10); + lv_obj_set_width(rain_meter, 75); + lv_obj_set_height(rain_meter, 75); + lv_linemeter_set_range(rain_meter, 0, 100); + + lv_obj_set_x(rain_static, 25); + lv_obj_set_y(rain_static, 90); + lv_obj_set_width(rain_static, 60); + lv_obj_set_height(rain_static, 40); + lv_label_set_text(rain_static, "% Rain"); + + lv_obj_set_x(temp_label, 110); + lv_obj_set_y(temp_label, 50); + lv_label_set_text(temp_label, "Temp (C°)"); + + lv_obj_set_x(pressure_label, 110); + lv_obj_set_y(pressure_label, 100); + lv_label_set_text(pressure_label, "Pressure (kPa)"); + + lv_obj_set_x(humidity_label, 110); + lv_obj_set_y(humidity_label, 150); + lv_label_set_text(humidity_label, "Humidity (%)"); + + lv_obj_add_style(temp_value_label, LV_LABEL_PART_MAIN, &large_style); + lv_obj_set_x(temp_value_label, 240); + lv_obj_set_y(temp_value_label, 50); + + lv_obj_add_style(pres_value_label, LV_LABEL_PART_MAIN, &large_style); + lv_obj_set_x(pres_value_label, 240); + lv_obj_set_y(pres_value_label, 100); + + lv_obj_add_style(humid_value_label, LV_LABEL_PART_MAIN, &large_style); + lv_obj_set_x(humid_value_label, 240); + lv_obj_set_y(humid_value_label, 150); + + LogOutput = lv_label_create(lv_scr_act(), NULL); + lv_label_set_long_mode(LogOutput, LV_LABEL_LONG_CROP); + lv_label_set_recolor(LogOutput, true); + lv_label_set_align(LogOutput, LV_LABEL_ALIGN_LEFT); + lv_obj_set_width(LogOutput, 280); + lv_obj_align(LogOutput, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 200); + lv_obj_set_style_local_bg_opa(LogOutput, LV_PAGE_PART_BG, LV_STATE_DEFAULT, 64); + + lv_task_handler(); + display_blanking_off(display); +} + +void reset_display(void) +{ +} + +void update_display(struct sensor_value temp, struct sensor_value hum, struct sensor_value press, + struct sensor_value gas) +{ + display_set_brightness(display, 0); + + lv_label_set_text_fmt(temp_value_label, "%.1f", sensor_value_to_double(&temp)); +#if CONFIG_HAS_PRESSURE + lv_label_set_text_fmt(pres_value_label, "%.1f", sensor_value_to_double(&press)); +#else + lv_label_set_text(pres_value_label, "N/A"); +#endif + lv_label_set_text_fmt(humid_value_label, "%.1f", sensor_value_to_double(&hum)); + + lv_label_set_text_fmt(LogOutput, "Powered By: %s", sensor_dev->name); + lv_label_set_text_fmt(city_label, "%s", "Montreal"); + + lv_task_handler(); +} diff --git a/samples/sensor/env_sensing/src/main.c b/samples/sensor/env_sensing/src/main.c new file mode 100644 index 000000000000..0288243cc05e --- /dev/null +++ b/samples/sensor/env_sensing/src/main.c @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2017 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include "disp.h" + +const struct device *display; +const struct device *sensor_dev; + +#include +LOG_MODULE_REGISTER(main); + + +#if CONFIG_LOG +#define sensor_log(...) LOG_INF(__VA_ARGS__) +#else +#define sensor_log(fmt, ...) printk(fmt, ##__VA_ARGS__) +#endif + +static void process_sample(void) +{ + struct sensor_value gas, temp, hum, press; + + if (sensor_sample_fetch(sensor_dev) < 0) { + LOG_ERR("Sensor sample update error"); + return; + } +#if CONFIG_HAS_TEMPERATURE + if (sensor_channel_get(sensor_dev, SENSOR_CHAN_AMBIENT_TEMP, &temp) < 0) { + LOG_ERR("Cannot read temperature channel"); + return; + } +#endif +#if CONFIG_HAS_HUMIDITY + if (sensor_channel_get(sensor_dev, SENSOR_CHAN_HUMIDITY, &hum) < 0) { + LOG_ERR("Cannot read humidity channel"); + return; + } +#endif +#if CONFIG_HAS_PRESSURE + if (sensor_channel_get(sensor_dev, SENSOR_CHAN_PRESS, &press) < 0) { + LOG_ERR("Cannot read pressure channel"); + return; + } +#endif +#if CONFIG_HAS_GAS + if (sensor_channel_get(sensor_dev, SENSOR_CHAN_GAS_RES, &gas) < 0) { + LOG_ERR("Cannot read gas channel"); + return; + } +#endif + + +#ifndef CONFIG_SAMPLE_DISPLAY_NONE + update_display(temp, hum, press, gas); +#endif + + if (IS_ENABLED(CONFIG_HAS_TEMPERATURE)) { + sensor_log("Temperature: %.1f C\n", sensor_value_to_double(&temp)); + } + if (IS_ENABLED(CONFIG_HAS_HUMIDITY)) { + sensor_log("Relative Humidity: %.1f%%\n", sensor_value_to_double(&hum)); + } + if (IS_ENABLED(CONFIG_HAS_PRESSURE)) { + sensor_log("Pressure: %.2f kPa", sensor_value_to_double(&press)); + } + if (IS_ENABLED(CONFIG_HAS_GAS)) { + sensor_log("Gas: %.2f", sensor_value_to_double(&gas)); + } +} + +static void handler_(const struct device *dev, + struct sensor_trigger *trig) +{ + process_sample(); +} + + +void main(void) +{ + +#if defined(CONFIG_HTS221) + sensor_dev = DEVICE_DT_GET_ANY(st_hts221); +#elif defined(CONFIG_TH02) + sensor_dev = DEVICE_DT_GET_ANY(hoperf_th02); +#elif defined(CONFIG_BME280) + sensor_dev = DEVICE_DT_GET_ANY(bosch_bme280); +#elif defined(CONFIG_TMP007) + sensor_dev = DEVICE_DT_GET_ANY(ti_tmp007); +#elif defined(CONFIG_SHT3XD) + sensor_dev = DEVICE_DT_GET_ANY(sensirion_sht3xd); +#elif defined(CONFIG_BME680) + sensor_dev = DEVICE_DT_GET_ANY(bosch_bme680); +#elif defined(CONFIG_MCP9808) + sensor_dev = DEVICE_DT_GET_ANY(microchip_mcp9808); +#elif defined(CONFIG_DPS310) + sensor_dev = DEVICE_DT_GET_ANY(infineon_dps310); +#elif defined(CONFIG_TI_HDC) + sensor_dev = DEVICE_DT_GET_ANY(ti_hdc); +#elif defined(CONFIG_MAX6675) + sensor_dev = DEVICE_DT_GET_ANY(maxim_max6675); +#elif defined(CONFIG_LPS22HB) + sensor_dev = DEVICE_DT_GET_ANY(st_lps22hb_press); +#elif defined(CONFIG_LPS22HH) + sensor_dev = DEVICE_DT_GET_ANY(st_lps22hh); +#elif defined(CONFIG_ENS210) + sensor_dev = DEVICE_DT_GET_ANY(ams_ens210); +#elif defined(CONFIG_DHT) + sensor_dev = DEVICE_DT_GET_ANY(aosong_dht); +#elif defined(CONFIG_SI7006) + sensor_dev = DEVICE_DT_GET_ANY(silabs_si7006); +#else +#error Not defined +#endif + + if (sensor_dev == NULL) { + LOG_ERR("Could not get sensor device"); + return; + } + if (!device_is_ready(sensor_dev)) { + LOG_ERR("Device %s is not ready.", sensor_dev->name); + return; + } + + +#ifdef CONFIG_SAMPLE_SENSOR_TRIGGER + rc = set_window_ucel(sensor_dev, TEMP_INITIAL_CEL * UCEL_PER_CEL); + if (rc == 0) { + trig.type = SENSOR_TRIG_THRESHOLD; + trig.chan = SENSOR_CHAN_AMBIENT_TEMP; + rc = sensor_trigger_set(dev, &trig, trigger_handler); + } + + if (rc != 0) { + printf("Trigger set failed: %d\n", rc); + return; + } + printk("Trigger set got %d\n", rc); +#endif + +#ifndef CONFIG_SAMPLE_DISPLAY_NONE + init_display(); + reset_display(); +#endif + + if (IS_ENABLED(CONFIG_SAMPLE_SENSOR_TRIGGER)) { + struct sensor_trigger trig = { + .type = SENSOR_TRIG_DATA_READY, + .chan = SENSOR_CHAN_ALL, + }; + if (sensor_trigger_set(sensor_dev, &trig, handler_) < 0) { + LOG_ERR("Cannot configure trigger"); + return; + } + } + + while (!IS_ENABLED(CONFIG_SAMPLE_SENSOR_TRIGGER)) { + process_sample(); + k_sleep(K_MSEC(2000)); + } + k_sleep(K_FOREVER); +} diff --git a/samples/sensor/env_sensing/src/resources.h b/samples/sensor/env_sensing/src/resources.h new file mode 100644 index 000000000000..4334083614cc --- /dev/null +++ b/samples/sensor/env_sensing/src/resources.h @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2021 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef LVGL_RESOURCES_H_ +#define LVGL_RESOURCES_H_ + +#include + +extern const char *location; + +#ifndef LV_ATTRIBUTE_MEM_ALIGN +#define LV_ATTRIBUTE_MEM_ALIGN +#endif + +#ifndef LV_ATTRIBUTE_IMG_CLOUDY +#define LV_ATTRIBUTE_IMG_CLOUDY +#endif + +#ifndef LV_ATTRIBUTE_IMG_RAINY +#define LV_ATTRIBUTE_IMG_RAINY +#endif + +#ifndef LV_ATTRIBUTE_IMG_FOGGY +#define LV_ATTRIBUTE_IMG_FOGGY +#endif + +#ifndef LV_ATTRIBUTE_IMG_SUNNY +#define LV_ATTRIBUTE_IMG_SUNNY +#endif + +const LV_ATTRIBUTE_MEM_ALIGN + LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_CLOUDY uint8_t cloudy_map[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, + 0x00, 0x03, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x00, + 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf0, + 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, + 0xfc, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, + 0xff, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0xff, + 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +const lv_img_header_t cloudy_header = { LV_IMG_CF_ALPHA_1BIT, 0, 2, 64, 64 }; + +const lv_img_dsc_t cloudy = { cloudy_header, 512, cloudy_map }; + +LV_IMG_DECLARE(cloudy); + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_RAINY uint8_t rainy_map[] = { + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, + 0xff, 0xc0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xff, + 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x1f, + 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, + 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, + 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, + 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x0e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, + 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x18, 0x00, 0x00, + 0x00, 0x0f, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x0f, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, + 0x00, 0x00, +}; + +const lv_img_header_t rainy_header = { LV_IMG_CF_ALPHA_1BIT, 0, 2, 64, 64 }; + +const lv_img_dsc_t rainy = { rainy_header, 512, rainy_map }; + +LV_IMG_DECLARE(rainy); + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_FOGGY uint8_t foggy_map[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1e, + 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x1e, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x0f, 0xff, 0xff, 0x07, 0xff, 0xe0, + 0x00, 0x00, 0x1f, 0xff, 0xff, 0x8f, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xcf, 0xff, + 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xc7, 0xff, 0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xe1, + 0xf8, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xf0, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf1, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x70, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, + 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x70, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf8, + 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xe0, 0x00, 0x07, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, + 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, + 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x00, + 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, + 0x07, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0f, 0xf0, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x01, + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +const lv_img_header_t foggy_header = { LV_IMG_CF_ALPHA_1BIT, 0, 2, 64, 64 }; + +const lv_img_dsc_t foggy = { foggy_header, 512, foggy_map }; + +LV_IMG_DECLARE(foggy); + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_SUNNY uint8_t sunny_map[] = { + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0xe0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0xe0, + 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x81, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc1, + 0xe0, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x78, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x00, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0xf8, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x70, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0e, 0x00, 0x7f, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x1f, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0x00, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x1e, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, + 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, + 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x01, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, + 0x00, 0x07, 0x83, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x07, 0x81, 0xff, 0xff, 0xff, 0xff, + 0x80, 0x00, 0x07, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x00, 0x7f, 0xff, 0xff, + 0xfe, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, + 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x01, 0xc0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, + 0x00, 0x00, +}; + +const lv_img_header_t sunny_header = { LV_IMG_CF_ALPHA_1BIT, 0, 2, 64, 64 }; + +const lv_img_dsc_t sunny = { sunny_header, 512, sunny_map }; + +LV_IMG_DECLARE(sunny); + +#endif /* LVGL_RESOURCES_H_ */ From a09f9a18c50e1d21095db2c0e2b6076e7251381e Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 8 Jun 2021 19:55:44 -0400 Subject: [PATCH 13/13] sample: env_sensing: use NODELABEL Use NODELABEL and a unified label for all sensors set in overlays, this way we just address the temperature/humidity sensor using env_sensor. Learned that today in Marti's device tree talk :-) Signed-off-by: Anas Nashif --- .../env_sensing/sensor_overlay/bme280.overlay | 2 +- .../sensor_overlay/bme280_spi.overlay | 2 +- .../env_sensing/sensor_overlay/bme680.overlay | 2 +- .../env_sensing/sensor_overlay/dps310.overlay | 2 +- .../env_sensing/sensor_overlay/ens210.overlay | 2 +- .../sensor_overlay/hdc1080.overlay | 2 +- .../env_sensing/sensor_overlay/hts221.overlay | 2 +- .../sensor_overlay/lps22hb-press.overlay | 2 +- .../sensor_overlay/lps22hh.overlay | 2 +- .../sensor_overlay/max6675.overlay | 2 +- .../sensor_overlay/mcp9808.overlay | 2 +- .../env_sensing/sensor_overlay/ms5837.overlay | 2 +- .../env_sensing/sensor_overlay/sht3xd.overlay | 2 +- .../env_sensing/sensor_overlay/th02.overlay | 2 +- samples/sensor/env_sensing/src/main.c | 39 ++----------------- 15 files changed, 17 insertions(+), 50 deletions(-) diff --git a/samples/sensor/env_sensing/sensor_overlay/bme280.overlay b/samples/sensor/env_sensing/sensor_overlay/bme280.overlay index 95a8fadd82b5..04d25aa3f2ea 100644 --- a/samples/sensor/env_sensing/sensor_overlay/bme280.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/bme280.overlay @@ -12,7 +12,7 @@ */ &arduino_i2c { status = "okay"; - bme280@77 { + env_sensor: bme280@77 { compatible = "bosch,bme280"; reg = <0x77>; label = "BME280_I2C"; diff --git a/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay b/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay index c368ceb1d293..92476ec3b7e2 100644 --- a/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/bme280_spi.overlay @@ -9,7 +9,7 @@ &arduino_spi { status = "okay"; cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; - bme280@0 { + env_sensor: bme280@0 { compatible = "bosch,bme280"; reg = <0>; label = "BME280_SPI"; diff --git a/samples/sensor/env_sensing/sensor_overlay/bme680.overlay b/samples/sensor/env_sensing/sensor_overlay/bme680.overlay index 1a8a765a3375..f6ef9518b1d2 100644 --- a/samples/sensor/env_sensing/sensor_overlay/bme680.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/bme680.overlay @@ -6,7 +6,7 @@ &arduino_i2c { status = "okay"; - bme680@77 { + env_sensor: bme680@77 { compatible = "bosch,bme680"; reg = <0x77>; label = "BME680"; diff --git a/samples/sensor/env_sensing/sensor_overlay/dps310.overlay b/samples/sensor/env_sensing/sensor_overlay/dps310.overlay index aa866af3834a..99a13be16030 100644 --- a/samples/sensor/env_sensing/sensor_overlay/dps310.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/dps310.overlay @@ -9,7 +9,7 @@ */ &arduino_i2c { - DPS310@77 { + env_sensor: DPS310@77 { status = "okay"; compatible = "infineon,dps310"; reg = <0x77>; diff --git a/samples/sensor/env_sensing/sensor_overlay/ens210.overlay b/samples/sensor/env_sensing/sensor_overlay/ens210.overlay index 6d6d0e26a718..b34914de2346 100644 --- a/samples/sensor/env_sensing/sensor_overlay/ens210.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/ens210.overlay @@ -7,7 +7,7 @@ status = "okay"; clock-frequency = ; - ens210: ens210@43 { + env_sensor: ens210@43 { compatible = "ams,ens210"; reg = <0x43>; label = "ENS210"; diff --git a/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay b/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay index f09f5d82c0ed..6114961daeb4 100644 --- a/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/hdc1080.overlay @@ -6,7 +6,7 @@ &arduino_i2c { - ti_hdc: ti_hdc@40 { + env_sensor: ti_hdc@40 { compatible = "ti,hdc","ti,hdc1080"; reg = <0x40>; label = "HDC1080"; diff --git a/samples/sensor/env_sensing/sensor_overlay/hts221.overlay b/samples/sensor/env_sensing/sensor_overlay/hts221.overlay index 1b9fc300cb6e..18ad96aed862 100644 --- a/samples/sensor/env_sensing/sensor_overlay/hts221.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/hts221.overlay @@ -6,7 +6,7 @@ &arduino_i2c { - hts221@5f { + env_sensor: hts221@5f { compatible = "st,hts221"; reg = <0x5f>; label = "HTS221"; diff --git a/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay b/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay index a77a0dee06e3..e7f4d533ce2a 100644 --- a/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/lps22hb-press.overlay @@ -4,7 +4,7 @@ */ &arduino_i2c { - lps22hb-press@5d { + env_sensor: lps22hb-press@5d { compatible = "st,lps22hb-press"; reg = <0x5d>; label = "LPS22HB"; diff --git a/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay b/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay index dfc1d601b0df..321dc0dae1e9 100644 --- a/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/lps22hh.overlay @@ -5,7 +5,7 @@ */ &arduino_i2c { - lps22hh@5d { + env_sensor: lps22hh@5d { compatible = "st,lps22hh"; reg = <0x5d>; drdy-gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>; /* D6 */ diff --git a/samples/sensor/env_sensing/sensor_overlay/max6675.overlay b/samples/sensor/env_sensing/sensor_overlay/max6675.overlay index 5b0321eb187f..f880b74badbe 100644 --- a/samples/sensor/env_sensing/sensor_overlay/max6675.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/max6675.overlay @@ -5,7 +5,7 @@ */ &arduino_spi { - max6675@0 { + env_sensor: max6675@0 { compatible = "maxim,max6675"; reg = <0>; spi-max-frequency = <4300000>; diff --git a/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay b/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay index fe06ef6ae496..87caeb909f4a 100644 --- a/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/mcp9808.overlay @@ -5,7 +5,7 @@ */ &arduino_i2c { - mcp9808@18 { + env_sensor: mcp9808@18 { compatible = "microchip,mcp9808"; reg = <0x18>; int-gpios = <&gpioc 16 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; diff --git a/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay b/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay index 13b431d7971d..2f799d4a13d7 100644 --- a/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/ms5837.overlay @@ -7,7 +7,7 @@ &arduino_i2c { status = "okay"; clock-frequency = ; - ms5837@76 { + env_sensor: ms5837@76 { compatible = "meas,ms5837"; reg = <0x76>; label = "MS5837"; diff --git a/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay b/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay index 63798af105c4..884318b3937d 100644 --- a/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/sht3xd.overlay @@ -5,7 +5,7 @@ */ &arduino_i2c { /* SDA PTE25, SCL PTE24, ALERT PTE26 */ - sht3xd@44 { + env_sensor: sht3xd@44 { compatible = "sensirion,sht3xd"; reg = <0x44>; label = "SHT3XD"; diff --git a/samples/sensor/env_sensing/sensor_overlay/th02.overlay b/samples/sensor/env_sensing/sensor_overlay/th02.overlay index a107e22789cf..988b9baa5710 100644 --- a/samples/sensor/env_sensing/sensor_overlay/th02.overlay +++ b/samples/sensor/env_sensing/sensor_overlay/th02.overlay @@ -5,7 +5,7 @@ */ &arduino_i2c { - th02@40 { + env_sensor: th02@40 { compatible = "hoperf,th02"; reg = <0x40>; label = "TH02"; diff --git a/samples/sensor/env_sensing/src/main.c b/samples/sensor/env_sensing/src/main.c index 0288243cc05e..f33e983809b3 100644 --- a/samples/sensor/env_sensing/src/main.c +++ b/samples/sensor/env_sensing/src/main.c @@ -70,10 +70,10 @@ static void process_sample(void) sensor_log("Relative Humidity: %.1f%%\n", sensor_value_to_double(&hum)); } if (IS_ENABLED(CONFIG_HAS_PRESSURE)) { - sensor_log("Pressure: %.2f kPa", sensor_value_to_double(&press)); + sensor_log("Pressure: %.2f kPa\n", sensor_value_to_double(&press)); } if (IS_ENABLED(CONFIG_HAS_GAS)) { - sensor_log("Gas: %.2f", sensor_value_to_double(&gas)); + sensor_log("Gas: %.2f\n", sensor_value_to_double(&gas)); } } @@ -86,40 +86,7 @@ static void handler_(const struct device *dev, void main(void) { - -#if defined(CONFIG_HTS221) - sensor_dev = DEVICE_DT_GET_ANY(st_hts221); -#elif defined(CONFIG_TH02) - sensor_dev = DEVICE_DT_GET_ANY(hoperf_th02); -#elif defined(CONFIG_BME280) - sensor_dev = DEVICE_DT_GET_ANY(bosch_bme280); -#elif defined(CONFIG_TMP007) - sensor_dev = DEVICE_DT_GET_ANY(ti_tmp007); -#elif defined(CONFIG_SHT3XD) - sensor_dev = DEVICE_DT_GET_ANY(sensirion_sht3xd); -#elif defined(CONFIG_BME680) - sensor_dev = DEVICE_DT_GET_ANY(bosch_bme680); -#elif defined(CONFIG_MCP9808) - sensor_dev = DEVICE_DT_GET_ANY(microchip_mcp9808); -#elif defined(CONFIG_DPS310) - sensor_dev = DEVICE_DT_GET_ANY(infineon_dps310); -#elif defined(CONFIG_TI_HDC) - sensor_dev = DEVICE_DT_GET_ANY(ti_hdc); -#elif defined(CONFIG_MAX6675) - sensor_dev = DEVICE_DT_GET_ANY(maxim_max6675); -#elif defined(CONFIG_LPS22HB) - sensor_dev = DEVICE_DT_GET_ANY(st_lps22hb_press); -#elif defined(CONFIG_LPS22HH) - sensor_dev = DEVICE_DT_GET_ANY(st_lps22hh); -#elif defined(CONFIG_ENS210) - sensor_dev = DEVICE_DT_GET_ANY(ams_ens210); -#elif defined(CONFIG_DHT) - sensor_dev = DEVICE_DT_GET_ANY(aosong_dht); -#elif defined(CONFIG_SI7006) - sensor_dev = DEVICE_DT_GET_ANY(silabs_si7006); -#else -#error Not defined -#endif + sensor_dev = DEVICE_DT_GET(DT_NODELABEL(env_sensor)); if (sensor_dev == NULL) { LOG_ERR("Could not get sensor device");