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 pin layout screens for PSLab v6 #2625

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

samruddhi-Rahegaonkar
Copy link
Contributor

@samruddhi-Rahegaonkar samruddhi-Rahegaonkar commented Feb 6, 2025

Fixes #2499

Summary by Sourcery

Add pin layout screens for PSLab v6.

New Features:

  • Display PSLab v6 pin layout diagrams.

Tests:

  • Update tests to accommodate v6 pin layout changes.

Copy link

sourcery-ai bot commented Feb 6, 2025

Reviewer's Guide by Sourcery

This pull request adds pin layout screens for PSLab v6, including front and back views with color-coded pin descriptions. It also updates the strings and colors resources to include the new pin layouts.

Class diagram for PSLab v6 Pin Layout implementation

classDiagram
    class PSLabPinLayoutFragment_v6 {
        -List~PinDetails_v6~ pinDetails_v6
        -Matrix matrix
        -Matrix savedMatrix
        +static boolean topside
        +static PSLabPinLayoutFragment_v6 newInstance()
        +onCreateView()
        +onResume()
        +onPause()
        -populatePinDetails()
        -getColor(int colorId)
        +onTouch(View v, MotionEvent event)
        -displayPinDescription(PinDetails_v6)
        -spacing(MotionEvent)
        -midPoint(PointF, MotionEvent)
    }

    class PinDetails_v6 {
        -String name
        -String description
        -int colorID
        +PinDetails_v6(String name, String description, int colorID)
        +getName()
        +getDescription()
        +getColorID()
    }

    PSLabPinLayoutFragment_v6 --> PinDetails_v6 : uses
Loading

File-Level Changes

Change Details Files
Added new string resources for PSLab v6 pin layouts and updated existing pin descriptions.
  • Added string resources for PSLab v6 pin layouts (front and back).
  • Updated existing pin descriptions with more details and translatable attributes.
  • Added new pin names and descriptions for various components like UART, Sine Wave, Square Wave, Logic Analyzer, Measurement Channels, SPI, I2C, Voltage Levels, Programming Pins, USB Pins, and Additional Pins.
app/src/main/res/values/strings.xml
Added new color resources for PSLab v6 pin layouts.
  • Added color definitions for various PSLab v6 pins, including UART, Sine Wave, Square Wave, Logic Analyzer, Measurement Channels, SPI, I2C, Voltage Levels, Programming Pins, USB Pins, and other components.
app/src/main/res/values/colors.xml
Updated MainActivity to include PSLab v6 pin layout options in the menu and navigation.
  • Added menu options for PSLab v6 pin layout (front and back).
  • Updated onOptionsItemSelected to handle the new menu options and display the corresponding pin layout fragments.
  • Modified displayPSLabPinLayout to handle both v5 and v6 layouts.
  • Added a new tag for the v6 pin layout.
app/src/main/java/io/pslab/activity/MainActivity.java
Created a new fragment for PSLab v6 pin layout.
  • Implemented PSLabPinLayoutFragment_v6 with zoom and drag capabilities.
  • Added touch listener to display pin descriptions on click.
  • Populated pin details with names, descriptions, and colors.
  • Added logic to switch between top and bottom views of the pin layout.
app/src/main/java/io/pslab/fragment/PSLabPinLayoutFragment_v6.java
Created a new data class for PSLab v6 pin details.
  • Created PinDetails_v6 to store pin name, description, and color ID.
app/src/main/java/io/pslab/items/PinDetails_v6.java
Added layout file for PSLab v6 pin layout fragment.
  • Added ImageView for the pin layout.
  • Added ImageView for the color map with transparency.
app/src/main/res/layout/fragment_pin_layout_v6.xml

Assessment against linked issues

Issue Objective Addressed Explanation
#2499 Add pin layout screens for PSLab v6
#2499 Ensure menu entries lead to pin layout screens for both PSLab v5 and v6

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

Overall Comments:

  • In PSLabPinLayoutFragment_v6's populatePinDetails method, the fourth square wave entry mistakenly uses getString(R.string.square_wave_3) instead of getString(R.string.square_wave_4). Update the string resource to ensure the correct label is used.
  • The onTouch implementation uses getDrawingCache() to capture the color map bitmap, which is deprecated and can lead to inconsistent behavior. Consider using a more reliable method to capture the bitmap or compute the touched pixel from the resource.
  • Calling System.gc() in onPause() is generally discouraged as it can adversely affect performance. Remove it or replace it with more targeted memory management techniques if necessary.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

@AsCress
Copy link
Collaborator

AsCress commented Feb 6, 2025

