Category Archives: New Stuff

News about site and in general

How to make your Pebble smartwatch really tick

“Tick tock, goes the clock, And Now what shall we play?”.

Pebble smartwatch is an amazing piece of hardware with no less amazing software to support it. Pebble appstore boasts huge variety of watchfaces from intricately carved art pieces to simplicity personified. And the apps, my gods the apps! You want to track your sleep, count swimming stokes, automate your home – Pebble can do all those things and more. But something was missing. Something that ordinary mechanical clocks could do since the dawn of time.

Tick tock, goes the clock, And then what shall we see?
Continue reading →

Solution: Windows 10: Unable to start Appstore apps

Ok, I went ahead and upgraded to Windows 10. everything went smoothly, all my settings and installed apps preserved and work without a hitch. I am loving the interface and getting along with Cortana pretty good.

But after a while I encountered a weird issue: Appstore installed apps – e.g. Calendar, Mail etc. even Windows AppStore itself wouldn’t launch. I’d either get a cryptic error message, something along the lines “Application did not start, please contact system administrator” or very briefly a window would appear and immediately closed.

Looking into Event log was a bit more explanatory, but not too much: “Microsoft.WindowsStore_8wekyb3d8bbwe!App failed with error: Access is denied. See the Microsoft-Windows-TWinUI/Operational log for additional information.

If you google it – you will find many possible explanations of the problem and many possible ways to solve it offered, but none of those worked for me. Finally I figured it out (and Event Log entry gave me a clue): C:\Program Files\WindowsApps folder was missing necessary permissions:

WindowsApps

Namely, “ALL APPLICATION PACKAGES” was missing read & execute permissions on that folder (had to to uncheck “Hide protected operating system files” in Control Panel, File Explorer options to be able to see it). Once I added correct permissions – appstore apps started launching with no problems.

“Background” vibes on Pebble smartwatch

Matt Thompson from Pebble G+ community asked a question that got me curious: Is there a way to buzz Pebble vibe at regular intervals in the background, while a regular watchface is displayed in foreground?

Besides running a normal app, Pebble has 2 ways to run code in the background: background worker and Wakeup API.

Background worker can truly run in the background, but has no access to UI (and vibes are considered UI) as well as other limitations. Besides you can have only one background worker, so for example if you’re running MisFit app and want to run another background app – you’re out of luck.

WakeUp API has the ability to act as a timer in the background and launch your app when timer countdown finished. Interesting thing is – if your app doesn’t have any UI (windows) – it exits right away, so from the user’s point of view – it didn’t even ran – then point in the watch interface remains the same (if you’re looking at a watchface, or at settings etc. – you remain at the same spot).

We can use this to wake the app, buzz the vibe, reschedule wakeup time and exit. User will just hear a buzz with no visual indication that something was launched. Here’s a basic code to achieve this:

static uint32_t const segments[] = {1000, 500, 1000, 500, 1000};  

static void init(void) {

  wakeup_service_subscribe(NULL);
  wakeup_schedule(time(NULL) + 60, 0, false);
  
  vibes_cancel();
  
  VibePattern pat = {
    .durations = segments,
    .num_segments = ARRAY_LENGTH(segments),
  };
  vibes_enqueue_custom_pattern(pat);
  
}

int main(void) {
  init();
  app_event_loop();
}

This is pretty straightforward. Line 01 declares an array for custom vibe pattern (3 one-second buzzes separated by half-a-second silence) Line 05 subscribes to WakeUp event. Ordinary you need to specify a callback function as a parameter, but our entire code runs in the Init, so we don’t use it here. Line 06 schedules app wake-up in 60 seconds. Line 08 cancels any current vibes in case any are still running. Lines 10-13 prepare structure for custom vibe sequence and Line 14 runs the vibes.

That’s it. When you launch the app – it schedules its own wakeup, buzzes the vibe and exits immediately. You’re free to do what you want – set a watchface, run another app etc. When time comes – the app wakes up, buzzes the vibe, schedules next wakeup and exits without interfering with whatever user is doing. Etc. Etc. Etc.

Just remember that the only way to stop it is delete the app from the watch and wait for the current buzz sequence to finish.

Useful Links

Colorful watchfaces for Pebble Time

Pebble Time is latest and greatest smartwatch from Pebble corp. And one of the advantages it has over classic model is new epaper screen capable of supporting 64 colors. To test its capabilities I developed several color watchfaces. Some of them are the converted ones that originally were made for classic Pebble, some of them new. Click on the image to get redirected to Pebble appstore.

Long Shadow “Long Shadow” – inspired by stock LG G watchface, features large time and long colorful shadows. Config page allows customization of every color as well as shadow direction
TV Time “TV Time” – old-style TV displays time in cartoon format. Grid on the panel shows battery level
Simpe Striped “Simple Striped – Large time in color-striped font. Thin line at the bottom shows battery level both in length and coior
RusticSlider “Rustic Slider” – Though not in full color, uses Pebble Time gray shades to create realistic blocks with customizable sliding animation
Poochie “Poochie” – spoof of Gucci luxury digital watch
MeyerObjects “Meyer Objects” – Hour. minute and second hands are represented by wireframe design. Shake to display normal digital time. Configurable options
3D Wedge “3D Wedge” – Time displayed in diagonal skewed form along with date, time and battery percentage

Give them a try once you get your PT! Or, you can load them on your classic Pebble as B&W versions 🙂

