Skip to content

feat: ported sensors screen and BMP180 screen #2789

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

Merged
merged 16 commits into from
Aug 10, 2025

Conversation

Yugesh-Kumar-S
Copy link
Contributor

@Yugesh-Kumar-S Yugesh-Kumar-S commented Jul 16, 2025

Fixes #2788

Changes

  • Ported sensors screen
  • Ported the BMP180 sensor screen which fetches data from BMP180 sensor .
  • Added a new option to clear data in the bottom sensor controls.

Screenshots / Recordings

Screenshot_20250716-231832 Screenshot_20250720-190747
screen-20250802-172807.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.

Summary by Sourcery

Port the sensors screen into the Flutter app UI and hook it into the navigation flow.

New Features:

  • Port SensorsScreen with autoscan functionality, connection status display, and sensor selection list
  • Add '/sensors' route in main.dart and integrate navigation to the sensors screen from the instruments screen

Summary by Sourcery

Port the sensors screens into the Flutter UI and add full support for BMP180 sensor data collection and plotting.

New Features:

  • Add SensorsScreen with autoscan, connection status display, and selectable sensor list
  • Implement BMP180Screen displaying raw readings and interactive charts for temperature, altitude, and pressure
  • Introduce SensorChartWidget and SensorControlsWidget for reusable chart rendering and control panels
  • Add BMP180Provider to initialize the BMP180 sensor, manage data collection loop, and expose chart data
  • Integrate '/sensors' route and enable navigation to sensor screens from the instruments menu
  • Extend app localization with new sensor-related strings

Enhancements:

  • Make chartLineColor a constant to improve theme consistency

Copy link
Contributor

sourcery-ai bot commented Jul 16, 2025

Reviewer's Guide

Ports the sensors and BMP180 functionality into the Flutter app by adding new localization resources, theming, navigation routes, UI screens, reusable chart and control widgets, a BMP180 data provider, and a chart data model.

File-Level Changes

Change Details Files
Extended localization for sensor UI labels and messages
  • Added new keys (autoscan, selectSensor, clearData, etc.) in app_localizations.dart
  • Provided English translations for all new sensor strings in app_localizations_en.dart
lib/l10n/app_localizations.dart
lib/l10n/app_localizations_en.dart
Integrated SensorsScreen into app navigation flow
  • Imported SensorsScreen in main.dart and registered '/sensors' route
  • Updated InstrumentsScreen to navigate to '/sensors' on tab selection
lib/main.dart
lib/view/instruments_screen.dart
Added sensor-specific theming in colors
  • Declared new Color constants for sensor status, controls, and chart hints
  • Changed chartLineColor to a const definition
lib/theme/colors.dart
Created reusable sensor visualization widgets
  • Implemented SensorChartWidget with dynamic axes, grid, tooltips, and no-data view
  • Built SensorControlsWidget for play/pause, loop, time‐gap slider, readings input, and clear action
lib/view/widgets/sensor_chart_widget.dart
lib/view/widgets/sensor_controls.dart
Added SensorsScreen and BMP180Screen UI implementations
  • Built SensorsScreen with autoscan button, status panel, and selectable sensor list
  • Constructed BMP180Screen with raw data cards, chart widgets, and control panel
lib/view/sensors_screen.dart
lib/view/widgets/bmp180_screen.dart
Implemented BMP180Provider for sensor data management
  • Initialized I2C and ScienceLab instances, handled connection errors
  • Managed periodic data collection, looping, limits, and clearData logic
  • Exposed temperature, pressure, altitude data lists for charting
lib/providers/bmp180_provider.dart
Defined ChartDataPoint model for charting data
  • Created ChartDataPoint class with x/y properties, equality, serialization, and copyWith
lib/models/chart_data_points.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#2788 Port the sensors screen to implement individual screens for each sensor data.
#2788 Integrate the BMP180 sensor and port the BMP180 sensor screen.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

github-actions bot commented Jul 16, 2025

@Yugesh-Kumar-S Yugesh-Kumar-S changed the title feat: ported sensors screen feat: ported sensors screen and BMP180 screen Aug 2, 2025
@Yugesh-Kumar-S Yugesh-Kumar-S marked this pull request as ready for review August 2, 2025 12:10
Copy link
Contributor

@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 @Yugesh-Kumar-S - I've reviewed your changes - here's some feedback:

  • In SensorChartWidget._buildAxisLabels you have a nested Positioned inside another Positioned—this is redundant and could be simplified to prevent unintended layout behavior.
  • There’s a typo in colors.dart (senosrStatusBorder), please rename it to sensorStatusBorder for consistency.
  • BMP180Provider uses a hard-coded data point limit (50) and SensorsScreen has hard-coded sensor lists/addresses—consider extracting these into configurable constants or driving them dynamically to improve maintainability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In SensorChartWidget._buildAxisLabels you have a nested Positioned inside another Positioned—this is redundant and could be simplified to prevent unintended layout behavior.
- There’s a typo in colors.dart (`senosrStatusBorder`), please rename it to `sensorStatusBorder` for consistency.
- BMP180Provider uses a hard-coded data point limit (50) and SensorsScreen has hard-coded sensor lists/addresses—consider extracting these into configurable constants or driving them dynamically to improve maintainability.

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 and I'll use the feedback to improve your reviews.

@Yugesh-Kumar-S
Copy link
Contributor Author

Yugesh-Kumar-S commented Aug 2, 2025

Sorry for a very long PR.
lib/view/sensors_screen.dart - main sensor screen to select appropriate sensor.
lib/view/widgets/sensor_controls.dart - reusable control widget for all sensor screens.
lib/view/widgets/sensor_chart_widget.dart - reusable chart widget for all sensors.
lib/view/widgets/bmp180_screen.dart - bmp180 sensor screen (uses the above widgets).
lib/providers/bmp180_provider.dart - provider for bmp180 sensor data.

@marcnause marcnause self-requested a review August 3, 2025 15:08
@Yugesh-Kumar-S
Copy link
Contributor Author

@marcnause i have changed the altitude label to estimated altitude(since it is calculated value and not read from sensor) like mr.Bessman suggested in last week meeting.
Screenshot_20250810-145311

@marcnause
Copy link
Contributor

I was wondering if the axes of the plots should have values like in the old version of the app. I am unsure if this would add valuable information or if it would only be visual clutter. I actually like the clean look of the new version.

What do you think? Was it a conscious decision to omit the values?

@Yugesh-Kumar-S
Copy link
Contributor Author

I was wondering if the axes of the plots should have values like in the old version of the app. I am unsure if this would add valuable information or if it would only be visual clutter. I actually like the clean look of the new version.

What do you think? Was it a conscious decision to omit the values?

Yes sir, I intentionally removed the axis values and added a Current Value section at the top right of the chart. Users can still tap on the chart to view the exact time and sensor values. Since the time interval is in milliseconds, the axis labels were changing too quickly, which made the chart harder to read.

@marcnause marcnause merged commit ff8c73d into fossasia:flutter Aug 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port sensors screen and BMP180 screen.
2 participants