prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ERT_TASK(PebbleTask_KernelMain);
const AppInstallId id = config->id;
const bool is_worker = config->worker;
if (id == INSTALL_ID_INVALID) {
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid ID");
return;
}
const PebbleProcessMd *md = NULL;
#if !RECOVERY_FW
if (app_install_id_from_app_db(id)) {
if (!process_... | if (task == PebbleTask_App) {
analytics_stopwatch_stop(ANALYTICS_APP_METRIC_FRONT_MOST_TIME);
} |
analytics_external_collect_app_cpu_stats();
analytics_external_collect_app_flash_read_stats();
}
// ---------------------------------------------------------------------------------------------
//! This method returns true if the process is safe to kill (it has exited out of it's main function). If the
//! the p... |
, "There are %*i lights", 3, 4);
cl_assert_equal_s(dstbuf, "There are 4 lights");
// Left-align, Variable length character output
snprintf(dstbuf, 256, "There are %*i lights", -3, 4);
cl_assert_equal_s(dstbuf, "There are 4 lights");
// Variable length digits output
snprintf(dstbuf, 256, "There are %.*... | (dstbuf, "There are 010 lights, 037777777774") | |
eam, const pb_field_t *field, void **arg) {
char *ret_sender_type = *(char **)arg;
size_t str_len = stream->bytes_left;
PBL_ASSERTN(str_len <= PLOG_MAX_SENDER_TYPE_LEN);
return pb_read(stream, (uint8_t *)ret_sender_type, str_len);
}
// --------------------------------------------------------------------------... | pb_decode(&stream, pebble_pipeline_Payload_fields, &payload) | ;
*payload_send_time = payload.send_time_utc;
if (payload.sender.has_version && payload_sender_v_major && payload_sender_v_minor) {
*payload_sender_v_major = payload.sender.version.major;
*payload_sender_v_minor = payload.sender.version.minor;
}
*type = ProtobufLogType_Measurements;
return success;
}
... |
layer_set_update_proc(window_get_root_layer(window), prv_update_proc) | ;
watch_model_init();
data->hour_path = gpath_create(&HOUR_PATH_INFO);
data->minute_path = gpath_create(&MINUTE_PATH_INFO);
data->bg_bitmap = gbitmap_create_with_resource(data->clock_model.bg_bitmap_id);
}
static void prv_window_unload(Window *window) {
MultiWatchData *data = app_state_get_user_data();
g... | |
ata *data = window_get_user_data(s_window);
const GRect *bounds = &data->canvas_layer->bounds;
const GRect *frame = &data->canvas_layer->frame;
graphics_context_set_stroke_color(ctx, GColorGreen);
graphics_draw_rect(ctx, &GRect(bounds->origin.x + frame->origin.x,
bounds->origi... | (ctx, p0, p1, data->stroke_width) | ;
} else {
graphics_draw_line(ctx, GPoint(p0.x.integer, p0.y.integer),
GPoint(p1.x.integer, p1.y.integer));
}
return;
}
if (data->operation == OP_ROTATE3) {
int line_length = 60;
time_t now;
uint16_t now_ms = time_ms(&now, NULL);
uint32_t seconds = pbl_o... |
horizontal_line_dotted(&ctx, GPoint(0, 3), MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
gra... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1) | ;
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 11), 3);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 13), 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 15), 20);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 17), 21... |
cell_layer->bounds;
GRect new_bounds = prev_bounds;
// Translate the drawing_box to the bounds of the layer:
ctx->draw_state.drawing_box.origin.y += y;
ctx->draw_state.drawing_box.size.h = cursor->h;
// Set the height appropriately on the cell layer
new_bounds.size.h = cursor->sep;
layer_s... | (ctx, prev_state) | ;
}
static inline void prv_menu_layer_draw_section_header(MenuLayer *menu_layer, Layer *cell_layer,
MenuCellSpan *cursor, GContext* ctx) {
cell_layer->bounds.size.h = cursor->h;
cell_layer->frame.size.h = cursor->h;
cell_layer->frame.origin.y = cursor->y;
// Callback to get the shared cell instance filled... |
ber_subtitle_height;
}
grect_align(&container_rect, cell_layer_bounds, GAlignCenter, true /* clip */);
// Draw the FCC title in the top left of the container
// We'll reuse this box for the title, subtitle, and icon frames
GRect box = (GRect) { .size = GSize(container_rect.size.w, fcc_title_height) };
grec... | (cd->menu_items) | ;
cd->menu_items[cd->menu_count - 1] = *item;
}
static void prv_append_regulatory_compliance_mark(SystemCertificationData *cd,
GBitmap *mark) {
// Determine whether adding this mark overflows the cell, necessitating
// another cell for this mark.
uint16_t mark_... |
BLESubscription subscription_type,
GAPLEClient client) {
bt_lock();
BTErrno ret_val = prv_subscribe(characteristic_ref, subscription_type, client,
false /* is_cleaning_up */);
bt_unlock();
return ret_val;
}
// --------------... | vSemaphoreDelete(s_gatt_client_subscriptions_semphr) | |
T:
e->callback.callback(e->callback.data);
return;
case PEBBLE_PROCESS_KILL_EVENT:
process_manager_close_process(e->kill.task, e->kill.gracefully);
return;
case PEBBLE_SUBSCRIPTION_EVENT:
// App button events depend on this, so this needs to be in the minimal event handler.
... | shell_event_loop_handle_event(e) | ;
}
static NOINLINE void prv_launcher_main_loop_init(void) {
s_back_hold_timer = new_timer_create();
process_manager_init();
app_manager_init();
worker_manager_init();
vibes_init();
battery_monitor_init();
evented_timer_init();
#if CAPABILITY_HAS_MAGNETOMETER
ecompass_service_init();
#endif
tick_tim... |
gacy percentage status handling. Someday, we can hopefully
// remove them outright and it should just involve deleting these routines
//
static bool prv_legacy_firmware_update_get_percent_progress(uint32_t *progress) {
if (!s_current_completion_status.use_legacy_mode) {
return false;
}
LegacyFwUpdateComplet... | ((result == FirmwareUpdateRunning) ||
(result == FirmwareUpdateStopped) ||
(result == FirmwareUpdateCancelled)) | |
{
PBL_LOG(LOG_LEVEL_ERROR, "Failed to read HRM FW image header!");
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "FW update image is v%" PRIu8 ".%" PRIu8 ".%" PRIu8,
HRM_SW_VERSION_PART_MAJOR(image_header.sw_version_major),
HRM_SW_VERSION_PART_MINOR(image_header.sw_version_major),
image_... | {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to read AS7000 version info");
} |
mutex_unlock(dev->state->lock);
}
// Prompt Commands
// ===============
#include "console/prompt.h"
#include <string.h>
void command_hrm_wipe(void) {
// HEX records to write 0xFFFFFFFF to the magic number region.
const char *erase_magic_record = ":047FFC00FFFFFFFF85";
const char *eof_record = ":00000001FF";... |
s_next_app = (NextApp) {
.md = app_md,
.common = config->common,
};
s_next_app.common.transition = prv_get_transition(&config->common, new_app_id);
if ((config->common.reason == APP_LAUNCH_WAKEUP) && (config->common.args != NULL)) {
WakeupInfo *wakeup_info = (WakeupInfo *)config->common.args;
... | prv_app_switch(true /*gracefully*/) | ;
}
const PebbleProcessMd* app_manager_get_current_app_md(void) {
return s_app_task_context.app_md;
}
AppInstallId app_manager_get_current_app_id(void) {
return s_app_task_context.install_id;
}
ProcessContext* app_manager_get_task_context(void) {
return &s_app_task_context;
}
bool app_manager_is_watchface_run... |
+ 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_coun... | (&s_started_handler_calls, spawn) | , 1);
// Run to the completion of C, start of D
prv_advance_to_ms_with_timers(start_ms + 1080 + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, d), 1);
// Run to the completion of... |
parent, &child_a);
layer_add_child(&parent, &child_b);
layer_remove_child_layers(&parent);
cl_assert(child_a.parent == NULL);
cl_assert(child_a.next_sibling == NULL);
cl_assert(child_b.parent == NULL);
cl_assert(parent.first_child == NULL);
}
void test_layer__insert_below(void) {
Layer parent, child_a, c... | (ab, stack[1]) | ;
// go back one level and then to sibling
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(b, actual);
cl_assert_equal_i(0, current_stack);
cl_assert_equal_p(b, stack[0]);
// no more siblings on root level
actual = __layer_tree_trav... |
_LEVEL_DEBUG, "Sending Data to PP endpoint %u (0x%x):",
pp_header.endpoint_id, pp_header.endpoint_id);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, buffer, pp_header.length);
DataNode *data_node = kernel_malloc(sizeof(DataNode) + pp_header.length);
list_init(&data_node->node);
data_node->endpoint... | ((const ListNode *)s_fake_transport_head,
(const ListNode *)fake_transport) | , true);
if (fake_transport->session) {
// Causes clean up of CommSession:
fake_transport_set_connected((Transport *)fake_transport, false /* connected */);
}
list_remove((ListNode *) fake_transport, (ListNode **) &s_fake_transport_head, NULL);
DataNode *data_node = fake_transport->sent_data;
while (d... |
prv_setup_dialog(actionable_dialog_get_dialog(actionable_dialog), &config, (void *)ctx) | ;
actionable_dialog_push(actionable_dialog, prv_get_window_stack());
}
static bool prv_should_prompt(const ActionToggleConfig *config) {
switch (config->prompt) {
case ActionTogglePrompt_Auto:
#if PLATFORM_SPALDING
return ((pebble_task_get_current() == PebbleTask_App) &&
(app_launch_reason(... | |
pplib_free(palette);
}
// we are keeping the image data to avoid copying it
upng_destroy(upng, !retval);
return retval;
}
static uint16_t prv_gbitmap_png_create_palette_for_grayscale(upng_t *upng, GColor8 **palette_out) {
uint16_t palette_entries = 0;
uint32_t bpp = upng_get_bpp(upng);
// Convert Lumina... | ntohs(*(uint16_t*)alpha_palette) | ;
}
return transparent_gray;
}
|
n/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/activity_private.h"
#include "services/normal/activity/health_util.h"
#include "services/normal/activity/hr_util.h"
#include "services/normal/activity/workout_service.h"
#include "system/logging.h"
#include "util/size.h"
#include <std... | i18n_noop("AVG PACE (/KM)") | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | worker_manager_launch_next_worker(data->app_install_id) | ;
// Pop the worker crash dialog
actionable_dialog_pop(data->actionable_dialog);
}
static void prv_worker_crash_click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_UP, prv_worker_crash_button_up_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_worker_crash_button_down_han... |
e * 1000 /* ms */) / interval_ms;
analytics_stopwatch_start_at_rate(
ANALYTICS_DEVICE_METRIC_BLE_ESTIMATED_BYTES_ADVERTISED_COUNT,
bytes_per_second, AnalyticsClient_System);
}
}
}
s_current = next;
bt_driver_advert_c... | {
if (!s_gap_le_advert_is_initialized) {
goto unlock;
}
is_registered = prv_is_registered_job(job);
if (is_registered) {
PBL_LOG(LOG_LEVEL_INFO, "Unscheduling advertising job: %s",
prv_string_for_debug_tag(job->tag));
prv_unlink_job(job);
prv_perform_next_job(fal... |
unlock:
bt_unlock();
if (is_registered) {
kernel_free(job->terms);
kernel_free(job);
}
}
void gap_le_advert_unschedule_job_types(
GAPLEAdvertisingJobTag *tag_types, size_t num_types) {
bt_lock();
ListNode *first_node = bt_driver_advert_client_has_cycled() ? &s_current->node : &s_jobs->node;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (left_margin_px, show_action_bar ? 11 : left_margin_px) | ;
const uint16_t right_margin_px = action_bar_width + content_and_action_bar_horizontal_spacing;
const uint16_t text_single_line_text_offset_px = 17;
const int16_t text_layer_line_spacing_delta = -4;
const GFont dialog_text_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
const GFont dialog_subtext_font... |
in_buf, sizeof(min_buf), ".%d", min_offset_percent);
}
snprintf(region_name, buffer_size, "UTC%+d%s", hour_offset, min_buf);
}
} else {
strncpy(region_name, "---", buffer_size);
}
}
int16_t clock_get_timezone_region_id(void) {
return rtc_get_timezone_id();
}
void clock_set_timezone_by_region... | if (timestamp_midnight == yesterday_midnight) {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
if (with_fulltime) {
time_fmt = i18n_noop("Yesterday, %l:%M %p");
} else {
time_fmt = i18n_noop("Yesterday");
}
break;
case FullSty... |
prv_format_time(buffer, buf_size, time_fmt, timestamp);
}
static void prv_clock_get_relative_time_string(char *buffer, int buf_size, time_t timestamp,
bool capitalized, int max_relative_hrs,
bool with_fulltime) {
time_t ... |
ue;
}
}
return false;
}
void gap_le_connection_for_each(GAPLEConnectionForEachCallback cb, void *data) {
for (int i = 0; i < ARRAY_LENGTH(s_connections); ++i) {
cb(s_connections[i], data);
}
}
void launcher_task_add_callback(CallbackEventCallback callback, void *data) {
callback(data);
}
bool sys_h... | ble_hrm_is_sharing_to_connection(&s_conn_a) | );
// Expect permissions UI to be presented:
prv_assert_permissions_ui_and_respond(true /* is_granted */);
// Expect HRM manager to be subscribed to:
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 1);
prv_assert_event_service_subscribed(true);
cl_assert_equal_b(true, ble_hrm_is_sharin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (prv_select_workout_cb) | ;
Window *window = &selection_window->window;
MenuLayer *menu_layer = &selection_window->menu_layer;
menu_layer_set_selected_index(menu_layer, MenuIndex(0, row), MenuRowAlignCenter, false);
window_set_on_screen(window, true, true);
window_render(window, &s_ctx);
}
// Tests
//////////////////////
void test... |
1056, 104},
{ -336, 1104, 88},
{ -344, 960, -40},
{ -368, 880, -152},
{ -320, 1048, 0},
{ -176, 1192, 176},
{ -144, 1120, 128},
{ -136, 896, 56},
{ -168, 856, -40},
{ -144, 864, -168},
// 5 seconds
{ -216, 776, 16},
{ -304, 648, -88},
{ -336, 680, -240},
{ -320, ... | { 1128, 232, -80},
{ 1096, 272, -56},
{ 1488, 232, 40},
{ 1560, 512, 152},
{ 1088, 704, 72},
{ 1264, 512, 16},
{ 976, 432, -96},
{ 1024, 296, -32},
{ 1200, 328, 56},
{ 1480, 280, 48},
{ 1240, 136, 24},
{ 1176, -32, 72},
{ 1208, -64, 24},
{ 1176, -32, -48},
{ 9... |
// 13 seconds
{ 1000, -24, -48},
{ 1192, -56, -72},
{ 840, -96, -136},
{ 1112, -168, -48},
{ 1136, -104, 24},
{ 1200, 80, -248},
{ 1232, 48, -152},
{ 1248, 0, -144},
{ 984, 96, -144},
{ 768, 120, -128},
{ 824, 144, -40},
{ 1000, 168, 16},
{ 1128, 216, -16},
{... |
t sibling
if (top_of_stack->next_sibling) {
return stack[*current_depth] = top_of_stack->next_sibling;
}
// there are no more siblings
// continue with siblings of parents/grandparents
while (*current_depth > 0) {
(*current_depth)--;
const Layer *sibling = stack[*current_depth]->next_sibling;
... | process_manager_compiled_with_legacy2_sdk() | ) {
layer->bounds = (GRect){.size = layer->frame.size};
} else {
// Legacy 2.x behavior needed for ScrollLayer
// Grow the bounds if it doesn't cover the area that the frame is showing.
// This is not a necessity, but supposedly a handy thing.
const int16_t visible_width = layer->bounds.size.w + ... |
econds
{ 1456, 80, -168},
{ 976, 120, -200},
{ 808, 88, -96},
{ 896, 144, -24},
{ 1032, 184, 8},
{ 1056, 240, -8},
{ 1112, 256, -8},
{ 1256, 328, 0},
{ 960, 520, 224},
{ 1152, 656, -192},
{ 1152, 296, -80},
{ 1168, 280, 24},
{ 1376, 320, 128},
{ 1632, 296, 24},
... | { 1104, 400, -104},
{ 1168, 296, -24},
{ 1400, 432, 128},
{ 1736, 376, 112},
{ 1448, 200, 112},
{ 1424, -32, 192},
// 74 seconds
{ 1384, -144, 104},
{ 1296, -48, -16},
{ 1112, 24, -48},
{ 960, -24, -8},
{ 984, -160, -16},
{ 632, -296, -48},
{ 888, -184, -104},
... |
{ 1232, 56, -176},
{ 1192, 40, -192},
{ 1304, -32, -152},
{ 1184, 24, -152},
{ 936, 96, -112},
{ 984, 128, -112},
{ 1112, 144, -16},
{ 1232, 160, 80},
{ 1184, 248, 64},
{ 1240, 296, 104},
{ 1496, 496, 168},
{ 1080, 888, 64},
{ 1184, 448, 64},
// 77 seconds
{ ... |
d */);
return;
}
*cb_data = (ChainingWindowCBData) {
.item = item,
// Claim the buffer so it doesn't get automatically free'd.
// The action group needs to stick around
.event_ref = event_service_claim_buffer(event),
.standalone_action = data->standalone_action,
};
Attribute *title_attr... | if (!data->chaining_data.notif->header.dismissed &&
timeline_item_find_dismiss_action(data->chaining_data.notif) &&
notification_window_is_modal()) {
// Only perform the dismiss if:
// 1) The notification has a dismiss action
// 2) The notification has not already been dismis... |
prv_handle_success_fail_response(data, &action_result->attr_list, true /* success */);
// Perform the dismiss after showing the UI (to try and improve perceived responsiveness)
if (should_perform_dismiss) {
// Call this directly so that we don't get another action result
ancs_perfor... |
ile apps because they don't have a way
// of knowing the max number of slices supported by the firmware, and so they send us as many
// slices as they can fit in a BlobDB packet. We just take as many slices as we support and trim
// the excess.
if (validation_context.validated_size < *len) {
PBL_LOG(LOG_LEV... | settings_file_exists(&s_app_glance_db.settings_file, key, (size_t)key_len) | ) {
rv = settings_file_delete(&s_app_glance_db.settings_file, key, (size_t)key_len);
} else {
rv = S_SUCCESS;
}
prv_close_file_and_unlock_mutex();
return rv;
}
/////////////////////////
// Testing code
/////////////////////////
#if UNITTEST
void app_glance_db_deinit(void) {
app_glance_db_flush();... |
criberState by AccelSessionRef
static bool prv_session_ref_list_filter(ListNode* node, void* data) {
AccelSubscriberState *state = (AccelSubscriberState *)node;
return state->session_ref == (AccelSessionRef)data;
}
// -------------------------------------------------------------------------------------------
// G... | {
imu_power_down();
} |
mutex_unlock_recursive(s_mutex);
}
// ----------------------------------------------------------------------------------------------
static void prv_restore_fifo_mode_callback(void* data) {
mutex_lock_recursive(s_mutex);
{
ACCEL_LOG_DEBUG("Restoring FIFO settings after peek");
prv_update_driver_config(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (RTC_BKP_BOOTBIT_DR) | );
dbgserial_newline();
}
void boot_version_write(void) {
if (boot_version_read() == s_bootloader_timestamp) {
return;
}
RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, s_bootloader_timestamp);
}
uint32_t boot_version_read(void) {
return RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
}
|
r(ClickRecognizerRef recognizer, void *context) {
ActionMenuLayer *aml = context;
const bool up = (click_recognizer_get_button_id(recognizer) == BUTTON_ID_UP);
const int new_idx = aml->selected_index + (up ? -1 : 1);
prv_set_selected_index(aml, new_idx, true /* animated */);
}
static void prv_select_handler(Cl... | (cell_layer_bounds->origin,
GPoint(offset_x, offset_y)) | ;
graphics_context_set_stroke_color(ctx, PBL_IF_COLOR_ELSE(GColorDarkGray, GColorWhite));
separator_start_point.y += config->separator.h;
for (int i = 0; i < config->separator.h; i++) {
// First point from bottom will be +0, second +1, third +0, etc.
separator_start_point.y--;
separator_s... |
rect.size.w, 32);
graphics_context_set_text_color(ctx, TEXT_COLOR);
graphics_draw_text(ctx, name, font, name_rect, overflow_mode, alignment, NULL);
}
static void prv_base_layer_update_proc(struct Layer *layer, GContext *ctx) {
WorkoutSummaryWindow *summary_window = window_get_user_data(layer_get_window(layer));... | (action_bar, BUTTON_ID_UP, summary_window->action_bar_start) | ;
action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, summary_window->action_bar_more);
workout_summary_update_activity_type(summary_window, activity_type);
return summary_window;
}
void workout_summary_window_push(WorkoutSummaryWindow *summary_window) {
app_window_stack_push(&summary_window->window, true)... |
(fake_gatt_is_service_discovery_running(), true) | ;
// Start again (expect to fail):
cl_assert_equal_i(gatt_client_discovery_discover_all(&device),
BTErrnoInvalidState);
// take down the connection and a disconnection event should be emitted
gap_le_connection_remove(&device);
prv_assert_event(&device, BTErrnoServiceDiscoveryDisconnected... | |
et_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc);
cl_assert_equal_i(last_median, 51);
cl_assert(last_update_utc >= rtc_get_time() - 1);
cl_assert(last_update_utc <= rtc_get_time());
// Reset the stats, the median should be 0
activity_metrics_prv_reset_hr_stats();
activity_metri... | cl_assert_equal_i(metric_values[5], 0000) | |
pts from the accel
bma255_write_register(BMA255Register_INT_EN_0, 0);
prv_disable_operating_mode(AccelOperatingMode_ShakeDetection);
}
void accel_enable_shake_detection(bool enable) {
if (s_shake_detection_enabled == enable) {
// the requested change matches what we already have!
return;
}
PBL_LOG(L... | prv_selftest_axis(BMA255Axis_X) | ;
pass &= prv_selftest_axis(BMA255Axis_Y);
pass &= prv_selftest_axis(BMA255Axis_Z);
// g-range should be 4g to copy the BMI160
bma255_set_scale(BMA255Scale_4G);
return pass;
}
bool accel_run_selftest(void) {
return bma255_selftest();
}
////////////////////////////////////////////////////////////////////... |
CT
x = (grect_get_max_x(bounds) - action_bar_width - icon_size.w) / 2;
#else
// On round displays we right align it with respect to the same imaginary vertical line that the
// text is right aligned to if action bar is present otherwise do what rect does
if (show_action_bar) {
x = grect_get_max_x(bounds) - ... | {
dialog_set_text(&workout_dialog->dialog, text);
} |
void workout_dialog_set_subtext(WorkoutDialog *workout_dialog, const char *text) {
if (workout_dialog->subtext_buffer) {
applib_free(workout_dialog->subtext_buffer);
}
uint16_t len = strlen(text);
workout_dialog->subtext_buffer = applib_malloc(len + 1);
strncpy(workout_dialog->subtext_buffer, text, len ... |
rite_offset) {
break;
}
}
// Read the chunk header
if (!prv_pfs_seek(logging_session->storage.fd, read_offset, FSeekSet)) {
last_whole_items_read_bytes = -1;
goto exit;
}
if (!prv_pfs_read(logging_session->storage.fd, &chunk_hdr, sizeof(chunk_hdr))) {
last_whole_item... | {
consumed_bytes = -1; // error
goto exit;
} |
if (logging_session->storage.num_bytes < chunk_hdr.num_bytes) {
PBL_LOG(LOG_LEVEL_ERROR, "Inconsistent tracking of num_bytes");
consumed_bytes = -1; // error
goto exit;
}
logging_session->storage.num_bytes -= chunk_hdr.num_bytes;
}
logging_session->storage.read_off... |
ntMovementUpdate,
.data.movement_update = {
.steps = value,
},
},
};
event_put(&e);
} else if (metric == ActivityMetricDistanceMeters) {
state->distance_mm = state->step_data.distance_meters * MM_PER_METER;
} else if (metric == ActivityMetricActiveKCalor... | {
steps_in_minute = state->step_data.steps
- state->steps_per_minute_last_steps;
} |
// Update the walking rate
state->steps_per_minute = steps_in_minute;
state->steps_per_minute_last_steps = state->step_data.steps;
ACTIVITY_LOG_DEBUG("new steps/minute: %"PRIu16"", state->steps_per_minute);
// Update the number of stepping minutes and the last active minute
if (state->steps_p... |
st *attributes = layout->attributes;
StringList *headings = attribute_get_string_list(attributes, AttributeIdHeadings);
StringList *paragraphs = attribute_get_string_list(attributes, AttributeIdParagraphs);
const size_t num_headings = string_list_count(headings);
if (num_headings == 0) {
return NULL;
}
... | ARRAY_LENGTH(vertical_config_nodes) | ,
.container.nodes = (LayoutNodeConfig **)&vertical_config_nodes,
};
#if PBL_RECT
const LayoutNodeConfig * const horizontal_config_nodes[] = {
icon_config_node,
&vertical_config.container.extent.node,
};
const LayoutNodeHorizontalConfig horizontal_config = {
.container.extent.node.type = LayoutN... |
ecause they don't have a way
// of knowing the max number of slices supported by the firmware, and so they send us as many
// slices as they can fit in a BlobDB packet. We just take as many slices as we support and trim
// the excess.
if (validation_context.validated_size < *len) {
PBL_LOG(LOG_LEVEL_WARNING... | (&s_app_glance_db.settings_file, key, (size_t)key_len) | ) {
rv = settings_file_delete(&s_app_glance_db.settings_file, key, (size_t)key_len);
} else {
rv = S_SUCCESS;
}
prv_close_file_and_unlock_mutex();
return rv;
}
/////////////////////////
// Testing code
/////////////////////////
#if UNITTEST
void app_glance_db_deinit(void) {
app_glance_db_flush();... |
WorkoutMetricType_Hr};
WorkoutActiveWindow *active_window = workout_active_create_tripple_layout(
top_metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller);
prv_create_window_and_render(active_window... | (
top_metric, middle_metric, ARRAY_LENGTH(scrollable_metrics), scrollable_metrics,
&s_sports_data, &s_sports_controller) | ;
prv_create_window_and_render(active_window, 1);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__sports_hr_z3(void) {
s_sports_data = (SportsData) {
.current_bpm = 180,
.duration_string = "30:00",
.distance_string = "5.0",
.pace_string = "6:00",
};
W... |
lue should something go
* wrong on the packing end.
*/
static const uint8_t LEVEL_MAP[8] = { LOG_LEVEL_ALWAYS, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING,
LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_VERBOSE,
LOG_LEVEL_DEBUG_VERBOSE, LOG_LEVEL_DE... | (&s_log_buffer.circular_buffer) | ;
if (length == 0) {
return;
}
s_log_buffer.transmitting = true;
circular_buffer_read(&s_log_buffer.circular_buffer, length, &data, &length);
hw_uart_send(CONFIG_LOG_UART, data, length, prv_uart_tx_callback, NULL);
}
static void prv_log_to_buffer(uint8_t *buffer, uint16_t length) {
prv_lock();
if (... |
"Today", buffer, buf_size);
} else if (midnight == (today_midnight - SECONDS_PER_DAY)) {
i18n_get_with_buffer("Yesterday", buffer, buf_size);
} else if (midnight == (today_midnight + SECONDS_PER_DAY)) {
i18n_get_with_buffer("Tomorrow", buffer, buf_size);
} else if (midnight <= (today_midnight + (5 * SECON... | prv_format_time(buffer, buf_size, time_fmt, timestamp) | ;
}
static void prv_clock_get_relative_time_string(char *buffer, int buf_size, time_t timestamp,
bool capitalized, int max_relative_hrs,
bool with_fulltime) {
time_t difference = rtc_get_time() - timestamp;
time_t today_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | { return NULL; } |
void graphics_context_mark_dirty_rect(GContext* ctx, GRect rect) {}
const GlyphData* text_resources_get_glyph(FontCache* font_cache, const Codepoint codepoint,
FontInfo* fontinfo) { return NULL; }
extern int32_t prv_convert_1bit_addr_to_8bit_x(GBitmap *dest_bitmap, uint32_... |
_x, src_begin_x, src_end_x - 1)) {
// Check if content should wrap (under and over) for tiling
if (!WITHIN(src_x, src_bitmap->bounds.origin.x,
grect_get_max_x(&src_bitmap->bounds) - 1)) {
// keep correct bounds alignment for circular when tiling
... | {
const uint32_t bit = (1 << i);
const bool set = src & bit;
if (set) {
dest[dest_x] = GColorBlack.argb;
}
} |
break;
case GCompOpSet:
for (int i = src_start_idx; i < src_end_idx; ++i, ++dest_x) {
const uint32_t bit = (1 << i);
const bool set = src & bit;
if (!set) {
dest[dest_x] = GColorWhite.argb;
}
}
break;
... |
me_ms += elapsed_ms;
return true;
}
bool WEAK animation_get_progress(Animation *animation, AnimationProgress *progress) {
if (!animation) {
return false;
}
// For use in this stub, start time is 0, so anything past 0 is elapsed
*progress = ((AnimationPrivate*)animation)->duration_ms * ANIMATION_NORMALIZE... | animation_spawn_create(Animation *animation_a, Animation *animation_b,
Animation *animation_c, ...) {
return animation_create();
}
Animation *WEAK animation_spawn_create_from_array(Animation **animation_array,
uint32_t array_len... | {
return animation_create();
}
bool WEAK animation_set_auto_destroy(Animation *animation, bool auto_destroy) {
return false;
}
PropertyAnimation *WEAK property_animation_create_layer_frame(
struct Layer *layer, GRect *from_frame, GRect *to_frame) {
return property_animation_create(NULL, layer, from_frame, ... |
ndow_stack()->list_head);
app_window_stack_push(window, true);
cl_assert_equal_i(app_window_stack_count(), 1);
app_window_stack_pop(true);
cl_assert_equal_i(app_window_stack_count(), 0);
window_destroy(window);
}
void test_window_stack__basic_modal_push(void) {
Window *window = window_create();
Wind... | app_state_get_window_stack() | );
cl_check(!app_state_get_window_stack()->list_head);
app_window_stack_push(window1, true);
cl_assert_equal_i(app_window_stack_count(), 1);
cl_assert_equal_i(window1->on_screen, true);
app_window_stack_insert_next(window2);
cl_assert_equal_i(app_window_stack_count(), 2);
cl_assert_equal_i(window1->on... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_finish_request_response(&request, resp, false /* should_free_request */) | ;
}
bool bt_driver_advert_client_get_tx_power(int8_t *tx_power) {
// TODO PBL-34354: Must use ble_read_tx_power, but we don't know the connection index here.
// Will have to figure out how to store and keep track of them.
*tx_power = 0;
return true;
}
void bt_driver_advert_set_advertising_data(const BLEAdData... |
ster_PMU_SELFTEST, axis_bits | SELFTEST_SIGN_NEGATIVE);
psleep(50);
uint8_t new_negative;
int16_t negative = prv_read_axis(axis, &new_negative);
negative = prv_raw_to_mgs(negative);
prv_soft_reset();
int delta = positive - negative;
delta = abs(delta);
PBL_LOG(LOG_LEVEL_DEBUG,
"Self test ax... | (buf, 64, "(0x19) Int Map 0: 0x%"PRIx8, int_map_0) | ;
prompt_send_response_fmt(buf, 64, "(0x16) Int EN 0: 0x%"PRIx8, int_en_0);
prompt_send_response_fmt(buf, 64, "(0x1a) Int Map 1: 0x%"PRIx8, int_map_1);
prompt_send_response_fmt(buf, 64, "(0x17) Int EN 1: 0x%"PRIx8, int_en_1);
prompt_send_response_fmt(buf, 64, "(0x1b) Int Map 2: 0x%"PRIx8, int_map_2);
prompt... |
816, 320, 184},
{ 840, 376, 64},
{ 920, 416, 112},
{ 1144, 664, 24},
{ 1304, 624, 120},
{ 1728, 648, 88},
{ 1352, 496, 48},
{ 1216, 320, 56},
{ 1512, 216, 128},
{ 1608, 104, 248},
{ 1400, 72, 280},
{ 1216, 0, 264},
{ 1080, 0, 224},
{ 952, -16, 200},
// 22 seconds... | { 1496, 672, 152},
{ 1800, 600, 216},
{ 1216, 264, 168},
{ 1360, 232, 144},
{ 1656, 112, 280},
{ 1560, 88, 320},
{ 1296, 64, 224},
{ 1088, 8, 192},
{ 992, 8, 168},
{ 968, 32, 96},
{ 904, 72, 16},
{ 792, -24, 64},
{ 752, -192, 64},
{ 736, -136, -48},
{ 1192, -1... | |
{ 936, -112, 56},
{ 1056, 24, -56},
{ 1224, -168, -56},
{ 1424, -104, 80},
{ 1360, 184, -40},
{ 1296, 352, -168},
{ 1000, 424, -104},
{ 760, 184, 32},
{ 776, 152, 88},
{ 848, 240, 40},
{ 896, 328, 24},
{ 848, 392, -40},
// 25 seconds
{ 904, 344, -72},
{ 1184, 4... | { 1064, 272, -80},
{ 1240, 360, -144},
{ 1680, 280, 8},
{ 1568, 456, 0},
{ 1016, 432, 16},
{ 1192, 328, 40},
{ 1072, 256, 88},
{ 920, 200, 72},
{ 856, 136, 88},
{ 784, 80, 120},
{ 856, 56, 152},
{ 848, 32, 160},
{ 768, -8, 176},
{ 928, -16, 112},
{ 1072, 16, 5... |
{ 1344, 120, 24},
{ 1296, 384, -288},
{ 1152, 440, -240},
{ 784, -16, 88},
{ 616, 872, -200},
{ 800, 352, -16},
{ 840, 232, 176},
{ 760, 384, 80},
{ 808, 448, 32},
{ 904, 864, 48},
{ 1048, 376, -16},
{ 1192, 488, 40},
{ 1800, 400, 88},
{ 1320, 336, -24},
{ 91... |
get out!!");
__disable_irq();
RTC_ITConfig(RTC_IT_WUT, DISABLE);
RTC_WakeUpCmd(DISABLE);
// disable all IRQn_Type >= 0 interrupts
for (size_t i = 0; i < ARRAY_LENGTH(NVIC->ISER); i++) {
NVIC->ICER[i] = NVIC->ISER[i];
}
// disable SysTick
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
enter_stop_mo... | prompt_send_response("You must run \"bt test stop\" to conduct sleep test!") | |
g_info_valid;
}
if (name_out) {
strncpy(name_out, data.ble_data.name, BT_DEVICE_NAME_BUFFER_SIZE);
}
if (requires_address_pinning_out) {
// Not supported in v2
*requires_address_pinning_out = false;
}
if (flags) {
// Not supported in v2
*flags = 0;
}
result = true;
done:
prv_cleanu... | (device_name_out, data.bt_classic_data.name) | ;
}
result = true;
done:
prv_cleanup_struct(&data);
return result;
}
static void prv_load_bt_classic_pairing_data(
BTClassicPairingData *data, BTDeviceAddress *addr, const char *device_name,
SM128BitKey *link_key, uint8_t platform_bits) {
*data = (BTClassicPairingData) {
.address = *addr,
.li... |
) {
layout->max_used_size = GSizeZero;
PBL_LOG(LOG_LEVEL_DEBUG, "Invalid UTF8");
return;
}
int str_len_bytes = (utf8_bounds.end - utf8_bounds.start);
Codepoint text_hash = hash((const uint8_t*) utf8_bounds.start, str_len_bytes);
if (prv_text_layout_is_fresh(layout, font, box, overflow_mode, alignm... | if (temp_box.size.h <= 0) {
// the text is not ever going to make it on screen. Bail early.
return;
} |
if (layout) {
layout->box.origin = global_box.origin;
}
WalkLinesCallbacks callbacks = {
.render_line_cb = render_all_render_line_cb,
.layout_update_cb = update_all_layout_update_cb,
.stop_condition_cb = is_clip_box_overflow_bottom_stop_condition_cb
};
int16_t line_spacing_delta = prv_lay... |
e_open_and_lock(&file) != S_SUCCESS) {
return false;
}
// We cheat a bit here because the only typical values we store are sleep related
SleepData data;
status_t s = settings_file_get(&file, key, key_len, (uint8_t *)&data, sizeof(data));
prv_file_close_and_unlock(&file);
if (s != S_SUCCESS || data.ve... | prv_key_is_valid(key, key_len) | |
for (int i = 0; i < NUM_BUTTONS; ++i) {
// What stable state is the button in, according to the debouncing algorithm?
bool debounced_button_state = bitset32_get(&s_debounced_button_state, i);
// What is the current physical state of the button?
bool is_pressed = button_is_pressed(i);
if (is_pressed... |
#if !defined(MANUFACTURING_FW)
// Now that s_debounced_button_state is updated, check to see if the user is holding down the reset
// combination.
static uint32_t s_hard_reset_timer = 0;
if ((s_debounced_button_state & RESET_BUTTONS) == RESET_BUTTONS) {
s_hard_reset_timer += 1;
can_power_down_tim4 = f... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return;
} | |
ght 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, s... | (&src_bitmap->bounds) | ;
// how many 32-bit blocks do we need to bitblt on this row:
const int16_t dest_end_x = grect_get_max_x(&dest_rect);
const int16_t dest_y_end = grect_get_max_y(&dest_rect);
const uint8_t num_dest_blocks_per_row = (dest_end_x / 32) +
((dest_end_x % 32) ? 1 : 0) - dest_begin_x;
const GColor *palette = sr... |
on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/graphics.h"
#include "applib/gr... | (s_bolt_path) | ;
gpath_destroy(s_duplicates_path);
gpath_destroy(s_infinite_path);
gpath_destroy(s_crossing_path);
gpath_destroy(s_aa_clipping_path);
}
// tests
void test_graphics_gpath_${BIT_DEPTH_NAME}__filled(void) {
GContext ctx;
Layer layer;
prv_reset();
s_current_path = s_house_path;
test_graphics_context_in... |
e "process_management/pebble_process_info.h"
#include "process_management/pebble_process_md.h"
#include "services/normal/filesystem/pfs.h"
#include "services/normal/blob_db/app_db.h"
// Fixture
////////////////////////////////////////////////////////////////
// Fakes
//////////////////////////////////////////////////... | (0 , strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES)) | ;
// check app 2
memset(&temp, 0, sizeof(AppDBEntry));
cl_assert_equal_i(S_SUCCESS, app_db_get_app_entry_for_uuid(&app1.uuid, &temp));
cl_assert_equal_b(true, uuid_equal(&app1.uuid, &temp.uuid));
cl_assert_equal_i(0, strncmp((char *)&app1.name, (char *)&temp.name, APP_NAME_SIZE_BYTES));
// check app 3
m... |
ific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "applib/ui/window_private.h"
#include "applib/ui/layer.h"
#include "util/math.h"
#include "util.h"
#include "clar.h"
#include <stdio.h>
// Helper Fu... | (10, 15, 32, 24) | );
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_inside_offset_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
l... |
t_bitmap, "draw_circle_offset_r8_quad_top_right.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_circle_quadrant_draw_1px_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, GCornerBottomLeft);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle... | test_graphics_context_init(&ctx, fb) | ;
layer_init(&layer, &GRect(0, 0, 60, 60));
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &white_layer_update_callback);
layer_r... |
) {
GenericGlanceIconBitmapProcessor *processor_with_data =
(GenericGlanceIconBitmapProcessor *)processor;
// Restore the saved compositing mode and tint color
ctx->draw_state.compositing_mode = processor_with_data->saved_compositing_mode;
ctx->draw_state.tint_color = processor_with_data->saved_tint_color;
... | launcher_app_glance_structured_get_highlight_color(structured_glance) | |
_img_pos.x,
config->no_music_img_pos.y,
NO_MUSIC_IMAGE_SIZE.w, NO_MUSIC_IMAGE_SIZE.h);
bitmap_layer_init(&window->bitmap_layer, &NO_MUSIC_IMAGE_RECT);
bitmap_layer_set_bitmap(&window->bitmap_layer, &window->bitmap);
bitmap_layer_s... | prv_update_track_progress(data) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const VibeScoreInfo *info = prv_vibe_score_find_info(id);
return info ? info->name : "";
} |
static int prv_get_index(VibeScoreId id) {
for (unsigned int x = 0; x < VIBE_MAP_SIZE; x++) {
if (S_VIBE_MAP[x].id == id) {
return x;
}
}
return 0;
}
VibeScoreId vibe_score_info_cycle_next(VibeClient client, VibeScoreId curr_id) {
AlertType alert_type;
switch (client) {
case VibeClient_No... |
ttings_glance->hrm_sharing_event_info);
#endif
kino_reel_destroy(settings_glance->icon);
kino_reel_destroy(settings_glance->charging_indicator_icon);
}
app_free(settings_glance);
}
static void prv_set_glance_icon(LauncherAppGlanceSettings *settings_glance,
uint32_t new_icon_... | launcher_app_glance_structured_notify_service_glance_changed(structured_glance) | |
e on the edge
const int32_t height = 2 * (max_height + 1); // Add one more pixel in case on the edge
// add two pixels just in case of rounding isssues
const int32_t max_distance = integer_sqrt((width * width) + (height * height)) + 2;
const int32_t min_x = src_ic.x - max_distance;
const int32_t mi... | ctx->draw_state.stroke_color = gcolor_alpha_blend(src_color, dst_color);
break;
}
case GCompOpOr: {
const GColor dst_color = get_bitmap_color(dest_bitmap, x, y);
if (tint_color.a != 0) {
GColor actual_color = tint_color;
actual_color.a = sr... |
// Restore context color
ctx->draw_state.stroke_color = ctx_color;
graphics_release_frame_buffer(ctx, dest_bitmap);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | interpolate_int16(distance_normalized,
0,
DISP_ROWS_LAST_INDEX) | );
// This is the delta between the new offset and the previous offset.
const int32_t modal_offset_delta_y = new_modal_offset_y - s_data.cur_modal_offset_y;
if (modal_offset_delta_y == 0) {
// if we aren't going to move the modal, just bail
return;
}
// Start from the bottom of the display (last row... |
s_context_set_stroke_color(&context, color);
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorClear.argb);
color.a = 0;
graphics_context_set_stroke_color(&context, color);
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorClear.argb);
// Stroke Color - 2-bit
graphics_context_set_s... | prv_draw_rect(&context, &GRect(10, 20, 40, 10)) | );
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circle_draw_1px_aa(&context, GPoint(50, 50), 10));
#else
ASSERT_CALLED(graphics_circle_draw_1px_non_aa(&context, GPoint(50, 50), 10));
#endif
setup_test... |
imeline);
prv_set_indices(*timeline);
PBL_LOG(LOG_LEVEL_DEBUG, "Finished building list.");
#ifdef TIMELINE_SERVICE_DEBUG
prv_debug_print_pins(*timeline);
#endif
return rv;
}
bool timeline_add(TimelineItem *item) {
return (S_SUCCESS == pin_db_insert_item(item));
}
bool timeline_exists(Uuid *id) {
return (p... | (iter, prv_iter_next, prv_iter_prev, iter_state) | ;
}
return rv;
}
void timeline_iter_copy_state(TimelineIterState *dst_state, TimelineIterState *src_state,
Iterator *dst_iter, Iterator *src_iter) {
PBL_ASSERTN(dst_state && src_state && dst_iter && src_iter);
timeline_item_free_allocated_buffer(&dst_state->pin);
*dst_state =... |
it out now, this should send any remaining data out
success = protobuf_log_session_flush(session_ref);
cl_assert(success);
if (num_samples_encoded < num_samples) {
if (s_saved_encoded_msg == NULL) {
LOG("No message available yet...");
} else {
msg = prv_parse_encoded_mset_payload(s_saved_enco... | {
pebble_pipeline_Event events[] = {
{
.type = pebble_pipeline_Event_Type_UnknownEvent,
.duration = 17,
.has_duration = true,
.time_utc = rtc_get_time() - 3000,
},
{
.type = pebble_pipeline_Event_Type_UnknownEvent,
.duration = 34,
.has_duration = true,
.time... | |
if (!prv_is_awaiting_ack(outbox->phase)) {
// Reply was received and handled in the mean time, or app message was closed.
return;
} |
prv_handle_nack_or_ack_timeout(outbox, APP_MSG_SEND_TIMEOUT);
}
void app_message_outbox_handle_app_outbox_message_sent(AppOutboxStatus status, void *cb_ctx) {
AppMessageCtxOutbox *outbox = &app_state_get_app_message_ctx()->outbox;
AppMessageSenderError e = (AppMessageSenderError)status;
if (e != AppMessageSe... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
record_mock_call(s_tick_timer_service_subscribe) {
.tick_units = tick_units,
};
} |
void test_rocky_api_tickservice__initialize(void) {
fake_app_timer_init();
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
s_tick_timer_service_subscribe = (MockCallRecordings){0};
s_log_internal__expected = NULL;
}
void test_rocky_api_tickservice__cleanup(void) {
jerry_cleanup();
rocky_run... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (success) {
return S_SUCCESS;
} else {
return E_INVALID_ARGUMENT;
} |
}
status_t prefs_db_delete(const uint8_t *key, int key_len) {
return E_INVALID_OPERATION;
}
status_t prefs_db_flush(void) {
return E_INVALID_OPERATION;
}
|
(slave->bus->state->bus_mutex) | ;
}
bool i2c_bitbang_recovery(I2CSlavePort *slave) {
PBL_ASSERTN(slave);
static const int MAX_TOGGLE_COUNT = 10;
static const int TOGGLE_DELAY = 10;
// Protect access to bus
mutex_lock(slave->bus->state->bus_mutex);
if (slave->bus->state->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted bitban... | |
assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(2bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat2BitPalette);
}
// Tests 4-bit palettized PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_4_bit(void) {
GBitmap *bitmap = setup_png_test(TES... | TEST_PBI_FILE_FMT(2bitpalette) | ));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat2BitPalette);
}
// Tests 4-bit transparent greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_4_bit_transparent(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(4bitpalette));
c... |
ite;
// Status bar is clear on round, because the banner is rendered under it
status_bar_layer_set_colors(&data->status_layer, PBL_IF_ROUND_ELSE(GColorClear, status_color),
gcolor_legible_over(status_color));
}
static void prv_interaction_handler(SwapLayer *swap_layer, void *context) ... | (swap_layer, window) | ;
layer_add_child(root_layer, swap_layer_get_layer(swap_layer));
StatusBarLayer *status_layer = &data->status_layer;
status_bar_layer_init(status_layer);
status_bar_layer_set_colors(status_layer, PBL_IF_RECT_ELSE(GColorBlack, GColorClear),
PBL_IF_RECT_ELSE(GColorWhite, GColorBlack... |
action);
}
return emoji_level;
}
static void prv_handle_voice_transcription_result(PebbleEvent *e, void *context) {
DictationSessionStatus status = e->dictation.result;
char *transcription = e->dictation.text;
VoiceResponseData *data = context;
if (status == DictationSessionStatusSuc... | level_getters[reply](responses_level, action, root_level) | ;
}
item++;
}
return responses_level;
}
static void prv_postpone_15_minutes(ActionMenu *action_menu,
const ActionMenuItem *action_menu_item,
void *context) {
TimelineActionMenu *timeline_action_menu = context;
const TimelineItem *... |
rv_update_range_text_layer(data);
}
// Public Functions
void time_selection_window_set_to_current_time(TimeSelectionWindowData *time_selection_window) {
struct tm current_time;
clock_get_time_tm(¤t_time);
time_selection_window->time_data.hour = current_time.tm_hour;
time_selection_window->time_data.minut... | prv_text_layer_init(&window->layer, label_text_layer, header_font);
layer_set_hidden(&label_text_layer->layer, false);
// Range setup
TextLayer *range_text_layer = &time_selection_window->range_text_layer;
prv_text_layer_init(&window->layer, range_text_layer, header_font);
// Range subtitle setup
TextLa... |
void time_selection_window_deinit(TimeSelectionWindowData *time_selection_window) {
if (time_selection_window) {
status_bar_layer_deinit(&time_selection_window->status_layer);
selection_layer_deinit(&time_selection_window->selection_layer);
}
}
|
} });
kino_layer_set_alignment(&s_phone_ui_data->icon_layer, GAlignCenter);
layer_add_child(&s_phone_ui_data->core_ui_container, &s_phone_ui_data->icon_layer.layer);
// Caller ID text
const GRect caller_id_text_rect = GRect(TEXT_MARGIN_WIDTH, style->caller_id_pos_y,
w... | prv_display_caller_info(caller) | ;
}
prv_action_bar_setup(PhoneCallActions_None);
prv_window_pop_with_delay(OUTGOING_CALL_DELAY_MS);
}
void phone_ui_handle_missed_call(void) {
if (!s_phone_ui_data) {
return;
}
prv_stop_ringing();
prv_set_icon_resource(TIMELINE_RESOURCE_DISMISSED_PHONE_CALL);
prv_action_bar_setup(PhoneCallActi... |
if (bm_p1.x.raw_value != bm_p0.x.raw_value) {
bottom_margin.raw_value =
bm_p0.y.raw_value + ((bm_p1.y.raw_value - bm_p0.y.raw_value)
* (x - ((bm_p0.x.raw_value + add_bottom) / FIXED_S16_3_ONE.raw_value)))
* FIXED_S16_3_ONE.raw_value / (bm_p1.x.raw_value - bm_p0.x.ra... | (ctx, GPointFromGPointPrecise(p0), GPointFromGPointPrecise(p1)) | |
OMPATIBLE
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
#include <inttypes.h>
#include <stdint.h>
static PebbleMutex *s_mag_mutex;
static bool s_initialized = false;
static int s_use_refcount = 0;
// MAG3110 Register Address Map
#define DR_STATUS_REG 0x00
#define OUT_X_MSB_REG 0x01 /... | {
int offset = 2 * BOARD_CONFIG_MAG.mag_config.axes_offsets[axis];
bool do_invert = BOARD_CONFIG_MAG.mag_config.axes_inverts[axis];
int16_t mag_field_strength = ((raw_data[offset] << 8) | raw_data[offset + 1]);
mag_field_strength *= (do_invert ? -1 : 1);
return (mag_field_strength);
} |
// callers responsibility to know if there is valid data to be read
MagReadStatus mag_read_data(MagData *data) {
mutex_lock(s_mag_mutex);
if (s_use_refcount == 0) {
mutex_unlock(s_mag_mutex);
return (MagReadMagOff);
}
MagReadStatus rv = MagReadSuccess;
uint8_t raw_data[7];
// DR_STATUS_REG is i... |
ic void prv_enable_display_spi_clock() {
periph_config_enable(RCC_APB1PeriphClockCmd, DISPLAY_SPI_CLOCK);
}
static void prv_disable_display_spi_clock() {
periph_config_disable(RCC_APB1PeriphClockCmd, DISPLAY_SPI_CLOCK);
}
static void prv_enable_chip_select(void) {
gpio_use(DISP_GPIO);
GPIO_WriteBit(DISP_GPIO,... | GPIO_Init(DISP_GPIO, &s_disp_gpio_init) | ;
s_disp_gpio_init.GPIO_Mode = GPIO_Mode_OUT;
s_disp_gpio_init.GPIO_OType = GPIO_OType_OD;
s_disp_gpio_init.GPIO_Pin = PWR_CTL_PIN;
GPIO_Init(PWR_CTL_GPIO, &s_disp_gpio_init);
s_disp_gpio_init.GPIO_Mode = GPIO_Mode_OUT;
s_disp_gpio_init.GPIO_OType = GPIO_OType_PP;
s_disp_gpio_init.GPIO_Pin = DISP_PIN_... |
ve adjacent addresses
// MSB enables address auto-increment
int num_bytes = 6 * num_samples;
// Overflow bit doesn't get cleared until number of samples in fifo goes below
// the watermark. Read an extra item from the fifo and just throw it away.
int read_num_bytes = num_bytes + 6;
uint8_t start_addr = 1 ... | if (vibes_get_vibe_strength() == VIBE_STRENGTH_OFF) {
PebbleEvent e = {
.type = PEBBLE_CALLBACK_EVENT,
.callback = {
.callback = prv_handle_tap,
.data = NULL
}
};
*should_context_switch = event_put_isr(&e);
} |
}
void accel_set_running(bool running) {
s_running = running;
}
void accel_set_num_samples(uint8_t num_samples) {
if (num_samples == 0) {
// peek mode, no FIFO
lis3dh_set_fifo_mode(MODE_BYPASS);
lis3dh_disable_fifo();
} else {
lis3dh_set_fifo_wtm(num_samples - 1);
// clear fifo
lis3dh_s... |
and
* limitations under the License.
*/
#include <stdint.h>
#include <inttypes.h>
#include "board/board.h"
#include "boot_tests.h"
#include "drivers/button.h"
#include "drivers/dbgserial.h"
#include "drivers/display.h"
#include "drivers/flash.h"
#include "drivers/i2c.h"
#include "drivers/periph_config.h"
#include "... | RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE) | ;
// The Cortex-M user guide states that the reset values for the core registers
// are as follows:
// R0-R12 = Unknown
// MSP = VECTOR_TABLE[0] (main stack pointer)
// PSP = Unknown (process stack pointer)
// LR = 0xFFFFFFFF
// PC = VECTOR_TABLE[1]
// PRIMASK = 0x0
// FAU... |
//////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphic... | gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_y_offset_layer")) | );
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_ny_offset_layer")));
}
void test_graphics_draw_line__clear(void) {
GContext ctx;... |
= evt->subversion,
}
};
hc_endpoint_gap_le_connect_send_peer_version_info(&event);
}
static void prv_ble_peripheral_task(void *params) {
const BleTaskInitInfo *init_info = (const BleTaskInitInfo *)params;
PBL_LOG(LOG_LEVEL_DEBUG, "At least I started");
analytics_init();
hc_endpoint_analytics_send_re... | PBL_LOG(LOG_LEVEL_DEBUG, "Local address updated to "BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE_PTR(addr)) | ;
local_addr_handle_update(addr);
break;
}
case BLE_EVT_GAP_GET_PEER_VERSION_COMPLETE:
prv_handle_get_peer_version_complete((const ble_evt_gap_get_peer_version_t *)hdr);
break;
// GATT Client Events:
case BLE_EVT_GATTC_MTU_CHANGED:
p... |
teristic = subscription->characteristic,
.value_length = length,
};
CircularBuffer *buffer = s_circular_buffer[c];
bt_unlock();
// If we do not hold the bt_lock() at this point it's safe to block for a little bit waiting
// for notifications to be consumed
uint32_t write_timeout = bt_lock... | // In the error case, clean up the subscription data structure, if no longer used:
if (has_error && prv_prevailing_subscription_type(subscription) == BLESubscriptionNone) {
prv_remove_subscription(connection, subscription);
}
} |
// -------------------------------------------------------------------------------------------------
static bool prv_check_buffer(GAPLEClient client) {
if (s_circular_buffer[client] == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "App attempted to consume notifications without buffer.");
return false;
}
return tru... |
cl_assert_equal_s("16:00", time_buf) | ;
// June 8th 2015, 16:00:00 (T-48:00:00)
rtc_set_time(event_time - SECONDS_PER_DAY - (24 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Tue, 16:00", time_buf);
// June 16th 2015, 17:00:00 (T+7DAY+01:00:00)
rtc_set_time(... | |
info;
bd_address_t addr;
dialog_utils_bt_device_to_bd_address(&bonding->pairing_info.identity, &addr);
device_t *dev = find_device_by_addr(&addr, true /* create */);
dev->paired = true;
dev->bonded = true;
dev->is_gateway = bonding->is_gateway;
dev->flags = bonding->flags;
dev->mitm = info->is_mitm_pro... | {
bonding.should_pin_address = true;
connection_get_local_address(connection, &bonding.pinned_address);
} |
BleBondingFlag flags = 0;
if (connection_should_auto_accept_re_pairing(connection)) {
flags |= BleBondingFlag_ShouldAutoAcceptRePairing;
}
if (connection_is_reversed_ppogatt_enabled(connection)) {
flags |= BleBondingFlag_IsReversedPPoGATTEnabled;
}
bonding.flags = flags;
dev... |
DumpSPICmd) { .cmd = CoreDumpCmd_GetBuildID };
if (!prv_spi_transaction(&cmd, s_rx_buffer, sizeof(build_id))) {
PBL_LOG(LOG_LEVEL_ERROR, "Unable to get Build ID");
goto spi_failed;
}
memcpy(build_id, s_rx_buffer, sizeof(build_id));
// Get the memory region table
cmd = (CoreDumpSPICmd) { .cmd = CoreDu... | ((const uint8_t *)&chunk_hdr, flash_addr, sizeof(chunk_hdr)) | ;
flash_addr += sizeof(chunk_hdr);
flash_write_bytes(s_rx_buffer, flash_addr, sizeof(CoreDumpExtraRegInfo));
flash_addr += sizeof(CoreDumpExtraRegInfo);
// Terminate the core dump
chunk_hdr.key = CORE_DUMP_CHUNK_KEY_TERMINATOR;
chunk_hdr.size = 0;
if (flash_addr_max < (flash_addr + sizeof(chunk_hdr) + ch... |
ice_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
s_current_day = s_sunday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 3);
s_current_day = s_monday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 4);
s_current_day = s_tuesday;
cron_service_wakeup();
cl_assert... | cl_assert_equal_i(s_num_alarms_fired, 3) | ;
cl_assert_equal_i(s_num_alarm_events_put, 3);
cl_assert_equal_i(s_num_timeline_adds, 11);
cl_assert_equal_i(s_num_timeline_removes, 7);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. First one should be up again, but not until Saturday
s_current... |
_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should not draw anything
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) + 1);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r... | (&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw2_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 2);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw2_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP... |
ndex(uuid);
}
// ---------------------------------------------------------------------------------------------------------------
// Used by list_find to locate the handler for a specfic service index.
static bool prv_service_filter(ListNode *node, void *tp) {
PluginServiceEntry *info = (PluginServiceEntry *)node;
... | {
*state = (PluginServiceState) {
.event_service_info = {
.type = PEBBLE_PLUGIN_SERVICE_EVENT,
.handler = &prv_handle_event_service_event,
},
};
} | |
ng_rate(AccelManagerState *state,
uint32_t min_rate_mHz) {
// HACK
// We're dumb and don't support anything other than 12.5hz for jitter-free sampling. We chose
// this rate because it divides evenly into all the native rates we support right now.
// Supportin... | if (left != 0) {
empty = false;
break;
} |
state = (AccelManagerState *)state->list_node.next;
}
}
mutex_unlock_recursive(s_accel_manager_mutex);
return empty;
}
void accel_cb_new_sample(AccelDriverSample const *data) {
prv_update_last_accel_data(data);
s_accel_samples_collected_count++;
if (!s_buffer.clients) {
return; // no clien... |
ng_click_end_handler);
}
static void prv_volume_click_config_provider(void *context) {
window_single_repeating_click_subscribe(BUTTON_ID_UP, VOLUME_REPEAT_INTERVAL_MS,
prv_volume_click_handler);
window_single_repeating_click_subscribe(BUTTON_ID_DOWN, VOLUME_REPEAT_INTERVAL... | music_needs_user_to_start_playback_on_phone() | ) {
prv_push_no_music_window(data);
} else {
prv_pop_no_music_window(data);
}
bool title_changed = strncmp(data->title_buffer, title_buffer, MUSIC_BUFFER_LENGTH) != 0;
bool artist_changed = strncmp(data->artist_buffer, artist_buffer, MUSIC_BUFFER_LENGTH) != 0;
if (title_changed || artist_changed) {
... |
RTC_Date = t.tm_mday,
.RTC_Year = (t.tm_year % 100) // tm_year is years since 1900, RTC_Year is just 0-99
};
RTC_SetTime(RTC_Format_BIN, &rtc_time_struct);
RTC_SetDate(RTC_Format_BIN, &rtc_date_struct);
}
void rtc_get_time_ms(time_t* out_seconds, uint16_t* out_ms) {
uint32_t sub_seconds = 0;
RTC_DateTyp... | RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div2) | ;
exti_configure_other(ExtiLineOther_RTCWakeup, ExtiTrigger_Rising);
exti_enable_other(ExtiLineOther_RTCWakeup);
s_rtc_wakeup_initialized = true;
}
static uint64_t prv_get_time_milliseconds_since_epoch(void) {
time_t seconds;
uint16_t milliseconds;
rtc_get_time_ms(&seconds, &milliseconds);
return ((ui... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (neg) {
str[i++] = '-'; /* append sign */
} |
str[i] = '\0';
string_reverse(str);
}
static int8_t ascii_hex_to_int(const uint8_t c) {
if (isdigit(c)) return c - '0';
if (isupper(c)) return (c - 'A') + 10;
if (islower(c)) return (c - 'a') + 10;
return -1;
}
static uint8_t ascii_hex_to_uint(const uint8_t msb, const uint8_t lsb) {
return 16 * ascii... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.