Pushing pins to Pebble Time timeline from .NET code

Timeline on Pebble Time Pebble Time timeline is a very cool user interface allowing you to see future and past events and act upon them right on your watch. Right out of the box Pebble Time supports calendar pins that shows your future and past appointments in the timeline as well as weather alerts. But the real power comes from 3rd party apps using timeline – they can add anything from sports scores to latest news to TV showtimes – limit is just your imagination.
Pebble has always had open SDK – this is one of its major strengths, and Timeline is not an exception. Timeline API is a very straightforward way to push your own pins to users of your app. There’re various examples and libraries including PHP and node.js on how to deal with the timeline, but I, being mostly a Microsoft developer by trade, decided to bring Timeline into .NET. This particular example is in ASP.NET – pin is pushed from Webpage when user clicks a button, but it’s just one of the possible scenarios.

In order to push timeline pins successfully you will need 2 pieces:

  1. A watchapp that runs on Pebble. In fact after first run, that subscribes user to timeline, the app doesn’t have to be running on the watch anymore. It doesn’t even have to be on the watch. As long as it simple remains in your locker on the phone – you will continue to receive its pins
  2. Your own server that sends calls to Pebble public Timeline API to control pins

Continue reading →

Mask Effect for EffectLayer for Pebble

I’ve written before about EffectLayer library for Pebble smartwatch I’ve been working on. The idea is – user places the layer over screen and that layer applies an effect to screen content.

I’ve started with a few basic effects (invert, mirror) but since then several more developers joined the project adding more cool features. Ron added 90° rotation, zoom and lens effect. Gregoire Sage added cool blur effect. LeFauve not only added FPS effect, but also optimized the library to run the effects in a very efficient way: now effect can be defined as a function (even user defined function!) and that function passed as a parameter to effect_layer_add_effect method along with parameters for that effect.

I, for my part, contributed “mask” effect. What it does is essentially lets you show parts of background image thru user defined mask, creating a feel of transparency. Continue reading →

Universal access to Pebble framebuffer on Basalt and Aplite via coordinates

Rotate Effect on Aplite In my previous post I described how you can access framebuffer of Pebble screen via familiar X,Y coordinates. To reiterate: you capture framebuffer as a bitmap, and access bitmap as 2-dimentional matrix:

#define WINDOW_WIDTH 144
GBitmap *fb = graphics_capture_frame_buffer(ctx);
uint8_t (*fb_matrix)[WINDOW_WIDTH] = (uint8_t (*)[WINDOW_WIDTH]) gbitmap_get_data(fb);

After that you can access specific pixel on the screen via coordinates, e.g. fb_matrix[120][60] will represent pixel and coordinates Y = 120, X = 60

This works fine on Pebble Time (Basalt platform) where every pixel represented by a byte. But what about classic Pebble (I think this term is becoming quite popular, but to avoid confusion I will call it Aplite platform). On Aplite every byte in the framebuffer represent 8 pixels and the above approach doesn’t work.

Fortunately there’s a universal solution.
Continue reading →

Simplify access to Framebuffer on Pebble Time

Pebble smartwatch SDK offers a very extensive graphics library. And if that is not enough – you can access graphics memory directly for pixel-precision manipulation. For example this code

GBitmap *fb = graphics_capture_frame_buffer_format(ctx, GBitmapFormat8Bit);
uint8_t *fb_data = gbitmap_get_data(fb);

captures Pebble screen as a bitmap and consequently as raw uint8_t data you can manipulate. But the problem with this approach – you access the data as 1-dimensional array, which is very inconvinient when you’re dealing with 2-dimensional screen.

Fortunately due to magic of casting this problem can be addressed. Consider following addition to previous code:

#define WINDOW_WIDTH 144  
uint8_t (*fb_matrix)[WINDOW_WIDTH] = (uint8_t (*)[WINDOW_WIDTH]) fb_data;

Using this, you can access screen data via familiar coordinates. For example if you need to set pixel at coordinates Y=120, X=60 to black color, all you have to do is

fb_matrix[120][60] = 0;

And now we can rewrite InverterLayer from previous post to a simpler form. First in layer callback we create bitmap matrix and call effect function:

static void effect_layer_update_proc(Layer *me, GContext* ctx) {
  // getting layer coordinates
  GRect layer_frame = layer_get_frame(me);  
  
  //capturing framebuffer bitmap into 2-d matix
  GBitmap *fb = graphics_capture_frame_buffer_format(ctx, GBitmapFormat8Bit);
  uint8_t (*fb_matrix)[WINDOW_WIDTH] = (uint8_t (*)[WINDOW_WIDTH]) gbitmap_get_data(fb);
  
  //callig effect function
  effect_invert(fb_matrix, layer_frame);

  //releasing framebuffer
  graphics_release_frame_buffer(ctx, fb);
  
}

And actual inverting function becomes much simpler as well, simple loop thru layer pixel, inverting colors:

// position: x,y,h,w of the layer  
void effect_invert(uint8_t (*fb_a)[WINDOW_WIDTH], GRect position) {
  
  for (int y = 0; y < position.size.h; y++)
     for (int x = 0; x < position.size.w; x++)
        fb_a[y + position.origin.y][x + position.origin.x] = ~fb_a[y + position.origin.y][x + position.origin.x];
  
}

You can see this approach in EffectLayer library.