Combining BTLE and SpriteKit for Alvio’s iPad game

Alvio by Qol Devices is one of 10 companies from the first R/GA Connected Devices Accelerator. Their breathing training system combines an iPad with a breath-powered Bluetooth controller to help kids with respiratory challenges such as asthma.  This platform makes breathing therapy fun for kids by gamifying what was previously a tiresome process for both parent and child.

A myriad of tech challenges arose during development of this product.  The challenges spanned hardware, BTLE communication, game design and the complexity of breath-controlled interaction.

Alvio’s initial hardware prototype used a serial cable connection between the breathing apparatus and an iPad. One of our first jobs was to implement a Bluetooth Low Energy (BTLE) communication system. This freed up the user to comfortably breathe in their natural space without being tied down by cables.

For the application we used a Core Bluetooth implementation with its standard Peripheral (has data) to Central (wants data) pattern. The Bluetooth service in this case contained two characteristics — the strength of breathing and resistance set by the device. These characteristics’s values were contained in 16 bit chunks of data in the Bluetooth stream. By converting this data into a signed integer and normalizing the result we established a range of usable values from -100 (inhale) to 100 (exhale) for a strong breath.

The Alvio games were built using Apple’s native 2D game framework, SpriteKit. Our game character needed to move smoothly between frame animations (expanding, contracting, breathing, looking around etc) as well as move smoothly around the screen. When our breathing data was attached directly to the game character’s velocity the movement was extremely jolty and unnatural. We solved this by creating a simple custom animation and physics engine in SpriteKit for the character’s movement, complimenting SpriteKit’s existing physics and animation systems.

To smooth out the numbers being returned from the Bluetooth payload we used a classic in/out easing equation, and attached the resulting values to the character’s acceleration. Controlling the acceleration, as opposed to the velocity, created a more fluid movement that gave the character’s body weight and water resistance, as well as a smooth deceleration beyond the time of final exhale.

R/GA’s team of creatives and developers collaborated closely with Alvio, adding that extra bit of polish that led to the recent win of the Gold Lion award at Cannes.  More importantly, though, is that we created a platform with the potential to change the lives of millions of children.

We’ve recently announced the next class for the R/GA Connected Devices Accelerator.  If you or your startup have a great idea that helps connect digital and physical, we’d love for you to apply.

Restored from Internet Archive · Capture: Fri, 29 Jan 2016 21:27:03 GMT