Skip to content

docs : Added automatic scalling for graphs #2708

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

ChehakTrehan
Copy link

@ChehakTrehan ChehakTrehan commented May 30, 2025

Fixes #

Changes

Screenshots / Recordings

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

Enable automatic scaling for sensor data graphs, fix the MPU6050 I2C address, expand documentation for the Robotic Arm feature, and add compass help and UI enhancements in settings.

New Features:

  • Add Robotic Arm Control documentation in README
  • Expose LineChart instances via getChart() in data fragments

Bug Fixes:

  • Correct MPU6050 I2C address from 0x68 to 0x69 across activities and sensor classes

Enhancements:

  • Enable automatic Y-axis auto-scaling for Gyroscope, Accelerometer, LuxMeter, BaroMeter, and Thermometer charts
  • Add compass help menu and toast notifications in SettingsActivity and CreateConfigActivity
  • Replace lux unit string from "(lx)" to "lx"

Documentation:

  • Add "Documentation" navigation label in Arabic, Polish, Russian, and Sinhala localization files

Copy link

sourcery-ai bot commented May 30, 2025

Reviewer's Guide

This PR enables automatic Y-axis scaling in all data visualization fragments by removing fixed limits and integrating MPAndroidChart’s auto-scale methods, enriches documentation with a detailed Robotic Arm guide and new navigation entries, corrects the MPU6050 I2C address mappings across sensor classes, implements real-time servoWrite logic for the robotic arm controls, and introduces UI/menu enhancements including toast feedback and external documentation links.

Sequence Diagram for Real-time Robotic Arm Servo Control

sequenceDiagram
    actor User
    participant SeekArcSlider
    participant RoboticArmActivity
    participant PSLabHardware

    User->>SeekArcSlider: Adjusts servo position
    SeekArcSlider->>RoboticArmActivity: onProgressChanged(progress, fromUser)
    RoboticArmActivity->>RoboticArmActivity: Calculate angle from progress
    alt PSLab Connected
        RoboticArmActivity->>PSLabHardware: scienceLab.servoWrite(servoIndex, angle)
    end
Loading

Entity Relationship Diagram for RoboticArmProfile Data

