prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
terState word_iter_state = (WordIterState) { 0 };
Line line = (Line) { 0 };
// Allocate immutable types
bool success = false;
const char *sentence = "Foo bar";
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, sentence);
cl_assert(success);
const TextBoxParams text_box_params = (TextBoxParams) {... | (line.width_px == 2 * HORIZ_ADVANCE_PX) | ;
cl_assert(iter_next(&word_iter));
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 2 * HORIZ_ADVANCE_PX);
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(!lin... |
/*
* 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... | (str, "\n") | ;
}
void prv_each_app_ids(uint32_t num_ids, AppInstallId *ids, EachCb cb, void *context) {
for (uint32_t i = 0; i < num_ids; i++) {
// app_title +1 to add newline per line
AppInstallId app_id = ids[i];
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(app_id, &entry)) {
continue... |
pliance 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, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either... | fun(GColorFromHEX(0xaa0000)) | |
0},
{ 784, 232, -8},
{ 832, 328, -144},
{ 1120, 384, -168},
{ 1344, 336, -120},
{ 1552, 224, 88},
{ 1712, 376, 64},
{ 1112, 480, -24},
{ 896, 272, 24},
{ 1016, 48, 152},
{ 1040, 72, 96},
{ 872, 40, 176},
{ 736, 56, 192},
{ 704, 152, 24},
{ 728, 88, 104},
{ 752... | { 736, 16, 16},
{ 736, -16, 24},
{ 664, -104, 80},
{ 1056, -24, -8},
{ 1200, 48, -112},
{ 1664, -40, 96},
{ 1216, 224, -80},
{ 1304, 288, -176},
{ 1184, 368, -56},
{ 704, 256, 80},
{ 576, 216, 80},
{ 680, 192, 144},
{ 808, 208, 200},
{ 824, 328, 128},
{ 776, 3... | |
_context_set_fill_color(ctx, peek_layer->bg_color);
// Fill the peek background as a circle on round displays; this is needed to animate the
// peek moving right as a circle to become the side bar on timeline as well as moving up to
// become the top banner in the notifications window
#if PBL_ROUND
// U... | GRect(0, NUMBER_OFFSET_Y, frame->size.w, 40) | ;
// number layer
text_layer_init_with_parameters(&peek_layer->number.text_layer,
&text_rect,
NULL, fonts_get_system_font(FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM),
GColorBlack, GColorClear, text_alignment,
... |
) {
if (value_len != entry->value_len) {
PBL_LOG(LOG_LEVEL_WARNING, "Attempt to set %s using invalid value_len of %"PRIu32"",
entry->key, (uint32_t)value_len);
return false;
}
status_t rv = E_ERROR;
mutex_lock(s_mutex);
{
SettingsFile file = {{0}};
if (settings_file_open(&file, SH... | prv_prefs_entry(event->key, event->key_len) | ;
if (!entry) {
return;
}
// Read in the updated value from the backing store
bool success = prefs_private_read_backing(event->key, event->key_len, entry->value,
entry->value_len);
if (success) {
// Call the state update handler in case this pref needs to t... |
ffer[10];
prompt_send_response_fmt(buffer, sizeof(buffer), "%d", mfg_info_get_watch_color());
}
void command_color_write(const char* color_num) {
char *end;
int color = strtol(color_num, &end, 10);
if (*end) {
prompt_send_response("Invalid color");
return;
}
mfg_info_set_watch_color(color);
co... | prv_bootloader_test_copy(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN,
FLASH_REGION_FIRMWARE_SCRATCH_END) | ;
BLTEST_LOG("STAGE 1 -- Marking new FW boot bit");
boot_bit_set(BOOT_BIT_NEW_FW_AVAILABLE);
} else {
BLTEST_LOG("STAGE 1 -- Copying STAGE 2 to PRF");
flash_prf_set_protection(false);
prv_bootloader_test_copy(FLASH_REGION_SAFE_FIRMWARE_BEGIN, FLASH_REGION_SAFE_FIRMWARE_END);
BLTEST_LOG("STAG... |
.
//! Always lock the bus and peripheral config access before enabling it
static void bus_enable(uint8_t bus_idx) {
// Don't power up rail if the bus is already in use (enable can be called to reset bus)
if (i2c_buses[bus_idx].user_count == 0) {
bus_rail_power_up(bus_idx);
}
bus_pin_cfg_i2c(BOARD_CONFIG.i... | {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted reset of disabled bus %d by device %d", bus_idx, device_id);
bus_unlock(bus);
return;
} |
PBL_LOG(LOG_LEVEL_WARNING, "Resetting I2C bus %" PRId8, bus_idx);
// decrement user count for reset so that if this user is the only user, the
// bus will be powered down during the reset
bus->user_count--;
// Reset and reconfigure bus and pins
bus_reset(bus_idx);
//Restore user count
bus->user_cou... |
/*
* 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... | (raw_value) | ;
}
GSize interpolate_gsize(int32_t normalized, GSize from, GSize to) {
return (GSize) {
.w = interpolate_int16(normalized, from.w, to.w),
.h = interpolate_int16(normalized, from.w, to.w),
};
}
GPoint interpolate_gpoint(int32_t normalized, GPoint from, GPoint to) {
return (GPoint) {
.x = interpolate... |
AttributeIdBody, "");
// We show the app name if we don't have a custom icon, otherwise we use the title
if (!IS_EMPTY_STRING(app_name) && loaded_node->icon_is_default) {
title = app_name;
}
if (!IS_EMPTY_STRING(title) && !IS_EMPTY_STRING(subtitle)) {
// we got a title & subtitle, we're done
} else... | (menu_layer, GColorWhite, GColorBlack) | ;
menu_layer_set_highlight_colors(menu_layer,
PBL_IF_COLOR_ELSE(DEFAULT_NOTIFICATION_COLOR, GColorBlack),
GColorWhite);
menu_layer_set_click_config_onto_window(menu_layer, window);
layer_add_child(&window->layer, menu_layer_get_layer(menu_layer)... |
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 "compositor_shutter_transitions.h"
#include "services/common/compositor/compositor_transitions.h"
#include "app... | (normalized, def->start.y, def->end.y) | ;
}
// piecewise interpolator between 0 and to for the first half of ANIMATION_NORMALIZED_MAX
// and between -to and 0 for the second half
static int16_t prv_interpolate_two_ways(AnimationProgress normalized_progress, int16_t end) {
const int16_t from = s_data.is_first_half ? 0 : -end;
const int16_t to = s_data.is... |
ANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"draw_rotated_bitmap_origin_color_assign_center_45.Xbit.pbi"));
// Test transparency
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_context_set_fill_color(&ctx, GColorBlue);
gra... | (&ctx.dest_bitmap, "draw_rotated_bitmap_offset_bottomedge_2.Xbit.pbi") | );
// top edge center rotation point, Angle 2
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPoint(30, 1), DEG_TO_TRIGANGLE(2), GPoint(72, 84));
cl_check(gbitmap_pbi_eq(&ctx.dest_b... |
/*
* 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... | APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"j\": %s", buf) | ;
}
r = strftime(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp(buf, "05", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"m\": %s", buf);
}
r = strftime(buf, buf_size, "%M", &good_data);
if (r == 0 || strncmp(buf, "04", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error w... |
lr __asm("lr");
uintptr_t saved_lr = lr;
return prv_strdup(task_heap_get_for_current_task(), s, saved_lr);
}
// app_* functions that allocate on the app heap
///////////////////////////////////////////////////////////
void *app_malloc(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;... | kernel_heap_get() | |
called when we begin a new outbox,
// so the state should always be clean when we return successfully.
prv_outbox_prepare(outbox);
*iterator = &outbox->iterator;
outbox->phase = OUT_WRITING;
outbox->result = APP_MSG_OK;
return APP_MSG_OK;
}
static void ack_nack_timer_callback(void *data) {
AppMessageCtx... | prv_transition_to_accepting(outbox) | ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Unit test interfaces
AppTimer *app_message_outbox_get_ack_nack_timer(void) {
AppMessageCtxOutbox *outbox = &app_state_get_app_message_ctx()->outbox;
return outbox ? outbox->ack_nack_timer : NULL;
}
|
Simple write register command with no error handling
static bool prv_write_register(uint8_t register_address, uint8_t value) {
return i2c_write_register(I2C_LIS3DH, register_address, value);
}
static void prv_clear_fifo(void) {
// Use I2C calls instead of accel wrappers to avoid recursion (reset called from lis3d... | (LOG_LEVEL_ERROR, "Failed to enter low power mode") | ;
}
bool accel_running(void) {
return (s_running);
}
bool accel_start(void) {
if (!s_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to start accel, not yet initialized");
return false;
}
if (s_running) {
return true; // Already running
}
i2c_use(I2C_LIS3DH);
s_running = true;
return t... |
ll_function(func, JSON, args, args_count);
}
T_STATIC jerry_value_t prv_json_stringify(jerry_value_t object) {
return prv_call_json_function(GLOBAL_JSON_STRINGIFY, &object, 1);
}
T_STATIC jerry_value_t prv_json_parse(const char *object) {
JS_VAR string_obj = jerry_create_string_utf8((const jerry_char_t *)object);... | jerry_value_has_error_flag(json_string) | ) {
return jerry_acquire_value(json_string);
}
if (jerry_value_is_undefined(json_string)) {
// ECMA v5.1, 15.12.3, Note 5: Values that do not have a JSON representation (such as undefined
// and functions) do not produce a String. Instead they produce the undefined value.
return rocky_error_unexpect... |
LE_4G:
cfg_val = BMI160_ACC_RANGE_4G;
break;
case BMI160_SCALE_8G:
cfg_val = BMI160_ACC_RANGE_8G;
break;
case BMI160_SCALE_16G:
cfg_val = BMI160_ACC_RANGE_16G;
break;
default:
WTF;
}
prv_write_reg(BMI160_REG_ACC_RANGE, cfg_val);
s_raw_unit_to_mgs = 32768 / sca... | BMI160_DBG("%"PRId16" %"PRId16" %"PRId16, data->x, data->y, data->z) | ;
}
static IMUCoordinateAxis prv_get_axis_direction(uint8_t int0_status, uint8_t int2_status,
uint8_t mask, uint8_t shift, int32_t *direction) {
*direction = ((int2_status & BMI160_INT_STATUS_2_ANYM_SIGN) == 0) ? 1 : -1;
IMUCoordinateAxis axis = AXIS_X;
const Accel... |
/*
* 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... | applib_free(session) | |
/*
* 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... | settings_file_set(&s_contacts_db.settings_file, key, key_len, val, val_len) | |
8, 424, 64},
{ 1680, 584, 128},
{ 1304, 752, 136},
// 37 seconds
{ 1120, 784, -24},
{ 1088, 1016, -112},
{ 864, 656, -112},
{ 880, 488, -24},
{ 1048, 640, 0},
{ 1400, 480, 0},
{ 1336, 320, -16},
{ 1208, 168, 56},
{ 1264, 248, -16},
{ 1288, 312, -24},
{ 1168, 376, ... | { 936, 640, -112},
{ 864, 624, -56},
{ 1112, 616, 24},
{ 1320, 488, 16},
{ 1232, 296, 32},
{ 1200, 208, 8},
{ 1264, 216, -40},
{ 1288, 280, -56},
{ 1176, 336, -40},
{ 1152, 288, -48},
{ 1232, 288, -96},
{ 1112, 240, -152},
{ 1224, 104, -104},
// 43 seconds
{ 9... |
{ 1208, 168, -112},
{ 1040, 104, -32},
{ 1128, 208, -184},
{ 1088, 264, -232},
{ 1248, 256, -208},
{ 1248, 272, -192},
{ 1096, 320, -280},
{ 1064, 344, -256},
{ 1096, 344, -200},
{ 1168, 408, -144},
{ 1144, 496, -136},
{ 1136, 552, -160},
{ 1528, 664, -128},
{ 12... |
/*
* 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... | (list_get_next(&a) == NULL) | ;
cl_assert(list_get_head(&b) == &b);
}
void test_list__pop_tail(void) {
ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL;
list_insert_after(&a, &b);
ListNode *new_tail = list_pop_tail(&a);
cl_assert(new_tail == &a);
cl_assert(list_get_prev(&b) == NULL);
cl_assert(list_get_tail(&b) == &b);
}
void test_li... |
p();
// Schedule 1 event in a minute
time_t first_event = sys_get_time() + WAKEUP_EVENT_WINDOW;
WakeupId first_wakeup_id = sys_wakeup_schedule(first_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(first_wakeup_id), first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minut... | wakeup_handle_clock_change() | ;
// There should be a missed wakeup event and a popup displayed
cl_assert_equal_b(s_popup_occurred, true);
// Make sure the wakeup event is no longer scheduled
cl_assert_equal_i(sys_wakeup_query(first_timer), E_DOES_NOT_EXIST);
}
|
alog = actionable_dialog_get_dialog(actionable_dialog);
dialog_set_text(dialog, "Custom Actionable Dialog");
dialog_set_background_color(dialog, GColorRed);
dialog_set_icon(dialog, data->resource_id_80);
// Create custom action bar for the dialog.
// TODO destroy action bar / icon in unload callback
Action... | dialog_show_status_bar_layer(dialog, true) | |
Mode_PWM2 << 8);
// The timer forces the pin high when the counter is greater than
// or equal to this value. Since ARR is 63999, this means the
// pin will be high for exactly one tick of the timer (~16 us)
TIM3->CCR4 = 63999;
// Enable channel 4
TIM3->CCER = TIM_CCER_CC4E;
// Hook up the VCOM pin's a... | {
memcpy(buffer[i + y_offset] + x_offset, bitmap + i * width, width);
} |
}
static void prv_display_buffer(uint8_t buffer[DISP_ROWS][DISP_LINE_BYTES]) {
prv_display_start_write();
for (int i = 0; i < DISP_ROWS; i++) {
prv_display_write_line(i, buffer[i]);
}
prv_display_end_write();
}
void display_boot_splash(void) {
uint8_t buffer[DISP_ROWS][DISP_LINE_BYTES];
// Draw black... |
id) {
uint8_t scale_reg_val = bmi160_read_reg(BMI160_REG_ACC_RANGE) & 0xf;
if (scale_reg_val == BMI160_ACC_RANGE_2G) {
return BMI160_SCALE_2G;
} else if (scale_reg_val == BMI160_ACC_RANGE_4G) {
return BMI160_SCALE_4G;
} else if (scale_reg_val == BMI160_ACC_RANGE_8G) {
return BMI160_SCALE_8G;
} el... | prv_get_curr_system_time_ms() | * 1000;
uint32_t time_since_data_collection_us = prv_get_time_since_sample(sensor_time);
BMI160_DBG("%"PRIu32" us delay since sample was collected",
time_since_data_collection_us);
return (curr_time_us - time_since_data_collection_us);
}
static void prv_read_curr_accel_data(AccelDriverSample *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... | {
GRect r = {
.size.w = glyph->header.width_px,
.size.h = glyph->header.height_px,
.origin.x = glyph->header.left_offset_px,
.origin.y = glyph->header.top_offset_px
};
return r;
} |
/// This function returns the x coordinate of where to write the contents of a given word (32-bits)
/// of data from the 1-bit frame buffer into the 8-bit framebuffer
/// @param dest_bitmap 8-bit destination frame buffer bitmap
/// @param block_addr source address in 1-bit frame buffer of where the word is being upda... |
| RCC_APB2Periph_SYSCFG
| RCC_APB2Periph_TIM9
| RCC_APB2Periph_TIM10
| RCC_APB2Periph_TIM11;
RCC_APB2PeriphResetCmd(apb2_periphs, ENABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE);
}
static void __attribute__((noreturn)) prv_jump_to_fw(void) {
void *initial_stack_pointer, *reset_handler;
prv_... | (BOOT_BIT_FW_START_FAIL_STRIKE_ONE) | ) {
dbgserial_putstr("Boot failed, strike 2");
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
} else {
dbgserial_putstr("Boot failed, strike 1");
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
}
return false;
}
static bool prv_check_force_boot_recovery(void) {
if (boot_bit_test(BOOT_BIT_FO... |
2_16_add(num1, num2);
sum_c = (Fixed_S32_16){ .raw_value = (int32_t)((float)-5 * (1 << FIXED_S32_16_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
// sum = -2 + 5 = 3
num1 = (Fixed_S32_16){ .raw_value = (int32_t)((float)-2 * (1 << FIXED_S32_16_PRECISION)) };
num2 = (Fixed_S32_16){ .raw_value = (... | cl_assert(mul.raw_value == mul_c.raw_value) | ;
// -2.5*-3.3 ==> 163840 * 216268.8 = 163840 * 216268 ==> 35433349120 / 65536 ==> 540670 ~= 8.25
num1 = (Fixed_S32_16){ .raw_value = (int32_t)((float)-2.5 * (1 << FIXED_S32_16_PRECISION)) };
num2 = (Fixed_S32_16){ .raw_value = (int32_t)((float)-3.3 * (1 << FIXED_S32_16_PRECISION)) };
mul = Fixed_S32_16_mul(nu... |
nt16_t);
cl_assert(BLOB_DB_SUCCESS == *resp_ptr);
resp_ptr += sizeof(uint8_t);
cl_assert((resp_ptr - s_data) == s_sending_data_length);
}
/*************************************
* Checking for valid DELETE command *
*************************************/
static const uint8_t s_delete_cmd_success[] = {
// M... | cl_assert(BLOB_DB_INVALID_OPERATION == *resp_ptr) | ;
resp_ptr += sizeof(uint8_t);
cl_assert((resp_ptr - s_data) == s_sending_data_length);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// BLOBDB SYNC TESTS
///////////////////////////////////////////////////////////////////////////////////////////////////
st... |
/*
* 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_dump_bonding(bonding) | ;
if (bonding->flags & BleBondingFlag_IsReversedPPoGATTEnabled) {
// Trigger GATT service rediscovery to find the emulated PPoGATT server
gatt_client_discovery_discover_all(address);
}
}
void bonding_sync_handle_hc_remove(const BleBonding *bonding) {
PBL_LOG(LOG_LEVEL_ERROR, "Controller isn't supposed t... |
/*
* 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... | (bg_color) | ) {
graphics_context_set_fill_color(ctx, bg_color);
graphics_fill_rect(ctx, &image->layer.bounds);
}
graphics_context_set_compositing_mode(ctx, image->compositing_mode);
if (image->bitmap != NULL) {
const GSize size = image->bitmap->bounds.size;
const bool clips = true; // bitmap layer not allowe... |
/*
* 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... | rocky_runtime_context_deinit() | ;
fake_pbl_malloc_check_net_allocs();
s_log_internal__expected = NULL;
}
////////////////////////////////////////////////////////////////////////////////
// Helpers for Tests
////////////////////////////////////////////////////////////////////////////////
static void prv_do_call_user_function(const char *script)... |
{ 24, -24, -992},
{ 32, 8, -992},
{ 24, -16, -984},
{ 32, -16, -1024},
{ 32, -24, -984},
{ 32, 0, -992},
{ 32, -24, -984},
{ 32, -8, -992},
{ 32, -24, -992},
{ 32, -32, -992},
{ 32, 0, -984},
{ 24, -8, -1000},
{ 32, -16, -968},
{ 32, -40, -976},
{ 24, -80, -100... | { -104, -312, -976},
{ -184, -256, -944},
};
*len = ARRAY_LENGTH(samples);
return samples;
} |
// ----------------------------------------------------------------
// Sample captured: 2015-10-02 16:18:13 local
AccelRawData *activity_sample_non_walk_pbl_25482_14(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME non_walk_pbl_25482_14
//> TEST_EXPECTED 0
//> T... |
,{1189036800,"36","07"},{1189123200,"36","07"},
{1189209600,"36","07"},{1189296000,"36","07"},{1189382400,"37","07"},{1189468800,"37","07"},{1189555200,"37","07"},{1189641600,"37","07"},{1189728000,"37","07"},
{1189814400,"37","07"},{1189900800,"37","07"},{1189987200,"38","07"},{1190073600,"38","07"},{1190160000,"3... | strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00) | ;
cl_assert_equal_s(tmbuf, "+0010");
jan_2_2015__13_00_00.tm_gmtoff = 3600;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "+0100");
jan_2_2015__13_00_00.tm_gmtoff = 4200;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_0... |
_out), 0);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! BT Classic Pairing Info
void test_bluetooth_persistent_storage__bt_classic_store_and_get(void) {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char name_o... | cl_assert_equal_s(name_2, name_out) | ;
cl_assert_equal_i(platform_bits_2, platform_bits_out);
// Add a thrid pairing
BTDeviceAddress addr_3 = {{0x31, 0x32, 0x33, 0x34, 0x35, 0x36}};
SM128BitKey link_key_3 = {{0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}};
char name_... |
lude "fake_spi_flash.h"
#include "fake_system_task.h"
// We start time out at 5pm on Jan 1, 2015 for all of these tests
static const struct tm s_init_time_tm = {
// Thursday, Jan 1, 2015, 5:pm
.tm_hour = 17,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
#define ACTIVITY_FIXTURE_PATH "activity"... | {
while (s_queue_value <= 0) {
fake_system_task_callbacks_invoke_pending();
}
s_queue_value--;
return true;
} |
signed portBASE_TYPE xQueueGenericSend(QueueHandle_t xQueue, const void * const pvItemToQueue,
TickType_t xTicksToWait, portBASE_TYPE xCopyPosition) {
PBL_ASSERTN(xQueue == QUEUE_HANDLE);
s_queue_value++;
return true;
}
QueueHandle_t xQueueGenericCreate(unsigned portBASE_... |
if (s_power_state == PowerStateCritical) {
// Still critical after timeout, transition to standby
prv_transition(PowerStateStandby);
} |
}
static void prv_begin_standby_timer(void) {
PBL_LOG_COLOR(LOG_LEVEL_INFO, BATT_LOG_COLOR, "Battery critical: begin standby timer");
// If the watch was already running, give them 30s, otherwise just 2s.
uint32_t standby_timeout = (s_first_run) ? 2000: 30000;
new_timer_start(s_standby_timer_id, standby_timeo... | |
ack lines
// The bottom half consists of a diagonal white line on a black background
void test_bitblt_palette_1bit__2bit_palette_to_1bit_assign(void) {
GBitmap *src_bitmap =
get_gbitmap_from_pbi("test_bitblt_palette_1bit__2bit_palette_to_1bit.pbi");
bitblt_bitmap_into_bitmap(&s_dest_bitmap, src_bitmap, GP... | cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorDarkGray, 0), 0x55555555) | ;
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorDarkGray, 1), 0xAAAAAAAA);
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorBlack, 0), 0x00000000);
cl_assert_equal_i(graphics_private_get_1bit_grayscale_pattern(GColorBlack, 1), 0x00000000);
}
void test_bitblt_palette_1bit_... |
te) {
return (VibeNote *)notes_attribute->data;
}
static VibeNoteIndex *prv_vibe_score_get_pattern_list(GenericAttribute *pattern_attribute) {
return (VibeNoteIndex *)pattern_attribute->data;
}
static unsigned int prv_vibe_score_get_num_note_types(GenericAttribute *notes_attribute) {
return notes_attribute->len... | {
return NULL;
} |
VibeScore *vibe_score = applib_zalloc(data_size);
if (!vibe_score || sys_resource_load_range(app_num, resource_id, VIBE_DATA_OFFSET,
(uint8_t*)vibe_score, data_size) != data_size) {
applib_free(vibe_score);
return NULL;
}
// Validate the loaded command seq... |
d), first_event);
TimerID first_timer = wakeup_get_current();
// Schedule another a minute away
time_t second_event = sys_get_time() + WAKEUP_EVENT_WINDOW * 2;
WakeupId second_wakeup_id = sys_wakeup_schedule(second_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(second_wakeup_id), second_event);
Tim... | (first_timer) | , E_DOES_NOT_EXIST);
}
|
iveWindow *active_window, void *i18n_owner) {
GRect label_box = *box;
GTextOverflowMode overflow_mode = GTextOverflowModeWordWrap;
if (metric_type == WorkoutMetricType_Custom) {
// I seriously have no idea why the height is hardcoded to 40 and overflow is set to word
// wrap when there's a note that says ... | (text_node) | ;
}
static void prv_static_layer_update_proc(struct Layer *layer, GContext *ctx) {
WorkoutActiveWindow *active_window = window_get_user_data(layer_get_window(layer));
WorkoutMetricType metric_type = WorkoutMetricType_None;
if (layer == &active_window->top_metric_layer) {
metric_type = active_window->top_met... |
},
{ 1352, 744, -176},
// 50 seconds
{ 1128, 704, -248},
{ 1256, 656, -240},
{ 1744, 616, -200},
{ 1928, 416, -88},
{ 1600, 232, -48},
{ 1296, 232, -72},
{ 1072, 264, -96},
{ 904, 224, -80},
{ 752, 152, -64},
{ 656, 104, -16},
{ 432, -168, -24},
{ 520, -160, -64},... | { 840, 648, -104},
{ 888, 760, -192},
{ 864, 784, -232},
{ 824, 744, -280},
{ 888, 728, -304},
{ 888, 680, -288},
{ 1080, 608, -232},
{ 1408, 664, -272},
{ 1280, 656, -304},
{ 1600, 488, -144},
{ 1760, 456, -80},
{ 1640, 368, -152},
{ 1288, 280, -88},
// 56 second... |
{ 1496, 624, -376},
{ 1424, 576, -184},
{ 1680, 600, -96},
{ 1976, 512, -32},
{ 1656, 352, 64},
{ 1400, 248, 96},
{ 1232, 256, 64},
{ 1080, 240, 72},
{ 896, 216, -8},
{ 744, 152, -64},
{ 608, 32, -80},
{ 536, -16, -72},
{ 568, -16, -160},
{ 616, -120, -208},
... |
/*
* 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... | (&hdr, sizeof(hdr)) | ;
}
static void prv_send_footer(void) {
QemuCommChannelFooter footer = (QemuCommChannelFooter) {
.signature = htons(QEMU_FOOTER_SIGNATURE)
};
prv_send_bytes(&footer, sizeof(footer));
}
// ------------------------------------------------------------------------------------
// Tests
void test_qemu_serial__fo... |
nclude "fake_new_timer.h"
#include "fake_battery.h"
#include "fake_system_task.h"
#include "fake_rtc.h"
#include "kernel/events.h"
#include "system/logging.h"
#include "system/reboot_reason.h"
static bool s_entered_standby;
static bool s_in_low_power;
static bool s_error_window_shown;
static bool s_warning_window_sho... | cl_assert(delta_percent < (INT32_MIN + 100)) | ;
}
// Check that the percentage reported is somewhat protected from transient voltage changes
void test_battery_monitor__charge_fluctuate_voltage(void) {
int high_percent = 70;
int low_percent = 20;
int high_mv = battery_curve_lookup_voltage_by_percent(high_percent, true);
int low_mv = battery_curve_lookup_vo... |
RIx32" to value 0x%"PRIx16,
stress_addr2, stress_data2);
flash_write_bytes((uint8_t *)&stress_data2, stress_addr2, sizeof(stress_data2));
return FLASH_TEST_SUCCESS;
}
// Run address read/write stess test - if iterations is 0, then stop only when button is pushed;
// else go until iterations hit
stati... | if (ticks[0] > ticks[1]) {
SWAP(ticks[0], ticks[1]);
} |
if (ticks[1] > ticks[2]) {
SWAP(ticks[1], ticks[2]);
if (ticks[0] > ticks[1]) {
SWAP(ticks[0], ticks[1]);
}
}
PBL_LOG(LOG_LEVEL_DEBUG, "Read %lu bytes, median throughput %lu KBps", num_bytes, (num_bytes * 1000 * 64 / ticks[1]));
}
app_free(read_buffer);
return FLASH_... |
le_dialog_create("Simple Vibe Dialog");
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
dialog_set_text(dialog, "A Simple Dialog For Flow Testing!\nHello!");
dialog_set_background_color(dialog, GColorLavenderIndigo);
dialog_set_icon(dialog, data->resource_id_80);
dialog_set_vibe(dialog, true);
dia... | dialog_set_background_color(dialog, GColorRed) | |
4},
{ 1016, -32, 72},
{ 1016, -16, 64},
// 72 seconds
{ 1008, 64, 32},
{ 1072, -8, 48},
{ 976, -32, 48},
{ 984, -40, 24},
{ 968, -80, -16},
{ 968, -72, 0},
{ 1016, -56, -32},
{ 1048, -56, -64},
{ 1352, -88, -16},
{ 1520, -72, -48},
{ 1208, 8, -136},
{ 792, 8, ... | { 984, -96, -160},
{ 872, -104, -232},
{ 912, -136, -264},
{ 984, -168, -256},
{ 1016, -184, -240},
{ 984, -152, -256},
{ 968, -176, -256},
{ 1008, -184, -208},
{ 1072, -152, -168},
{ 1096, -96, -128},
{ 1056, -88, -128},
{ 1104, -88, -72},
// 78 seconds
{ 1208, -... |
{ 1008, -184, 112},
{ 1064, -160, 184},
{ 1072, -248, 280},
{ 1056, -216, 320},
{ 1000, -216, 336},
{ 960, -208, 328},
{ 1248, -192, 360},
{ 1424, -152, 336},
{ 1200, -232, 368},
{ 1056, -344, 384},
{ 960, -360, 416},
{ 912, -416, 344},
{ 1000, -456, 336},
{ 1032... |
/*
* 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... | PBL_LOG(LOG_LEVEL_INFO, "Notification added: %s", uuid_string) | ;
notifications_handle_notification_added(id);
}
timeline_item_free_allocated_buffer(¬ification);
return S_SUCCESS;
}
int notif_db_get_len(const uint8_t *key, int key_len) {
if (key_len < UUID_SIZE) {
return 0;
}
return notification_storage_get_len((Uuid *)key);
}
status_t notif_db_read(const... |
en(&fd, key, key_len) == (int)data_len) {
uint8_t curr_val[data_len];
settings_file_get(&fd, key, key_len, &curr_val[0], data_len);
// Don't bother rewriting the exact same info. Pairing info is precious,
// we want to minimize cases where we could mess it up
if (memcmp(&curr_v... | if (shared_prf_storage_get_local_device_name(name, BT_DEVICE_NAME_BUFFER_SIZE)) {
bt_persistent_storage_set_local_device_name(name, BT_DEVICE_NAME_BUFFER_SIZE);
} |
SM128BitKey keys[SMRootKeyTypeNum];
if (shared_prf_storage_get_root_key(SMRootKeyTypeEncryption, &keys[SMRootKeyTypeEncryption]) &&
shared_prf_storage_get_root_key(SMRootKeyTypeIdentity, &keys[SMRootKeyTypeIdentity])) {
#if !defined(RELEASE) && !defined(PLATFORM_TINTIN)
PBL_LOG(LOG_LEVEL_INFO, "Loading ... |
lli Balamarugan", dest, buffer_length);
cl_assert_equal_s(dest, "Pankajava");
cl_assert_equal_m(dest + buffer_length, GUARD_REFERENCE, NAME_LENGTH - buffer_length);
}
void test_phone_formatting__overflowing_space(void) {
const size_t buffer_length = 10;
char dest[NAME_LENGTH];
memset(dest, GUARD_CHAR, NAME_... | (dest, "030 90 26 0") | ;
}
|
partially_overwritten_record_pos);
set_flag(&file->iter.hdr, SETTINGS_FLAG_OVERWRITE_COMPLETE);
settings_raw_iter_write_header(&file->iter, &file->iter.hdr);
}
return S_SUCCESS;
}
static status_t bootup_check(SettingsFile* file) {
return cleanup_partial_transactions(... | settings_raw_iter_write_key(&file->iter, key) | ;
settings_raw_iter_write_val(&file->iter, val);
// Mark the new record as write complete, now that we have completely written
// out the header, key, and value.
set_flag(&new_hdr, SETTINGS_FLAG_WRITE_COMPLETE);
settings_raw_iter_write_header(&file->iter, &new_hdr);
file->used_space += rec_size;
// Fina... |
LEVEL_DEBUG, "Received a command packet of type %" PRIu8
" which is not supported by this implementation.",
(uint8_t)packet->s.kind);
// Pretend it is an RR packet
}
prv_process_ack(packet->s.ack_number);
if (packet->s.poll_or_final) {
prv_send_supervisory_response(Su... | (LOG_LEVEL_DEBUG, "Reached maximum number of retransmit attempts.") | ;
prv_bounce_ncp_state();
}
}
static void prv_start_retransmit_timer(uint8_t sequence_number) {
pulse2_reliable_retransmit_timer_start(
RETRANSMIT_TIMEOUT_MS, sequence_number);
}
static void prv_assert_reliable_buffer(void *buf) {
PBL_ASSERT(buf == &s_tx_buffer->information[0],
"The passe... |
sults_window_unload(Window *window) {
HealthAPITestAppData *data = window_get_user_data(window);
text_layer_destroy(data->results_card.text_layer);
}
// -------------------------------------------------------------------------------
static void prv_hr_select_click_handler(ClickRecognizerRef recognizer, void *con... | health_service_set_heart_rate_sample_period(0 /*interval_s*/) | ;
}
// -----------------------------------------------------------------------------------------
static void prv_debug_cmd_step_history(int index, void *context) {
HealthAPITestAppData *data = context;
prv_display_scalar_history_alert(data, "Steps", HealthMetricStepCount);
}
// ---------------------------------... |
0),
.expected_output = true,
},
{
.input = jerry_create_object(),
.expected_output = true,
},
{
.input = jerry_create_external_function(prv_dummy),
.expected_output = true,
},
};
for (int i = 0; i < ARRAY_LENGTH(cases); ++i) {
bool output = !cases[i].expected_o... | (-32768, -32768, 32767, 32767) | ,
},
{
.argv = {
[0] = jerry_create_number(0),
[1] = jerry_create_number(0),
[2] = jerry_create_number(0),
[3] = jerry_create_number(4096.0),
},
.argc = 4,
.error_msg = "TypeError: Argument at index 3 is invalid: Value out of bounds for native type",
}... |
/*
* 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... | kino_player_set_reel_with_resource(&kino_layer->player, resource_id) | ;
}
void kino_layer_set_reel_with_resource_system(KinoLayer *kino_layer, ResAppNum app_num,
uint32_t resource_id) {
kino_player_set_reel_with_resource_system(&kino_layer->player, app_num, resource_id);
}
KinoReel *kino_layer_get_reel(KinoLayer *kino_layer) {
return ki... |
roperty_animation->subject, result);
}
// -----------------------------------------------------------------------------------------
void property_animation_update_fixed_s32_16(PropertyAnimation *property_animation_h,
const uint32_t distance_normalized) {
PBL_ASSERTN(!anim... | } else if (property_animation->animation.implementation->update
== (AnimationUpdateImplementation)property_animation_update_grect) {
property_animation->values.to.grect = to_value ? *((GRect*)to_value)
: implementation->accessors.getter.grect(subject);
... |
: implementation->accessors.getter.gcolor8(subject);
property_animation->values.from.gcolor8 = from_value ? *((GColor8*)from_value)
: implementation->accessors.getter.gcolor8(subject);
} else if (property_animation->animat... |
;
const WindowTransitionImplementation *window_transition_get_default_pop_implementation() {
return &window_transition_default_pop_implementation;
}
Animation *window_transition_default_push_create_animation(WindowTransitioningContext *context) {
window_transition_context_disappear(context);
window_transition_c... | (PebbleTask_KernelMain) | ;
}
void test_window_stack__cleanup(void) {
stub_pebble_tasks_set_current(PebbleTask_App);
app_window_stack_pop_all(false);
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
modal_manager_pop_all();
fake_animation_cleanup();
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
// Tests
/////... |
/*
* 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... | text_layer_set_text(text, ALL_CODEPOINTS) | ;
// Trim text layer and scroll content to fit text box
GSize max_size = text_layer_get_content_size(app_state_get_graphics_context(), text);
text_layer_set_size(text, max_size);
static const int vert_scroll_padding = 4;
scroll_layer_set_content_size(scroll_layer, GSize(144, max_size.h + vert_scroll_padding)... |
hdr->val_len;
}
// Flags are stored in flash the inverse of how you might normally expect- a
// zero denotes that the flag is set, a 1 means it is not. This is because our
// flash chip is NOR flash, and thus is all 1's by default.
// Once setting a flag, we cannot unset it.
static void set_flag(SettingsRecordHeader ... | if (partially_overwritten(hdr)) {
// The only case where we should hit this is if we are compacting a file
// which has a record which was in the middle of being overwritten, but
// the write of the new record didn't finish by the time we rebooted.
// There should only ever be one such record, a... |
// Get the old key and value
uint8_t *key = kernel_malloc(hdr->key_len);
settings_raw_iter_read_key(&file->iter, key);
uint8_t *val = kernel_malloc(hdr->val_len);
settings_raw_iter_read_val(&file->iter, val, hdr->val_len);
// Include in re-written file if it passes the filter
if (!filter_... |
// start light
{ 0, 0x34, 0},
{ 0, 0x34, 0},
{ 0, 0x34, 0},
{ 0, 0x75, 16},
{ 0, 0x76, 6},
// 180: Local time: 12:14:00 AM
{ 0, 0x76, 0},
{ 0, 0x86, 19},
{ 0, 0x7d, 3},
{ 0, 0x7d, 3},
{ 0, 0x7d, 0},
{ 0, 0x7d, 0},
{ 0, 0x7d, 0},
{ 0, 0x7d, 0},
{ 0, 0x7d, 0... | { 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 5},
// 330: Local time: 02:44:00 AM
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},... |
{ 0, 0x63, 0},
{ 0, 0x63, 0},
{ 0, 0x73, 30},
{ 0, 0x64, 0},
{ 0, 0x64, 0},
{ 0, 0x64, 0},
{ 0, 0x64, 0},
{ 0, 0x64, 0},
{ 0, 0x64, 0},
// 405: Local time: 04:00:00 AM
{ 0, 0x64, 35},
{ 0, 0x66, 47},
{ 0, 0x68, 0},
{ 0, 0x67, 36},
{ 0, 0x66, 16},
{ 0, 0x6... |
1].id, 1);
cl_assert_equal_i(item->action_group.actions[1].type, TimelineItemActionTypeGeneric);
cl_assert_equal_i(item->action_group.actions[1].attr_list.num_attributes, 2);
cl_assert_equal_i(item->action_group.actions[1].attr_list.attributes[0].id, AttributeIdTitle);
cl_assert_equal_s(item->action_group.actio... | ("", string_list_get_at(list, 1)) | ;
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s(NULL, string_list_get_at(list, 3));
// 4 strings (first and last two are empty)
list->serialized_byte_length = 4;
list->data[0] = '\0';
list->data[1] = 'b';
list->data[2] = '\0';
list->data[3] = '\0'; // end of data
list->data[4]... |
ght_grey, transparent)
// Tests 1-bit jazzberry_jam colored palettized PNG loading into gbitmap
// tests covers an old bug in image tooling where 1 color was 2 power 0
// so bitdepth was detected as 0 (incorrectly)
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_1_bit_jazzberry_jam(void) {
... | (1bitpalette) | |
/*
* 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... | cl_assert_equal_i(num_intervals, 2) | |
/*
* 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... | (&layout->icon_layer, (KinoLayerCallbacks) {}, NULL) | ;
kino_layer_set_reel(&layout->icon_layer, reel, true);
}
static void prv_continue_reel(TimelineLayout *layout, KinoReel *new_reel, uint32_t start) {
const uint32_t duration = kino_reel_get_duration(new_reel);
if (duration > start) {
kino_layer_play_section(&layout->icon_layer, start, duration);
}
}
stati... |
yright 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... | (LLC_OUTMSG_UNKNOWN_PROTOCOL_NUMBER, protocol, packet,
length) | ;
}
void prv_handle_change_baud(void *body, size_t body_length) {
if (body_length != sizeof(uint32_t)) {
// Don't send a response; the client will have already changed its receiver
// baud rate.
return;
}
uint32_t *new_baud = body;
pulse_change_baud_rate(*new_baud);
}
|
LOCK_HAND_STYLE_ROUNDED_WITH_HIGHLIGHT:
default:
prv_draw_watch_hand_rounded(ctx, hand, center);
break;
}
}
static GPointPrecise prv_get_clock_center_point(ClockLocation location, const GRect *bounds) {
GPoint imprecise_center_point = {0};
switch (location) {
case CLOCK_LOCATION_TOP:
im... | gbitmap_create_with_resource(data->clock_model.bg_bitmap_id) | ;
}
static void prv_window_unload(Window *window) {
MultiWatchData *data = app_state_get_user_data();
gpath_destroy(data->hour_path);
gpath_destroy(data->minute_path);
gbitmap_destroy(data->bg_bitmap);
}
static void prv_app_did_focus(bool did_focus) {
if (!did_focus) {
return;
}
app_focus_service_un... |
address_and_irk(&e);
gap_le_connection_by_device(&device);
// Register connection intent for app:
gap_le_connect_connect_by_bonding(bonding_id,
true /* no auto_reconnect */,
true /* is_pairing_required */,
... | prv_dummy_device(1) | ;
gap_le_connect_connect(&device,
false /* no auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientApp);
gap_le_connect_deinit();
// Connection intents survive air-plane mode:
cl_assert_equal_i(gap_le_connect_connection_intents_... |
(window_layer, text_layer_get_layer(text_layer)) | ;
}
static void window_unload(Window *window) {
text_layer_destroy(text_layer);
}
static void init(void) {
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animate... | |
law or agreed to in writing, software
* distributed under the License is distributed 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 "applib/ui/app_win... | {
return &window_transition_default_pop_implementation;
} |
Animation *window_transition_default_push_create_animation(WindowTransitioningContext *context) {
window_transition_context_disappear(context);
window_transition_context_appear(context);
return animation_create();
}
const WindowTransitionImplementation window_transition_default_push_implementation = {
.creat... |
/*
* 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... | {
case SDL_QUIT:
keypress = 1;
break;
case SDL_KEYDOWN:
keypress = 1;
break;
} |
}
}
}
|
k(AnimationCurveFunction ptr) {
uintptr_t bits = (uintptr_t)ptr;
uint8_t top_byte = bits >> 24;
PBL_ASSERTN((top_byte & 0b11000100) == 0); // Function pointer outside of packable range!
top_byte = ((top_byte & 0b00111000) >> 1) | (top_byte & 0b11);
bits = (top_byte << 24) | (bits & 0xffffff);
bits >>= 1;
... | PBL_ASSERTN(animation != NULL) | ;
PBL_ASSERTN(animation->implementation->update != NULL);
if (animation_legacy2_is_scheduled(animation)) {
animation_legacy2_unschedule(animation);
}
const uint32_t now = animation_legacy2_get_ms_since_system_start();
animation->abs_start_time_ms = now + animation->delay_ms;
if (animation->implementat... |
/*
* 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... | GSize(25, 25) | ;
GPoint c0_points[] =
{ {10, 4}, {13, 1}, {19, 1}, {23, 6}, {23, 13}, {1, 13}, {1, 8}, {4, 4}};
GPoint c1_points[] =
{{7, 7}, {13, 1}, {19, 1}, {23, 6}, {23, 13}, {1, 13}, {1, 8}, {4, 4}, {10, 4}};
GPoint c2_points[] = {{1, 19}, {7, 13}};
GPoint c3_points[] = {{3, 24}, {14, 13}};
GPoint c... |
/*
* 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... | PBL_ASSERTN(s_timer == TIMER_INVALID_ID) | ;
s_app_started = true;
#ifndef NO_WATCH_TIMEOUT
prv_start_timer(true /* create a timer */);
#endif
}
void app_idle_timeout_stop(void) {
if (s_timer != TIMER_INVALID_ID) {
new_timer_delete(s_timer);
s_timer = TIMER_INVALID_ID;
s_app_started = false;
}
}
void app_idle_timeout_pause(void) {
if (s... |
i < s_command_list_index; ++i) {
cl_assert_equal_i(s_command_list[i].addr, commands[i].addr);
cl_assert_equal_i(s_command_list[i].type, commands[i].type);
}
}
static int s_dummy_value = 42;
static int *s_callback_ctx = &s_dummy_value;
static void prv_callback(void *context, status_t status) {
cl_assert_eq... | (
0, 0, 69 * 1024, 96 * 1024,
(EraseCommand[]) {
{ 0, SectorEraseCommand },
{ 64 * 1024, SubsectorEraseCommand },
{ 68 * 1024, SubsectorEraseCommand },
{ },
}) | ;
}
void test_flash_erase__96k_app_banks_3(void) {
// App that's in an unaligned bank but smaller than 64k
prv_test_erase_optimal_range(
32 * 1024, 32 * 1024, (32 + 18) * 1024, (32 + 96) * 1024,
(EraseCommand[]) {
{ 32 * 1024, SubsectorEraseCommand },
{ 36 * 1024, SubsectorEraseComm... |
----------------------------------------------------------------------------------
typedef struct SetAlarmTimeContext {
int hour;
int minute;
} SetAlarmTimeContext;
static bool prv_set_alarm_time_op(AlarmId id, AlarmConfig *config, void *context) {
SetAlarmTimeContext *ctx = context;
if (config->kind == ALARM_... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Canceling snooze timer because alarm was disabled");
// Harmless if the alarm is not currently snoozing - the snooze timer still exists to be stopped
prv_clear_snooze_timer();
} | |
gsVibePatternsData;
static void prv_log_analytic_if_toggled(VibePatternFeature feature, VibeClient client,
SettingsVibePatternsData *data) {
if ((data->toggled_vibes_mask & feature) == feature) {
analytics_event_vibe_access(feature, alerts_preferences_get_vibe_score_for_cl... | vibe_intensity_get() | ;
const VibeIntensity next_system_default_vibe_intensity =
vibe_intensity_cycle_next(current_system_default_vibe_intensity);
// Set the next system default vibe intensity and vibe a short pulse so the user can feel it
vibe_intensity_set(next_system_default_vibe_intensity);
alerts_prefer... |
.expected_output = true,
},
{
.input = jerry_create_array(0),
.expected_output = true,
},
{
.input = jerry_create_object(),
.expected_output = true,
},
{
.input = jerry_create_external_function(prv_dummy),
.expected_output = true,
},
};
for (int i ... | (4095.875) | ,
},
.argc = 4,
.expected_output = PP(-32768, -32768, 32767, 32767),
},
{
.argv = {
[0] = jerry_create_number(0),
[1] = jerry_create_number(0),
[2] = jerry_create_number(0),
[3] = jerry_create_number(4096.0),
},
.argc = 4,
.error_msg = "T... |
/*
* 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... | jerry_get_number_value(js_seconds) | ,
.tm_min = (int)jerry_get_number_value(js_minutes),
.tm_hour = (int)jerry_get_number_value(js_hours),
.tm_mday = (int)jerry_get_number_value(js_mdays),
.tm_mon = (int)jerry_get_number_value(js_month),
.tm_year = (int)jerry_get_number_value(js_year) - 1900,
.tm_wday = (int)jerry_get_number_value... |
s_resources.h"
#include "stubs_syscalls.h"
extern size_t prv_get_list_max_command_size(GDrawCommandList *command_list);
static GColor s_fill_color;
static GColor s_stroke_color;
static uint8_t s_stroke_width;
static uint16_t s_path_num_points;
static GPoint *s_stroke_points = NULL;
static GPoint *s_fill_points = NULL... | (s_fill_points) | ;
s_fill_points = NULL;
}
if (s_precise_lines) {
free(s_precise_lines);
s_precise_lines = NULL;
}
}
// tests
void test_gdraw_command__draw_command_stroke(void) {
GDrawCommand *command = malloc(sizeof(GDrawCommand) + (sizeof(GPoint) * 2));
*command = (GDrawCommand){
.type = GDrawCommandTypePa... |
ng file in place\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_in_place", 4096));
uint8_t key[4];
int key_len = sizeof(key) - 1;
memcpy(key, "key", sizeof(key));
uint8_t val[4] = {0x11, 0x22, 0x33, 0x44};
int val_len = sizeof(val);
set_and_verify(&file, key, key_len, val, ... | // Force us to move to the record `search_for_idx` + 1
settings_raw_iter_next(&file.iter);
// We now are forced to start searching in the middle, wrap around, and continue searching
// from the beginning. This will result in us calling `settings_raw_iter_next` NUM_RECORDS - 1
// times.
before_count = setti... | |
/*
* 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... | tick_timer_service_unsubscribe() | ;
app_free(data);
}
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* progress_app_get_info() {
static const PebbleProcessMdSystem progress_app_info = {
.common.main_func = &s_main,
.name = "Progress Bar Test"
};
return (const PebbleProcessMd... |
rms_fired, 1);
s_current_day = s_saturday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
s_current_day = s_sunday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
s_current_day = s_monday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
s_curr... | alarm_create(&(AlarmInfo) { .hour = 13, .minute = 15, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_2 }) | ;
prv_assert_alarm_config(id2, 13, 15, false, ALARM_KIND_CUSTOM, schedule_2);
cl_assert_equal_i(s_num_alarms_fired, 1);
s_current_day = s_tuesday;
s_current_hour = 1;
s_current_minute = 0;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 2);
}
void test_alarm__disable_upcoming_alarm(void) {
... |
OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "recognizer.h"
#include "recognizer_impl.h"
#include "recognizer_list.h"
#include "recognizer_manager.h"
#include "recognizer_private.h"
#include "applib/appli... | PBL_ASSERTN(recognizer) | ;
if (recognizer->impl != impl) {
return NULL;
}
return recognizer->impl_data;
}
void recognizer_transition_state(Recognizer *recognizer, RecognizerState new_state) {
PBL_ASSERTN(recognizer);
PBL_ASSERTN(new_state < RecognizerStateCount);
PBL_ASSERTN(new_state != RecognizerState_Possible);
prv_set_s... |
{
return false;
} |
*addr = core_dump_get_slot_address(last_used_idx);
if (core_dump_size(*addr, size) != S_SUCCESS) {
return false;
}
*addr += sizeof(CoreDumpFlashRegionHeader);
return true;
}
static void prv_handle_flash_geometry_request(const void *payload, uint32_t length) {
if (length != sizeof(FlashGeometryRequest... | |
ect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, false, 2, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, 2));
setup_test(&context,... | graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10)) | ;
#if PBL_COLOR
ASSERT_CALLED(graphics_line_draw_stroked_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN));
#else
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN));
#endif
setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_rect... |
ActionBarLayerIconPressAnimationMoveUp);
action_bar_layer_set_icon_press_animation(data->action_bar,
BUTTON_ID_DOWN,
ActionBarLayerIconPressAnimationMoveDown);
action_bar_layer_add_to_w... | layer_add_child(background, text_layer_get_layer(text[TextHole])) | ;
// Par label.
text[TextParLabel] = text_layer_create(GRect(par_box_x_offset, par_label_y_offset,
stroke_box_width, label_height));
prv_setup_text_layer(text[TextParLabel], font_key_label, i18n_get("PAR", data),
GTextAlignmentCenter);
layer... |
e 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, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expre... | if (s_event_handler_map[tag].message_handler == message_handler &&
s_event_handler_map[tag].dropped_handler == dropped_handler) {
return tag;
} | |
esource_ids.auto.h"
#include "services/common/analytics/analytics.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "shell/prefs.h"
#include "system/passert.h"
#include "util/math.h"
static const int16_t MAX_OFFSET_MAGNITUDE = 10;
typedef enum {
DisplayCalibrationState_X_Adjust,
... | GSize(layer_bounds->size.w, stripe_width) | |
/*
* 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... | (!pstring_equal(NULL, NULL)) | ;
}
void test_pstring__equal_cstring(void) {
const char *str1 = "Phil";
uint8_t ps1_buf[128];
PascalString16 *ps1 = (PascalString16 *)&ps1_buf;
ps1->str_length = strlen(str1);
memcpy(ps1->str_value, str1, strlen(str1));
const char *str2 = "PhilG";
cl_assert(pstring_equal_cstring(ps1, str1));
cl_ass... |
x.lineTo(x2, b2);\n"
"\n"
" ctx.lineWidth = i;\n"
" ctx.stroke();\n"
"}\n"
"for (var i = 1; i <= 5; i++) {\n"
" ctx.beginPath();\n"
" var y1 = 40 + i * 20;\n"
" var y2 = y1 + 10.5;\n"
" ctx.moveTo(t1, y1);\n"
" ctx.lineTo(b1, y1);\n"
" ctx.moveTo(t1, y2);\... | gbitmap_pbi_eq(&s_context.dest_bitmap, TEST_NAMED_PBI_FILE("rocky_rendering_arc")) | |
/*
* 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... | dbgserial_print("Checksumming ") | ;
dbgserial_print_hex(firmware_description->firmware_length);
dbgserial_print(" bytes\r\n");
uint32_t calculated_crc = crc_calculate_bytes(
(const uint8_t*) FIRMWARE_BASE, firmware_description->firmware_length);
dbgserial_print("Checksum - wanted ");
dbgserial_print_hex(firmware_description->checksum)... |
option_menu_set_choice(&data->option_menu, prv_get_chosen_row_index(data));
// Switching to a different worker, display confirmation dialog
switch_worker_confirm(app_node->install_id, true /* set as default */,
app_state_get_window_stack());
} else {
// User sel... | app_free(data) | ;
}
static Window *prv_init(void) {
SettingsActivityTrackerData *data = app_zalloc_check(sizeof(SettingsActivityTrackerData));
const OptionMenuCallbacks option_menu_callbacks = {
.unload = prv_unload_cb,
.draw_row = prv_draw_row_cb,
.select = prv_select_cb,
.get_num_rows = prv_get_num_rows... |
n 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 "mfg_bt_test_app.h"
#include "applib/app.h"
#include "applib/fonts/fonts.h"
#include "applib/ui/ui.h"
#i... | window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler) select_single_click_handler) | ;
window_single_click_subscribe(BUTTON_ID_BACK, (ClickHandler) back_single_click_handler);
}
static void handle_init() {
AppData *data = task_malloc_check(sizeof(AppData));
app_state_set_user_data(data);
*data = (AppData) {
.test_state = BtTestStateInit,
.reset_timer = TIMER_INVALID_ID,
};
Windo... |
app_heap_analytics_log_native_heap_oom_fault(bytes, heap_ptr);
sys_app_fault(lr);
}
}
void NOINLINE app_crashed(void) {
// Just sit here and look pretty. The purpose of this function is to give app developers a symbol
// that they can set a breakpoint on to debug app crashes. We need to make sure this fu... | mcu_state_is_thread_privileged() | ) {
// We're hosed! We can't recover so just reboot everything.
RebootReason reason = { .code = RebootReasonCode_StackOverflow, .data8[0] = task };
reboot_reason_set(&reason);
reset_due_to_software_failure();
return;
}
// We got this! Let's redirect this task to a spin function and tell the app... |
gbitmap_create_blank_with_palette(GSize size, GBitmapFormat format,
GColor *palette, bool free_on_destroy) {
PBL_ASSERTN(!process_manager_compiled_with_legacy2_sdk());
if (!prv_platform_supports_format(size, format)) {
return NULL;
}
if (!prv_is_palettized_format(format)) {
return NULL;
}
GBi... | {
PBL_LOG(LOG_LEVEL_WARNING, "Bitmap metadata is inconsistent! data_size %u",
(unsigned int) data_size);
PBL_LOG(LOG_LEVEL_WARNING, "format %u row_size_bytes %"PRIu16" width %"PRId16" height %"PRId16,
format, bitmap->row_size_bytes, bitmap->bounds.size.w, bitmap->bounds.size.h);
retu... | |
out...
RtcTicks elapased_ticks = rtc_get_ticks() - s_manager_state.sensor_start_ticks;
RtcTicks max_startup_time = milliseconds_to_ticks(HRM_SENSOR_SPIN_UP_SEC * MS_PER_SECOND);
if (elapased_ticks >= max_startup_time) {
// If it's been past the tolerable startup time, we have a valid reading - even th... | if (!turn_sensor_on && hrm_is_enabled(HRM)) {
// Turn off the sensor now
HRM_LOG("Turning off HR sensor");
hrm_disable(HRM);
sys_accel_manager_data_unsubscribe(s_manager_state.accel_state);
s_manager_state.accel_state = NULL;
prv_is_sensor_stable(NULL); // inform state machine tha... |
}
mutex_unlock_recursive(s_manager_state.lock);
}
// Timer callback that we use to re-enable the HR sensor in case we turned it off for a while
static void prv_update_enable_timer_cb(void *context) {
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
}
//! The system task needs its own handler fo... |
ct bottom_bounds = label_text_container;
bottom_bounds.size.h = fade_height;
bottom_bounds.origin.y = grect_get_max_y(&label_text_container) -
(fade_height + VERTICAL_PADDING);
graphics_draw_bitmap_in_rect(ctx, &aml->item_animation.fade_bottom, &bottom_bounds);
}
#endif
}
sta... | if (prv_aml_is_short(aml)) {
return line_height;
} |
#if PBL_ROUND
return menu_layer_is_index_selected(menu_layer, cell_index) ?
MENU_CELL_ROUND_FOCUSED_SHORT_CELL_HEIGHT :
MENU_CELL_ROUND_UNFOCUSED_TALL_CELL_HEIGHT;
#else
const int16_t max_visible_height = line_height * MAX_NUM_VISIBLE_LINES;
const int16_t actual_height = aml->layout_cach... |
{ 56, 424, -824},
{ 32, 320, -808},
{ 40, 344, -888},
{ 64, 448, -928},
{ 112, 464, -976},
{ 136, 616, -904},
{ 176, 648, -872},
{ 200, 584, -824},
{ 216, 584, -800},
{ 224, 560, -816},
{ 208, 560, -896},
{ 184, 488, -928},
{ 160, 496, -904},
// 585 seconds
{ ... | { 472, 832, -456},
{ 472, 832, -456},
{ 480, 824, -464},
{ 472, 832, -472},
{ 472, 824, -464},
{ 472, 824, -464},
{ 488, 840, -472},
{ 488, 832, -456},
{ 480, 816, -448},
{ 456, 800, -464},
{ 448, 808, -480},
{ 472, 840, -512},
{ 496, 832, -488},
{ 520, 832, -472}... |
{ 472, 824, -472},
{ 472, 824, -464},
{ 472, 824, -472},
{ 472, 824, -472},
{ 464, 832, -480},
{ 464, 824, -464},
{ 480, 840, -456},
// 593 seconds
{ 464, 832, -456},
{ 464, 824, -488},
{ 480, 800, -496},
{ 496, 832, -464},
{ 472, 824, -448},
{ 448, 832, -472},
... |
/*
* 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... | (LOG_LEVEL_WARNING, "layer stack exceeded (%d). Will skip rendering.", stack_size) | ;
}
}
// no children, try next 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 = st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.