PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
alarm.h File Reference
#include <board/board.h>
#include <pbl/util/units.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>

Data Structures

struct  AlarmInfo
 Alarm configuration. More...
 

Macros

#define SMART_ALARM_RANGE_S   (30 * PBL_SEC_PER_MIN)
 How long before its time a smart alarm may go off, in seconds.
 
#define SMART_ALARM_SNOOZE_DELAY_S   (1 * PBL_SEC_PER_MIN)
 Interval at which a smart alarm re-checks the sleep state, in seconds.
 
#define SMART_ALARM_MAX_LIGHT_SLEEP_S   (30 * PBL_SEC_PER_MIN)
 Light sleep threshold for smart alarms, in seconds.
 
#define SMART_ALARM_MAX_SMART_SNOOZE   (SMART_ALARM_RANGE_S / SMART_ALARM_SNOOZE_DELAY_S)
 Number of sleep state checks a smart alarm makes before firing unconditionally.
 
#define ALARMS_APP_HIGHLIGHT_COLOR   PBL_IF_COLOR_ELSE(GColorJaegerGreen, GColorBlack)
 Highlight color of the alarms app.
 
#define ALARM_INVALID_ID   (-1)
 Invalid alarm ID, returned on failure.
 

Typedefs

typedef int AlarmId
 Unique ID of a configured alarm.
 
typedef void(* AlarmForEach) (AlarmId id, const AlarmInfo *info, void *context)
 Callback for alarm_for_each().
 

Enumerations

enum  AlarmKind {
  ALARM_KIND_EVERYDAY = 0 , ALARM_KIND_WEEKENDS , ALARM_KIND_WEEKDAYS , ALARM_KIND_JUST_ONCE ,
  ALARM_KIND_CUSTOM
}
 Recurrence of an alarm. More...
 
enum  AlarmType { AlarmType_Basic , AlarmType_Smart , AlarmTypeCount }
 Alarm type, as shown on its timeline pin. More...
 
enum  AlarmTone { AlarmTone_Reveille = 0 , AlarmTone_Beacon , AlarmTone_Bell , AlarmTone_Chime }
 Built-in alarm tones, played on speaker hardware when sound is enabled. More...
 

Functions

AlarmId alarm_create (const AlarmInfo *info)
 Create and schedule an alarm.
 
void alarm_set_time (AlarmId id, int hour, int minute)
 Set the time of an alarm.
 
void alarm_set_kind (AlarmId id, AlarmKind kind)
 Set the recurrence of an alarm.
 
void alarm_set_custom (AlarmId id, const bool scheduled_days[PBL_DAY_PER_WEEK])
 Make an alarm run on specific days of the week.
 
void alarm_set_smart (AlarmId id, bool smart)
 Set whether an alarm is a smart alarm.
 
void alarm_set_sound_enabled (AlarmId id, bool enabled)
 Set whether an alarm plays a tone.
 
void alarm_set_vibrate_enabled (AlarmId id, bool enabled)
 Set whether an alarm vibrates.
 
void alarm_set_tone (AlarmId id, AlarmTone tone)
 Set the tone of an alarm.
 
bool alarm_get_info (AlarmId id, AlarmInfo *info_out)
 Get the configuration of an alarm.
 
AlarmId alarm_get_most_recent_id (void)
 Get the most recently fired alarm.
 
bool alarm_get_custom_days (AlarmId id, bool scheduled_days[PBL_DAY_PER_WEEK])
 Get the days of the week an alarm runs on.
 
void alarm_set_enabled (AlarmId id, bool enable)
 Enable or disable an alarm.
 
void alarm_delete (AlarmId id)
 Delete an alarm and its timeline pins.
 
bool alarm_get_enabled (AlarmId id)
 Check whether an alarm is enabled.
 
bool alarm_get_hours_minutes (AlarmId id, int *hour_out, int *minute_out)
 Get the time of an alarm.
 
bool alarm_get_kind (AlarmId id, AlarmKind *kind_out)
 Get the recurrence of an alarm.
 
bool alarm_get_next_enabled_alarm (time_t *next_alarm_time_out)
 Get the time of the next enabled alarm.
 
bool alarm_is_next_enabled_alarm_smart (void)
 Check whether the next enabled alarm is a smart alarm.
 
bool alarm_get_time_until (AlarmId id, time_t *time_out)
 Get the time until an alarm next goes off.
 
void alarm_set_snooze_alarm (void)
 Snooze the most recently fired alarm for the current snooze delay.
 
uint16_t alarm_get_snooze_delay (void)
 Get the snooze delay.
 
void alarm_set_snooze_delay (uint16_t delay_m)
 Set and persist the snooze delay for all alarms.
 
void alarm_dismiss_alarm (void)
 Dismiss the most recently fired alarm, cancelling its snooze.
 
void alarm_for_each (AlarmForEach cb, void *context)
 Call a function for each configured alarm.
 
bool alarm_can_schedule (void)
 Check whether another alarm can be created.
 
void alarm_handle_clock_change (void)
 Reschedule all alarms after the wall clock time changed.
 
void alarm_init (void)
 Initialize the alarm service.
 
void alarm_service_enable_alarms (bool enable)
 Enable or disable alarm events globally.
 
const char * alarm_get_string_for_kind (AlarmKind kind, bool all_caps)
 Get the display string of an alarm recurrence, e.g.
 
void alarm_get_string_for_custom (bool scheduled_days[PBL_DAY_PER_WEEK], char *alarm_day_text)
 Describe the days of a custom alarm.
 
void alarm_prefs_set_alarms_app_opened (uint8_t version)
 Record the version of the alarms app that was last opened.
 
uint8_t alarm_prefs_get_alarms_app_opened (void)
 Get the version of the alarms app that was last opened.