precipiSTATION Android App
I do not know Java or Swift well. And I am also not a professional programmer. So I used MIT's App Inventor 2 to create this app. Perhaps the best way to understand the app is to look at the video below or the user guide here. And to actually set up a Photon with the firmware, and create and load the .apk on an Android device.
I do not know Java or Swift well. And I am also not a professional programmer. So I used MIT's App Inventor 2 to create this app. Perhaps the best way to understand the app is to look at the video below or the user guide here. And to actually set up a Photon with the firmware, and create and load the .apk on an Android device.
The precipiSTATION app grew over time from a hard-coded manage running one program at a set time (very simple) to a fairly full blown sprinkler control app (somewhat complex). It looks more complicated than it is because of the myriad App Inventor 2 blocks. But it is still fairly complicated because it provides many features, and because I did not architect it up front, instead just adding features as I progressed. It is probably larger in terms of blocks than an optimal App Inventor program would normally be. I put comments into the blocks (click the "?" button on the blocks) to show the purpose of each. In the meantime, a very short summary.
When the app starts, it connects to the precipiSTATION and, using POSTs and GETs:
When the app starts, it connects to the precipiSTATION and, using POSTs and GETs:
- displays screen that just shows that connection to precipiSTATION is in progress
- fetches program names from precipiSTATION, parses the returned data, and saves to list, populates appropriate list pickers
- fetches station names from precipiSTATION, parses returned data, and saves to list and database, populates appropriate list pickers
- fetches on/off status and Twitter enable/disable status from precipiSTATION, and sets button displays accordingly
- fetches overall sprinkler status from precipiSTATION
- parses status data, creating lists for further analysis of regular scheduled programs status, stations run once status, programs run once status, and sprinkler test status
- creates status display for each of running now, already ran today, scheduled to run now
- displays fully populated main screen
- returns connection error dialog if connection to precipiSTATION fails
By touching the "Manage Programs" button on that screen, the app switches to a management console view of the first screen (app makes status invisible and makes management console buttons visible, stays on same screen). From this console you can set up and manage programs (which causes app to switch to Screen 2), or set up Station Names (which causes the app to switch to Screen 3, labeled Station_Name_Entry below).
Screen 2 initializes by displaying a list-picker of program names, and then fetches the time data for the selected program and populates the appropriate fields, or if it is a new program, asks the user for the program name, and opens a blank program. When the user is done with data entry, they hit the "Upload" button, and the dialog alert comes up summarizing the program, and they can then OK it and upload it to precipiSTATION. The app then returns to Screen 1.
Screen 3 provides text input boxes for the entry of ASCII station names, displaying the current names as it opens. When a user is done data entry, they press the Upload button and the app sequentially uploads each of the 16 station names using 16 function calls to the precipiSTATION, while displaying the upload status. It returns to Screen 1 once complete.
If you download the .aia file below, and load it into App Inventor 2, you will be able to see the somewhat sparse commentary (in the "blocks" section) I have been able to enter for each block group.
To make this app work with your core, you will have to go to the "blocks" section, enter your Core ID and API Token in the variables blocks in the upper far left of the app (see graphic below), build an .apk, mail it to yourself on your Android phone,, and install it on your Android device. (See this for more info).
Screen 3 provides text input boxes for the entry of ASCII station names, displaying the current names as it opens. When a user is done data entry, they press the Upload button and the app sequentially uploads each of the 16 station names using 16 function calls to the precipiSTATION, while displaying the upload status. It returns to Screen 1 once complete.
If you download the .aia file below, and load it into App Inventor 2, you will be able to see the somewhat sparse commentary (in the "blocks" section) I have been able to enter for each block group.
To make this app work with your core, you will have to go to the "blocks" section, enter your Core ID and API Token in the variables blocks in the upper far left of the app (see graphic below), build an .apk, mail it to yourself on your Android phone,, and install it on your Android device. (See this for more info).
![](http://www.weebly.com/weebly/images/file_icons/file.png)
precipistation.aia | |
File Size: | 231 kb |
File Type: | aia |