Two Useful Workshop Phone Applications
As explained below, these apps are not available through app stores but source code and debug versions of the Android and Windows Phone installers are available from www.model-engineer.co.uk/apps. This note also explains how to build the apps or derivatives that might be based on the code.
Source Code for Metal Bender App
Enjoy more Model Engineer reading in the monthly magazine.
Click here to subscribe & save.
I am making the code available under the MIT license choosealicense.com/licenses/mit/. In brief, the code can be copied, modified or reused as long as the license and copyright are preserved. There is no implied warranty but if problems are found, please report them through the forum.
User Interface
When opened, each app presents itself as a simple form with buttons to perform the main operations – Calculate, Reset and Help. The apps have been designed to run best in landscape mode and in most cases, do not require any scrolling (other than on the help pages). To achieve this, the buttons are at the top.
Fields with a grey background are not user editable and only fields with a non-zero value are treated as inputs. Fields containing zero are calculated if appropriate. For example, if the radius of a circle is entered but the diameter is left as zero, it will be calculated and vice versa.
Pressing Reset clears the visible fields on the current tab, but other tabs are unaffected.
Both apps are self-documenting – pressing the Help button displays a page describing the usage of the app. As far as possible, accessibility guidelines have been followed although this may not be evident on a phone or tablet.
Geometry App
The Geometry app performs a collection of geometrical calculations often encountered in a workshop. The calculations and their required fields are described in the help text and are summarised below. Each type of calculation has its own tab:
- Circles – basic properties as well as chords and segments. For example, finding the depth of cut when machining a flat of a particular width on a round bar
- Regular Polygons with at least 3 sides. This relates side length, inscribed and superscribed circles, internal angles, overall height and area. Circular, square and hexagonal stock materials are often encountered and their relationships are important
- Right-angled Triangles relates side lengths, angles and area
- Rectangles relates side lengths, diagonals and area
- PCD calculates the angles, distance across centres and distance across holes for a Pitch Circle Diameter situation. It can also calculate the list of coordinates based on the centre or one corner
- Sine Bar is a simple version of the right-triangle tab and relates the bar length, the height above the datum and the elevation angle
- mm-inch conversion includes fractional inches
The circles tab is shown in photo 1.
By default, all results are calculated to 3 decimals. This can only be changed by altering the code – look for the line “var dps = 3;” in geometry.js (see notes on source code below).
MetalBender App
The Metal Bending app calculates the position of the clamp plate and hinge for using a bending brake that might be found in the home workshop. This is not suitable for industrial bending machines.
The calculation requires a “K factor” that depends on the metal being used. However, this factor isn’t well defined and, in industry, can vary from one workshop to another. The app uses a table of commonly used defaults, but these can be updated by the user. The help page explains the calculation in more detail.
The main screen is shown in photo 2.
By default, all results are calculated to 1 decimal place. This can be changed through the user interface (on the settings page).
The app stores the number of decimals and the table of K values in local storage and should not need any special permissions. Data is stored in JSON format.
Supported Platforms
As described below, I have built debug versions of Android and Windows apps but I have only tested the Android version. For anyone with a suitable developer accounts or build environment it should be possible to build full release versions and the iPhone version as well.
Since the code doesn’t rely on any phone-specific features, it should also run without modification on all modern browsers. I have tested it on Firefox, Chrome and Internet Explorer although you may have to allow scripts to run.
The Source Code
The apps are written using HTML, CSS and JavaScript. They use JQuery but not JQueryMobile, which placed too many restrictions on the UI design. They do not rely on any platform-specific libraries.
Each app has a similar structure, consisting of the following files:
- License – describes the MIT license under which this code is made available
- Readme.md – a very brief description of the app
- Config.xml – required by PhoneGap Build, which is described below
- Icon.png – the image that appears in app lists and on the home screen
- Index.html – all of the app user interface is defined in this file
- res folder – contains a 96 x 96 icon and any other images needed in the help text
- js folder – JavaScript files:
- Bending.js or Geometry.js – the code required to perform calculations, manage the screen, etc.
- Jquery-3.2.1-min.js – a minified copy of the JQuery library. This has to be included explicitly rather than use an online reference because the phone can’t be guaranteed to have network access
- css folder – contains appstyle.css, which defines the styles for various elements.
The source code can be maintained in any development environment and several of them allow apps to be built for specific phone operating systems. Examples include Visual Studio with Xamarin, Eclipse or Mono. However, it can also be edited in a simple text editor such as Notepad++, which provides a degree of syntax checking.
Building the Apps
A disadvantage of using a locally installed development environment is that the target platform SDKs must also be loaded, and these can be onerous, particularly if multiple targets are to be supported.
An alternative is to use an online build environment and the attached apps were built with PhoneGap Build (build.phonegap.com). This builds apps for Android, Windows Phone and Apple iPhone without needing to install anything on the host system. An Adobe logon is required but there is no fee for non-commercial users.
PhoneGap Build allows the user to build one project if uploading a zip file or several projects if they are linked to open-source GitHub repositories. The zip files associated with this article are in the correct format for uploading to PhoneGap Build. PhoneGap rebuilds the app whenever the source code is uploaded and, once built, the installable files can be downloaded.
If you have a developer account on an app store you can up-load the associated developer key. Without this key, you will only be able to build debug versions of Android and Windows Phone apps although this should not affect their operation and would allow remote debugging if developer mode is enabled on the phone (on Android, at least).
Installing the Android Apps
Apps that aren’t available from an app store have to be installed in a different way. On Android, there are two options for “side loading” an app:
- Send an email to yourself with the apk file as an attachment. Open the email on the phone and load the attachment, then select the install option.
- Connect the phone to a PC and copy the apk file to the Download folder on either the internal storage or the SD card. On the phone, navigate to the folder (eg: Settings > Storage > Internal storage > Explore > Download) and tap on the file. Note that this may vary between Android versions and between manufacturers.
You will probably need to enable “Unknown sources” in the security settings. Both apps have home page icons.
Source Code for Metal Bender App
Editor’s Footnote:
I have only been able to test the Android versions of the apps on my phone. They were very easy to install by emailing them to my gmail account. The only issue I found was that to see the tabs in the Geometry App the phone must be in ‘landscape’ mode. Thanks to Chris for these useful workshop apps.