Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove many duplicate samples for temperature sensors, add unified sample #35854

Closed
wants to merge 13 commits into from

Conversation

nashif
Copy link
Member

@nashif nashif commented Jun 1, 2021

  • samples: sensors: remove dps310 sensor sample
  • samples: sensor: remove thermometer sample
  • samples: sensor: remove TI HDC1080 sample
  • samples: sensor: remove th02 sample
  • samples: sensor: remove ms5837 sample
  • samples: sensor: remove MAX6675 sample
  • samples: sensor: remove grove sample
  • samples: sensor: remove LPS22HB sample
  • samples: sensor: remove ENS210 sample
  • samples: sensor: remove BME680 sample
  • samples: sensor: remove DHT sample
  • samples: sensor: add unified environment sensing sample

The above are so far the samples I removed, more to come. The goal is to have 1 samples for all those temp/humidity/pressure/gas samples and have them all in one single application that support those sensors that had samples already but also support sensors that never had a way to verify and test them.

I also took the opportunity to make this all work with various displays, one being the grove lcd and then also using some of the TFT shields using LVGL. Still work in progress and more sensors to integrate, also trying to find a decent way to support additional sensors without adding more ifdef`ry.

Right now you can build this with display support like this:

west build -b nrf5340dk_nrf5340_cpuapp samples/sensor/temperature/ -- -DCONFIG_SAMPLE_SENSOR_HDC1080=y -DCONFIG_SAMPLE_DISPLAY_LVGL=y -DSENSOR=hdc1080 -DCONFIG_LOG=y -DCONFIG_LOG_MODE_IMMEDIATE=y  -DSHIELD=adafruit_2_8_tft_touch_v2

or you can skip display completely and just get something on the screen:

 west build -b frdm_k64f samples/sensor/temperature/ -- -DCONFIG_SAMPLE_SENSOR_SI7006=y -DCONFIG_SAMPLE_DISPLAY_NONE=y -DSENSOR=si7006 -DCONFIG_LOG=y

@nashif nashif requested a review from MaureenHelm as a code owner June 1, 2021 23:06
@nashif nashif marked this pull request as draft June 1, 2021 23:06
@nashif nashif requested review from carlescufi and galak June 1, 2021 23:12
@nashif nashif added the area: Sensors Sensors label Jun 1, 2021
@nashif nashif force-pushed the sensor_cleanup branch 2 times, most recently from ce705e1 to 6dcb414 Compare June 2, 2021 14:30
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we unifying display and sensor samples?

I don't think the environmental sensor app should have any display code in it. The console should be fine.

@nashif
Copy link
Member Author

nashif commented Jun 2, 2021

Why are we unifying display and sensor samples?

because this is a sample and should be as close as possible to how sensors will be used, this is not a test to only exercise sensor code. Sample start to be useful when they integrate multiple features and subsystems. Also, you can drop the display completely using the configs and just get console output if you wish.

@erwango erwango requested a review from avisconti June 9, 2021 07:29
@avisconti
Copy link
Collaborator

Why are we unifying display and sensor samples?

because this is a sample and should be as close as possible to how sensors will be used, this is not a test to only exercise sensor code. Sample start to be useful when they integrate multiple features and subsystems. Also, you can drop the display completely using the configs and just get console output if you wish.

I like this idea. I had same doubt infact.

@avisconti
Copy link
Collaborator

The approach seems good to me. I guess it is currently not complete, as for example the triggers are not enabled for all sensors. Moreover I wonder if in documentation we should also list the complete set of boards/shields for a given sensor (e.g. for HTS221 it is just listed disco_l475_iot1, but you can also obtain it from a shield already supported in zephyr, which might makes things too complicated though)

void main(void)
{

#if defined(CONFIG_HTS221)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to remove all the duplicate samples but this PR just shift the issue to the one big sample, look at this #elfi tree below, this will continue to grow. The same for all the "config SAMPLE_SENSOR_*.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code was already removed in the latest patch and simplified even more. Still trying to find a more flexible solution with Kconfigs and DTS, but this is a price we have to pay to make this work regardless of board and sensor, we just need to make it suck less. Open for suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us use labels and device name, and prefix it with device type, like you did it for I2C shell, or as I suggested in #21709, 😄 duck and run away

@nashif
Copy link
Member Author

nashif commented Jun 9, 2021

I guess it is currently not complete, as for example the triggers are not enabled for all sensors.

yes, still need to to do the triggers.

nashif added 11 commits June 9, 2021 06:59
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
nashif added 2 commits June 9, 2021 07:25
Merge all sensor samples into one.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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 <anas.nashif@intel.com>
@mbolivar-nordic mbolivar-nordic self-requested a review June 9, 2021 15:08
@mbolivar-nordic
Copy link
Contributor

mbolivar-nordic commented Jun 9, 2021

I'm really against this approach (mixing display and sensor code in a single sample). I won't block the PR.

@nashif
Copy link
Member Author

nashif commented Jun 9, 2021

I'm really against this approach (mixing display and sensor code in a single sample). I won't block the PR.

  • last point in User Experience Study Recommendations #27073.
  • We already have some of the samples being removed in this PR use display, so this is not new.
  • This is probably not going to be the only sample to cover temp/humidity sensors, we can have 3-4 levels of samples, i.e. hello world with console only, w/ display, w/ BT (something we had in the past but was removed at some point..)

@mbolivar-nordic
Copy link
Contributor

This just says " Comprehensive sample app and tutorial."

I have no idea how that applies to this PR.

  • We already have some of the samples being removed in this PR use display, so this is not new.

In my view, that means a bad decision was previously localized to just a few samples, and now will affect the only sample for a large variety of drivers. This is worse than what we had before in my opinion.

  • This is probably not going to be the only sample to cover temp/humidity sensors, we can have 3-4 levels of samples, i.e. hello world with console only, w/ display, w/ BT (something we had in the past but was removed at some point..)

I think a small, self-contained sample is best. So a sample for sensor with console only in some directory sounds great. I really appreciate the effort towards that. But then I think the better idea would be a separate sample for displays. Mixing drivers like this in a single sample makes it harder for application developers to copy/paste just what they need for the driver they're trying to get working.

But like I said, I'm not blocking this PR.

@github-actions
Copy link

github-actions bot commented Aug 9, 2021

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Aug 9, 2021
@github-actions github-actions bot closed this Aug 24, 2021
@nashif nashif removed the Stale label Sep 7, 2021
@nashif nashif reopened this Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Nov 7, 2021

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 7, 2021
@nashif nashif removed the Stale label Nov 7, 2021
@github-actions
Copy link

github-actions bot commented Jan 7, 2022

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jan 7, 2022
@github-actions github-actions bot closed this Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants