In this blog, I will explain the feature to generate “Config File” in PSLab Android Application
What is a Config File?
The main aim of this feature is to make PSLab board a self data logger, which would read user-defined configs from a config file stored on SD card connected to PSLab board and based on instrument, parameters and time interval stored in config file PSLab board would automatically log those values.
Now as the first step of this feature, an option is added to PSLab Android application, where user can create a config file. User can select an instrument, parameters associated with that instrument and time interval. With this feature, user can easily generate a config file which can later be used by PSLab board for logging.
The option to generate a config file is given in the side navigation menu on the main screen.
Once the user selects the “Generate Config File” option, the user will be directed to the following screen where user can create a config file with intended parameters
As can be seen in the screenshot above the user can select instruments for which the config file needs to be created from a drop-down menu. User can specify the time interval, for which the data should be logged by the PSLab board. Based on the instrument selected by the user corresponding parameters will be shown at the bottom. User can select whichever parameters are required and click on “CREATE CONFIG FILE” button and a config file will be saved on device local storage.
A config file for Oscilloscope with 25-sec interval and CH1, CH2 and CH3 parameters would look something like below,
When a user clicks on Create Config File button, First we check whether the user has provided a time interval, if not a toast message appears to let the user know that time interval is missing. This is done using the following lines of code,
Once the user sets the time interval and selects the parameters, the following lines of code generates a string array containing params selected by the user.
After we have the list of selected parameters we call the following function to create the config file
In the first part of this function, we check whether there exists a PSLab directory in the local storage of the device, if not the directory is created. After that, we create a file named “pslab_config.txt”. After that, we use FileWriter to write data to the file.
In a nutshell with this feature user can create config files easily. The following GIF demonstrated this functionality.
- Android Documentation on Files object
- Create a text file in Android
- Video tutorial on storing text file to internal storage
- CSV Logger in PSLab project repo
Tags: PSLab, Android, GSoC 19, Config File, data logger