prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ept 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, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KI... | (&layer, &ctx) | |
, -8},
{ -928, 640, -248},
{ -1160, 672, -224},
{ -1376, 632, -344},
{ -1328, 648, -360},
{ -1360, 608, -352},
{ -1192, 480, -416},
{ -1080, 464, -232},
{ -864, 304, 16},
{ -608, 320, 24},
{ -528, 328, 48},
{ -520, 240, 128},
{ -512, 264, 112},
{ -592, 304, 88},
{... | { -1016, 184, -376},
{ -704, 32, -272},
{ -568, 120, -320},
{ -560, 208, -312},
// 107 seconds
{ -624, 208, -288},
{ -672, 240, -256},
{ -768, 304, -328},
{ -888, 280, -328},
{ -1072, 256, -288},
{ -1104, 200, -152},
{ -1616, 288, -256},
{ -1592, 256, -168},
{ -12... |
{ -736, 512, -264},
{ -1080, 592, -320},
{ -1216, 432, -136},
{ -1696, 600, -304},
{ -1376, 504, -184},
{ -976, 376, -232},
{ -1208, 432, -264},
{ -1288, 368, -160},
{ -1088, 184, -24},
{ -856, 192, -56},
{ -736, 232, -80},
{ -632, 144, -56},
{ -504, 32, -40},
{ ... |
pyright 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 writin... | if ((clipped_rect.origin.y == (rect.origin.y + rect.size.h) - radius) && (corner_mask & GCornersBottom)) {
if (corner_mask & GCornerBottomLeft) {
corner_insets_left = round_bottom_corner_lookup[radius];
}
if (corner_mask & GCornerBottomRight) {
corner_insets_right = round_bottom_corner... |
int32_t left_side = MAX((int32_t)(corner_insets_left & 0xf) - left_cropped_columns_count, 0);
int32_t right_side = MAX((int32_t)(corner_insets_right & 0xf) - right_cropped_columns_count, 0);
int32_t corner_insets = left_side + right_side;
int32_t width = corner_insets < clipped_rect.size.w ? (clipped... |
ayoutLayer *new_previous = prv_fetch_next_layout(swap_layer, -1);
// if there is no layout to swap up to, abort
if (!new_previous) {
return false;
}
swap_layer->previous = new_previous;
GRect prev_frame = swap_layer->previous->layer.frame;
const GRect *current_frame = &swap_layer->current->layer.fram... | (swap_layer, offset, AnimationCurveEaseOut) | |
ig *config,
bool render, GSize *size_out, void *user_data) {
const LayoutLayer *layout = user_data;
const int16_t horizontal_margin = 1;
const int16_t hr_height = 2;
GRect hr_box = GRectZero;
if (box && render) {
hr_box = grect_inset_internal(*box, horizontal... | ARRAY_LENGTH(s_time_vertical_config_nodes) | ,
.container.nodes = (LayoutNodeConfig **)&s_time_vertical_config_nodes,
};
static const LayoutNodeConfig * const s_horizontal_config_nodes[] = {
&s_icon_vertical_container_config.container.extent.node,
&s_time_vertical_container_config.container.extent.node,
};
static const LayoutNodeHorizontalConf... |
r
SerializedAppGlanceSliceHeader *serialized_slice_header =
(SerializedAppGlanceSliceHeader *)glance_buffer_cursor;
*serialized_slice_header = (SerializedAppGlanceSliceHeader) {
.type = current_slice->type,
.total_size = serialized_slice_total_size,
.num_attributes = attr_list->num_att... | {
rv = app_glance_db_insert((uint8_t *)uuid, UUID_SIZE, (uint8_t *)serialized_glance,
serialized_glance_size);
} | |
w);
if (!data || !finished) {
// We could have gotten cleaned up in the middle of an animation, bail
applib_free(anim_ctx);
return;
}
if (data->view_model.cur_level->parent_level == anim_ctx->next_level) {
--data->view_model.num_dots;
} else {
++data->view_model.num_dots;
}
data->view_m... | animation_get_duration(data->level_change_anim, true, true) | );
}
ActionMenuLevel *parent_level = data->view_model.cur_level->parent_level;
if (parent_level) {
prv_set_level(data, parent_level);
} else {
prv_action_window_pop(true, &data->action_menu);
}
}
static void prv_click_config_provider(void *context) {
ActionMenuData *data = context;
action_menu_l... |
n)->duration_ms * ANIMATION_NORMALIZED_MAX /
((AnimationPrivate*)animation)->abs_start_time_ms;
return true;
}
bool WEAK animation_get_elapsed(Animation *animation, int32_t *elapsed_ms) {
if (!animation) {
return false;
}
// For use in this stub, start time is 0, so anything past 0 is elapsed
*elap... | {
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, to_frame);
}
PropertyAnimation *WEAK property_animation_create(
const PropertyAnimationImplementation *implementation, void *su... |
r = (*iter)->next;
mutex_unlock_recursive(s_list_mutex);
if (logging_session->data) {
mutex_destroy(logging_session->data->mutex);
kernel_free(logging_session->data);
}
kernel_free(logging_session);
return;
}
iter = &((*iter)->next);
}
mutex_unlock_recursive(s_... | mutex_lock_recursive(s_list_mutex) | ;
DataLoggingSession *logging_session = s_logging_sessions;
while (logging_session != NULL) {
// Read the next pointer first, just in case the callback ends up removing the session.
DataLoggingSession *next_logging_session = logging_session->next;
if (!callback(logging_session, data)) {
mutex_un... |
er->common.persistent;
const bool old_is_persistent = old_header->common.persistent;
if (new_is_peeking != old_is_peeking) {
// Peeking items always take priority
return (old_is_peeking ? 1 : 0) - (new_is_peeking ? 1 : 0);
} else if (old_is_peeking && (new_is_persistent != old_is_persistent)) {
// Whe... | {
s_peek_event_data.show_before_time_s = before_time_s;
timeline_event_refresh();
} | |
lse {
cl_assert_equal_i(actual_resting_kcalories[i], exp_resting_kcalories[i]);
}
}
}
// ---------------------------------------------------------------------------------------
// Test that we correctly initialize the setting upon startup based on the stored settings file
void test_activity__settings(void... | time_util_get_midnight_of(rtc_get_time()) | ;
ActivitySession old_activity = {
.start_utc = day_start + 12 * SECONDS_PER_HOUR,
.length_min = 120,
.type = ActivitySessionType_Walk,
.step_data = {
.steps = 100,
.active_kcalories = 200,
.resting_kcalories = 300,
.distance_meters = 400,
},
};
ActivitySession new_acti... |
/*
* 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 (addr & SUBSECTOR_ADDR_MASK);
} |
static bool prv_prf_supports_flash_protection(void) {
#if IS_BIGBOARD
// Bigboards should always exercise flash protection
return true;
#else
FirmwareMetadata prf;
if (!version_copy_recovery_fw_metadata(&prf)) {
return false;
}
return (prf.version_timestamp > MIN_PRF_TIMESTAMP_SUPPORTING_PROTECTION);
... |
);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */);
resource_init();
prv_initialize_icons();
}
void test_menu_layer_system_cells__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_deinit(&s_tictoc_icon_bitmap);
gbitmap_deinit(&s_smart_alarm_icon_bi... | {
gpoint_add_eq(&config->icon->bounds.origin, GPoint(4, 4));
config->icon->bounds.size.w -= 8;
config->icon->bounds.size.h -= 8;
} |
}
switch (cell_type) {
case MenuCellType_Basic:
// These should be ignored, we want to make sure they are!
menu_cell_basic_draw(ctx, cell_layer, config->title, config->subtitle, config->icon);
break;
case MenuCellType_BasicCustom:
menu_cell_basic_draw_custom(
ctx, cell_lay... |
equal_i(2, menu_layer_get_selected_index(&l).row);
const int16_t basic_cell_height = menu_cell_basic_cell_height();
cl_assert_equal_i(2 * basic_cell_height, l.selection.y);
menu_layer_set_selected_next(&l, false, MenuRowAlignNone, false);
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).section);
cl_as... | {
cl_assert_equal_p(cell_layer->window, s_menu_layer_hierarchy.scroll_layer.layer.window);
cl_assert_equal_p(cell_layer->parent, &s_menu_layer_hierarchy.scroll_layer.content_sublayer);
const GPoint actual = layer_convert_point_to_screen(cell_layer, GPointZero);
const GPoint expected = layer_convert_point_to_scr... |
int prv_num_sublayers(const Layer *l) {
int result = 0;
Layer *child = l->first_child;
while (l) {
l = l->next_sibling;
result++;
}
return result;
}
void test_menu_layer__menu_cell_is_part_of_hierarchy(void) {
menu_layer_init(&s_menu_layer_hierarchy, &GRect(10, 10, 100, 180));
Layer *layer = &s... |
/*
* 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;
} |
static void prv_handle_response_from_phone(void *data) {
s_num_writebacks++;
BlobDBSyncSession *session = data;
blob_db_sync_next(session);
}
static void prv_generate_responses_from_phone(void) {
while (fake_system_task_count_callbacks()) {
fake_system_task_callbacks_invoke_pending();
}
}
BlobDBToke... |
ta.mutex);
}
static bool find_soonest_ack_timeout_cb(DataLoggingSession *session, void *data) {
RtcTicks *soonest_ack_timeout = (RtcTicks*) data;
if (session->comm.ack_timeout != 0
&& (session->comm.ack_timeout < *soonest_ack_timeout || *soonest_ack_timeout == 0)) {
*soonest_ack_timeout = session->comm.a... | if (num_bytes < 1) {
// not sending anything
return true;
} | |
* 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, software
* distributed u... | prv_wait_for_conversion(device->adc) | ) {
continue;
}
uint32_t vmon = ADC_GetConversionValue(device->adc);
// Only save values and increment counter if both reads were successful
reading_out->vref_total += vref;
reading_out->vmon_total += vmon;
++i;
}
ADC_Cmd(VREF_ADC, DISABLE);
if (!same_adc) {
ADC_Cmd(device->adc... |
// compiled to use the 3.0 animation API to work with 2.0 apps.
AnimationLegacy2Handlers *legacy_handlers = (AnimationLegacy2Handlers *)&handlers;
animation_legacy2_set_handlers((AnimationLegacy2 *)animation_h, *legacy_handlers, context);
return true;
}
AnimationPrivate *animation = prv_find_animation... | {
return false;
} |
animation->delay_ms = delay_ms;
return true;
}
// -------------------------------------------------------------------------------------------
uint32_t animation_get_delay(Animation *animation_h) {
if (animation_private_using_legacy_2(NULL)) {
// We need to enable other applib modules like scroll_layer, me... |
n_resources.h"
#include "resource/resource_storage_impl.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
uint32_t offset;
uint32_t length;
} Resource;
#define MANIFEST_SIZE (sizeof(ResourceManifest))
#define TABLE_ENTRY_SIZE (sizeof(ResTableEntry))
#define MAX_RESOURCES_FOR_SYSTEM_... | ("%s: Failed to read table entry for %d\n", __FILE__, resource_id) | ;
return false;
}
if ((entry.resource_id != resource_id) ||
(entry.length == 0)) {
// empty resource
printf("%s: Invalid resourcel for %d\n", __FILE__, resource_id);
return false;
}
res->offset = SYSTEM_STORE_METADATA_BYTES + entry.offset;
res->length = entry.length;
return true;
}
... |
GTextOverflowModeWordWrap);
#if PBL_ROUND
text_layer_enable_screen_text_flow_and_paging(subtext_layer, TEXT_FLOW_INSET_PX);
#endif
layer_add_child(&window->layer, &subtext_layer->layer);
}
if (show_action_bar) {
action_bar_layer_add_to_window(&workout_dialog->action_bar, window);
}
//... | (action_bar, context) | |
anup_and_send_response(ResponseCode code) {
// Save this value, as it'll be cleaned up by prv_cleanup but we'll need them to send the
// response. We want to cleanup first before sending the response so that we tell the phone
// that we're ready for the next message after we've done all of our housekeeping.
uin... | {
case PutBytesInit:
return offsetof(InitRequest, index);
case PutBytesPut:
return sizeof(PutRequest);
case PutBytesCommit:
return sizeof(CommitRequest);
case PutBytesAbort:
return sizeof(AbortRequest);
case PutBytesInstall:
return sizeof(InstallRequest);
default:
... |
}
static bool prv_has_invalid_request_length(const PutBytesCommand command, uint32_t actual_length) {
const size_t expected_length = prv_expected_minimum_length_by_command(command);
const bool has_invalid_length = (actual_length < expected_length);
if (has_invalid_length) {
PBL_LOG(LOG_LEVEL_ERROR,
... |
id test_bitblt_circular__color_1_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE);
GBitmap *native_framebuffer = graphics_context_get_bitmap(ctx);
cl_assert(native_framebuffer->info.format == GBitmapFormat8BitCircular);
cl_assert(DISPLAY_FRAMEBUFFER_BYTES == 25944);
bitblt_bitmap_into_bitmap(native... | (native_framebuffer) | |
Animation
///////////////////////////////
T_STATIC void prv_play_animation_update(Animation *animation, const AnimationProgress normalized) {
KinoPlayer *player = animation_get_context(animation);
int32_t animation_elapsed_ms = 0;
uint32_t elapsed_ms = 0;
uint32_t kino_reel_duration = kino_reel_get_duration(p... | {
Animation *animation = (Animation *)kino_player_create_play_animation(player);
if (animation) {
animation_schedule(animation);
}
} |
void kino_player_play_section(KinoPlayer *player, uint32_t from_elapsed_ms,
uint32_t to_elapsed_ms) {
if (player && player->reel) {
kino_reel_set_elapsed(player->reel, from_elapsed_ms);
prv_create_play_animation(player, from_elapsed_ms, to_elapsed_ms);
animation_schedule(pl... |
_t), (uint8_t *)&value, sizeof(uint32_t));
}
}
// ensure all values of every entry is equal to LOOPS
uint32_t desired_value = LOOPS;
settings_file_each(&file, prv_each_check_all_values, (void *)&desired_value);
}
void test_settings_file__manual_compaction_increment(void) {
printf("\nTesting manual file ... | if (j < 255) {
settings_file_delete(&file, key, key_len);
} |
}
printf("Making sure we handle running out of storage gracefully...\n");
memcpy(key, "k255", 5);
memcpy(val, "v255", 5);
cl_assert_equal_i(settings_file_set(&file, key, key_len, val, val_len), E_OUT_OF_STORAGE);
int val_len_out = settings_file_get_len(&file, key, key_len);
cl_must_pass(val_len_out);
u... |
n_menu, int selection, void *context) {
SettingsTimeData *data = ((SettingsOptionMenuData *)context)->context;
const uint16_t region_id = data->continent_start[data->continent_selected] + selection;
clock_set_timezone_by_region_id(region_id);
const bool continent_animated = false;
app_window_stack_remove(dat... | {
if (!clock_timezone_source_is_manual() && *new_row == TimeRow_Timezone) {
*new_row = old_row;
}
} |
static uint16_t prv_num_rows_cb(SettingsCallbacks *context) {
return TimeRowNum;
}
static void prv_deinit_cb(SettingsCallbacks *context) {
SettingsTimeData *data = (SettingsTimeData*) context;
i18n_free_all(data);
app_free(data->continent_names);
app_free(data->region_names);
app_free(data->region_names_... |
orkout_data, &s_workout_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_workout_active__workout_render_open_workout(void) {
s_workout_data = (WorkoutData) {
.steps = 0,
.duration_s = 84,
.distance_m = 0,
.avg_pa... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_workout_active__sports_pace_long_values(void) {
s_sports_data = (SportsData) {
.current_bpm = 71,
.duration_string = "04:20:39",
.distance_string = "115.12",
.pace_string = "12:34",
};
WorkoutMetricType top_metric = WorkoutMetricType_Duration;
WorkoutMetricType middle_metric = W... |
rail_gpio, GPIO_OType_PP, GPIO_Speed_2MHz);
}
prv_bus_rail_power_down(bus);
}
void i2c_use(I2CSlavePort *slave) {
PBL_ASSERTN(slave);
mutex_lock(slave->bus->state->bus_mutex);
if (slave->bus->state->user_count == 0) {
prv_bus_enable(slave->bus);
}
slave->bus->state->user_count++;
mutex_unlock(sla... | {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted access to disabled bus %s", bus->name);
mutex_unlock(bus->state->bus_mutex);
return false;
} |
// Disable stop mode while the I2C transfer is in progress - stop mode disables I2C peripheral
stop_mode_disable(bus->stop_mode_inhibitor);
// If bus is busy (it shouldn't be as this function waits for the bus to report a non-idle state
// before exiting) reset the bus and wait for it to become not-busy
//... |
critical_section = false;
pulse_logging_init();
}
void test_pulse_logging__simple(void) {
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "Test");
cl_assert_equal_i(s_num_event_puts, 0);
cl_assert_equal_i(s_num_packets_sent, 1);
cl_assert_equal_i(s_num_bytes_sent, LOG_METADATA_LENGTH + 4);
cl_assert_equal_s(s_... | cl_assert_equal_i(s_num_event_puts, 1) | ;
cl_assert_equal_i(s_num_packets_sent, 0);
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTestF");
cl_assert_equal_i(s_num_event_puts, 1);
cl_assert_equal_i(s_num_packets_sent, 0);
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTestG");
s_l... |
_ACC_CONF, acc_odr,
BMI160_ACC_CONF_ACC_ODR_MASK << BMI160_ACC_CONF_ACC_ODR_SHIFT);
#ifdef BMI160_DEBUG
PBL_ASSERTN(interval_us == prv_get_sampling_interval_from_hw());
#endif
BMI160_DBG("Set sampling rate to %"PRIu32, (uint32_t)(1000000/interval_us));
if (s_accel_power_mode == BMI160_Accel_Mode_Normal) ... | prv_write_reg(BMI160_REG_FIFO_CONFIG_1, desired_cfg) | ;
}
}
bool enable_int = num_samples != 0;
bool use_fifo = num_samples > 1;
prv_configure_accel_sampling(enable_int, use_fifo);
}
int accel_peek(AccelDriverSample *data) {
prv_read_curr_accel_data(data);
return 0;
}
void accel_set_shake_sensitivity_high(bool sensitivity_high) {
// Configure the thres... |
false /*display_logs*/);
if (status != FLASH_TEST_SUCCESS) {
stuck_at_low = true;
}
}
if (stuck_at_low) {
// Restore data back to original if stuck at low occurred
status = write_initial_pattern(false /*display_logs*/, false /*skip_base_addr*/,
... | if (halfwordcount*2 % (256*1024) == 0) {
// Reading flash words (which are 16 bits) hence double
if (iterations) {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Read 256KB, iteration: %d of %"PRId32,
iteration_count, iterations);
} else {
PBL_LOG(LOG_LEVEL_DEBUG, ">> Read 256KB, iterati... | |
/*
* 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... | (EWD1000->i2c) | ;
}
static void prv_wait_for_interrupt(void) {
const RtcTicks timeout = rtc_get_ticks() + RTC_TICKS_HZ * INIT_TIMEOUT_S;
while (gpio_input_read(&EWD1000->int_gpio)) {
if (rtc_get_ticks() > timeout) {
PBL_CROAK("Touch controller didn't respond!");
}
}
}
// Status Register Operations
//////////////... |
/*
* 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 endpoint;
} |
}
return NULL;
}
static bool prv_is_endpoint_allowed_with_session(const PebbleProtocolEndpoint* endpoint,
CommSession *session) {
PebbleProtocolAccess granted_access_bitset = PebbleProtocolAccessNone;
switch (comm_session_get_type(session)) {
case CommSessi... |
ld the mic from a dot
// and show text
#if (0) // https://pebbletechnology.atlassian.net/browse/PBL-20406
prv_short_vibe();
#endif
prv_enable_select_click(data);
prv_stop_fly_dot(data);
prv_hide_mic_dot(data);
prv_hide_progress_bar(data);
prv_show_unfold_animation(data, false /... | status_bar_layer_init(status_bar) | ;
const GColor status_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
status_bar_layer_set_colors(status_bar, status_bg_color, GColorBlack);
layer_add_child(root_layer, (Layer *) status_bar);
KinoReel *image = kino_reel_create_with_resource_system(SYSTEM_APP,
... |
PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite));
const int32_t width_of_action_bar_with_padding = ACTION_BAR_WIDTH + PBL_IF_RECT_ELSE(2, -4);
const int32_t width = window->layer.bounds.size.w - width_of_action_bar_with_padding;
const int32_t x_offset = PBL_IF_RECT_ELSE(0, 22);
#if PLATFORM_ROBERT || PLATFORM_CA... | kino_layer_deinit(&data->kino_layer) | |
/*
* 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... | (written_pcba_serial2_long) | ;
pcba_serial = mfg_get_pcba_serial_number();
cl_assert_equal_s(written_pcba_serial1, pcba_serial);
// Write second time
const char* written_pcba_serial2 = "abcdefghijkx";
command_pcba_serial_write(written_pcba_serial2);
pcba_serial = mfg_get_pcba_serial_number();
cl_assert_equal_s(written_pcba_serial2, ... |
/*
* 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... | system_flash_write(FIRMWARE_BASE + i, buffer, chunk_size, NULL, NULL) | ) {
dbgserial_putstr("We're dead");
return false;
}
prv_display_write_progress(i + chunk_size, firmware_length, NULL);
}
return true;
}
static bool check_firmware_crc(FirmwareDescription* firmware_description) {
dbgserial_print("Checksumming ");
dbgserial_print_hex(firmware_description->fir... |
{ 960, 216, -376},
{ 1000, 152, -392},
{ 800, 120, -336},
{ 648, 64, -368},
{ 528, 104, -336},
{ 448, 128, -216},
{ 504, 176, -272},
{ 624, 200, -280},
{ 808, 288, -320},
{ 1040, 352, -496},
{ 1352, 232, -344},
{ 1112, 360, -424},
{ 1224, 232, -288},
// 67 seconds... | { 520, 32, -160},
{ 480, 80, -192},
{ 608, 112, -192},
{ 784, 152, -184},
{ 1040, 16, -336},
{ 1192, 96, -320},
{ 1656, -48, -512},
{ 1256, 336, -232},
{ 960, 312, -552},
{ 1080, 144, -352},
{ 864, 112, -344},
{ 536, 104, -240},
{ 352, 104, -192},
{ 440, 184, -200... |
{ 1016, 264, -328},
{ 1112, 104, -232},
{ 1144, 32, -216},
{ 832, 40, -224},
{ 584, 16, -240},
{ 552, 96, -248},
{ 624, 112, -216},
// 75 seconds
{ 800, 88, -288},
{ 960, 104, -336},
{ 1152, 40, -384},
{ 1560, 16, -600},
{ 1168, 256, -352},
{ 976, 184, -400},
... |
void prv_notify_timeout(void *context) {
if (smartstrap_fsm_state_test_and_set(SmartstrapStateNotifyInProgress,
SmartstrapStateReadComplete)) {
// we need to handle the timeout from KernelBG
ReadCompleteContext context = {
.success = false,
.is_notify = tr... | (timeout_ms, SMARTSTRAP_MAX_TIMEOUT) | ;
// transition the FSM state
if (!smartstrap_fsm_state_test_and_set(SmartstrapStateReadReady, SmartstrapStateReadDisabled)) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to change smartstrap FSM state (%d)",
smartstrap_fsm_state_get());
return SmartstrapResultBusy;
}
// We are now be in a state wh... |
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... | |
_t rx_index = 0;
uint8_t tx_index = 0;
uint8_t buffer[sizeof(core_dump_connect_ping)];
uint16_t tx_start_ticks;
bool rx_mode;
printf("Waiting for host:\n");
for (int count = 10; count > 0; --count) {
printf(".");
// Feed the watchdog
hw_watchdog_set_pos_val(0xFF);
// Configure for RX mode... | ("\nHost connected\n") | ;
while (true) {
// Feed the watchdog
hw_watchdog_set_pos_val(0xFF);
prv_get_cmd((uint8_t *)&cmd, sizeof(cmd));
if (crc32(CRC32_INIT, &cmd, sizeof(cmd)) != CRC32_RESIDUE) {
printf("cmd CRC failed");
prv_low_power_mode();
}
// Feed the watchdog
hw_watchdog_set_pos_val(0xFF);
... |
/*
* 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... | syscall_failed() | ;
}
}
text_resources_init_font(fontinfo->base.app_num, fontinfo->base.resource_id,
fontinfo->extension.resource_id, fontinfo);
}
|
ebuffer_clear(&s_fb);
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
s_app_state_get_graphics_context = &s_ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers */);
lo... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_health_activity_summary_card__render_current_behind_typical3(void) {
HealthData health_data = {
.step_data = 460,
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,... |
menu_layer_init(&l, &GRect(10, 10, height, 180));
menu_layer_set_center_focused(&l, true);
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks){
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.get_cell_height = prv_get_row_height_depending_on_selection_state,
});
const int... | menu_layer_get_selected_index(&l) | .row);
cl_assert_equal_i(4 * basic_cell_height, l.selection.y);
menu_layer_set_selected_next(&l, false, MenuRowAlignNone, false);
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).section);
cl_assert_equal_i(5, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(5 * basic_cell_height, l.selection.... |
oint origin = rect->origin;
const int16_t width = rect->size.w;
const int16_t height = rect->size.h;
// Subtract out twice the respective radius values to get the actual width and height of the
// rectangle lines
const int16_t width_actual = width - (2 * radius);
const int16_t height_actual = height - (2 *... | {
// Antialiased and Stroke Width == 1 (not suppported on 1-bit color)
// Note: stroke width == 2 is rounded down to stroke width of 1
prv_draw_round_rect_aa(ctx, rect, radius);
return;
} |
}
#endif
if (ctx->draw_state.stroke_width > 1) {
// Non-Antialiased and Stroke Width > 1
prv_draw_round_rect_stroked(ctx, rect, radius, ctx->draw_state.stroke_width);
} else {
// Non-Antialiased and Stroke Width == 1
prv_draw_round_rect(ctx, rect, radius);
}
}
}
void graphics... |
/*
* 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... | layer_init(&action_bar->layer, &GRectZero) | ;
action_bar->layer.update_proc = (LayerUpdateProc) action_bar_legacy2_update_proc;
action_bar->layer.property_changed_proc =
(PropertyChangedProc) action_bar_legacy2_changed_proc;
action_bar->background_color = GColor2Black;
}
ActionBarLayerLegacy2 *action_bar_layer_legacy2_create(void) {
ActionBarLayer... |
/*
* 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... | {
strncpy(serial_number, mfg_get_serial_number(), serial_number_size);
if (serial_number_size > MFG_SERIAL_NUMBER_SIZE) {
// FIXME: manually adding a null-terminator if there is space
// strncpy should pad the end of strings with nulls if there is space, but
// everywhere that seems to use OTP or regist... |
void mfg_info_get_pcba_serialnumber(char *pcba_serial_number, size_t pcba_serial_number_size) {
strncpy(pcba_serial_number, mfg_get_pcba_serial_number(), pcba_serial_number_size);
if (pcba_serial_number_size > MFG_PCBA_SERIAL_NUMBER_SIZE) {
// same assumption as in mfg_info_get_pcba_serialnumber
pcba_seri... |
/*
* 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 uint8_t*) response, strlen(response)) | ;
accessory_send_data((const uint8_t*) "\r\n", sizeof(char) * 2);
}
static void prv_display_prompt(void) {
accessory_send_data((const uint8_t*) ">", sizeof(char));
}
static PromptContext s_prompt_context = {
.response_callback = prv_command_response_callback,
.command_complete_callback = prv_display_prompt,
}... |
/*
* 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... | (s_num_alarms_fired, 0) | ;
cl_assert_equal_i(s_num_alarm_events_put, 0);
// Trigger at the right time
prv_set_time(s_current_day, 10, 0);
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 6);
cl_assert_equal_i(s_num_timeline_rem... |
able 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 "clar.h"
#in... | (s_mfg_serial_failing) | );
}
|
last resource.
uint32_t store_length = resource_end_offset + resource_store_get_metadata_size(entry);
// Catch an overflow if the store is enormous (unlikely unless corrupted)
if (store_length < resource_end_offset) {
// overflow
PBL_LOG(LOG_LEVEL_ERROR, "Overflow while validating resource");
return... | {
return (ResourceVersion) {0};
} |
return manifest.version;
}
uint32_t resource_storage_get_num_entries(ResAppNum app_num, uint32_t resource_id) {
ResourceManifest manifest;
if (!prv_get_manifest_by_id(app_num, resource_id, &manifest)) {
return 0;
}
return manifest.num_resources;
}
// if resource_id == 0 then check all of resource stora... |
{
ppp_control_protocol_handle_incoming_packet(PULSE2_LCP, packet, length);
}
// Data link layer
// ===============
// PULSE task
// ----------
//
// This task handles both the processing of bytes received over dbgserial and
// running the reliable transport receive expiry timer.
static TaskHandle_t s_pulse_task_h... | {
_Static_assert(pdMS_TO_TICKS(1000) == RTC_TICKS_HZ,
"RtcTicks uses different units than FreeRTOS ticks");
timeout = timer_expiry_tick - now;
} |
}
mutex_unlock(s_reliable_timer_state_lock);
return timeout;
}
static void prv_pulse_task_feed_watchdog(void) {
task_watchdog_bit_set(PebbleTask_PULSE);
}
static void prv_pulse_task_idle_timer_callback(void* data) {
if (s_pulse_task_idle && uxQueueMessagesWaiting(s_pulse_task_queue) == 0) {
prv_pulse_t... |
eed 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 "scroll_app.h"
#include "ap... | {
ScrollAppData *data = app_state_get_user_data();
app_free(data);
} |
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
const PebbleProcessMd* scroll_app_get_info() {
static const PebbleProcessMdSystem s_scroll_app_info = {
.common.main_func = &s_main,
.name = "Scroller"
};
return (const PebbleProcessMd*) &s_scroll_app_info;
}
|
/*
* 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_raw_iter_begin(&file->iter) | ; !settings_raw_iter_end(&file->iter);
settings_raw_iter_next(&file->iter)) {
SettingsRecordHeader hdr = file->iter.hdr;
printf("Record { last_modified: %d, ", hdr.last_modified);
printf("flags: "PRIb8", ", TO_BINARY(hdr.flags));
printf("key_hash: %"PRIu8", key_len: %d, val_len: %d }\n", hdr.key_... |
ixed, radius_inner_fixed, angle_start, angle_end);
}
void graphics_fill_radial(GContext *ctx, GRect rect, GOvalScaleMode scale_mode,
uint16_t inset_thickness,
int32_t angle_start, int32_t angle_end) {
GPointPrecise center;
Fixed_S16_3 radius_outer;
grect_polar_... | (¢er, size) | ;
}
void grect_polar_calc_values(const GRect *r, GOvalScaleMode scale_mode, GPointPrecise *center,
Fixed_S16_3 *radius) {
if (!r) {
return;
}
GRect rect = *r;
grect_standardize(&rect);
const int16_t FIXED_ONE = FIXED_S16_3_ONE.raw_value;
const int16_t FIXED_HALF = FIXED_S... |
case WorkoutMetricType_AvgPace:
#if PBL_RECT
/// Average Pace Label
return i18n_noop("AVG PACE");
#else
/// Average Pace Label with units
return active_window->workout_controller->get_distance_string(i18n_noop("AVG PACE (/MI)"),
... | {
case WorkoutMetricType_Hr: {
GPoint heart_node_offset = GPoint(2, prefer_larger_font ? 5 : 0);
GTextNodeCustom *heart_node;
if (active_window->workout_controller->get_metric_value(
metric_type, active_window->workout_data) > 0) {
const size_t buffer_size = sizeof("000");
... | |
nager_peek(&s_last_accel_data);
return prv_compute_delta_pos(&last_accel_data, &s_last_accel_data) < ACCEL_MAX_IDLE_DELTA;
}
static bool prv_is_allowed_to_run(void) {
return (stationary_get_enabled() && !s_stationary_mode_inhibit);
}
static void prv_update_stationary_enabled(void *data) {
if (!battery_is_usb_co... | analytics_event_stationary_state_change(rtc_get_time(), StationaryAnalyticsExitNormally) | ;
prv_reset_stationary_counter();
s_current_state = StationaryStateAwake;
}
//! The accelerometer tap threshold will be set very low, so a small motion will wake
//! the watch back up
static void prv_enter_stationary_state(void) {
PBL_LOG(LOG_LEVEL_INFO, "Entering stationary: Changing run level");
if (s_curren... |
BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits
tmpreg &= CR1_CLEAR_MASK;
// get the baudrate prescaler
uint32_t prescaler = prv_spi_find_prescaler(bus);
// Master mode, 8 bit Data Size and Soft Slave select are hardcoded
// Direction, CPOL, CPHA, baudrate prescaler and first-bit come from th... | prv_spi_acquire_helper(slave) | ;
spi_ll_slave_burst_write(slave, out, len);
prv_spi_release_helper(slave);
}
void spi_slave_burst_read_write(const SPISlavePort *slave, const void *out, void *in, size_t len) {
prv_spi_acquire_helper(slave);
spi_ll_slave_burst_read_write(slave, out, in, len);
prv_spi_release_helper(slave);
}
void spi_slave... |
ame = &data->timeline_window.layer.frame;
*icon_frame_out = (GRect) {
.origin.x = layer_frame->origin.x + (layer_frame->size.w - UNFOLD_DOT_SIZE_PX) / 2,
.origin.y = layer_frame->origin.y + (layer_frame->size.h - UNFOLD_DOT_SIZE_PX) / 2,
.size = UNFOLD_DOT_SIZE,
};
#elif ANIMATION_SLIDE
GRect icon_fra... | (sidebar_slide, (AnimationHandlers) {
.started = prv_intro_or_exit_anim_started,
.stopped = prv_exit_anim_stopped,
}, data) | |
{
handle_init();
app_event_loop();
handle_deinit();
} |
const PebbleProcessMd* event_service_app_get_info() {
static const PebbleProcessMdSystem event_service_app_info = {
.common.main_func = &s_main,
.name = "Event Service App",
};
return (const PebbleProcessMd*) &event_service_app_info;
}
| |
cription_dialog = context;
app_timer_cancel(transcription_dialog->pop_timer);
prv_stop_text_animation(transcription_dialog);
}
static void prv_transcription_dialog_load(void *context) {
TranscriptionDialog *transcription_dialog = context;
transcription_dialog->was_pushed = true;
if (transcription_dialog->buf... | ((ExpandableDialog *)transcription_dialog,
RESOURCE_ID_ACTION_BAR_ICON_CHECK, prv_transcription_dialog_select_handler) | ;
Dialog *dialog = expandable_dialog_get_dialog((ExpandableDialog *)transcription_dialog);
dialog_set_callbacks(dialog, &(DialogCallbacks) {
.unload = prv_transcription_dialog_unload,
.load = prv_transcription_dialog_load
}, transcription_dialog);
dialog_show_status_bar_layer(dialog, true /... |
t_bytes) + 1;
*out_bytes_remaining = bytes_remaining;
*out_chunk_payload_size = MIN(bytes_remaining, s_state.tx_chunk_size_bytes);
}
static void prv_object_queue_handle_chunk_sent(void) {
DBG("Sent Chunk Successfully.");
size_t bytes_remaining_before_sent_chunk;
size_t sent_chunk_payload_size;
prv_calc_cu... | (APP_LOG_LEVEL_ERROR, "Not enough mem to recv postMessage() of %"PRIu32" bytes",
(uint32_t) chunk->total_size_bytes) | ;
// https://pebbletechnology.atlassian.net/browse/PBL-42466
// TODO: AppMessage NACK the message so the other side can retry later. Not doing this will
// derail the protocol and thus cause a reset of the session.
return true; // false would close the session!
}
s_state.in.reassembly_b... |
e_elapsed = (20 * SECONDS_PER_MINUTE);
// Add a run session
ActivitySession run_activity = {
.start_utc = utc_sec - time_elapsed,
.length_min = time_elapsed,
.type = ActivitySessionType_Run,
.ongoing = true,
};
activity_sessions_prv_add_activity_session(&run_activity);
// Add a walk session
... | (ActivityMetricHeartRateZone2Minutes, 1, &zone2_minutes) | ;
cl_assert_equal_i(zone2_minutes, 2);
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes);
cl_assert_equal_i(zone3_minutes, 2);
// Add some more "regular" heart rates.
// This shouldn't affect our zone counts
prv_set_median_hr_for_minutes(70 /* BPM */, 3 /* minutes */);
cl_assert... |
/*
* 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... | launcher_task_add_callback(prv_push_enable_in_mobile_dialog, data) | ;
}
// ---------------------------------------------------------------------------
void health_tracking_ui_app_show_disabled(void) {
// Show at most once per app launch
AppInstallId app_id = app_manager_get_current_app_id();
if (app_id == s_last_app_id) {
return;
}
s_last_app_id = app_id;
/// Health d... |
&s_meta_v0_system,
sizeof(s_meta_v0_system),
BLEGATTErrorSuccess);
// Still one client:
cl_assert_equal_i(ppogatt_client_count(), 1);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
Transport *client2 =... | {
prv_notify_services_discovered(1);
ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_system,
sizeof(s_meta_v0_system),
BLEGATTErrorSucc... | |
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 express or implied.
* See the License for the specif... | {
if (pattern_list[i] >= num_note_types) {
return false;
}
} |
GenericAttribute *repeat_delay_attribute =
generic_attribute_find_attribute(&score->attr_list, VibeAttributeId_RepeatDelay,
score->attr_list_size);
if (repeat_delay_attribute) {
if (repeat_delay_attribute->length != sizeof(uint16_t)) {
return false;
}
... |
int32_t position;
animation_get_elapsed(seq, &position);
cl_assert_equal_i(position, 100);
// Now, advance sequence to almost the end of seq. Positions don't include the delay, so
// pass false for 'include_delay'
animation_set_elapsed(seq, animation_get_duration(seq, false /*delay*/, true /*play_count*/)... | prv_count_handler_entries(&s_stopped_handler_calls, seq) | , 1);
#endif
}
// --------------------------------------------------------------------------------------
// Test creating a spawn where where some children are already scheduled and some have
// already completed.
//
// Here's a graph of what we are doing
//
// 0 10 310 320 330 500 680 730 85... |
/*
* 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(ctx) | ;
ctx->lock = false;
framebuffer_dirty_all(ctx->parent_framebuffer);
return true;
}
GContext *graphics_context_get_current_context(void) {
return &s_ctx;
}
// Stubs
/////////////////////
#include "stubs_analytics.h"
#include "stubs_animation_timing.h"
#include "stubs_app_install_manager.h"
#include "stubs_ap... |
rn 0;
}
const uint32_t timeout_s = ((start > now) ? start : end) - now;
return MIN(timeout_s, UINT32_MAX / MS_PER_SECOND) * MS_PER_SECOND;
}
static void prv_set_timer(unsigned int timeout_ms) {
if (!timeout_ms) {
PBL_LOG(LOG_LEVEL_INFO, "Not setting timer.");
} else if (new_timer_start(s_timer, timeout_m... | mutex_unlock(s_mutex) | ;
mutex_destroy(s_mutex);
s_mutex = NULL;
}
void timeline_event_handle_blobdb_event(void) {
prv_update_status_async();
}
void timeline_event_refresh(void) {
prv_update_status_async();
}
bool timeline_event_is_all_day(CommonTimelineItemHeader *common) {
return (common->all_day ||
(common->duration... |
776, 152, 32},
{ 728, 136, 64},
{ 648, 96, 48},
{ 744, 104, 64},
{ 952, 152, 8},
{ 1216, 152, -8},
// 60 seconds
// elapsed: 1 minutes
{ 1680, 344, 40},
{ 1280, 536, -248},
{ 1272, 688, -448},
{ 1344, 776, -376},
{ 1224, 432, -56},
{ 1008, 400, -56},
{ 824, 352, -... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25666_2
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ 432, 368, -848},
{ 44... |
{ 528, 768, -280},
{ 552, 920, -144},
{ 440, 976, -32},
{ 304, 960, 0},
{ 272, 992, 176},
{ 248, 1048, 256},
{ 248, 1024, 368},
{ 232, 1080, 376},
{ 272, 1024, 536},
{ 320, 976, 528},
{ 312, 952, 704},
{ 456, 1176, 872},
{ 456, 1136, 792},
{ 408, 912, 624},
{... |
ercentage label, format %02d%%
SimpleDialog finished_dialog;
ProgressLayer progress_layer;
AppTimer *timer;
unsigned int percent_complete;
ProgressUISource progress_source;
bool is_finished;
} ProgressUIData;
////////////////////////////////////////////////////////////
// Progress Logic
static void prv_qu... | window_get_user_data(window) | |
{ 24, 1080, -304},
{ -128, 952, -312},
{ -152, 752, -320},
{ -168, 608, -304},
{ -192, 560, -320},
{ -192, 568, -352},
// 84 seconds
{ -232, 672, -384},
{ -248, 816, -416},
{ -232, 888, -400},
{ -224, 960, -408},
{ -336, 1056, -320},
{ -312, 1256, -336},
{ -296, 1... |
{ -136, 496, -1112},
{ -144, 648, -1056},
{ -272, 720, -968},
{ -200, 816, -952},
{ -32, 624, -880},
{ -16, 376, -768},
{ -32, 216, -592},
{ -104, 360, -664},
{ -120, 312, -664},
{ -88, 368, -696},
{ -136, 368, -704},
{ -80, 488, -808},
{ 16, 504, -872},
{ 40, 53... | |
{
layer_init(layers[i], &GRectZero);
} |
// Create this hierarchy:
//
// +-parent
// |
// '->child_b
//
layer_add_child(&parent, &child_b);
// Insert child_a above child_b (first_child code path):
//
// +-parent
// |
// '->child_b->child_a
//
layer_insert_above_sibling(&child_a, &child_b);
cl_assert(child_b.pare... | |
line == ExtiLineOther_RTCAlarm) {
return RTC_Alarm_IRQn;
}
if (exti_line == ExtiLineOther_RTCWakeup) {
return RTC_WKUP_IRQn;
}
WTF;
}
static void prv_configure_nvic_channel(IRQn_Type irqn) {
NVIC_SetPriority(irqn, EXTI_PRIORITY);
NVIC_EnableIRQ(irqn);
}
static void prv_check_nvic_channel(IRQn_Type... | {
NVIC_ClearPendingIRQ(EXTI2_IRQn);
prv_handle_exti(2);
} |
void EXTI3_IRQHandler(void) {
NVIC_ClearPendingIRQ(EXTI3_IRQn);
prv_handle_exti(3);
}
void EXTI4_IRQHandler(void) {
NVIC_ClearPendingIRQ(EXTI4_IRQn);
prv_handle_exti(4);
}
void EXTI9_5_IRQHandler(void) {
NVIC_ClearPendingIRQ(EXTI9_5_IRQn);
for (int i = 5; i <= 9; ++i) {
prv_check_handle_exti(i);
}... |
tex_unlock_recursive(s_pfs_mutex);
PBL_LOG(LOG_LEVEL_INFO, "FS-Format Done");
}
int pfs_sector_optimal_size(int min_size, int namelen) {
min_size += sizeof(FileHeader);
min_size += sizeof(FileMetaData);
min_size += namelen;
int bytes_per_sector = PFS_PAGE_SIZE - sizeof(PageHeader);
int num_pages = min_si... | (display_buf) | |
et_selection_index();
const OptionMenuCallbacks callbacks = {
.select = prv_intensity_menu_select,
};
const char *title = PBL_IF_RECT_ELSE(i18n_noop("INTENSITY"), i18n_noop("Intensity"));
settings_option_menu_push(
title, OptionMenuContentType_SingleLine, index, &callbacks, ARRAY_LENGTH(s_intensity_la... | if (backlight_is_enabled()) {
subtitle = i18n_noop("On");
} else {
subtitle = i18n_noop("Off");
} |
break;
case SettingsDisplayMotionSensor:
title = i18n_noop("Motion Enabled");
if (backlight_is_motion_enabled()) {
subtitle = i18n_noop("On");
} else {
subtitle = i18n_noop("Off");
}
break;
case SettingsDisplayAmbientSensor:
title = i18n_noop("Ambient S... |
S" 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 "services/normal/voice/transcription.h"
#include "test_transcription_example.h"
static int s_c... | (result, false) | ;
}
// tests
void test_transcription__iterate_words(void) {
uint8_t words_test[] = {
0,
0x04, 0x00,
't', 'e', 's', 't',
51,
0x05, 0x00,
'h', 'e', 'l', 'l', 'o',
101,
0x03, 0x00,
't', 'h', 'e'
};
uint8_t *end = words_test + sizeof(words_test);
uint8_t *result;
result = t... |
c_begin_x = MAX(src_row_info.min_x, src_bitmap->bounds.origin.x);
const int16_t src_end_x = MIN(grect_get_max_x(&src_bitmap->bounds),
src_row_info.max_x + 1);
int16_t src_x = src_initial_x + src_origin_offset.x;
for (int16_t dest_x = dest_begin_x; dest_x < dest_end_x; ++de... | MAX(src_row_info.min_x, src_bitmap->bounds.origin.x) | ;
const int16_t src_end_x = MIN(grect_get_max_x(&src_bitmap->bounds),
src_row_info.max_x + 1);
int16_t src_x = src_initial_x + src_origin_offset.x;
for (int16_t dest_x = dest_begin_x; dest_x < dest_end_x; ++dest_x, ++src_x) {
if (!WITHIN(src_x, sr... |
/*
* 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... | {
bt_driver_id_set_local_device_name(s_local_device_name);
} |
void bt_local_id_configure_driver(void) {
// Request the local address from the BT driver and cache it:
bt_driver_id_copy_local_identity_address(&s_local_address);
if (!prv_has_device_name()) {
if (!bt_persistent_storage_get_local_device_name(s_local_device_name,
... |
buf, sizeof(time_buf), format_time);
cl_assert_equal_s("June 16", time_buf);
}
void test_clock__month_named_abbrev_date(void) {
char time_buf[64];
const time_t jun10th_noon_2015 = 1433937600;
prv_clock_reset(0);
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - ... | (tomorrow_morning, daypart_string) | ;
// (12pm tomorrow) time tomorrow between 12pm and 6pm is tomorrow afternoon
daypart_string = clock_get_relative_daypart_string(timestamp, 32 /* hours_in_the_future */);
cl_assert_equal_s(tomorrow_afternoon, daypart_string);
// (6pm tomorrow) time tomorrow between 6pm and 9pm is tomorrow evening
daypart_st... |
t(42);
// APP_LOG(APP_LOG_LEVEL_INFO, "Updating persist value from %d to %d", value, value + 1);
persist_write_int(42, value + 1);
}
}
static void health_event_handler(HealthEventType event, void *context) {
APP_LOG(APP_LOG_LEVEL_INFO, "app: Got health event update. event_id: %"PRIu32"",
(uint32_... | handle_deinit() | ;
}
|
_effect(icon_reel, UNFOLD_EXPAND_AMOUNT);
kino_reel_scale_segmented_set_bounce_effect(icon_reel, UNFOLD_BOUNCE_AMOUNT);
kino_layer_init(&data->mic_window.icon_layer, &icon_frame);
// do not clip bounds of window - animated icon will be hidden when it's not within the
// visible bounds
kino_layer_se... | prv_cancel_dictation(voice_window) | |
/*
* 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... | (callback_called) | ;
cl_assert(flash_locked);
}
void test_system_flash__handle_erase_error(void) {
return_status = FLASH_ERROR_OPERATION;
cl_assert(!system_flash_erase(FLASH_BASE, 16 KiB, NULL, NULL));
cl_assert(flash_locked);
}
void error_in_middle_cb(uint32_t num, uint32_t den, void *context) {
int *countdown = context;
i... |
e {
// Data was seen, reset the interval counter
s_stop_mode_monitor.intervals_without_data = 0;
}
// Regardless of what happened, this interval is over and should be reset
s_stop_mode_monitor.data_seen_this_interval = false;
}
static void prv_start_timer_cb(void *context) {
new_timer_start(s_stop_mod... | (ACCESSORY_UART) | )) continue;
// this section needs to be atomic since the UART IRQ also modifies these variables
portENTER_CRITICAL();
if (s_send_history.has_data) {
// The send buffer is full. This means that the receive interrupt hasn't fired to clear the
// buffer which indicates that there is bus contention preventin... |
l_assert((resp_ptr - s_data) == s_sending_data_length);
}
/*************************************
* Checking for valid DELETE command *
*************************************/
static const uint8_t s_delete_cmd_success[] = {
// Message Header
0x04, // Pebble protocol message ID: DELETE
0x17, ... | cl_assert((resp_ptr - s_data) == s_sending_data_length) | |
ation = {
.setup = prv_setup_handler,
.update = prv_update_handler,
.teardown = prv_teardown_handler
};
h = animation_create();
cl_assert(h != NULL);
void *context = h;
animation_set_handlers(h, handlers, context);
animation_set_implementation(h, &implementation);
animation_set_duration(h, d... | (&s_teardown_handler_calls, a) | |
/*
* 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(atoi(" 500"), 500);
cl_assert_equal_i(atoi(" 765"), 765);
cl_assert_equal_i(atoi(" 573888"), 573888);
cl_assert_equal_i(atoi(" 713713"), 713713);
} |
void test_atoi__suffix(void) {
cl_assert_equal_i(atoi("500hurf"), 500);
cl_assert_equal_i(atoi("765berserker"), 765);
cl_assert_equal_i(atoi("573888 redmage"), 573888);
cl_assert_equal_i(atoi("713713 4 job fiesta111"), 713713);
}
void test_atoi__sign(void) {
cl_assert_equal_i(atoi("+500"), 500);
cl_asser... |
;
} else if (shape == GPATH_OPEN_BUCKET) {
// Move the line 2*X per 3*Y
data->bucket_offset.x += (data->bucket_velocity_x * PIXEL_SPEED_PER_FRAME * 2);
if (data->bucket_offset.x < 0 ||
data->bucket_offset.x > data->window.layer.bounds.size.w) {
data->bucket_velocity_x = data->buc... | app_timer_register(1000 / TARGET_FPS, timer_callback, NULL) | ;
}
static void init(void) {
AppData *data = task_malloc_check(sizeof(AppData));
memset(data, 0x00, sizeof(AppData));
s_display_colors[0] = GColorWhite;
s_display_colors[1] = GColorRed;
s_display_colors[2] = GColorGreen;
s_display_colors[3] = GColorBlue;
s_display_colors[4] = (GColor)((uint8_t)0b1111110... |
true /* auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoOK);
registered = gap_le_connect_has_connection_intent(&device, GAPLEClientApp);
cl_assert_equal_b(registered, true);
// Register another connec... | fake_GAPAPI_get_device_resolving_to_fake_irk() | ;
BTBondingID bonding_id = prv_add_bonding_for_fake_resolvable_device();
// Register connection intent:
BTErrno e = gap_le_connect_connect_by_bonding(bonding_id,
true /* auto_reconnect */,
false /* is_pairing_required... |
.size.w) {
if (color != src_bmp->palette[x].argb) {
return false;
}
} else {
if (color != surround_color.argb) {
return false;
}
}
}
}
return true;
}
// Tests
////////////////////////////////////
// setup and teardown
void test_bitblt_palette__in... | cl_assert(sizeof(s_palette) == (1 << BITS_PER_PIXEL)) | |
.attributes = &item->attr_list,
.mode = prv_get_mode(index),
.app_id = &item->header.parent_id,
.context = info,
};
TimelineLayout *layout = (TimelineLayout *)layout_create(item->header.layout, &config);
layer_add_child(&layer->layouts_layer, (Layer *)layout);
GRect icon_rect;
timeline_layer_g... | prv_get_index_delta(layer) | ;
GRect from_frame, to_frame;
prv_get_end_of_timeline_frame(layer, from_index, &from_frame);
prv_get_end_of_timeline_frame(layer, to_index, &to_frame);
PropertyAnimation *prop_animation = property_animation_create_layer_frame(
(Layer *)&layer->end_of_timeline, &from_frame, &to_frame);
Animation *animati... |
/*
* 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_state_get_user_data() | |
equal_i(windows[1]->on_screen, false);
cl_assert_equal_i(windows[2]->on_screen, false);
for (uint8_t idx = 0; idx < 3; idx++) {
window_destroy(windows[idx]);
}
}
void test_window_stack__insert_next(void) {
Window *window1 = window_create();
Window *window2 = window_create();
stub_pebble_tasks_set_cur... | window_create() | |
GEdgeInsets(0, ACTION_BAR_WIDTH + x_margin, 0,
x_margin));
GRect frame = grect_inset(window_layer->bounds, insets);
frame.origin.y = label_y_offset;
return frame;
}
//! Drawing function for our Window's base Layer. Draws the background, the labe... | (NumberWindow) | |
; }
// setup and teardown
void test_gdraw_command_sequence__initialize(void) {
}
void test_gdraw_command_sequence__cleanup(void) {
}
size_t prv_create_test_sequence(GDrawCommandSequence **sequence_ptr) {
size_t size = sizeof(GDrawCommandSequence) + (sizeof(GDrawCommandFrame) * 2) +
(sizeof(GDrawCommand) *... | cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_elapsed(sequence, 44)) | ;
cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_elapsed(sequence, 45));
cl_assert_equal_p(frame, gdraw_command_sequence_get_frame_by_elapsed(sequence, 46));
// test that frame is skipped when the duration is zero (first frame shown will be the first one
// with non-zero duration
frame = gdraw_... |
another read request (should report busy)
assert_result_busy(app_smartstrap_attribute_read(attr));
// check that it was sent successfully
SmartstrapRequest request = {
.service_id = 0x1111,
.attribute_id = 0x2222,
.write_mbuf = NULL,
.read_mbuf = NON_NULL_MBUF,
.timeout_ms = SMARTSTRAP_TIMEOU... | cl_assert(!s_pending_did_write.active) | ;
// check that it was sent successfully
SmartstrapRequest request = {
.service_id = 0x1111,
.attribute_id = 0x2222,
.write_mbuf = NON_NULL_MBUF,
.read_mbuf = NON_NULL_MBUF,
.timeout_ms = SMARTSTRAP_TIMEOUT_DEFAULT
};
// fake the response and expect a did_write and a did_read handler call
... |
s
{ 304, 624, -480},
{ 272, 576, -520},
{ 408, 784, -584},
{ 320, 592, -456},
{ 376, 600, -464},
{ 456, 696, -512},
{ 472, 576, -408},
{ 584, 672, -416},
{ 936, 920, -424},
{ 832, 696, -216},
{ 840, 520, -168},
{ 824, 928, -440},
{ 752, 784, -208},
{ 744, 688, -19... | { 1200, 464, 256},
{ 1048, 400, 296},
{ 952, 384, 192},
{ 864, 312, 144},
{ 888, 440, 40},
// 8 seconds
{ 888, 504, -16},
{ 960, 528, -56},
{ 1248, 536, -24},
{ 1744, 664, 96},
{ 1672, 600, 168},
{ 1096, 344, 96},
{ 1216, 256, 120},
{ 1440, 168, 272},
{ 1416, ... | |
est_image",
test_data->test_name);
GBitmap *bitmap = test_data->bitmap_create_func(test_image_filename);
cl_assert(bitmap);
cl_assert(gbitmap_get_format(bitmap) == test_data->expected_test_image_bitmap_format);
// Draw the two variations of the test image at GPointZero
prv_composite_t... | prv_offset_layer_test(GPoint(0, -40)) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_bitmap_layer_inside(void) {
prv_offset_bitmap_layer_test(GPointZero);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_bitmap_layer_across_x(void) {
prv_... |
_timeout_values[] = { 3000, 5000, 8000 };
static const char *s_timeout_labels[] = {
i18n_noop("3 Seconds"),
i18n_noop("5 Seconds"),
i18n_noop("8 Seconds")
};
static int prv_timeout_get_selection_index() {
uint32_t timeout_ms = backlight_get_timeout_ms();
for (size_t i = 0; i < ARRAY_LENGTH(s_timeout_values)... | {
subtitle = i18n_noop("On");
} | else {
subtitle = i18n_noop("Off");
}
break;
case SettingsDisplayBacklightIntensity:
title = i18n_noop("Intensity");
subtitle = s_intensity_labels[prv_intensity_get_selection_index()];
break;
case SettingsDisplayBacklightTimeout:
title = i18n_noop("Timeout");
s... |
eturn sizeof(CommitRequest);
case PutBytesAbort:
return sizeof(AbortRequest);
case PutBytesInstall:
return sizeof(InstallRequest);
default:
WTF;
}
}
static bool prv_has_invalid_request_length(const PutBytesCommand command, uint32_t actual_length) {
const size_t expected_length = prv_e... | kernel_malloc_check(sizeof(PutBytesStorageInfo)) | ;
storage_info->index = request->index;
}
}
const bool success = pb_storage_init(&s_pb_state.storage, s_pb_state.type, s_pb_state.total_size,
storage_info, s_pb_state.append_offset);
kernel_free(storage_info);
return success;
}
static void prv_do_init(void) {
... |
ngth < PULSE_MIN_FRAME_LENGTH || frame_length == SIZE_MAX) {
// Decoding failed, this frame is bogus
return;
}
uint32_t fcs;
if (crc32(CRC32_INIT, s_current_rx_frame, frame_length) == CRC32_RESIDUE) {
net16 protocol_be;
memcpy(&protocol_be, s_current_rx_frame, sizeof(protocol_be));
uint16_t p... | {
s_pulse_task_idle = true;
xSemaphoreTake(s_pulse_task_service_semaphore, timeout);
s_pulse_task_idle = false;
// Read the timer state again in case it changed while we were waiting.
timeout = prv_poll_timer(&timer_sequence_number);
} |
// Even if the timer expired, drain the received bytes queue first.
// We don't want to risk the queue filling up while the timer
// handler is running.
char c;
while (xQueueReceive(s_pulse_task_queue, &c, 0) == pdTRUE) {
if (UNLIKELY(c == FRAME_DELIMITER)) {
size_t decoded_length = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.