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

feat: Added APDS9960 Gesture, Color, Proximity and Ambient Light Sensor #2539

Merged
merged 6 commits into from
Aug 25, 2024

Conversation

AsCress
Copy link
Contributor

@AsCress AsCress commented Aug 19, 2024

Adds support for the APDS9960 Gesture, Color, Proximity and Ambient Light Sensor.

The APDS9960 is a versatile digital, RGB, ambient light, proximity, and gesture sensor.
Some of its features: -
1. RGB Color Sensing: It can accurately measure red, green, and blue (RGB) light levels, allowing it to detect and differentiate between different colors in the environment.
2. Ambient Light Sensing: It includes an ambient light sensor capable of measuring the intensity of ambient light.
3. Proximity Sensing: It can detect the presence of objects or obstacles in close proximity to the sensor. It emits infrared (IR) light and measures the reflection to determine the distance between the sensor and nearby objects.
4. Gesture Detection: One of its standout features is its ability to recognize a variety of hand gestures, such as swipe, flick, and circle motions.

Changes

  • The UI for the sensor (sensor_apds9960.xml) is developed akin to the UI for the existing sensors, providing raw data and graphical plots in a clear and user-friendly manner.
  • The sensor activity (SensorAPDS9960.java) follows on a similar pattern as the already present sensors.
  • A dedicated communication library for the sensor (APDS9960.java) is developed by porting the adafruit library for the sensor to Java.

Screenshots / Recordings

Here is a screen recording demonstrating the functioning: -

Screen_recording_20240819_201444.mp4

Checklist:

  • No hard coding: I have used resources from strings.xml, dimens.xml and colors.xml without hard coding any value.
  • No end of file edits: No modifications done at end of resource files strings.xml, dimens.xml or colors.xml.
  • Code reformatting: I have reformatted code and fixed indentation in every file included in this pull request.
  • No extra space: My code does not contain any extra lines or extra spaces than the ones that are necessary.

Note:-
This has been tested with the sensor.
@marcnause Could you please also test this and confirm if this works fine ?

Summary by Sourcery

Introduce support for the APDS9960 sensor, including gesture, color, proximity, and ambient light sensing. Develop a new communication library and user interface for the sensor, enhancing the application's sensor capabilities.

New Features:

  • Add support for the APDS9960 sensor, enabling gesture, color, proximity, and ambient light sensing capabilities.

Enhancements:

  • Develop a dedicated communication library for the APDS9960 sensor by porting the Adafruit library to Java.
  • Implement a user interface for the APDS9960 sensor, providing raw data and graphical plots in a user-friendly manner.

Copy link

sourcery-ai bot commented Aug 19, 2024

@AsCress AsCress self-assigned this Aug 19, 2024
@AsCress AsCress added Feature New addition to the existing app Instrument: Sensors labels Aug 19, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @AsCress - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@marcnause
Copy link
Contributor

I successfully tested the sensor (proximity, color and light sensing) with the v5 board and the v3.0.2 firmware. We agreed that gestures will be added in a future PR.

@AsCress AsCress force-pushed the APDS9960 branch 4 times, most recently from 83104c8 to eec870a Compare August 21, 2024 10:57
@AsCress
Copy link
Contributor Author

AsCress commented Aug 21, 2024

@CloudyPadmal @marcnause @bessman
This PR now adds support for gestures too using the APDS9960 !! 🥳🥳
Support for four basic (LEFT, RIGHT, UP, DOWN) gestures has been implemented as done in the adafruit driver for the sensor.
Since only one of the engines of the sensor, either the gesture engine or the proximity engine can work at a time, the features have been separated in the app.
Here is a screen recording demonstrating the complete functionality implemented for the sensor in the app: -

Screen_recording_20240821_160744.mp4

@marcnause Could you also please test these features with the sensor and confirm that they work fine?

P.S.- Please ignore the issues found out by static code analysis as they are complexity related and we can't do much to reduce the complexity when the driver functionality requires that (ported from the adafruit driver).

Copy link

github-actions bot commented Aug 21, 2024

@marcnause
Copy link
Contributor

marcnause commented Aug 21, 2024

Yay! 🥳 I tested the sensor again and I can confirm that the gesture detection is working fine with my sensor and is fun to use. 😉

I think that getGesture could be refactored to reduce the complexity (e.g. move block in the while-loop to an extra method), but I am nit sure that it would make the code more readable.

Would it be possible to increase the width of the Spinner for he mode selection? Also I think it would be easier for the user to understand the screen if the mode selection would be the first element of the screen. What do you think?

@AsCress
Copy link
Contributor Author

AsCress commented Aug 22, 2024

@marcnause Thanks for testing! Your suggestions regarding the layout are nice ones! I've updated the layout accordingly. Even if we refactor the getGesture method, we won't be able to reduce the N-Path complexity (I've already done quite a few refactoring by moving the code into other methods).

@marcnause
Copy link
Contributor

@AsCress Thumbs up for the changed layout! I think it looks really good.

@AsCress
Copy link
Contributor Author

AsCress commented Aug 24, 2024

@marcnause Is there something that you would like to discuss regarding this PR or maybe give it a final review ? This is ready to be merged from my side.

@marcnause marcnause merged commit b12dcce into fossasia:development Aug 25, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New addition to the existing app Instrument: Sensors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants