Giter Site home page Giter Site logo

pslab-android's Introduction

PSLab Android App

Repository for the PSLab Android App for performing experiments with the Pocket Science Lab open-hardware platform.

Build Codacy Badge Mailing List Minimum API Level Maximum API Level GitHub repo size Gitter Twitter Follow

This repository holds the Android App for performing experiments with PSLab. PSLab is a tiny pocket science lab that provides an array of equipment for doing science and engineering experiments. It can function like an oscilloscope, waveform generator, frequency counter, programmable voltage and current source and also as a data logger. Our website is at https://pslab.io

Get it on Google Play Get it on F-Droid

Buy

Communication

Roadmap

  • First we need to get communication between Android App and PSLab working.
  • Implement Applications and expose PSLab Hardware functionality to the user.
  • Implement wireless connectivity

Screenshots

Video Demo

Features

Feature Description Status
Home Screen Show status and version of PSLab device ✔️
Instruments Exposes PSLab instruments like Oscilloscope, etc ✔️
Oscilloscope Shows variation of analog signals ✔️
Multimeter Measures voltage, current, resistance and capacitance ✔️
Logical Analyzer Captures and displays signals from digital system ✔️
Wave Generator Generates arbitrary analog and digital waveforms ✔️
Power Source Generates programmable voltage and currents ✔️
Luxmeter Measures the ambient light intensity ✔️
Barometer Measures the Pressure ✔️
Accelerometer Measures the acceleration of the device ✔️
Gyrometer Measures the rate of rotation ✔️
Compass Measures the absolute rotation relative to earth magnetic poles ✔️
Thermometer Measures the ambient temperature ✔️
Gas Sensor Detects gases, including NH3, NOx, alcohol, benzene, smoke and CO2 ✔️
Robotic Arm Controller Allows to control 4 servo motors of the robotic arm independently ✔️

How to set up the Android app in your development environment

Application Flavors

There are 2 flavors (build variants) of PSLab Android application.

  1. Play Store Flavor

  • Play Store flavor uses Google Maps to display location stored in logs in Data logger.
  1. Fdroid Flavors

  • Fdroid flavor uses Open Street Maps to display location stored in logs in Data logger.

Development Setup

Before you begin, you should already have the Android Studio SDK downloaded and set up correctly. You can find a guide on how to do this here: Setting up Android Studio

Setting up the Android Project

For setting up the PSLab Android project you may follow any of the two methods listed below, that is, you may download the repository zip file or you may directly clone the repository to Android Studio.

By downloading the zip file

  1. Download the pslab-android project source. You can do this either by forking and cloning the repository (recommended if you plan on pushing changes) or by downloading it as a ZIP file and extracting it.

  2. Open Android Studio, you will see a Welcome to Android window. Under Quick Start, select _Import Project (Eclipse ADT, Gradle, etc.)To debug over Wi-Fi follow the steps given in this Blog.

By direct cloning

  1. Open Android Studio, you will see a Welcome to Android window. Under Quick Start, select "check out project from version control".
  2. Select git from the drop down menu that appeared.
  3. Go to the repository and click clone or download button.
  4. From the dropdown that appeared, copy the link.
  5. Paste the URL that you copied and press clone.
  6. Android studio should now begin building the project with gradle.
  7. Once this process is complete and Android Studio opens, check the Console for any build errors.
  • Note: If you receive a Gradle sync error titled, "failed to find ...", you should click on the link below the error message (if available) that says Install missing platform(s) and sync project and allow Android studio to fetch you what is missing.
  1. Once all build errors have been resolved, you should be all set to build the app and test it.
  2. To Build the app, go to Build>Make Project (or alternatively press the Make Project icon in the toolbar).
  3. If the app was built successfully, you can test it by running it on either a real device or an emulated one by going to Run>Run 'app' or pressing the Run icon in the toolbar.

If you want build apk only, go to Build>Build apk and apk would be build and directory where apk is generated would be prompted by Android Studio.

