Monday, September 28, 2015

Flic Bluetooth Button Review

I had mentioned the flic Bluetooth buttons earlier when I was talking about adding physical controls to my Digital Dash Project (http://mikesgeneralblog.blogspot.com/2015/08/physical-controls-for-digital-dash.html).  I had been an early backer of the project on Indiegogo with the idea of using them specifically for that system.  I ended up ordering five of them, and four were delivered over the weekend. (Not sure what happened to the fifth one, but it was a late addition and may not come for a while.)

Although I won't be using them entirely as I planned, I've installed one in the car and will be experimenting with the others.  Since these are new, I thought I'd do a review.

What is a flic?

A flic is a self-contained Bluetooth button that can be connected to both Android and IOS devices to perform tasks when pressed.  The free flic software has direct integration with a number of apps and can be used with both IFTT and Tasker (Android only) to control nearly any action that you care to automate. Each flic can recognize three different activation types (Click, Double-Click, and Hold).  You can program these separately, so each button can essentially do three things.

Flics are the brainchild of a Swedish company, Shortcut Labs, who used Indiegogo to crowd fund the startup.  They reached their initial funding goal in only 30 hours and ended up with over $900,000 in pledges; 801% of their original goal.

Packaging

The flics arrived in an attractive box that has a thank you message to Indiegogo backers on the bottom.  The Flics themselves are nestled in custom foam cutouts inside the box.  There are two layers of these, and each one can hold three flics, so each box can contain six buttons.  The foam rests on a cardboard stand which has some space underneath where the optional clips are stored.  

There was also an insert directing you to the website (https://flic.io/), and a large round sticker that  you can use to show your support.

All in all, the packaging provides a nice presentation and holds the contents securely and safely.







Hardware

Each flic is slightly larger than a U.S. quarter and just over a quarter-inch thick.  The body is covered with a textured, velvety rubber embossed with the cursive version of the name from the logo.  

The back is hard plastic that comes covered with thin transparent shield.  Removing that exposes the reusable adhesive that you use to stick the flic to a non-porous surface. If the adhesive loses its stickiness, you can just clean it with water and it will regain its holding power.  I had originally intended to mount a couple of these to the back of the steering wheel in my car, but I don't think the adhesive would be up to that task; it holds the button just fine on the console, however.




The unit is entirely self-contained and powered by a button cell battery that the company claims will last up to five years.  They also claim that the battery is common item and can be easily replaced, although there are no instructions that tell you what to get or how to change it.

Flics come in black, white, green, yellow, turquoise, but I choose all black ones for my application.

The button is light, but it has very nice tactile experience and a satisfying physical "click" when pressed.

There's also a small clip that you can attach to your flic so that you can clip the button to clothing.  The company suggests you might want to do this for personal safety or to provide a way of faking a phone call to get out of a bad Tinder date.

Software

The free flic app is available in both the Apple and Google app stores and is required for operation.  It is used for pairing the button to your device, assigning actions, and changing settings.  You do need a free flic account to use the software.

The flic app is also where you start and stop the flic service.  This service must be running in order to use a flic on your device.  By default, it runs as a foreground service that starts when your device does and puts up a persistent notification.  You can use it as a background service as well, but then it is subject to be killed by memory management.  There doesn't seem to be any appreciable battery drain from this service when it isn't being used, so there's really no need to ever turn it off, but you can if you'd really like to.  

Once you've set up a flic (See Operation, below) you can access the individual functions.  There are 46 built-in app integrations and most of them give you several options to choose from.  You have free rein to set things up as you wish.  That is, one button can control up to three different apps: a single-click might turn on your Phillips Hue lights, while a double-click might send a text message, and a hold command could start a Skype call.

More sophisticated options such as IFTT and "Send Intent" allow for even greater control.  (And, of course, there's Tasker, integration, which means you can do anything you want.  Tasker is covered separately, below.)

I won't cover all the settings, but there is one that I particularly like.  By default, a flic will play pleasant sounding chimes through your device to indicate that it has been pressed.  Each action type has a different chime associated with it, so you know right away if your press has been registered.  For my Digital Dash project, this is ideal and I've left it enabled, but you can turn it off if you wish.

Finally, the app also has a help section that explains most functions, but it also has context sensitive help that walks you through most operations.

This is a nice, simple piece of software that gets the job done.  It has a clean and open look that make it easy to navigate and use.

Operation

Here are the basic steps to using a flic.

Pairing

Pairing is a simple operation.  Just open the flic app and press the button once.  The app generates a key and links the button to your device.  Once that is done, the process is automatic from then on.  Flic appears to use Bluetooth Near to detect the button and activate it.  You don't need to turn it on, wake it up, or do anything else; it's just there when you need it. Once it's in range, it's active.  Once the button is paired, you can go ahead and rename it and configure it.

Configuring

Open the app and touch the button entry on the screen.  It will then take you to another screen where you can add actions for each type of button press.  Just tap the plus sign to get a list of programs.  Click one of those and the system will guide you through the steps to get everything set up.  If you already have an action, there is a standard "three dot" menu that allows you to Remove, Edit, or Execute the action.






Use with Tasker

When I first opened the flic app and began scrolling through the list of possible integrations, I was a bit concerned because I didn't see Tasker anywhere on the list.  I was afraid it didn't make the initial release cut and that I'd need to wait before I could use it.

However, on a hunch, I went into Tasker itself, created an Event profile, and chose the Plugin category.  Sure enough, there was flic.  Installing the app also installed the Tasker plugin.

Using it is very simple.  Once you chosen flic as the Event handler, you just click the standard Tasker plugin configuration icon and you are taken to a screen where you choose the flic you are programming and which of the three activation types you are trying to capture.  Once you've done that, you link the profile to the task you want to execute.  In other words, it's just like every other Tasker plugin you've ever used.  Note that the plugin gives you a few more options, such as triggering on either the up or down portion of a press and executing a task based on the button connecting or disconnecting.




It only took me a few minutes to program the flic to act as a Next Track button for both Pandora and PowerAmp.  In the next day or two I'll be programming its other functions to provide additional music control and I'm confident that it will work as expected.


Notes and Observations

Here are a few random things about using the flic.

You can have up to eight (8) flics connected to a single device.

A flic can only be paired to one device at a time.  If you want to use it with a new mobile, you need to disconnect it from the old one first and move it to the new one by opening the flic app on the new device and pressing and holding the button for at least seven seconds.  The app will connect to the flic servers and download the button's key.  Since all this is stored in your flic account, it will also download the configuration for the button, so your programmed actions come over as well.

Response time is excellent.  When my Digital Dash project is in full swing, it really works the tablet; running turn-by-turn navigation, regularly querying web servers via Bluetooth tethering, running Torque (which is also writing it's own log file), sending and receiving AutoRemote messages, handling interactive screen overlays, playing music, and more.  Despite all that, there was never any lag between pressing the the flic and hearing the confirmation chime.  This is a very fast implementation.

There is a "Providers" screen under settings where you can disable apps or services that you don't use or configure the ones you do.

Conclusions

I like these little buttons a lot. There were some delays in getting them out, but I'm glad the company chose to delay and release a product that they were happy with rather than putting out something that wasn't quite finished.  I feel that they delivered exactly what they promised and I have no regrets about backing them.

As of the time of this review, flics are not yet shipping to the general public.  However you can pre-order them on their website (https://flic.io/) with an estimated time delivery of about eight weeks.

If you need or want a simple physical control for a project, flics are a good choice.



Wednesday, September 23, 2015

Navigation ETA Information Revisited

The display of ETA information that I talked about in my last entry about the Digital Dash project was (I thought) pretty neat, since it expanded on the philosophy of bringing as much useful information to one screen as possible.  It was also, unfortunately, very short-lived.

I got to use the feature on exactly one trip.  Then, after we returned home, I made the mistake of upgrading my tablet to Lollipop.  I figured it had been out awhile and had had a couple of point releases, so it was probably safe.  Wrong.

In the first place, it completely messed up my GPS.  After upgrading it took more than five minutes to get a lock, and even when it did, it had an error of up to 900 feet and would drop out every couple of minutes.  I was on the verge of flashing back to KitKat when I saw a post where someone mentioned the "GPS Status Test & Fix - No Ads" app as a possible solution.  Fortunately, installing it did the trick and my GPS is working normally again.  At the same time, the original "GPS Status" app that I was using wasn't working at all, so I've uninstalled that one.

The other thing that Lollipop broke was Google Maps notifications.  Well, maybe not broke, exactly, but it did change things to the point where AutoNotification can't return the ETA data any more.  The information is still there, and AN can actually respond to it, but it can't report it back to Tasker as a variable.  I've reached out to the AN developer and he's investigating, but I haven't heard anything back from him yet.

There's no guarantee, of course, that he'll be able to fix it or that it won't break again, so rather than waiting, I decided to see if there was any other way to get the information I wanted.

Turns out, there is.

I originally started out looking to see if there was an intent that I could call or monitor for this information.  I didn't find one, but I did find plenty of discussions from developers wanting to create different types of navigation apps, particularly for geocaching.  It seemed like they were always directed to check out something called the "Google Maps DistanceMatrix API".

A little more research turned up that this was a web-based service that can be called via a simple HTTP Get command.  You simply create a query string with a starting point, a destination point, and few settings and ship it off to the server.  You get back a data block (either xml or json) that contains, among other things, the distance to the target and the estimated travel time.  Just what I needed.

I played around with it a bit and came up with the code I needed.  I added a couple of lines to my V3_Compass routine to save the current latitude and longitude, added one line to the V3_StartNavigation task that saved my chosen destination to a new global variable, and added one more line to the V3_TimeAndTorque task to call my new routine so that it gets executed about every 30 seconds.

Here's that new task: 

APIQuery (113)
A1: Variable Set [ Name:%dayhalf To:AM Do Maths:Off Append:Off ] 

We start off by assuming that we will be arriving at our destination during the morning hours.  Later, we'll test this assumption and modify this variable if necessary.

A2: Variable Set [ Name:%uri To:/maps/api/distancematrix/xml?origins=%V3_Lat+%V3_Long&destinations=%V3_CurrentDestination&mode=driving&units=imperial&key=My Google Key Do Maths:Off Append:Off ] 
A3: HTTP Get [ Server:Port:https://maps.googleapis.com Path:%uri Attributes: Cookies: User Agent: Timeout:10 Mime Type: Output File: None Trust Any Certificate:Off Continue Task After Error:On ] 

This is the heart of the routine.  We use variables from other parts of the system to construct a properly-formatted query string and ship it off to the Google Maps DistanceMatrix API.  Although anyone can call the non-secure version of the API, I signed up for a free Google Developer Account and obtained a Key so that I could use a secure connection and be able to monitor performance.  This query will return a consistently formatted block of xml data containing the information I need and put it in Tasker's built-in %HTTPD variable.  Much of the rest of this task is devoted to extracting the relevant pieces.

A4: Variable Split [ Name:%HTTPD Splitter:text> Delete Base:Off ] 
A5: Variable Split [ Name:%HTTPD2 Splitter:< Delete Base:Off ] 
A6: Variable Set [ Name:%timeleft To:%HTTPD21 Do Maths:Off Append:Off ] 
A7: Variable Search Replace [ Variable:%timeleft Search:hours Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:hr ] 
A8: Variable Search Replace [ Variable:%timeleft Search:mins Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:min ] 

The first thing I obtain is the travel time remaining.  It's almost in the format I want, but to shorten it up a bit for display, I replace "hours" with "hr" and "mins" with "min".

A9: Variable Split [ Name:%HTTPD4 Splitter:< Delete Base:Off ] 
A10: Variable Set [ Name:%distance To:%HTTPD41 Do Maths:Off Append:Off ] 

The next piece is the distance to the destination.  This is already formatted as I want, so I just have to split it out.

A11: Variable Split [ Name:%HTTPD1 Splitter:value> Delete Base:Off ] 
A12: Variable Split [ Name:%HTTPD12 Splitter:< Delete Base:Off ] 
A13: Variable Set [ Name:%durationvalue To:%HTTPD121 Do Maths:Off Append:Off ] 

For the first two pieces of information above, I extracted the "text" versions.  That is, the information as presented in a human-readable format.  However, the xml contains "values" for this information as well: the distance is also sent as meters, and the travel time is also sent in seconds.  Because the API does not return an ETA, I need to calculate it myself, and it's easier to do by manipulating a single block of seconds rather than individual hours and minutes.  Accordingly, I grab the travel time value to use in that calculation.  

A14: Variable Split [ Name:%TIME Splitter:. Delete Base:Off ] 

This line grabs the system time from Tasker's built-in variable (which is in 24-hour format) and splits it into separate hours and minutes variables.

A15: Variable Set [ Name:%eta To:((%TIME1*3600)+(%TIME2*60))+%durationvalue Do Maths:On Append:Off ]

The line above converts the hours and minutes into a single variable that represents the seconds since midnight.  It then adds the number of seconds left to travel to that value.  The result is the ETA expressed in seconds.

A16: Variable Set [ Name:%hours To:floor(%eta/3600) Do Maths:On Append:Off ] 
A17: Variable Set [ Name:%minutes To:floor(((%eta/3600)-%hours)*60+.5) Do Maths:On Append:Off ] 

The above two lines simply convert the seconds back into hours and minutes.

A18: Variable Set [ Name:%dayhalf To:PM Do Maths:Off Append:Off ] If [ %hours > 11 & %hours < 24 ]

Now it's time to revisit that %dayhalf variable.  If %hours is greater than 11, then we will be arriving at our destination in the afternoon and need to set %dayhalf to "PM"; unless %hours is also greater than 23.  In that case, we will be arriving sometime after midnight of the next day, which is morning again so we leave %dayhalf alone.

A19: Variable Subtract [ Name:%hours Value:12 Wrap Around:0 ] If [ %hours > 12 ]
A20: Variable Subtract [ Name:%hours Value:12 Wrap Around:0 ] If [ %hours > 12 ]

I prefer the 12-hour time format, so these two lines take care of converting 24-hour time back to what I want.  The same action is used twice just in case our trip will take us past midnight.

A21: Variable Set [ Name:%V3_ETA To:%timeleft (%distance)ETA: %hours:%minutes %dayhalf Do Maths:Off Append:Off ] 

The final step is to take all the information we've derived and put it into a variable which is linked to a text box display on the main screen.

Once again, here's what that looks like:



To test this, we took the Z3 out for a little drive this weekend.  We drove over a neighboring town and when we got ready to come back, I called up my navigation panel and chose "Home" as the destination.  In about 15 seconds, the ETA display showed up on the main screen and began tracking the trip.  I watched it pretty closely and it seemed to work perfectly.  The ETA that it showed turned out to be exactly right and it counted down time and distance very accurately.

Later, I logged on to my Google Developer account and checked the stats for usage on the Distance Matrix API.  It showed 44 calls, which was exactly correct for the 22 minute trip, and every call was successful.  I also checked my cellular data usage and showed that my Bluetooth tethering app went through just under 8Mb for the day.  I have no way of knowing just how much of that was for Distance Matrix calls, but even it accounted for all of it, I'm no danger of running over my 10GB monthly allowance even if I use navigation heavily.

Update:  I tried this again today.(The weather here has been beautiful this weekend.)  Same idea, but this time it was a longer test.  On a 49-minute trip, I can see that the system handled 98 successful events and the info tracked perfectly.  My phone showed data usage of about 5MB, so it is using even less than I had previously thought.  It looks like I could run this system 24 hours per day all month and not even use half of my monthly data allowance.



Thursday, September 10, 2015

Ok, this is just weird.


I'm not sure if it's Moe's pageboy bob, Curly's barefoot tummy tickling, the bondage, or the general assault on fashion, but something about this image just gives me the creeps.

On second thought, it's the tummy tickling.  Ugh.

Tuesday, September 08, 2015

A New Digital Dash Feature

It's been a long time since I've really added a new feature to the system.  Most things I've done over the last year have been tweaks and enhancements.  But just in time for our unofficial-end-of-summer road trip last weekend I did add something new.

I had seen a tutorial showing how to use AutoInput and AutoVoice to create a system that could grab the ETA information from Google Maps and send it as a text message to someone to let them know when you would be arriving.  It looked pretty good, but, A) I really don't ever need to do that, and B) I know for a fact that voice commands are ...ineffective in a convertible with the top down cruising along at 70 with the stereo blasting.

If you're one of the 22 people who have read the first installment of this adventure "Adding Tech to a Z3 Using an Android Phone", you might remember that I ended that by saying that I really wanted a fully voice controlled interface.  Well, I actually did have that at one point.  I spent a good deal of time during the first few months of 2014 building it.  I used AutoVoice in continuous mode on my phone to create an always-listening system that could capture and interpret voice commands and send them off as AutoRemote messages to the tablet to be executed.  It was really pretty full-featured and could switch apps, start navigation, control music, search for and play specific songs, and so on.  All in all, it recognized about 30 different commands.  And it worked perfectly...in my home office, where I created it.

In the car, however, it was another matter.  The first warm spring day that I could get the car out, I backed into the driveway, fired up the system, and began testing.  Even with a good Bluetooth headset and the car not even moving, my commands were recognized about one out of every ten times when the stereo was on, even when I was speaking quite loudly.

There's a nice elderly lady in our neighborhood who still brings me cookies once in a while because she feels sorry for me.  She had seen me sitting in the car yelling "Torque!", "Maps!", "Torque!", "Damn it!", and became convinced that I have Tourette Syndrome.  Needless to say, I abandoned voice control in favor of what I'm using now.

Anyway, although I didn't take away anything directly from that tutorial, it got me wondering if there was some other way to catch and use the ETA information. Turns out, there is.

In addition to displaying that info on its own screen, Maps also creates a notification that contains essentially the same thing.  By using AutoNotification I'm able to capture it, massage it into a more compact format, and display it on the main screen.  Like this:



Even though this might not seem like that big of a deal, it's very useful for me since 90% of the time when I flip over to the Maps app, it's to see this information.

You see, I live in one of the fly-over states and most of my road trips include directions like: "...Continue straight for 87 miles, then turn right and continue straight for 64 miles...". I don't really need to check those directions very often.  About the only time I actually use the turn-by-turn information is when I'm skirting the edge of a city.  (Defined as any place with a population of more than 5000.)

So having this on-screen all the time keeps me from switching apps as often, which is safer and doesn't annoy my wife as much.

I'm not necessarily thrilled with how it looks at the moment.  It seems a bit crowded and messy, but I think if I were to have it switch places with the connection icons, it would look better.

Something to do this winter while I'm eating cookies.