You can also be interested in:
This is a proof of concept of how we can develop a simple calculator app (basic operations over two numbers) for the U8 smartwatch taking advantage from the tasker+notification method described in my prevoius post. Read the "How to get the best of your U8 smartwatch" entry before going on if you've not done it yet.
How can we build a calculator?
Well, the only possibility to work with numbers with the U8 smartwatch is to use the dialer. Here we miss some things obviously, for example the operation symbols! But don't break down, we can do something about it. My approach was the following:
- The called number shoud have the information of the operation type and the two numbers over which the operation is made
- I will code the operation type into a number:
- I will use an informative schema, which will be the first part of my final string of numbers, separated from the rest by an asterisk (which is present in the dialer)
- In the informative schema I will describe the operation type
- I will separate the two numbers with an hash
Given the above rules the following operations are coded this way:
|345 * 4||3*345#4|
|255 / 9||4*255#9|
The tasker's task
Here comes the descriptive task code:
Let's describe it a bit:
- in A1 we match called numbers starting with a number between 1 and 4 and followed by an asterisk
- in A2 we end the call. I must say that in this case, with a called number including "special chars" the call is not ended by tasker and I don't know why. I end it manually.
- in A3 we execute a js code which parses the called number, gets the operation type and the operation numbers and constructs two variables: the operation string and the operation result
- in A4 we notify to the watch the operation result
That's it, as I told you it is only a proof of concept, but the code could be extended to consider decimal numbers, parenthesis, or even more complex operations. In some cases it would be enough to represent different math symbols as sequences of special chars, in others you may consider the idea of using the first part of the called number as an informative schema for the symbols used in the operation, for example:
could be interpreted as (55 + 3)/2 with these rules
|14||operations order (the first is a sum, the second a division)|
|#||Divides informations in the informative schema|
|9||Represents a parenthesis|
|*||End of the informative schema|
|55||The number 55|
|#||The first operation (a sum)|
|3||The second number, 3. It couldn't be 39 because 9 in this expression represents a parenthesis|
|#||The second operation (division)|
|2||A number: 2|
You'll just need to play a bit with regular expressions :)
Hope you enjoy, and write here your observations!