Loading...
Searching...
No Matches
System Bits

Bluetooth buzzing and the watch's own unit settings. More...

Files

file  src/c/pebble/system/units/units.c
 The SDK-facing units facade. Reads the clock for .beats and forwards the rest to the pure lib cores, clock/beats and units/distance.
file  src/c/pebble/system/units/units.h
 Swatch internet time in .beats, and distance formatting in miles or kilometres.
file  src/c/pebble/system/vibe/vibe.c
 The haptic feedback wrapper implementation.
file  src/c/pebble/system/vibe/vibe.h
 The haptic feedback wrapper.

Enumerations

enum  VibePulse { VibePulseShort , VibePulseLong , VibePulseDouble }
 Defines the available haptic pulse patterns. More...

Functions

int units_swatch_beats (void)
 The current swatch internet time, in .beats.
uint32_t units_ms_until_next_beat (void)
 Milliseconds until the next .beats boundary.
void units_format_distance (char *buffer, size_t size, int meters, bool miles)
 Formats a distance as "N.N MI" or "N.N KM".
void units_format_distance_value (char *buffer, size_t size, int meters, bool miles)
 Formats a distance as just "N.N", with no unit suffix, rounded to a tenth.
const char * units_distance_unit (bool miles)
 The unit label for the current distance mode, "MI" or "KM".
void vibe_pulse (VibePulse pulse)
 Fire a pulse unless in quiet time.
void vibe_custom (const uint32_t *durations, uint32_t num_segments)
 Buzz a custom on and off rhythm unless in quiet time. The durations are milliseconds that alternate buzz then pause then buzz and so on, starting on a buzz. Lets a caller play a little tune that the three canned pulses cannot.
void vibe_choice (uint8_t choice)
 Fire the pattern named by a VibeChoice (VIBE_NONE stays silent). The caller resolves the choice from wherever it likes, so the lib never has to know which setting it came from.
void vibe_bt_transition (bool connected)
 The default bluetooth-transition buzz: fire the pattern the user picked in settings for a connect or disconnect. A face installs this as system_store's vibe policy so the store itself never has to know about settings or buzzing.
void vibe_hourly (const struct tm *tick, uint8_t choice)
 Buzz once at the top of each hour. A face calls this from its time callback on every tick, and it buzzes on the first tick of each hour's minute 0.

Detailed Description

Bluetooth buzzing and the watch's own unit settings.

The odds and ends that belong to the watch itself rather than to any one face.

Enumeration Type Documentation

◆ VibePulse

enum VibePulse

Defines the available haptic pulse patterns.

Enumerator
VibePulseShort 

A single short pulse.

VibePulseLong 

A single long pulse.

VibePulseDouble 

Two short pulses.

Function Documentation

◆ units_distance_unit()

const char * units_distance_unit ( bool miles)

The unit label for the current distance mode, "MI" or "KM".

Parameters
milesMiles if true, otherwise km.
Returns
The unit label, held in static storage rather than allocated.

◆ units_format_distance()

void units_format_distance ( char * buffer,
size_t size,
int meters,
bool miles )

Formats a distance as "N.N MI" or "N.N KM".

Parameters
[out]bufferWhere the formatted distance is written.
sizeThe size of buffer.
metersThe distance, in metres.
milesFormats as miles if true, otherwise km.

◆ units_format_distance_value()

void units_format_distance_value ( char * buffer,
size_t size,
int meters,
bool miles )

Formats a distance as just "N.N", with no unit suffix, rounded to a tenth.

Pair with units_distance_unit when the unit wants its own small-font slot.

Parameters
[out]bufferWhere the formatted distance is written.
sizeThe size of buffer.
metersThe distance, in metres.
milesFormats as miles if true, otherwise km.

◆ units_ms_until_next_beat()

uint32_t units_ms_until_next_beat ( void )

Milliseconds until the next .beats boundary.

Returns
Milliseconds remaining until the next boundary.

◆ units_swatch_beats()

int units_swatch_beats ( void )

The current swatch internet time, in .beats.

Returns
The current time in .beats (0 to 999).

◆ vibe_bt_transition()

void vibe_bt_transition ( bool connected)

The default bluetooth-transition buzz: fire the pattern the user picked in settings for a connect or disconnect. A face installs this as system_store's vibe policy so the store itself never has to know about settings or buzzing.

Parameters
connectedTrue when the link just came up, false when it just dropped.

◆ vibe_choice()

void vibe_choice ( uint8_t choice)

Fire the pattern named by a VibeChoice (VIBE_NONE stays silent). The caller resolves the choice from wherever it likes, so the lib never has to know which setting it came from.

Parameters
choiceA VibeChoice value (VIBE_NONE / VIBE_SHORT / VIBE_LONG / VIBE_DOUBLE).

◆ vibe_custom()

void vibe_custom ( const uint32_t * durations,
uint32_t num_segments )

Buzz a custom on and off rhythm unless in quiet time. The durations are milliseconds that alternate buzz then pause then buzz and so on, starting on a buzz. Lets a caller play a little tune that the three canned pulses cannot.

The firmware copies each duration into its own vibe queue when the pattern is queued, so the array only has to last for the call. A stack array is fine.

Parameters
durationsThe on and off times in milliseconds. The first entry is a buzz.
num_segmentsHow many entries the durations array has.

◆ vibe_hourly()

void vibe_hourly ( const struct tm * tick,
uint8_t choice )

Buzz once at the top of each hour. A face calls this from its time callback on every tick, and it buzzes on the first tick of each hour's minute 0.

More than one ticker can tick inside minute 0, so it remembers when the hour that last buzzed began and buzzes each real hour once, including the hour the clocks repeat when they fall back. On a .beats clock the face sets hourly in its TimeConfig, so a tick lands in minute 0 at all.

The first call after launch only remembers its hour. Subscribing to a tick sends one tick straight away, so a face opened in minute 0 would otherwise buzz an hour that already buzzed before the wearer left it. A face that was not running at the top of the hour, such as one closed for an app, then stays silent until the next hour, which beats a second buzz on every return in minute 0.

Parameters
tickThe time of the tick, normally time_store_tm().
choiceA VibeChoice value, normally the Hourly Vibration setting. VIBE_NONE stays silent.

◆ vibe_pulse()

void vibe_pulse ( VibePulse pulse)

Fire a pulse unless in quiet time.

Parameters
pulseThe pulse pattern to fire.