× {{alert.msg}} Never ask again
Receive New Tutorials

Office Hours Q&A With Pebble Developer Evangelist

– {{showDate(postTime)}}

This article is based on the Codementor Office Hours hosted by Thomas Sarlandie, a developer evangelist working at Pebble. It answers questions such as how to efficiently handle debugging, how to handle floating point numbers and math in Pebble, and other questions the audience asked.

Pebble is a smart watch that is compatible with both iOS and Android devices, and it can be developed using C or JavaScript. As of February 2014, the Pebble app store had over 1,000 applications developed using Pebble’s free software development kit (SDK).

Is data visualization down the road with Pebble?

Yes, a lot of apps do data visualization, and there are many definitions to what data visualization is or could be. If you look at apps on the Pebble app store, you’ll find apps that connect to different web services like google analytics and other services that aggregate data for you. If you search for data visualization you’ll likely find a few apps.

How to deal with floats and math efficiently on Pebble watches

As the CPU on pebble does not have a floating point unit, it cannot use hardware acceleration on floating point numbers. However, there are two ways to deal with this, and they both evolve around using fixed points than floating points. Fixed-point math is when you know how many digits you have on your data. For example, if you only care about the last three 3 digits, you can multiply your number by 1000 after the digital separator. Or, if you look at how angles are handled on Pebble, you’d notice there’s a function like the compass that will give you a heading. Instead of taking a value between 0 and 360, it will take the value of 0 and 10,000, and you divide 10,000 by 360 to get the value of 1 degree. So that’s a general idea of how to do fixed point.

If you actually have a requirement for more precise math, for example to do some signal processing to process accelerometer data and count the user steps you can use a fixed point library that will replace the default floating point implementation in the compiler. If you want more details on this we have a presentation on pebble developer’s site in 2014 with a section on size, and it covers different ways of optimizing you app for floating points. In there we have an example of how to use a fixed point, which is also available on Github.

Is there a mechanism for the watch to dial 911 on the phone even without SIM?

Because of the way iOS is designed, Pebble cannot dial directly on the phone because it could create incurred cost for the user, so iOS does not allow Pebble to dial to the phone. However, you can do this on Android, but then it will be an Android-only app and not work on iOS. It will, however, work without a SIM card.

How to log for debugging purposes when in an event-driven loop

When you deploy an app on Cloud Pebble, you can view the app logs and you can see some debugging information in the logs.

However, if you are logging from a loop in your app, you have to be careful. All your log messages are going to be sent via Bluetooth, so if you’re also using Bluetooth to do another type of communication such as exchanging messages with JavaScript code or talking to an iOS/Android app, this will impact the logs on your app and slow them down, especially if you’re trying to log twenty times per second. One solution is to make your log messages a little smarter instead of having them send a message every time you go through the loop. For example, if you’re trying to debug when something explodes, then show a log message if the value is out of the normal range. If you’re trying to debug timing problems, show a specific error message if it has been more than twenty milliseconds since the last call, but don’t push logs continuously, especially if you have 15~20 messages per second. If you don’t do this, the Bluetooth link won’t be fast enough to log all messages and you’d end up dropping some, which is not going to help you.

Is it possible to record a reminder message with a push of the button?

Pebble does not have a built-in microphone, but something that works really well is having an iOS or Android app talk to pebble, and when you press a button on your pebble, you send a message to your iOS app and the iOS app uses the phone’s microphone to record. It works very well because most of the time the phone is not far away at all from pebble. There have been use-cases where you press a button and your Pebble tells your phone to record 30 seconds for music recognition, and then afterwards it sends you a reply to your watch.

In terms of hardware, is there any plan to include possibility of measuring body metrics e.g. pulse as S5 can do?

Not in pebble, but if you want to explore that type of app, I can recommend you get in touch in me via  thomas[at]getpebble[dot]com, and I’ll send you the Bluetooth Smart SDK that will allow your pebble app to connect to BLE accessories. There are a lot of body sensors available with BLE APIs for different body metrics, so you can get heart rate, respiration volume and other information through those Bluetooth smart accessories. Also, if your athletes are on bikes, there are great bike accessories that will allow data to be transferred via Bluetooth. In this case, your pebble will sit on your wrist, connect to those accessories, get the information, and display the stats. It can also let the user know when they’re starting a new run/sprint, and once you process the information you can save it in on the mobile apps.


Other Posts Based on this Office Hour:

Thomas Sarlandie is a mobile developer who has written some of the most popular french iOS apps such as LeMonde.fr and SNCF apps, and he has also written a book on iOS development before. Thomas currently works as a developer evangelist for Pebble. You can use the Codementor coupon to buy Pebble with a $20 discount, and it will be valid for the first 200 developers to claim it.

Thomas SarlandieNeed Thomas’s help? Book a 1-on-1 session!

or join us as an expert mentor!

Codementor User
Codementor User
@sarfata and github.com/sarfata - Connecting hardware to software! Developer Evangelist @Pebble
Hire the Author

Questions about this tutorial?  Get Live 1:1 help from JavaScript experts!
K M Rakibul Islam (Rakib)
K M Rakibul Islam (Rakib)
Top Ruby on Rails Mentor of January - October, 2017 (10 months in a row!) at Codementor | Experienced (8+ years) and friendly Ruby on Rails Developer/Mentor (with passion for helping others learn) | 890+ Sessions
I am the Top Ruby on Rails Mentor of January, February, March, April, May, June, July and August 2016 (8 months in a row) and January, February,...
Hire this Expert
Adam Dorling
Adam Dorling
Full Stack Web Developer of 6 years, Programmer of 8 years
I've been a Web Developer of 6 years, working on websites in both Chinese and English. I primarily work with PHP/Laravel5, Javascript, SCSS, MySQL...
Hire this Expert

Live 1:1 help from expert developers

Codementor is your live 1:1 expert mentor helping you in real time.

comments powered by Disqus