You can't debug the usual way as PSLab device is connected to micro-USB port through OTG cable. So Android Device is not connected to PC through USB cable.

To debug over Wi-Fi follow the steps given in this Blog.

Permissions Required

  1. Record_Audio : It is required for oscilloscope to accept inputs from the phone inbuilt microphone. You can find its implementation in AudioJack.java.
  2. Access_Fine_Location and Internet : It is required for use in lux meter and compass to get the coordinates for tagging the data on the map. You can find its implementation in GPSLogger.java.
  3. Write_External_Storage : It is required for storing log files from instruments that can be transferred out for future analysis.
  4. Read_External_Storage : While writing logs in the storage, CSVLogger.java first checks whether there is any CSVLogger directory exist or not and that require this read permission.

Setup to use PSLab with Android App

To use PSLab device with Android, you simply need an OTG cable, an Android Device with USB Host feature enabled ( most modern phones have OTG support ) and PSLab Android App. Connect PSLab device to Android Phone via OTG cable. Rest is handled by App itself.

Contributions Best Practices

Code practices

Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics.

  • Single commit per pull request.
  • Reference the issue numbers in the commit message. Follow the pattern Fixes #<issue number> <commit message>
  • Follow uniform design practices. The design language must be consistent throughout the app.
  • The pull request will not get merged until and unless the commits are squashed. In case there are multiple commits on the PR, the commit author needs to squash them and not the maintainers cherrypicking and merging squashes.
  • If the PR is related to any front end change, please attach relevant screenshots in the pull request description.

How to git squash?

As a tip for new developers those who struggle with squashing commits into one, multiple commits may appear in your pull request mostly due to following reasons.

  • Intentionally adding multiple commit messages after each change without just git adding.
  • Updating the current branch with the remote so a merge commit takes place.

Despite any reason, follow the steps given below to squash all commits into one adhering to our best practices.

  • Setup remote to upstream branch if not set before

$ git remote add upstream https://github.com/fossasia/pslab-android.git

  • Check into the branch related to the pull request

$ git checkout <branch-name>

  • Perform a soft reset to retain the changes while removing all the commit details

$ git reset --soft upstream/development

  • Add files to the staging area

$ git add <file paths or "." to add everything>

  • Create a new commit with a proper message following commit message guidelines

$ git commit -m "tag: commit message"

  • If you have already made a pull request

$ git push -f origin <branch-name>

Branch Policy

We have the following branches

  • development All development goes on in this branch. If you're making a contribution, you are supposed to make a pull request to development. Make sure it passes a build check on Travis.
  • master This contains the stable code. After significant features/bugfixes are accumulated on development, we move it to master.
  • apk This branch contains automatically generated apk file for testing.

Code style

Please try to follow the mentioned guidelines while writing and submitting your code as it makes easier for the reviewer and other developers to understand.

  • While naming the layout files, ensure that the convention followed is (activity/fragment) _ (name).xml like activity_oscilloscope.xml , fragment_control_main.xml .
  • Name the views and widgets defined in the layout files as (viewtype/widget) _ (fragment/activity name) _ (no. in the file) like spinner_channel_select_la1 , button_activity_oscilloscope1 .
  • The activity/fragment file name corresponding to the layout files should be named as (activity/fragment name)(activity/fragment).java like ChannelsParameterFragment.java corresponding to the layout file fragment_channels_parameter.xml .
  • The corresponding widgets for buttons, textboxes, checkboxes etc. in activity files should be named as (viewtype/widget)(fragment/activity name)(no. in the file) like spinnerChannelSelect1 corresponding to spinner_channel_select1 .

Developers

Maintainers

The project is maintained by

Alumni

License

This project is currently licensed under the Apache License 2.0. A copy of LICENSE is to be present along with the source code. To obtain the software under a different license, please contact FOSSASIA.

pslab-android's People

Contributors

