-
Notifications
You must be signed in to change notification settings - Fork 807
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
fix: Display all implemented sensors in SensorActivity #2584 #2589
base: development
Are you sure you want to change the base?
fix: Display all implemented sensors in SensorActivity #2584 #2589
Conversation
Reviewer's Guide by SourceryThis PR fixes sensor display issues in SensorActivity by updating I2C addresses to ensure uniqueness for all sensors and cleaning up build dependencies. The main changes involve reassigning addresses for CCS811 and APDS9960 sensors to prevent conflicts, and updating Gradle dependencies. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @samruddhi-Rahegaonkar - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please verify that the new I2C addresses (0x3A for CCS811 and 0x3B for APDS9960) are valid and supported by these sensors. I2C addresses are typically hardware-defined and cannot be arbitrarily changed in software.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Build successful. APKs to test: https://github.com/fossasia/pslab-android/actions/runs/12388981148/artifacts/2336329720 |
Hello @samruddhi-Rahegaonkar ! Welcome here! |
As for this pull-request, it doesn't actually solve the mentioned issue of displaying the sensors which arn't listed in the |
@@ -83,7 +83,6 @@ dependencies { | |||
implementation("com.github.mirrajabi:search-dialog:1.2.4") | |||
implementation(files("../libs/croller-release.aar")) | |||
implementation("com.github.BeppiMenozzi:Knob:1.9.0") | |||
implementation("com.github.warkiz:IndicatorSeekBar:v2.1.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes which arn't required. You can just rollback build.gradle.kts.
sensorAddr.put(0x39, "TSL2561"); // Unique address for TSL2561 | ||
sensorAddr.put(0x69, "MPU925x"); // Unique address for MPU925x | ||
sensorAddr.put(0x29, "VL53L0X"); // Unique address for VL53L0X | ||
sensorAddr.put(0x3A, "CCS811"); // New unique address for CCS811 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned earlier, changing the address would make the sensor inoperable. You can retain the same address.
sensorAddr.put(0x69, "MPU925x"); // Unique address for MPU925x | ||
sensorAddr.put(0x29, "VL53L0X"); // Unique address for VL53L0X | ||
sensorAddr.put(0x3A, "CCS811"); // New unique address for CCS811 | ||
sensorAddr.put(0x3B, "APDS9960"); // New unique address for APDS9960 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this.
@@ -11,5 +11,5 @@ buildscript { | |||
} | |||
|
|||
plugins { | |||
id("com.android.application") version "8.7.3" apply false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, some changes that arn't required. You can rollback these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay @AsCress Thanks for Explaining me. I will do the needful !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AsCress Other than the SensorActivity the changes I have made because I was unable to run the application without making those changes. But after testing I will rollback it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AsCress to resolve this issue as you have said, I need to make changes in the method "PopulateSensors" to handle the cases where both having same addresses.
should I ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samruddhi-Rahegaonkar The problem here is with the data structure that we are using to store the sensor addresses.
A Map
in Java doesn't allow duplicate keys to be inserted. When we try to do that in lines 86 and 87 of SensorActivity.java
, it overwrites the previous entries, and hence the previous two sensors (MLX90614
and TSL2561
) actually never get inserted in the Map
.
The idea here would be to migrate to a different data structure which would allow storage of duplicate entries, and then using that in PopulateSensors
to display them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AsCress Instead of Map<Integer, String>
, we can use a Map<Integer, List<String>>
to associate multiple sensor names with the same address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samruddhi-Rahegaonkar Yep, that's one way. Go ahead and maybe try to implement whatever you find best in this PR.
Updated the sensor addresses to be unique in the SensorActivity class, resolving conflicts where multiple sensors were assigned the same address (e.g., 0x39 for APDS9960 and TSL2561).
Refactored the sensor initialization to ensure accurate mapping between sensor addresses and their names, allowing all implemented sensors to be correctly shown during the sensor scan.
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 the 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.
Summary by Sourcery
Fix sensor address conflicts in SensorActivity by assigning unique addresses to each sensor and refactor initialization for accurate mapping. Update the IndicatorSeekBar dependency version in the build configuration.
Bug Fixes:
Enhancements:
Build: