PebbleOS
Loading...
Searching...
No Matches
Macros | Functions
Notification images

Single slot holding the phone-supplied image of the notification on screen. More...

Macros

#define NOTIFICATION_IMAGE_SUPPORTED   0
 Whether the platform supports notification images.
 

Functions

void notification_image_service_init (void)
 Initialize the service.
 
bool notification_image_claim (const Uuid *item_id, uint8_t *token_out)
 Claim the slot for an item.
 
const struct GBitmap * notification_image_lock (const Uuid *item_id)
 Lock the slot and get the image of an item.
 
void notification_image_unlock (void)
 Unlock the slot locked by notification_image_lock().
 
bool notification_image_is_pending (const Uuid *item_id)
 Check whether the image of an item is still being fetched.
 
bool notification_image_store (uint8_t token, struct GBitmap *bitmap)
 Store a delivered image.
 
void notification_image_clear (void)
 Release the slot and free the stored image.
 

Detailed Description

Single slot holding the phone-supplied image of the notification on screen.

Only one notification card is focused at a time, so one slot is enough. A card claims the slot for its item, requests the image from the phone with the returned token, and draws whatever has been stored while holding the slot lock. Responses are delivered on KernelMain while cards render on KernelMain or the App task, so all functions are thread safe.

Macro Definition Documentation

◆ NOTIFICATION_IMAGE_SUPPORTED

#define NOTIFICATION_IMAGE_SUPPORTED   0

Whether the platform supports notification images.

Images need a color display and enough RAM for the decoded bitmap, so only emery and gabbro qualify, the same bar as album art.

Function Documentation

◆ notification_image_claim()

bool notification_image_claim ( const Uuid *  item_id,
uint8_t *  token_out 
)

Claim the slot for an item.

Drops any image held for a previous item.

Parameters
item_idItem to claim the slot for.
[out]token_outToken to send with the image request.
Returns
false if the slot already belongs to item_id, whether the image is in flight, delivered or the phone said it has none, so callers can drive this from a redraw; also false if an argument is NULL.

◆ notification_image_clear()

void notification_image_clear ( void  )

Release the slot and free the stored image.

◆ notification_image_is_pending()

bool notification_image_is_pending ( const Uuid *  item_id)

Check whether the image of an item is still being fetched.

Lets a card show a placeholder instead of an empty band until the phone answers.

Parameters
item_idItem to check.
Returns
true while the response for item_id is outstanding.

◆ notification_image_lock()

const struct GBitmap * notification_image_lock ( const Uuid *  item_id)

Lock the slot and get the image of an item.

The slot stays locked until notification_image_unlock(), which must be called even when this returns NULL. The lock is recursive.

Parameters
item_idItem whose image to get.
Returns
Stored bitmap, owned by the slot, or NULL if there is none for item_id.

◆ notification_image_service_init()

void notification_image_service_init ( void  )

Initialize the service.

Call once at boot before any other function here.

◆ notification_image_store()

bool notification_image_store ( uint8_t  token,
struct GBitmap *  bitmap 
)

Store a delivered image.

Takes ownership of bitmap; it, its pixel data and its palette must be allocated on the kernel heap. A stale token frees the bitmap.

Parameters
tokenToken returned by notification_image_claim().
bitmapDelivered image, or NULL when the phone had no image.
Returns
true if the slot resolved, so anything showing the notification must redraw, also when bitmap is NULL as that removes the pending placeholder.

◆ notification_image_unlock()

void notification_image_unlock ( void  )

Unlock the slot locked by notification_image_lock().