abhinavraj23 avatar abhishekbisht1429 avatar adityastic avatar akarshan96 avatar apoorva-raj avatar ascress avatar asitava1998 avatar avjeet avatar cloudypadmal avatar codewithsouma avatar cweitat avatar dependabot[bot] avatar dheerajkotwani avatar harsh-2711 avatar iamareebjamal avatar imrajat7 avatar kushmehta1511 avatar marcnause avatar mariobehling avatar namanrawat1 avatar neel1998 avatar nikit19 avatar princejhabak avatar rimjhim28 avatar smit2010 avatar theimpulson avatar vikum94 avatar viveksb007 avatar wavicles avatar yatri1609 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pslab-android's Issues

implement readLine function in CommunicationHandler.java

Implement readLine function in CommunicationHandler.java, so that we can read a line i.e String terminated by '\n' and we don't know length of string beforehand.

Possible approach- read single byte in a loop and check for '\n', when found return the byte array formed before encountering '\n'. Tried but error in reading single byte from bulkTransfer. May be due to high BaudRate of 1Mbps.

For now it would only be used to read version String of device.

Port AD7718

Have to implement AD7718 in the Android version!

Working on Peripherals

To avoid any confusion like I and @viveksb007 ended up working on the same code SensorList.py, I am hence telling I am starting to port MCP4728, NRF24L01, RadioLink into the Android app.

Add build instructions to compile and download standalone APK files

The source has been tested with Android Studio 2.3.1 with Gradle 3.2, and builds without errors once a few dependencies have been synced. However, automatic Download & execution failed.
Device: Xiaomi Redmi 3S + , Android Version 6.0.1 MMB29M, MIUI : Global 8.2 |Stable

as_err1

Console Output

04/14 15:38:33: Launching app
$ adb install-multiple -r /home/jithin/ACTIVE_PROJECTS/PSLab/pslab-android/app/build/outputs/apk/app-debug.apk /home/jithin/ACTIVE_PROJECTS/PSLab/pslab-android/app/build/intermediates/split-apk/debug/slices/slice_4.apk ... [Truncated]  ... slice_3.apk 
$ adb shell pm uninstall org.fossasia.pslab
DELETE_FAILED_INTERNAL_ERROR
Error while Installing APKs

The uninstall process causes it to fail , but the Apk can be installed via adb separately. Using the 'build apk' command creates app-debug.apk , so please add instructions on building a standalone Apk
$ adb install -r app-debug.apk

This App will wait for the debugger to attach ( Can be launched separately via Android Studio), and then displays the Home page.

I will try to test on a few other Android devices to check if the uninstallation failure is not an MIUI specific issue.

Changing "Applications" list with cardviews

The current Applications view consists of a list view with basic list items. It doesn't have much of a description on what each item would do.

Current View
device-2017-05-06-174450

This view can be enhanced with the help of a list view with card items or a grid view as follows!

Card Views Grid Views
image image

If this feature is okay to implement, I can get to work on it! :)

Opening "Applications" window for the first time lags!

As @viveksb007 pointed out in #92, the application lags a little bit when we're opening the Applications tab for the first time.
As observed from the logs,

05-06 22:53:11.275 8299-8299/org.fossasia.pslab D/dalvikvm: GC_FOR_ALLOC freed 2460K, 14% free 22474K/25992K, paused 35ms, total 39ms
05-06 22:53:11.275 8299-8299/org.fossasia.pslab I/dalvikvm-heap: Grow heap (frag case) to 24.156MB for 1440016-byte allocation
05-06 22:53:11.305 8299-8308/org.fossasia.pslab D/dalvikvm: GC_FOR_ALLOC freed 6690K, 38% free 17190K/27400K, paused 22ms, total 22ms
05-06 22:53:11.325 8299-8299/org.fossasia.pslab D/dalvikvm: GC_FOR_ALLOC freed 62K, 38% free 17127K/27400K, paused 16ms, total 16ms
05-06 22:53:11.325 8299-8299/org.fossasia.pslab I/dalvikvm-heap: Grow heap (frag case) to 20.651MB for 3240016-byte allocation
05-06 22:53:11.356 8299-8308/org.fossasia.pslab E/dalvikvm: adjustAdaptiveCoef max=4194304, min=1048576, ut=568
05-06 22:53:11.356 8299-8308/org.fossasia.pslab D/dalvikvm: GC_FOR_ALLOC freed 0K, 26% free 20291K/27400K, paused 25ms, total 25ms
05-06 22:53:11.386 8299-8303/org.fossasia.pslab E/dalvikvm: adjustAdaptiveCoef max=6291456, min=1572864, ut=368
05-06 22:53:11.386 8299-8303/org.fossasia.pslab D/dalvikvm: GC_CONCURRENT freed 1K, 14% free 23625K/27400K, paused 6ms+4ms, total 28ms