erDiagram
    RoboticArmProfile {
        string profileName PK "Name of the profile"
        int servo1Angle "Angle for Servo 1"
        int servo2Angle "Angle for Servo 2"
        int servo3Angle "Angle for Servo 3"
        int servo4Angle "Angle for Servo 4"
    }
    User ||--o{ RoboticArmProfile : Manages
Loading

Updated Class Diagram for Sensor Data Fragments Auto-Scaling

classDiagram
    class GyroscopeDataFragment {
        +LineChart getChart()
        #void visualizeData()
    }
    class AccelerometerDataFragment {
        +LineChart getChart()
        #void visualizeData()
    }
    class LuxMeterDataFragment {
        +void onResume()
    }
    class BaroMeterDataFragment {
        +void onResume()
    }
    class ThermometerDataFragment {
        +void onResume()
    }
Loading

Updated Class Diagram for Activity Logic Modifications

classDiagram
    class RoboticArmActivity {
        #void onCreate(Bundle savedInstanceState)
    }
    class SettingsActivity {
        #void onCreate(Bundle savedInstanceState)
        +boolean onCreateOptionsMenu(Menu menu)
        +boolean onOptionsItemSelected(MenuItem item)
    }
    class CreateConfigActivity {
        +boolean onOptionsItemSelected(MenuItem item)
    }
Loading

Updated Class Diagram for Sensor Address Configuration

classDiagram
    class MPU6050 {
        -int ADDRESS = 0x69
    }
    class MPU925x {
        -int ADDRESS = 0x69
    }
    class SensorActivity {
        #Map~Integer, String~ sensorAddr
    }
    class SensorDataLoggerActivity {
        #Map~Integer, String~ sensorAddress
    }
    class SensorList {
        #Map~Integer, String[]~ sensorList
    }
Loading

File-Level Changes

Change Details Files
Enable automatic Y-axis scaling in chart fragments
  • Removed hard-coded axis limits and related fields
  • Added getChart() getters to expose LineChart instances
  • Invoked setAutoScaleMinMaxEnabled, resetAxisMinimum/Maximum, notifyDataSetChanged, and invalidate on charts
GyroscopeDataFragment.java
AccelerometerDataFragment.java
LuxMeterDataFragment.java
BaroMeterDataFragment.java
ThermometerDataFragment.java
Add Robotic Arm feature documentation and update resource strings
  • New Robotic Arm section with usage and capabilities in README.md
  • Added nav_documentation key in all locale strings.xml files
  • Updated default lux_unit string to remove surrounding parentheses
README.md
values-ar/strings.xml
values-pl/strings.xml
values-ru/strings.xml
values-si/string.xml
values/strings.xml
Correct MPU6050 I2C address mappings
  • Changed sensorAddr.put and sensorAddress.put mappings from 0x68 to 0x69 in activities
  • Updated address constants in MPU6050 and MPU925x classes
SensorActivity.java
SensorDataLoggerActivity.java
SensorList.java
MPU6050.java
MPU925x.java
Implement real-time servo control in RoboticArmActivity
  • Captured angle values from SeekArc progress change listeners
  • Called scienceLab.servoWrite(index, angle) when connected
  • Ensured degreeText updates and editEnter reset logic remain intact
RoboticArmActivity.java
UI and menu enhancements for Settings, Compass, and config screens
  • Added a button click listener in SettingsActivity to show a Toast
  • Inflated a custom options menu and handled home, record, and help icons with Toast feedback
  • Opened external documentation link via CreateConfigActivity’s help menu item
SettingsActivity.java
CreateConfigActivity.java

Possibly linked issues

  • #0: PR adds automatic scaling to graphs in Lux, Accel, Baro, Gyro, Thermo screens, fixing fixed scales issue.

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

@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 @ChehakTrehan - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Typo causing compile error (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 5 other issues
  • 🟢 Security: all looks good
  • 🟢 Testing: 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 and I'll use the feedback to improve your reviews.

myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(CompassActivity.this, "Button clicked!", Toast.LENGTH_SHORT).show();
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Incorrect context in Toast call

Use SettingsActivity.this or simply this as the context to avoid confusion and potential memory leaks.

@@ -95,12 +103,29 @@
getSupportFragmentManager().beginTransaction().add(R.id.content, fragment).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_compass_help_menu, menu);
Copy link

Choose a reason for hiding this comment

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

issue: Menu resource seems misnamed

The use of 'activity_compass_help_menu' in SettingsActivity suggests a copy-paste error. Please use a menu resource appropriate for settings.

Comment on lines 161 to +164
if (item.getItemId() == android.R.id.home) {
finish();
finish();rea
}else if (item.getItemId() == R.id.compass_help_icon) {

Copy link

Choose a reason for hiding this comment

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

issue (typo): Typo causing compile error

Remove the extra "rea" after finish() to fix the syntax error.

Suggested change
if (item.getItemId() == android.R.id.home) {
finish();
finish();rea
}else if (item.getItemId() == R.id.compass_help_icon) {
if (item.getItemId() == android.R.id.home) {
finish();
}else if (item.getItemId() == R.id.compass_help_icon) {

@@ -25,7 +25,7 @@ public SensorList() {
sensorList.put(0x5A, new String[]{"MLX90614 PIR temperature"});
sensorList.put(0x1E, new String[]{"HMC5883L magnetometer", "LSM303 magnetometer"});
sensorList.put(0x77, new String[]{"BMP180/GY-68 altimeter", "MS5607", "MS5611"});
sensorList.put(0x68, new String[]{"MPU-6050/GY-521 accel+gyro+temp", "ITG3200", "DS1307", "DS3231"});
sensorList.put(0x69, new String[]{"MPU-6050/GY-521 accel+gyro+temp", "ITG3200", "DS1307", "DS3231"});
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Conflicting sensorList key

0x69 is assigned to two different sensor sets, causing one to overwrite the other. Please ensure each key is unique or combine the sensor sets as needed.

@@ -435,7 +438,16 @@ private void visualizeData() {
LineData data = new LineData(dataSet);

fragment.setChartData(data);

fragment.setYaxis(highLimit);
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Fixed Y-axis conflicting with auto-scaling

Remove setYaxis(highLimit) to allow auto-scaling to function as intended.

mChart.getAxisLeft().resetAxisMaximum();
mChart.getAxisRight().resetAxisMinimum();
mChart.getAxisRight().resetAxisMaximum();
initiateBaroSensor(sensorType);
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Erroneous initialization of non-thermometer sensors

Remove the initialization of Baro and Lux sensors from ThermometerDataFragment to ensure only the thermometer sensor is started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants