- The UI should expose all the functionalities of Oscilloscope that can be performed using PSLab.
- The UI should be very convenient to use. It should allow the user to access functionalities of the PSLab with ease.
- The UI should be attractive.
Since Android smartphones come with relatively small size, it was a challenge to develop a UI for Oscilloscope. In this blog, I am going to mention the steps involved in developing the Oscilloscope UI.
Step 1: Creating a mockup
Initially, a mock-up for Oscilloscope UI is created using moqups tool. Later, the mock-up was discussed in public channel where fellow developers and mentors approved it. Let’s discuss some benefits of adopting this layout for Oscilloscope Activity.
- The graph is ensured maximum screen space as it is the most important component/section of the Oscilloscope. This is also the reason why we kept the screen orientation to landscape.
- The widgets don’t populate the screen, make the UI look clean.
- The UI is comparable to basic app’s people use in their daily lives hence very convenient to use.
Mockup of Oscilloscope UI developed using moqups tool
Step 2: Deciding the API to be used
In Oscilloscope Activity, the main component is the graph. The captured data from the PSLab device is plotted on the graph. We decided to use MPAndroidCharts for the same.
Step 3: Deciding the space given to different sections of the UI
The next step was to decide how much screen space each section of Oscilloscope should acquire. There are 3 sections of the Oscilloscope UI.
- Side panel consisting of buttons, each button loads a different set Oscilloscope controls and features in 3.
- A lower panel which is basically a fragment displaying controls and features corresponding to the button selected in 2.
By trying different dimensions and arrangements the following configuration fits the best.
To achieve this, the dimensions of different sections is set programmatically. This makes the UI compatible with different screen sizes.
onWindowFocusChanged method is called in onCreate method. Here we are first receiving current layout parameters and then setting new layout parameters.
Step 4: Developing each section
The graph needs to be customized concerning following requirements
- Dual y axis, one dedicated to CH2 and another to analog input selected.
- Black background
- Grid lines
- Initial scale for x and y axis.
To achieve this a chartInit method is created which initializes the graph as per required. It is called in onCreate method.
2. Side Panel
It is a simple layout consisting of image buttons and text views. It is used to replace fragments in Lower Panel. To achieve this, image buttons and textviews were added to the layout and image buttons weight is set to 2. Later onClick listeners were added to both image buttons and textviews.
3. Lower Panel
The lower panel is frame layout which accommodates different fragments (one at a time). To achieve these different fragments are created that are ChannelsParametersFragment, TimebaseTriggerFragment, DataAnalysisFragment and XYPlotFragment. In ChannelsParametersFragment, TimebaseTriggerFragment and XYPlotFragment fragments, constraint views are used whereas in TimebaseTriggerFragment table layout is used. Each fragment allows the user to access different controls and features.
The Final Layout
The above is the GIF of the Oscilloscope UI.
This covers various steps for developing Oscilloscope UI in PSLab Android App.
- StackOverflow Answer to Programmatically change size of layouts
- MPAndroidChart GitHub Repository
- Commit to creating Oscilloscope UI