4

Is it possible to send a images to the Pebble watch using PebbleKit Javascript sendAppMessage.

My idea is to load an image from the web and send it to the watch and display them there. If an image is not possible directly then I was thinking of drawing the image to a canvas and trying to get bitmap data from the canvas to send to the watch.

Is any of this possible now or am I thinking of things that have not been done yet. If possible how? If not done yet how might you do it?

Looking to brainstorm and share possible code ideas.

I should also mention that I do not want to use an iOS or Android app, only the PebbleKit JS.

deadboy
  • 849
  • 2
  • 9
  • 28
ryuutatsuo
  • 3,924
  • 3
  • 27
  • 29

2 Answers2

3

There is a complete example of an app that uses JavaScript to download images in the pebble-hacks Github repository. This github projects hosts different non-official yet written by team pebble.

The one you are looking for is pebble-faces. The image download part is built in a separate source file to be easily re-used in your own project.

sarfata
  • 4,625
  • 4
  • 28
  • 36
  • This assumes the server is providing .pbi images which limits a number of scenarios. I'd love to see some example javascript code that converts an html to .pbi format (probably using https://developer.mozilla.org/en-US/docs/Web/API/ImageData) – Robert Levy Feb 28 '14 at 15:18
  • I tried that but could not get it to work because the JavaScript engine used by Pebble on iOS (Ejecta) does not support creating canvas object when it's running headless. – sarfata Feb 28 '14 at 19:47
  • Thanks for trying :) What do you think about adding a function to the PebbleKit API that calls into the native Pebble app to do the conversion? Anything that gets rid of having to do the conversion serverside would open up a bunch of doors (at least for me) – Robert Levy Feb 28 '14 at 19:54
  • It's on the wishlist! – sarfata Mar 01 '14 at 00:01
  • What is a .pbi image? searching online is not giving me much. If I have .png or .jpeg images is there a converter to create .pbi images? – ryuutatsuo Mar 02 '14 at 23:37
  • 1
    @ryuutatsuo It's causing me a nightmare. `.pbi` is bit per pixel monochrome - 1=>White, 0=>Black. Padded to 32bits wide. That JS sample is practically useless - if you had the .pbi ready on a server you may as well load into Pebble resources. – OJFord Mar 07 '14 at 07:15
  • 1
    Thanks for the feedback! I added a comment in the README file on how to prepare pbi file: https://github.com/pebble-hacks/pebble-faces/ - Hope this helps! – sarfata Mar 09 '14 at 06:20
  • Awesome, thank you @sarfata. There wouldn't be a batch process for the pbi files? – ryuutatsuo Mar 09 '14 at 18:06
  • 1
    You can easily build a shell command - something like: for i in \`ls *png\`; do python Pebble/tools/bitmapgen.py pbi $i $i.pbi; done – sarfata Mar 10 '14 at 01:41
  • Here is the batch shell I came up with can be easily changed. #!/bin/bash for f in /Users/dir/Downloads/*.png do filename=$(basename "$f") extension="${filename##*.}" filename="${filename%.*}" echo "$f ----> /Users/dir/Downloads/$filename.pbi" python /Users/dir/pebble-dev/PebbleSDK-2.0.1/Pebble/tools/bitmapgen.py pbi $f /Users/dir/Downloads/$filename.pbi done – ryuutatsuo Mar 10 '14 at 03:25
0

I also added a PHP port for the Python script here https://github.com/logbon72/pebblebitmap

It might come in handy if your run PHP applications that need to do conversion on the fly.

tlogbon
  • 1,212
  • 13
  • 12