there is a possible memory intensive task is happening. Currently I am investigating on this issue!

integrate TravisCI and Codacy

Please integrate TravisCI and Codacy, which would automate code review and easy to see build status before merging the PR.

Oscilloscope UI

This is the first step towards the development Oscilloscope's UI.

screenshot_1491903305

screenshot_1491903314

The above image showcase the landscape mode of the Oscilloscope Activity.
Gestures will also be integrated, like
-pinch zoom for changing the timebase.
-double tap on the graph to freeze.
-swipe down to save.

Please give suggestions on:
-layout and what needs to be improved.
-real-time graph api to be used ( I have used GraphView http://www.android-graphview.org). We can also use MPAndroidChart https://github.com/PhilJay/MPAndroidChart).
-I have researched on 3D graphs libraries but they are paid.
-any other thing I missed.

Control Activity's UI

The following are the screenshots of proposed design of Control Activity.

screenshot_1491877051

screenshot_1491877070

The following has been implemented using 2 ListViews.
Please give suggestions and also review Oscilloscope's UI #33 so that I can make amendments while the python code is been ported.

Handling abrupt disconnection/device not found cases

Addition of a manual Retry/Reconnect button in the Home UI if connection fails even when the device is connected.
While in operation, if the device gets abruptly disconnected, two solutions can be done-

  1. Landing back on Home UI and trying to reconnect again.
  2. Displaying a toast asking user to manually reconnect again.

Although its a minor issue, I would like to do it to get started and also get a hang of this project.

Autogenerate app in apk branch

Please create an apk branch and autogenerate the app here on each build. Please ensure the previous apks are not saved in the history to ensure the repository is not getting super big.

Follow the way it is done for open event android and ask in the open event android channel for help, if needed.

modify polynomial processing functions in AnalogChannel

modify polynomial processing functions in AnalogInputSource to handle arguments as single value and array both.
Source File link

New Polynomial Implementation should be taken into consideration i.e Polynomial object provided by apache common math library and necessary changes should be made.
About Apache Common Math Polynomial #71

Communication error

To be tested with hardware

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.fossasia.pslab/org.fossasia.pslab.activity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
	at android.app.ActivityThread.access$900(ActivityThread.java:153)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5441)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
	at org.fossasia.pslab.communication.CommunicationHandler.open(CommunicationHandler.java:80)
	at org.fossasia.pslab.communication.ScienceLab.<init>(ScienceLab.java:34)
	at org.fossasia.pslab.activity.MainActivity.onCreate(MainActivity.java:74)
	at android.app.Activity.performCreate(Activity.java:6303)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
	... 9 more

Home Fragment UI

screen shot 2017-04-06 at 11 16 41 pm

This is a proposed design for Home Fragment UI. The following things will be implemented

  • Pinch Zoom
  • Improvement in the quality of the image of the PIN Diagram and the description of the PINs.

Avoid Confusion

To avoid any confusion like I and @viveksb007 ended up working on the same code SensorList.py, I am hence telling I am starting to port MCP4728, NRF24L01, RadioLink (Peripherals) into the Android app. If you are working on same do let me know @viveksb007

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.