@samruddhi-Rahegaonkar Thanks for your work! So two things before we move forward with this:

  1. You might want to check the failing CI. We follow the conventional commit semantics for naming our pull requests. You could have a look and rename your pull request according to that.
  2. You may want to rebase your changes over development. The branch you've chosen currently isn't rebased over the development branch (our default branch). That's precisely the reason why this PR shows a total of 9 commits to be merged (also including the ones from your previous PRs). It's a good practice to always checkout a new branch from development / choose a branch up to date with the branch which the PR is supposed to merge into (in this case, development), and then make changes to it.

Added a pin layout screens for PSLab v6.
@AsCress AsCress changed the title Added pin layout screens for PSLab v6. feat: added pin layout screens for PSLab v6 Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

Copy link
Collaborator

@AsCress AsCress left a comment

Choose a reason for hiding this comment

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

@samruddhi-Rahegaonkar Reviewed. Lots of work to be done here.
I may have missed more errors. Please kindly check all the pins again once.

@@ -86,6 +87,7 @@ public class MainActivity extends AppCompatActivity {
private static final String TAG_INSTRUMENTS = "instruments";
private static final String TAG_ABOUTUS = "aboutUs";
private static final String TAG_PINLAYOUT = "pinLayout";
private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6";
private static final String TAG_PINLAYOUT_V6 = "pinLayoutV6";

@@ -561,7 +589,6 @@ public void onReceive(Context context, Intent intent) {
}
}
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

The file MainActivity.java has formatting issues. Kindly reformat the whole file as we have discussed earlier as well (Ctrl + A, Ctrl + Alt + L)

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file doesn't require any changes, does it ?
Kindly rollback this whole file, if it doesn't.

<color name="sq2">#D35FBC</color>
<color name="sq3">#C837AB</color>
<color name="sq4">#A02C89</color>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please reformat, also removing the extra leading spaces at the end.

@@ -0,0 +1,272 @@
package io.pslab.fragment;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole file requires reformatting as well.

pinDetails_v6.add(new PinDetails_v6(getString(R.string.cs1), getString(R.string.cs1_description), getColor(R.color.cs1)));
pinDetails_v6.add(new PinDetails_v6(getString(R.string.sdi), getString(R.string.sdi_description), getColor(R.color.sdi)));
pinDetails_v6.add(new PinDetails_v6(getString(R.string.sck), getString(R.string.sck_description), getColor(R.color.sclk)));
pinDetails_v6.add(new PinDetails_v6(getString(R.string.sdo), getString(R.string.sdo_description), getColor(R.color.sdo)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the color for this pin is configured wrongly in the image. Clicking this image causes the dialog for the SCK pin above to be opened.

<!-- Voltage Levels -->
<string name="vdd_3_3v_description" translatable="false">VDD (+3.3V) power supply pin.</string>
<string name="voltage_0_3_3v_description" translatable="false">Voltage level pin (0-3.3V).</string>
<string name="voltage_plus_3_3v_description" translatable="false">Positive voltage level (+3.3V).</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't a Positive Voltage Level.

Suggested change
<string name="voltage_plus_3_3v_description" translatable="false">Positive voltage level (+3.3V).</string>
<string name="voltage_plus_3_3v_description" translatable="false">Variable voltage pin (±3.3V).</string>


<!-- Voltage Levels -->
<string name="vdd_3_3v_description" translatable="false">VDD (+3.3V) power supply pin.</string>
<string name="voltage_0_3_3v_description" translatable="false">Voltage level pin (0-3.3V).</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<string name="voltage_0_3_3v_description" translatable="false">Voltage level pin (0-3.3V).</string>
<string name="voltage_0_3_3v_description" translatable="false">Variable voltage pin (0-3.3V).</string>

<string name="vdd_3_3v_description" translatable="false">VDD (+3.3V) power supply pin.</string>
<string name="voltage_0_3_3v_description" translatable="false">Voltage level pin (0-3.3V).</string>
<string name="voltage_plus_3_3v_description" translatable="false">Positive voltage level (+3.3V).</string>
<string name="voltage_plus_minus_5_0v_description" translatable="false">Dual voltage supply (±5.0V).</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<string name="voltage_plus_minus_5_0v_description" translatable="false">Dual voltage supply (±5.0V).</string>
<string name="voltage_plus_minus_5_0v_description" translatable="false">Variable voltage (±5.0V).</string>

<string name="voltage_0_3_3v_description" translatable="false">Voltage level pin (0-3.3V).</string>
<string name="voltage_plus_3_3v_description" translatable="false">Positive voltage level (+3.3V).</string>
<string name="voltage_plus_minus_5_0v_description" translatable="false">Dual voltage supply (±5.0V).</string>
<string name="current_3ma_description" translatable="false">Current pin (3mA).</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<string name="current_3ma_description" translatable="false">Current pin (3mA).</string>
<string name="current_3ma_description" translatable="false">Current pin (<=3mA).</string>

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.

Add pin layout screens for PSLab v6
2 participants