Vibration patterns stored as resources, and their selection per alert type.
More...
|
| typedef uint8_t | VibeNoteIndex |
| | Index into the notes table of a vibe score.
|
| |
Vibration patterns stored as resources, and their selection per alert type.
A vibe score resource starts with VIBE_SIGNATURE, followed by a VibeScore whose attribute list holds a table of VibeNote (VibeAttributeId_Notes), the pattern as indices into that table (VibeAttributeId_Pattern) and optionally a delay before the pattern repeats (VibeAttributeId_RepeatDelay).
if (score) {
}
VibeScore * vibe_client_get_score(VibeClient client)
Load the vibe score for an alert, as set in the alert preferences.
@ VibeClient_Notifications
Notifications.
Definition vibe_client.h:18
Vibe score, as stored in the resource after the signature.
Definition vibe_score.h:51
void vibe_score_do_vibe(VibeScore *score)
Play a vibe score once.
void vibe_score_destroy(VibeScore *score)
Free a vibe score.
◆ VibeScore
Vibe score, as stored in the resource after the signature.
◆ VibeNote
Vibration step of a vibe score.
| Data Fields |
|
uint8_t |
brake_duration_ms |
Time the motor brakes afterwards, in milliseconds. |
|
int8_t |
strength |
Motor strength, -100 to 100. |
|
uint16_t |
vibe_duration_ms |
Time the motor runs, in milliseconds. |
◆ VIBE_DATA_OFFSET
◆ VIBE_SCORE_VERSION
| #define VIBE_SCORE_VERSION (1) |
Highest vibe score format version supported.
◆ VIBE_SIGNATURE
| #define VIBE_SIGNATURE PBL_FOURCC('V', 'I', 'B', 'E') |
Signature at the start of a vibe score resource.
◆ VibeNoteIndex
Index into the notes table of a vibe score.
◆ VibeAttributeId
Attributes of a vibe score.
| Enumerator |
|---|
| VibeAttributeId_Invalid | Invalid attribute.
|
| VibeAttributeId_Notes | Table of VibeNote.
|
| VibeAttributeId_Pattern | Pattern, as a sequence of VibeNoteIndex into the notes table.
|
| VibeAttributeId_RepeatDelay | Delay before the pattern repeats, uint16_t in milliseconds (at most 60000).
|
◆ vibe_score_create_with_resource()
| VibeScore * vibe_score_create_with_resource |
( |
uint32_t |
resource_id | ) |
|
Load a vibe score from the resources of the calling process.
- Parameters
-
| resource_id | Resource ID of the score. |
- Returns
- Validated score, to be freed with vibe_score_destroy(), or NULL.
◆ vibe_score_create_with_resource_system()
| VibeScore * vibe_score_create_with_resource_system |
( |
ResAppNum |
app_num, |
|
|
uint32_t |
resource_id |
|
) |
| |
Load a vibe score from the resources of an app.
- Parameters
-
| app_num | Resource bank to load from. |
| resource_id | Resource ID of the score. |
- Returns
- Validated score allocated on the caller's heap, to be freed with vibe_score_destroy(), or NULL if missing, invalid or out of memory.
◆ vibe_score_destroy()
Free a vibe score.
- Parameters
-
◆ vibe_score_do_vibe()
Play a vibe score once.
Queues the pattern and starts the vibe motor. Does nothing if a vibe pattern is already playing.
- Parameters
-
◆ vibe_score_get_duration_ms()
| unsigned int vibe_score_get_duration_ms |
( |
VibeScore * |
score | ) |
|
Get the duration of one playback of a vibe score.
- Parameters
-
| score | Valid score, may be NULL. |
- Returns
- Total vibe and brake time of the pattern in milliseconds, 0 for NULL.
◆ vibe_score_get_repeat_delay_ms()
| unsigned int vibe_score_get_repeat_delay_ms |
( |
VibeScore * |
score | ) |
|
Get the delay before a vibe score repeats.
- Parameters
-
- Returns
- Repeat delay in milliseconds, or 0 if the score has none.
◆ vibe_score_validate()
| bool vibe_score_validate |
( |
VibeScore * |
score, |
|
|
uint32_t |
data_size |
|
) |
| |
Check whether a vibe score is well formed.
Checks the version, the sizes of all attributes, that notes and pattern exist, that the pattern only references existing notes and that the repeat delay is in range.
- Parameters
-
| score | Score to check, may be NULL. |
| data_size | Size of score in bytes. |
- Returns
- true if the score is valid.