prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
lse;
const char *sentence = NIHAO_JOINED NIHAO NIHAOMA_JOINED NIHAO_JOINED NIHAO_JOINED;
const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, sentence);
cl_assert(success);
const TextBoxParams text_box_params = (TextBoxParams) {
.utf8_bounds = &utf8_bounds,
// Width for first word only:
.box... | (line.height_px == 10) | ;
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 3);
cl_assert(line.origin.x == 0);
cl_assert(line.origin.y == 0);
cl_assert(line.suffix_codepoint == 0);
cl_assert(*line.start == 'F');
// b
cl_assert(*word_iter_state.current.start == 'b');
cl_assert(*word_iter_state.current.end == '\n');
cl_assert(wor... |
ading into gbitmap
// Result:
// - gbitmap matches platform loaded PBI
void 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_ass... | graphics_context_get_bitmap(ctx) | ;
GRect framebuffer_bounds = gbitmap_get_bounds(native_framebuffer);
cl_assert(native_framebuffer->info.format == GBitmapFormat8BitCircular);
cl_assert(DISPLAY_FRAMEBUFFER_BYTES == 25944);
// Set screen to black to match empty region with test image
graphics_context_set_fill_color(ctx, GColorBlack);
graphi... |
width -= right_edge_bits_count;
}
if (width > 0) {
memset(block, pattern, (width / 8));
}
}
}
// ## Line blending functions:
// This function draws horizontal line with AA edges, given values have to be adjusted for
// screen coordinates and clipped according to the clip box, does not respect t... | gbitmap_get_data_row_info(framebuffer, y1.integer) | ;
output = (GColor8 *)(data_row_info.data + x);
}
// last pixel with blending (don't render first *and* last pixel if line length is 1)
if (y2.fraction != 0) {
// Only draw the pixel if its within the bitmap data row range
if (WITHIN(x, data_row_info.min_x, data_row_info.max_x)) {
graphics_priv... |
/*
* 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... | for (size_t i=0; i < ARRAY_LENGTH(s_sector_addresses)-1; ++i) {
if (s_sector_addresses[i] <= address
&& address < s_sector_addresses[i+1]) {
return i;
}
} |
return ARRAY_LENGTH(s_sector_addresses)-1;
}
bool system_flash_erase(
uint32_t address, size_t length,
SystemFlashProgressCb progress_callback, void *progress_context) {
dbgserial_print("system_flash_erase(");
dbgserial_print_hex(address);
dbgserial_print(", ");
dbgserial_print_hex(length);
dbgser... |
T - curr_offset);
prev_offset = 0;
}
GRect first_icon_frame;
GRect second_icon_frame;
const int line_length =
prv_get_line_length(timeline_layer, &first_icon_frame, &second_icon_frame) / 3;
const int dot_padding = 1;
const int solid_line_length = line_length - dot_padding;
const int dot_line_le... | (ctx, &GRect(line1_start.x, line1_start.y,
REL_BAR_OVERLAP_STROKE_WIDTH, line_length)) | |
/*
* 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... | {
void *current_cb = system_task_get_current_callback();
if (!current_cb) {
PBL_LOG_SYNC(LOG_LEVEL_WARNING, "No system task callback in progress.");
return;
}
PBL_LOG_SYNC(LOG_LEVEL_WARNING, "System task callback: %p", current_cb);
reboot_reason->watchdog.stuck_task_callback = (uint32_t)current_cb;
... |
static void prv_log_stuck_task(RebootReason *reboot_reason, PebbleTask task) {
TaskHandle_t *task_handle = pebble_task_get_handle_for_task(task);
void *current_lr = (void*) ulTaskDebugGetStackedLR(task_handle);
void *current_pc = (void*) ulTaskDebugGetStackedPC(task_handle);
PBL_LOG_SYNC(LOG_LEVEL_WARNING, "... |
/*
* 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... | {
AppData *app_data = data;
app_window_stack_pop(false);
app_window_stack_push(&app_data->results_window, false);
} |
static void prv_test_update_proc(Layer *layer, GContext* ctx) {
AppData *app_data = window_get_user_data(layer->window);
GfxTest *test = app_data->current_test;
srand(RAND_SEED); // Setup rand for routines that need it
if (test->setup) {
test->setup(layer->window);
}
PROFILER_INIT;
PROFILER_START... |
/*
* 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... | (ctx, GColorBlack) | ;
graphics_draw_pixel(ctx, GPoint(5, 5));
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_draw_pixel(ctx, GPoint(5, 5));
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorClea... |
Is do a no-op if the color string is invalid
if (!jerry_value_has_error_flag(error_value)) {
func(rocky_api_graphics_get_gcontext(), color);
};
return jerry_create_undefined();
}
#define COLOR_BUFFER_LENGTH (12)
T_STATIC void prv_graphics_color_to_char_buffer(GColor8 color, char *buf_out) {
if (color.a <=... | rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_CLEARRECT, prv_clear_rect) | ;
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_FILLRECT, prv_fill_rect);
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_FILLRADIAL, prv_fill_radial);
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_STROKERECT, prv_stroke_rect);
rocky_add_function(ctx_prototype, ROCKY_CONTEXT2D_SAVE, prv_save);
rocky... |
/*
* 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_current_flush_line = 0;
framebuffer_reset_dirty_lines(s_current_framebuffer);
} |
static bool flush_get_next_line(DisplayRow* row) {
while (s_current_flush_line < DISP_ROWS) {
if (bitset8_get(s_current_framebuffer->dirty_lines, s_current_flush_line)) {
row->address = s_current_flush_line;
row->data = framebuffer_get_line(s_current_framebuffer, s_current_flush_line);
s_curre... |
/*
* 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... | ("basic", buffer, 4, expected, 3) | ;
}
{
char buffer[] = "ABCD";
const uint8_t expected[] = { 0x0, 0x10, 0x83 };
prv_test_decode_encode("upper", buffer, 4, expected, 3);
}
{
char buffer[] = "abcdABCD";
const uint8_t expected[] = { 0x69, 0xb7, 0x1d, 0x0, 0x10, 0x83 };
prv_test_decode_encode("twobyte", buffer, 8, expected... |
i/kino/kino_reel/scale_segmented.h"
#include "applib/ui/kino/kino_reel/transform.h"
#include "applib/ui/kino/kino_reel/unfold.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/kernel_ui.h"
#include "services/common/evented_timer.h"
#include "services/normal/timeline/notification_layout.h"
#include "services/normal/... | {
if (peek_layer) {
peek_layer_deinit(peek_layer);
}
task_free(peek_layer);
} | |
{ -16, 376, 296},
{ -32, 416, 352},
{ -144, 496, 496},
{ -240, 688, 864},
{ -280, 840, 1200},
{ -128, 776, 992},
{ -280, 912, 1032},
// 5 seconds
{ -224, 744, 1240},
{ 72, 736, 968},
{ 64, 592, 656},
{ 24, 512, 520},
{ -32, 384, 376},
{ -144, 312, 304},
{ -29... | { -32, 824, 1408},
{ -72, 584, 960},
{ -248, 544, 904},
{ -184, 368, 632},
{ -144, 328, 272},
{ -168, 336, 304},
{ -216, 392, 336},
{ -264, 560, 616},
{ -288, 744, 928},
{ -136, 792, 1096},
{ -216, 760, 832},
{ -376, 832, 1072},
{ -224, 816, 1240},
{ 16, 832, 816}... |
// 13 seconds
{ -600, 768, 752},
{ -504, 944, 944},
{ -496, 944, 736},
{ -648, 1096, 1104},
{ -64, 824, 920},
{ -192, 712, 776},
{ -224, 624, 696},
{ -88, 448, 400},
{ -120, 416, 216},
{ -152, 424, 288},
{ -248, 584, 472},
{ -272, 784, 632},
{ -272, 896, 768},
... |
true, 4);
graphics_context_set_fill_color(&ctx, GColorRed);
graphics_context_set_stroke_color(&ctx, GColorGreen);
graphics_draw_arc_internal(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG, angle_start, angle_end);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_arc_origin_aa_letter_c_color_4px.8bit.pbi"));
}
#define... | TO_TRIG(90) | , TO_TRIG(180)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight},
.full_quadrants = GCornerBottomRight,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(180),GCornerBottomLeft}
}));
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(180), TO_TRIG... |
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 KIND,... | ("23456789", data_out, 8) | == 0);
// Test partial copy (providing buffer of 6 bytes):
memset(data_out, 0, data_out_size);
cl_assert_equal_i(circular_buffer_copy(&buffer, data_out, 6), 6);
cl_assert(memcmp("234567", data_out, 6) == 0);
}
void test_circular_buffer__copy_offset(void) {
CircularBuffer buffer;
uint8_t storage[8];
cir... |
initialize(void) {
}
void test_math__cleanup(void) {
}
void test_math__atan2(void) {
check_atan2(10, 14);
check_atan2(3, 5);
check_atan2(5, 3);
check_atan2(10, 10);
check_atan2(-153, 217);
check_atan2(-28, -133);
check_atan2(323, -229);
check_atan2(245, 196);
check_atan2(65, -3);
check_atan2(331, ... | (WITHIN(-5, min, max), true) | ;
cl_assert_equal_i(WITHIN(0, min, max), true);
cl_assert_equal_i(WITHIN(5, min, max), true);
// Just out of bounds
cl_assert_equal_i(WITHIN(-11, min, max), false);
cl_assert_equal_i(WITHIN(11, min, max), false);
// Min and max are both negative
////////////////////////////////
min = -20;
max = -10;... |
/*
* 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_lock();
{
GAPLEConnection *connection = gap_le_connection_by_addr(&event->dev_address);
if (!connection) {
goto unlock;
}
connection->gatt_connection_id = event->connection_id;
connection->gatt_mtu = event->mtu;
BLE_LOG_DEBUG("GATT Connection for " BT_DEVICE_ADDRESS_FMT,
... |
void bt_driver_cb_gatt_handle_disconnect(const GattDeviceDisconnectionEvent *event) {
bt_lock();
{
GAPLEConnection *connection = gap_le_connection_by_addr(&event->dev_address);
if (!connection) {
goto unlock;
}
connection->gatt_connection_id = 0;
connection->gatt_mtu = 0;
BLE_LOG_DEB... |
EFERENCES;
#define PREF_KEY_ACTIVITY_ACTIVATED_TIMESTAMP "activityActivated"
static time_t s_activity_activation_timestamp = 0;
#define PREF_KEY_ACTIVITY_ACTIVATION_DELAY_INSIGHT "activityActivationDelayInsights"
static uint32_t s_activity_activation_delay_insight = 0;
#define PREF_KEY_ACTIVITY_HEALTH_APP_OPENED "ac... | (BOARD_CONFIG.backlight_on_percent) | ;
return false;
}
static bool prv_set_s_backlight_motion_enabled(bool *enabled) {
s_backlight_motion_enabled = *enabled;
return true;
}
static bool prv_set_s_stationary_mode_enabled(bool *enabled) {
s_stationary_mode_enabled = *enabled;
return true;
}
static bool prv_set_s_default_worker(Uuid *uuid) {
s_... |
>fg_color_index] | ALPHA_100);
} else if (data->property == PROPERTY_BG_COLOR) {
data->bg_color_index = (data->bg_color_index + 1) & 0x3F;
data->bg_color.argb = (s_color_table[data->bg_color_index] | ALPHA_100);
} else if (data->property == PROPERTY_ALPHA) {
data->alpha = (data->alpha + 0x40) & ALPHA_10... | text_layer_create(GRect(2, 2, 28, 20)) | |
animation_destroy can be called from the stopped handler
void test_animation__destroy_from_stopped_handler_with_auto_destroy(void) {
#ifdef TEST_INCLUDE_BASIC
prv_test_destroy_from_stopped_handler(true);
#endif
}
// --------------------------------------------------------------------------------------
// Test that ... | prv_last_update_distance(a) | , 0);
// Destroy it
animation_destroy(a);
#endif
}
// --------------------------------------------------------------------------------------
// Test a simple sequence animation
void test_animation__simple_sequence(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
... |
HEIGHT)) / 2));
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax1_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
// Should not draw anything
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, R... | (&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 2);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "dr... |
ssions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/graphics.h"
#include "stubs_applib_resource.h"
#include "stubs_app_state.h"
#include "stubs_compiled_with_legacy2_sdk.h"
#include "stubs_graphics_line.h"
#include "stubs_heap.h"
#include "... | (&ctx, (GColor8){.a= 1, .r = 3}) | ;
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.fill_color.argb);
graphics_context_set_fill_color(&ctx, (GColor8){.a= 0, .r = 3});
cl_assert_equal_i(GColorClearARGB8, ctx.draw_state.fill_color.argb);
}
|
8" 0x%"PRIx8, int0_status, int2_status);
}
int32_t direction = ((int2_status & BMA255_INT_STATUS_2_SLOPE_SIGN) == 0) ? 1 : -1;
direction *= (invert ? -1 : 1);
accel_cb_shake_detected(axis, direction);
}
}
// Services tap/motion interrupts
static void prv_bma255_IRQ1_handler(bool *should_context_swit... | (BMA255PowerMode_Standby) | |
al(void);
static void prv_display_plugged(void *data);
static void prv_dismiss_plugged(void);
static void prv_display_fully_charged(void *data);
static void prv_dismiss_fully_charged(void);
// TODO PBL-39883: Replace w/ QUIRK_RESET_ON_SHUTDOWN_WHILE_CHARGING once arbitrary prefixes land
#if PLATFORM_TINTIN || PLATFORM_... | {
app_manager_close_current_app(true);
modal_manager_set_min_priority(ModalPriorityMin);
} |
static void prv_display_plugged(void *data) {
if (!do_not_disturb_is_active()) {
vibes_short_pulse();
}
battery_ui_display_plugged();
status_led_set(StatusLedState_Charging);
}
static void prv_dismiss_plugged(void) {
battery_ui_dismiss_modal();
status_led_set(StatusLedState_Off);
}
static void prv... |
ftware
* 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 "codepoint.h"
#include "util/size.h"
#include <... | (NONSTANDARD_EMOJI_CODEPOINTS) | );
if (found) {
return true;
} else {
return ((codepoint >= MIN_SOFTBANK_EMOJI_CODEPOINT &&
codepoint <= MAX_SOFTBANK_EMOJI_CODEPOINT) ||
(codepoint >= MIN_UNIFIED_EMOJI_CODEPOINT &&
codepoint <= MAX_UNIFIED_EMOJI_CODEPOINT));
}
}
bool codepoint_is_special(const Code... |
;
animation_set_duration(bounceback_animation, 4 * ANIMATION_FRAME_MS);
animation_set_curve(bounceback_animation, AnimationCurveEaseOut);
animation_set_handlers(disappear_animation, (AnimationHandlers) {
.stopped = prv_update_icon,
}, new_bitmap);
Animation *sequence = animation_sequence_create(disapp... | reset_action_bar_revert_timer(context) | ;
// TODO: absolute volume + volume indicator, when that information is available.
bool is_volume_up = (click_recognizer_get_button_id(recognizer) == BUTTON_ID_UP);
prv_change_volume(is_volume_up);
// Trigger haptic feedback only on repeat
if (click_number_of_clicks_counted(recognizer) >= 2) {
prv_do_hap... |
uuid.h"
// Dialog Headers
#include "ble_gatt.h"
#include "ble_gattc.h"
#include "rwble_hl_error.h"
#include "ble_uuid.h"
#include <bluetooth/bluetooth_types.h>
#include <bluetooth/gatt_service_types.h>
#include <bluetooth/pebble_bt.h>
#include <util/uuid.h>
#define GATT_SERVICE_UUID ((uint16_t) 0x1801)
#define GATT_... | prv_att_uuid_to_uuid(&item->uuid, &desc_dest->uuid) | ;
char_dest->num_descriptors++;
end_ptr += sizeof(GATTDescriptor);
uuid_to_string(&desc_dest->uuid, uuid_str);
PBL_LOG(LOG_LEVEL_DEBUG,
" Found Descriptor %s Handle 0x%x", uuid_str, item->handle);
} else if (item->type == GATTC_ITEM_TYPE_INCLUDE) {
att_handles_includ... |
ing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/gtransform.h"
#include "applib/ui/layer.h"
#include "applib/ui/property_animation.h"
#include "applib/ui/property_animation_private.h"
#include "applib/ui/animation.h"
#include "ap... | {
RtcTicks ticks = rtc_get_ticks();
return (ticks * 1000 + RTC_TICKS_HZ / 2) / RTC_TICKS_HZ;
} |
// --------------------------------------------------------------------------------------
// Advance current time by N ms. This does NOT check to see if the timer should fire
// If you want to advance time and fire all timers that would have fired during that time
// call prv_advance_to_ms_with_timers()
static void p... |
/*
* 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... | {
params[0] = s_le_conn_params.slave_latency_events / num_samps;
params[1] = s_le_conn_params.supervision_to_ms / num_samps;
} | |
/*
* 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 true;
} |
void analytics_event_bt_error(AnalyticsEvent type, uint32_t error) {
}
void analytics_inc(AnalyticsMetric metric, AnalyticsClient client) {
}
typedef bool (*BondingSyncFilterCb)(const BleBonding *bonding, void *ctx);
const BleBonding *bonding_sync_find(BondingSyncFilterCb cb, void *ctx) {
return NULL;
}
void bt_... |
rvices/normal/bluetooth/ble_hrm.h"
#include "services/normal/notifications/action_chaining_window.h"
#include "services/normal/notifications/alerts_preferences.h"
#include "services/normal/notifications/ancs/ancs_notifications.h"
#include "services/normal/notifications/notification_constants.h"
#include "services/norma... | timeline_item_destroy(data->chaining_data.notif) | ;
data->chaining_data.notif = NULL;
}
if (data->progress_window) {
progress_window_destroy(data->progress_window);
data->progress_window = NULL;
}
applib_free(data->dialog.message);
data->dialog.message = NULL;
event_service_client_unsubscribe(&data->event_service_info);
prv_cancel_response... |
t num_data,
StatsBasicFilter filter, void *context, int32_t *basic_out) {
if (!data) {
return;
}
int32_t num_values = 0;
int32_t sum = 0;
int32_t min = INT32_MAX;
int32_t max = INT32_MIN;
int32_t consecutive_max = 0;
int32_t consecutive_current = 0;
int32_t consecutive_f... | {
if (!vals || !weights_x100 || num_data < 1) {
// Invalid args
return 0;
}
WeightedValue *values = task_zalloc(sizeof(int32_t) * num_data * 2);
if (!values) {
return 0;
}
// Copy the values and sort them in ascending order
for (size_t i = 0; i < num_data; i++) {
values[i] = (WeightedVal... | |
sert(child_b.parent == NULL);
cl_assert(parent.first_child == NULL);
}
void test_layer__insert_below(void) {
Layer parent, child_a, child_b, child_c;
Layer *layers[] = {&parent, &child_a, &child_b, &child_c};
for (int i = 0; i < ARRAY_LENGTH(layers); ++i) {
layer_init(layers[i], &GRectZero);
}
// Creat... | (b, actual) | ;
cl_assert_equal_i(0, current_stack);
cl_assert_equal_p(b, stack[0]);
// no more siblings on root level
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(NULL, actual);
cl_assert_equal_i(0, current_stack);
// do not descend
stack[0... |
/*
* 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_SYNC(LOG_LEVEL_INFO, "%sChecking 0x%lx over 0x%lx 0x%lx",
(perform_writes) ? "Writing and " : "", write_rand, region.begin,
region.end) | |
= GColorChromeYellow,
.did_close = prv_action_menu_did_close_cb,
};
ActionMenu *action_menu_window = app_action_menu_open(&config);
// Set the window on screen so its window handlers will be called
window_set_on_screen(&action_menu_window->window, true, true);
// Scroll down to the selected index
Act... | (root_level, selected_index, animation_state,
additional_crumbs) | |
/*
* 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_zalloc_check(sizeof(HealthData)) | |
his is an AlgDlsMinuteData line, get the name
if (strcmp(token, "AlgDlsMinuteData") == 0) {
PBL_ASSERT(state->test_entry.name[0] == 0, "Unexpected start of new samples");
token = strtok(NULL, "(");
// Copy starting from token + 1 to skip the '*' at the front
strncpy(state->test_entry.name, ... | sscanf(token + strlen(token) + 1, "%s", state->test_entry.name) | ;
}
}
// If this is a "static AlgDlsMinuteData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int steps = 0;
int orientation = 0;
int v... |
context_set_text_color(ctx, GColorWhite);
} else {
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_context_set_text_color(ctx, GColorBlack);
}
graphics_fill_rect(ctx, &cell_layer->bounds);
}
// Menu Layer Handling
//////////////////////
static void prv_select_callback(MenuLayer *menu_layer, ... | (0, STATUS_BAR_LAYER_HEIGHT) | ,
});
// Create the menu
MenuLayer *menu_layer = &data->menu_layer;
menu_layer_init(menu_layer, &bounds);
menu_layer_set_callbacks(menu_layer, data, &(MenuLayerCallbacks) {
.get_num_rows = prv_get_num_rows_callback,
.get_cell_height = prv_get_cell_height_callback,
.draw_row = prv_draw_row_callbac... |
>status_bit_masks.busy) ? E_BUSY : S_SUCCESS;
}
void qspi_flash_set_lower_power_mode(QSPIFlash *dev, bool active) {
qspi_use(dev->qspi);
uint8_t instruction;
uint32_t delay;
if (active) {
instruction = dev->state->part->instructions.enter_low_power;
delay = dev->state->part->standby_to_low_power_latenc... | qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_status,
dev->state->part->status_bit_masks.busy, false /* !set */, QSPI_NO_TIMEOUT) | ;
}
qspi_release(dev->qspi);
return (already_enabled) ? S_NO_ACTION_REQUIRED : S_SUCCESS;
}
status_t qspi_flash_lock_sector(QSPIFlash *dev, uint32_t addr) {
#if TARGET_QEMU
return S_SUCCESS;
#endif
qspi_use(dev->qspi);
prv_write_enable(dev);
// Lock or unlock the sector
const uint8_t instruction = ... |
/*
* 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... | hc_protocol_deinit() | ;
}
void bt_driver_power_down_controller_on_boot(void) {
// Don't make any assumptions about the state of the BT chip on initial bootup. (since the code
// runs in RAM) If we want to be in airplane mode, power the chip on then off
BTDriverConfig config = { };
if (bt_driver_start(&config)) {
bt_driver_stop(... |
.FMC_DataSetupTime = (h_clock / SETUP_STEP) + 1,
// Time between chip selects
// not on the datasheet, picked a random safe number
// FIXME: at high bus frequencies, more than one cycle may be needed
.FMC_BusTurnAroundDuration = 1, // TODO: actually ok? See back-to-back Read/Write Cycle
.FMC_CLK... | prv_write_configuration_register(configuration_register) | |
/*
* 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... | (&tuplet, 1,
(uint8_t *)&push_message->dictionary,
size) | );
// Including sizeof(AppMessagePush):
*size = sizeof(buffer);
return buffer;
}
static void prv_receive(uint32_t key, uint8_t value) {
uint32_t length = 0;
const uint8_t *msg= prv_build_push_message(key, value, &length);
launcher_app_message_protocol_msg_callback_deprecated(s_session, msg, length);
}
//... |
/*
* 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 0;
} |
}
static void prv_reload_menu_data(void *context) {
SettingsActivityTrackerData *data = context;
const uint16_t count = prv_num_rows(data);
const bool use_icons = (count != 0);
option_menu_set_icons_enabled(&data->option_menu, use_icons /* icons_enabled */);
option_menu_set_choice(&data->option_menu, prv_g... |
return; // Gotta wait for remote to subscribe.
}
if (!state->pending_response_data) {
return; // Gotta wait for FW to subscribe / write the emulated CCCD.
}
PBL_LOG(LOG_LEVEL_ALWAYS, "Phone & Watch have hit CCCD, initiate PPoGatt WA!");
hc_protocol_enqueue_with_payload(HcEndpointID_Gatt, HcMessageID_G... | (msg->command_id == HcMessageID_Gatt_Write) | ;
HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0];
BTErrno rv = BTErrnoOK;
hc_protocol_enqueue_response(msg, (uint8_t *)&rv, sizeof(rv)); // ack the write
prv_build_write_complete_payload(hdr, ((HcGattWriteData *)hdr)->att_handle, state);
prv_enqueue_write_complete_if_ready(state);
return true;
}
static ... |
{ 784, -712, 424},
{ 704, -472, -272},
{ 1136, -96, -224},
{ 1456, 144, -256},
{ 1160, 56, -248},
{ 1128, -8, -128},
{ 1328, 296, -224},
{ 1608, 464, -200},
{ 1816, 544, -256},
{ 1792, 800, -248},
{ 1568, 880, -416},
{ 976, 1112, -528},
{ 968, 1104, -368},
{ 1136,... |
{ 1704, 336, -32},
{ 1488, 272, -72},
{ 1544, 240, -72},
{ 1496, 192, -16},
{ 1528, 152, -24},
{ 1408, 120, -32},
{ 1208, 32, -48},
{ 800, -512, -56},
{ 960, -544, -48},
{ 592, -576, -112},
{ 1256, -64, -200},
{ 1464, 80, -184},
{ 1376, 176, -168},
{ 1448, 152, -... | |
E |
I2C_CR1_RXIE |
I2C_CR1_TCIE |
I2C_CR1_NACKIE |
I2C_CR1_ERRIE);
}
void i2c_hal_abort_transfer(I2CBus *bus) {
// Disable all interrupts on the bus
prv_disable_all_interrupts(bus);
// Generate a stop conditio... | (bus, I2CTransferEvent_NackReceived) | ;
return;
}
break;
case I2CTransferState_ReadData:
if ((i2c->ISR & I2C_ISR_RXNE) != 0) {
transfer->data[transfer->idx++] = i2c->RXDR;
}
if ((i2c->ISR & I2C_ISR_TCR) != 0) {
prv_resume_transfer(bus, false /* !generate_start */);
}
if ((i2c->ISR & I2C... |
ssage->transaction_id,
};
if (endpoint_id == ENDPOINT_ID) {
app_message_app_protocol_msg_callback(session, (const uint8_t*)&ack, sizeof(AppMessage), NULL);
} else {
cl_fail("Unhandled endpoint");
}
}
static void prv_nack_sent_callback(uint16_t endpoint_id, const uint8_t* data, unsigned int length) {
... | {
if (!s_is_connected) {
return false;
}
prv_send_data(endpoint_id, data, length);
return true;
} |
static AppOutboxSentHandler s_app_outbox_sent_handler;
static void *s_app_outbox_ctx;
static void prv_call_outbox_sent(int status) {
cl_assert(s_app_outbox_sent_handler);
s_app_outbox_sent_handler(status, s_app_outbox_ctx);
}
void app_outbox_send(const uint8_t *data, size_t length,
AppOutbo... |
ANCSAppData app_data_out = { 0 };
ancs_app_storage_load(app_data.bundle_id, &app_data_out);
cl_assert_equal_s(app_data.bundle_id, app_data_out.bundle_id);
cl_assert_equal_i(app_data.flags, app_data_out.flags);
cl_assert_equal_s(app_data.display_name, app_data_out.display_name);
ancs_app_destroy_buffer(&app_... | ancs_app_destroy_buffer(&app_data_out) | ;
}
ancs_app_storage_iter_begin();
for (unsigned int i = 0; ancs_app_storage_next(&app_data_out); ++i) {
PBL_LOG(LOG_LEVEL_DEBUG, "i: %d, name: %s, name_out: %s", i, apps[i].bundle_id, app_data_out.bundle_id);
cl_assert_equal_s(apps[i].bundle_id, app_data_out.bundle_id);
}
}
|
/*
* 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... | {
drawing_box.origin.y += 10;
} |
#endif
graphics_draw_text(ctx, graph_card->title, graph_card->title_font, drawing_box,
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
static void prv_draw_day_labels_background(HealthGraphCard *graph_card, GContext *ctx) {
const GRect *bounds = &graph_card->layer.bounds;
GRect b... |
DTH, SCREEN_HEIGHT);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled.${BIT_DEPTH_NAME}.pbi"));
printf("-- left\n");
prv_reset();
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
gpath_move_to(s_house_path, GPoint(0, SCREEN_HEI... | (&ctx, true) | ;
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_bolt_aa.8bit.pbi"));
// Duplicate points in GPath test - makes sure theres no division by zero ;)
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_duplicates_path;
... |
_offset_point(&path->points[0], path->rotation, &path->offset);
min_x = max_x = rot_points[0].x;
min_y = max_y = rot_points[0].y;
// begin finding the last path segment's direction going backwards through the path
// we must go backwards because we find intersections going forwards
for (int i = path->num_poi... | cb(ctx, i, (Fixed_S16_3){.integer = x_a}, (Fixed_S16_3){.integer = x_b},
(Fixed_S16_3){.integer = -1}, (Fixed_S16_3){.integer = -1}, user_data) | ;
}
}
}
cleanup:
applib_free(rot_points);
applib_free(intersections_up);
applib_free(intersections_down);
}
void gpath_fill_precise_internal(GContext *ctx, GPointPrecise *points, size_t num_points) {
if (!points) {
return;
}
// Convert precise points to normal points and draw filled path w... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (!size) {
return NULL;
} |
#if defined(MALLOC_INSTRUMENTATION)
void *result = task_malloc_with_pc(size, client_pc);
#else
void *result = task_malloc(size);
#endif
if (!result && mcu_state_is_thread_privileged()) {
// We want to trip an assert if our malloc failed and we're not running a 3rd party app.
PBL_CROAK_OOM(size, client_... |
udioEndpointSetupReceived);
prv_cancel_session();
PBL_LOG(LOG_LEVEL_WARNING, "Timeout waiting for session setup result ");
prv_send_event(VoiceEventTypeSessionSetup, VoiceStatusTimeout, NULL);
mutex_unlock(s_lock);
}
static VoiceStatus prv_get_status_from_result(VoiceEndpointResult result) {
VoiceStatus s... | if (s_state == SessionState_Recording) {
prv_stop_recording();
} | |
timestamp_midnight) {
prv_clock_get_full_relative_time(buffer, buf_size, timestamp, capitalized, with_fulltime);
} else if (difference >= (SECONDS_PER_HOUR * max_relative_hrs)) {
prv_clock_get_full_relative_time(buffer, buf_size, timestamp, capitalized, with_fulltime);
} else if (difference >= SECONDS_PE... | prv_clock_get_relative_time_string(buffer, buf_size, clamped_timestamp, false, HOURS_PER_DAY,
true) | ;
}
void clock_get_until_time(char *buffer, int buf_size, time_t timestamp,
int max_relative_hrs) {
prv_clock_get_relative_time_string(buffer, buf_size, timestamp, false, max_relative_hrs, true);
}
void clock_get_until_time_capitalized(char *buffer, int buf_size, time_t timestamp,
... |
onsider the watch as in motion, and restart the
//! stationary counter
static void prv_watch_is_in_motion(void) {
prv_handle_action(StationaryActionWakeUp);
}
static void prv_stationary_check_launcher_task_cb(void *unused_data) {
if (prv_update_and_check_accel_is_stationary()) {
prv_watch_is_motionless();
} ... | (&s_button_event_info) | ;
#if DEBUG_STATIONARY
regular_timer_add_seconds_callback(&s_accel_stationary_timer_info);
#else
regular_timer_add_minutes_callback(&s_accel_stationary_timer_info);
#endif
s_current_state = StationaryStateAwake;
}
static void prv_handle_awake_action(StationaryAction action) {
switch (action) {
case Statio... |
if (next_state == s_power_state) {
return;
} |
PowerStateID old_state = s_power_state;
s_power_state = next_state;
if (power_states[old_state].exit) {
power_states[old_state].exit();
}
if (power_states[next_state].enter) {
power_states[next_state].enter();
}
}
static void prv_enter_lpm(void) {
#ifndef BATTERY_DEBUG
if (!firmware_update_is_in... | |
/*
* 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... | (data_read, flash_addr, read_length) | |
buffer);
}
void test_health_sleep_detail_card__cleanup(void) {
}
// Helpers
//////////////////////
// static void prv_create_card_and_render(HealthData *health_data) {
// Window *window = health_sleep_detail_card_create(health_data);
// window_set_on_screen(window, true, true);
// window_render(window, &s_ctx)... | scroll_layer_get_content_size(&card->scroll_layer) | .h;
scroll_layer_set_content_offset(&card->scroll_layer, offset, false);
#endif
window_render(&card->window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
|
cell_layer, MenuIndex *cell_index,
SettingsWatchfacesData *data) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data->data_source, cell_index->row);
GBitmap *bitmap = app_menu_data_source_get_node_icon(&data->data_source, node);
const char *subtitle = (data->active_wat... | (window, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appear,
.unload = prv_window_unload,
}) | ;
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void s_main(void) {
handle_init();
app_event_loop();
}
#else
static void s_main(void) {}
#endif // !TINTIN_FORCE_FIT
const PebbleProcessMd* watchfaces_get_app_info() {
static const Pebbl... |
/*
* 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... | (scroll_bounds) | ;
// Verify paging is disabled by default
cl_assert_equal_b(false, prv_scroll_layer_is_paging_enabled(scroll_layer));
// Verify shadow_layer is not hidden when paging disabled
cl_assert_equal_b(false, scroll_layer_get_shadow_hidden(scroll_layer));
scroll_layer_set_paging(scroll_layer, true);
// Verify pa... |
{
HealthActivitySummaryCardData *data = layer_get_data(base_layer);
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
0, HEALTH_PROGRESS_BAR_MAX_VALUE);
const int32_t progress_max = MAX(data->current_steps, data->daily_average_steps);
if (!progress_max) ... | layer_set_update_proc(base_layer, prv_base_layer_update_proc) | ;
// set health data
*health_activity_summary_card_data = (HealthActivitySummaryCardData) {
.health_data = health_data,
.icon = kino_reel_create_with_resource(RESOURCE_ID_HEALTH_APP_ACTIVITY),
.progress_bar = {
.num_segments = ARRAY_LENGTH(s_activity_summary_progress_segments),
.segments = s... |
ance->subtitle_update = update;
GTextNode *node = prv_structured_glance_create_text_node(
structured_glance, structured_glance->subtitle_font, subtitle_buffer_size,
prv_structured_glance_subtitle_dynamic_text_node_update);
// Clip subtitle text nodes to their draw box since we scroll them if they're too... | prv_create_structured_glance_title_subtitle_node(structured_glance, glance_frame) | |
k: %"PRIu32", type: %d", token, o->type);
switch (o->type) {
case ObjectFirmware:
case ObjectSysResources:
prv_finish_fw_update_if_completed();
break;
case ObjectRecovery:
boot_bit_set(BOOT_BIT_NEW_PRF_AVAILABLE);
// >>> Fall-through! <<<
default:
break;
}
o->token = 0;
s_pb_state.... | (request->filename) | + 1);
strcpy(storage_info->filename, request->filename);
break;
}
case ObjectWatchApp:
case ObjectWatchWorker: {
PebbleTask task = (request->type == ObjectWatchApp) ? PebbleTask_App : PebbleTask_Worker;
char filename[APP_FILENAME_MAX_LENGTH + 1];
app_storage_get_file_name(file... |
bby", "555-555-5555");
}
void test_phone_pp__start(void) {
uint8_t pp_msg[] = {0x08, 0x1a, 0xd4, 0x77, 0x08};
phone_protocol_msg_callback(s_session, pp_msg, sizeof(pp_msg));
fake_system_task_callbacks_invoke_pending();
prv_assert_last_event(PhoneEventType_Start, true /* check_cookie */, false /* check_name_num... | (e.type, PEBBLE_NULL_EVENT) | ;
}
// PBL-34640 Make sure we don't put an incoming call event to a state response - the incoming call
// state is only used for iOS 8 devices now and just causes trouble
void test_phone_pp__get_phone_call_state_response_incoming(void) {
pp_get_phone_state_set_enabled(true);
uint8_t pp_msg[] = {0x83,
... |
êëēėęÿûüùúūîïíī"
"įìôöòóœøōõàáâäæãåāßśšłžźżçćčñń∑´®†¥¨ˆπ"
"∂ƒ©˙∆˚¬…Ω≈√∫˜µ≤≥÷¡™£¢∞§¶•ªº–≠`“‘"
"«ÈÉÊËĒĖĘŸÛÜÙÚŪÎÏÍĪĮÌÔÖÒÓŒØŌÕÀÁÂÄÆÃÅĀŚ"
"ŠŁŽŹŻÇĆČÑŃ∑ˇ∏”’»˝¸˛◊ı˜¯˘¿"
"あいうえおかきくけこさしすせそたちつてとなに"
"ぬねのはひふへほまみむめもやゆよらりるれろわ"
"をんアイウエオサシ... | (s_perftest_text_arguments.font_key, "RESOURCE_ID_GOTHIC_18") | == 0) {
font_index = TestStringFont_Gothic18;
} else if (strcmp(s_perftest_text_arguments.font_key, "RESOURCE_ID_GOTHIC_24_BOLD") == 0) {
font_index = TestStringFont_Gothic24B;
} else {
font_index = TestStringFont_Other;
}
#if TEXT_PERFTEST_MODAL
// Length replaces the yoffset argument
size_t le... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_failed();
}
return;
} |
}
// ------------------------------------------------------------------------------------------
DEFINE_SYSCALL(void, animation_service_timer_schedule, uint32_t ms) {
PebbleTask task = pebble_task_get_current();
TimerID *timer_id;
if (task == PebbleTask_KernelMain) {
timer_id = &s_kernel_main_timer_id;
}... |
ment(BLECharacteristic characteristic, uint8_t sn) {
PPoGATTPacket *packet = malloc(sizeof(PPoGATTPacket) + sizeof(s_short_data_fragment));
packet->sn = sn;
packet->type = PPoGATTPacketTypeData;
memcpy(packet->payload, s_short_data_fragment, sizeof(s_short_data_fragment));
ppogatt_handle_read_or_notification(... | fake_comm_session_cleanup() | ;
free(s_client_reset_request);
free(s_client_reset_complete);
}
void prv_notify_services_discovered(int num_services_to_register) {
for (int i = 0; i < s_num_service_instances && i < num_services_to_register; i++) {
ppogatt_handle_service_discovered(s_characteristics[i]);
}
}
void test_ppogatt__find_pebb... |
t(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(10, 10), 20, 5, true);
// No touch event generated when finger remains stationary
touch_handle_update(0, TouchState_FingerDown, &GPoint(10, 10), 5, 3686420);
touch_event = touch_event_queue_get_event(0, 1);
cl_a... | touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420) | ;
touch_handle_update(0, TouchState_FingerUp, &GPoint(15, 100), 0, 3686400);
TouchEvent *touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, TouchEvent_Liftoff, &GPointZero, 3686380, 0,
&GPoint(15, 100), 20, 0, true);
// touchdown event should reset the ... |
s = sys_activity_get_metric(ActivityMetricHeartRateRawBPM, 1, ¤t_value);
if (success && current_value != 0) {
num_samples++;
value = current_value;
}
}
HealthMinuteData *minute_data = state->cache->minute_data;
bool more_data = true;
while (more_data && (time_start < time_end)) {
... | state->event_handler(e->health_event.type, state->context) | |
ERAGE_SLEEP,
AVERAGE_SLEEP,
AVERAGE_SLEEP,
AVERAGE_SLEEP,
AVERAGE_SLEEP,
AVERAGE_SLEEP,
AVERAGE_SLEEP
};
memcpy(&s_data.metric_history[ActivityMetricSleepTotalSeconds], sleep_history,
sizeof(sleep_history));
activity_insights_init(rtc_get_time());
// Make sure we don't trigger... | (rtc_get_time() + SECONDS_PER_MINUTE) | ;
activity_insights_process_minute_data(rtc_get_time());
}
}
// ---------------------------------------------------------------------------------------
void prv_set_step_history_avg() {
// History with low median
static const int32_t step_history[ACTIVITY_HISTORY_DAYS] = {
AVERAGE_STEPS, // This is 'toda... |
ace_lots_apps(void) {
uint32_t to_free;
uint32_t before_size;
uint32_t after_size;
// test random number
prv_cleanup();
to_free = 150000;
before_size = app_cache_get_size();
cl_assert(before_size >= to_free);
cl_assert_equal_i(S_SUCCESS, app_cache_free_up_space(to_free));
fake_system_task_callbacks... | (after_size == (before_size - to_free)) | |
tx);
cl_check(framebuffer_is_empty("white_over_black", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &corners_all_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_corners_all.${BIT_DEPTH_NAME}... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r7_no_clip.${BIT_DEPTH_NAME}.pbi")) | |
/*
* 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(metric_values->values[i], other->values[i]) | ;
}
}
static void prv_check_attribute_list_serialize(AttributeList *attr_list_to_serialize,
const uint8_t *expected_attr_list_serialized,
size_t expected_attr_list_serialized_size) {
uint8_t buffer[expected_attr_list_serialized_size];
... |
/*
* 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... | attribute_get_uint32_list(&attr_list_out, AttributeIdMetricIcons) | ;
for (int i = 0; i < metric_values->num_values; i++) {
cl_assert_equal_i(metric_values->values[i], other->values[i]);
}
}
static void prv_check_attribute_list_serialize(AttributeList *attr_list_to_serialize,
const uint8_t *expected_attr_list_serialized,
... |
ion 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 under the License is distributed on an "AS... | if (is_remote_connected(remote) != is_remote_connected(other)) {
return is_remote_connected(remote) ? -1 : 1;
} else {
return strncmp(remote->name, other->name, sizeof(remote->name));
} |
}
static void add_remote(SettingsBluetoothData* data, StoredRemote* remote) {
const bool ascending = false;
data->remote_list_head = list_sorted_add(data->remote_list_head, &remote->list_node,
(Comparator) remote_comparator, ascending);
}
static StoredRemote* stored_remote_create(void) {
StoredRemote* re... |
if (!attr) {
// this attribute has likely since been destroyed
return;
}
event.smartstrap.attribute = mbuf_get_data(&attr->mbuf);
if (type == SmartstrapDataReceivedEvent) {
PBL_ASSERTN(attr->state == SmartstrapAttributeStateRequestInProgress);
prv_set_attribute_state(attr, SmartstrapAttributeSt... | mutex_unlock(s_attr_list_lock) | ;
}
void smartstrap_attribute_unregister_all(void) {
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr;
FOREACH_VALID_ATTR(attr) {
// At this point, the app is closing so there's no point in freeing the buffers, and doing so
// will crash the watch if the app had crashed (and the heap has 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... | (LOG_LEVEL_DEBUG, "INITIALIZING PROFILER FOR MUTEXES!") | ;
PROFILER_INIT;
PROFILER_START;
s_mutex = mutex_create();
for (int i=0; i < 10000; i++) {
mutex_lock(s_mutex);
mutex_unlock(s_mutex);
}
mutex_destroy(s_mutex);
s_mutex = NULL;
s_rmutex = mutex_create_recursive();
for (int i=0; i < 10000; i++) {
mutex_lock_recursive(s_rmutex);
}
for ... |
lize(void) {
s_num_event_puts = 0;
s_last_event = (PebbleEvent) { 0 };
s_num_packets_sent = 0;
s_num_bytes_sent = 0;
s_log_message_buffer[0] = '\0';
s_in_critical_section = false;
pulse_logging_init();
}
void test_pulse_logging__simple(void) {
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "Test");
cl... | (s_num_event_puts, 1) | ;
cl_assert_equal_i(s_num_packets_sent, 0);
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTestE");
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_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... | {
LightMutexHandle_t freertos_mutex = xLightMutexCreateRecursive();
OS_ASSERT(freertos_mutex != NULL);
PebbleRecursiveMutex * mutex = (PebbleRecursiveMutex *)create_pebble_mutex(freertos_mutex);
return mutex;
} |
void mutex_lock_recursive(PebbleRecursiveMutex * handle) {
uintptr_t myLR = (uintptr_t) __builtin_return_address(0);
OS_ASSERT(!mcu_state_is_isr());
xLightMutexLockRecursive(handle->common.freertos_mutex, portMAX_DELAY);
LOG_LOCKED(handle->common.lr, myLR);
}
bool mutex_lock_recursive_with_timeout_and_lr(Peb... |
rt_erase = true;
}
prv_send_frame(OPCODE_FLASH_ERASE, &response, sizeof(response));
// start the erase after sending the response
if (start_erase) {
uint32_t end_address = request->address + request->length;
s_flash_erase_in_progress = true;
flash_erase_optimal_range(
request->address, requ... | {
PBL_LOG(LOG_LEVEL_ERROR, "Got frame from server (loopback?)");
prv_reset_buffer(buf);
return;
} |
// reset the timeout timer
new_timer_start(s_timeout_timer, TIMEOUT_MS, prv_timeout_timer_cb, NULL, 0 /* flags */);
// look at the opcode and handle this message
if (header->opcode == OPCODE_PING) {
prv_handle_ping_request(payload, payload_length);
} else if (header->opcode == OPCODE_DISCONNECT) {
... |
/*
* 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... | flash_write_bytes((const uint8_t*) data, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, sizeof(*data)) | ;
}
static void prv_apply_patch_to_struct(void *patch, size_t size, size_t offset, bool should_erase) {
SharedPRFData data;
prv_fetch_struct(&data);
uint8_t *unmodified_data_patch_start = ((uint8_t *)&data) + offset;
// Struct is packed, so it's OK to use memcmp:
if (memcmp(unmodified_data_patch_start, patc... |
lection_config(void) {
const PreferredContentSize runtime_platform_default_size =
system_theme_get_default_content_size_for_runtime_platform();
return s_time_selection_configs[runtime_platform_default_size];
}
static int prv_cell_width(int i, int num_cells) {
const TimeSelectionSizeConfig * const config = ... | PBL_IF_RECT_ELSE(range_text_layer, range_subtitle_text_layer) | ;
const int range_origin_y = prv_selection_config()->range_origin_y;
const int extra_line_offset_y = PBL_IF_RECT_ELSE(2, 4);
prv_vertical_align_text_layer(time_selection_window, top_layer, range_origin_y,
1, extra_line_offset_y);
const GSize top_size = app_text_layer_get_content... |
d_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, false, 1);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY, RADIU... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw11_no_clip.${BIT_DEPTH_NAME}.pbi")) | ;
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 11);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw11_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_... |
econds, SLEEP_SUMMARY_PIN_CONFIG.detail_text,
SUBTITLE_BUFFER_LENGTH, &SLEEP_SUMMARY_PIN_CONFIG);
// Generate short subtitle text with the current step count
int hours = sleep_total_seconds / SECONDS_PER_HOUR;
int minutes = (sleep_total_seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE... | attribute_list_add_uint32(&pin_attr_list, AttributeIdLastUpdated, now_utc) | ;
attribute_list_add_uint8(&pin_attr_list, AttributeIdBgColor, GColorSunsetOrangeARGB8);
const int num_responses = 2;
ResponseItem *response_items = kernel_zalloc_check(num_responses * sizeof(ResponseItem));
response_items[0] = (ResponseItem) {
.type = ActivityInsightResponseTypePositive,
.text = i18n_... |
0x99, 0x2c, 0x7a, 0x1f, 0x3b, 0x96, 0xa9, 0x70};
AppInstallId tictoc_id;
AppInstallId music_id;
AppInstallId sports_id;
AppInstallId bg_counter_id;
AppInstallId menu_layer_id;
void test_app_install_manager__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
app... | cl_assert_equal_b(true, app_install_get_entry_for_uuid(&bg_counter.uuid, &uuid_entry)) | |
graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4);
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, 2));
}
void test_graphics_context_${BIT_DEPTH_NAME}__draw_stroke_width_even(void) {
// Stroke width even > 2, non-antialiased
setup_test(&context, false, SW_EVEN, GColorB... | (&context, &GRect(10, 20, 40, 10)) | |
strcat(data->name_text_buffer, "-") | ;
}
}
text_layer_set_text(&data->name_text_layer, data->name_text_buffer);
// Set the name font
#if !PLATFORM_ROBERT && !PLATFORM_CALCULUS
const bool first_use_is_complete = shared_prf_storage_get_getting_started_complete();
const char *name_font_key;
if (first_use_is_complete || data->has_pebble_mobil... | |
+ attr->string_list->serialized_byte_length + 1; // +1 for null char
case AttributeTypeUint32List:
return Uint32ListSize(attr->uint32_list->num_values);
default:
// The rest of the types fit within the Attribute struct
return 0;
}
}
static bool prv_deep_copy_attribute(Attribute *dest, const... | PBL_LOG(LOG_LEVEL_WARNING, "Adding attribute with type uint8 for non-uint8_t attribute") | ;
}
prv_add_attribute(list, id)->uint8 = uint8;
}
void attribute_list_add_string_list(AttributeList *list, AttributeId id, StringList *string_list) {
PBL_ASSERTN(prv_attribute_type(id) == AttributeTypeStringList);
prv_add_attribute(list, id)->string_list = string_list;
}
void attribute_list_add_uint32_list(At... |
arm(void) {
prv_clear_snooze_timer();
// Read from flash since the in-memory cache can be modified
prv_alarm_operation(s_most_recent_alarm_id, prv_analytics_op,
(void *)(intptr_t)AnalyticsEvent_AlarmDismissed);
}
// --------------------------------------------------------------------------... | ("EVERY DAY") | |
es is less on round
rect.origin.y -= 10;
}
rect.origin.x -= 24;
#endif
prv_render_metric_label(ctx, &rect, metric_type, active_window, layer);
// update rect y for the label height
if (active_window->layout == WorkoutLayout_TwoStaticAndScrollable) {
rect.origin.y += prefer_larger_font ? 11 : 15;
}... | (workout_dialog, "Workout End") | ;
Dialog *dialog = workout_dialog_get_dialog(workout_dialog);
dialog_show_status_bar_layer(dialog, true);
dialog_set_fullscreen(dialog, true);
dialog_set_text(dialog, i18n_get("End Workout?", workout_dialog));
dialog_set_background_color(dialog, BACKGROUND_COLOR);
dialog_set_text_color(dialog, TEXT_COLOR);... |
_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;
static bool s_path_open;
static uint16_t s_radius;
struct PreciseLine {
GPoin... | if (s_precise_lines) {
free(s_precise_lines);
s_precise_lines = NULL;
} | |
lorWhite);
const int16_t y_offset = 1;
const int16_t padding = r.size.w / 6;
const uint16_t corner_radius = 4;
GRect bg_rect = r;
bg_rect.origin.y = layer_bounds->origin.y;
bg_rect.size.h = layer_bounds->size.h;
bg_rect = grect_inset_internal(bg_rect, padding, y_offset);
... | (aml->item_animation.animation) | ;
aml->item_animation.animation = NULL;
}
static void prv_animate_cell(ActionMenuLayer *aml, GRect *label_text_frame, bool *draw_top_shading,
bool *draw_bottom_shading) {
// Check to see if this item spans more than max number of visible lines,
// in which case we want to make it scr... |
round.
PBL_LOG(LOG_LEVEL_DEBUG, "Erase of 0x%"PRIx32" failed (attempt %d)."
" Trying again...", saved_ctx.address, saved_ctx.retries);
return prv_flash_erase_start(
saved_ctx.address, saved_ctx.on_complete_cb, saved_ctx.cb_context,
saved_ctx.is_subsector, saved_ctx.retries + 1);
} ... | (sector_addr, false /* is_subsector */, on_complete_cb, context) | ;
}
void flash_erase_subsector(uint32_t sector_addr,
FlashOperationCompleteCb on_complete_cb,
void *context) {
prv_flash_erase_async(sector_addr, true /* is_subsector */, on_complete_cb, context);
}
void flash_erase_sector_blocking(uint32_t sector_addr) {
prv_... |
sions);
static WindowStack *prv_get_window_stack(void) {
if (pebble_task_get_current() == PebbleTask_App) {
return app_state_get_window_stack();
}
return modal_manager_get_window_stack(ModalPriorityVoice);
}
static void prv_put_analytics_event(VoiceUiData *data, bool success) {
size_t response_size = 0;... | (data, StateError) | ;
ExpandableDialog *long_error_dialog = &data->long_error_dialog;
expandable_dialog_init(long_error_dialog, "Error");
Dialog *dialog = expandable_dialog_get_dialog(long_error_dialog);
const GColor dialog_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
prv_init_dialog(data, dialog, text, resource_... |
st PropertyAnimationImplementation s_center_focus_selection_animation_in_out_impl = {
.base = {
.setup = prv_center_focus_animation_setup,
.update = prv_center_focus_animation_update_in_and_out,
.teardown = prv_center_focus_animation_teardown,
}
};
static const PropertyAnimationImplementat... | PBL_LOG(LOG_LEVEL_ERROR, "Please set menu layer callbacks before running menu_layer_set_selected_index.") | ;
return;
}
const uint16_t num_rows = menu_layer->callbacks.get_num_rows(menu_layer, index.section, menu_layer->callback_context);
if (index.row >= num_rows) {
index.row = num_rows - 1;
}
// when called from iteration triggered by menu_layer_set_selected_next() the
// selection.index.section could... |
ring(time_buffer));
}
void command_set_time(const char *arg) {
time_t t = atoi(arg);
if (t == 0) {
prompt_send_response("Invalid length");
return;
}
prv_update_time_info_and_generate_event(&t, NULL);
char buffer[80];
char time_buffer[26];
prompt_send_response_fmt(buffer, 80, "Time is now <%s>",... | {
if (capitalized) {
style = FullStyleCapital12h;
} else {
style = FullStyleLower12h;
}
} |
if (timestamp_midnight == today_midnight) {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
time_fmt = i18n_noop("%l:%M %p");
break;
case FullStyleLower24h:
case FullStyleCapital24h:
time_fmt = i18n_noop("%R");
break;
}
} else if (... |
t_subscribe(&state->accel_shake_info);
}
// ----------------------------------------------------------------------------------------------
void accel_session_shake_unsubscribe(AccelServiceState *state) {
event_service_client_unsubscribe(&state->accel_shake_info);
state->shake_handler = NULL;
}
// --------------... | sys_accel_manager_set_sample_buffer(state->manager_state, state->raw_data,
samples_per_update) | ;
applib_free(old_buf);
return result;
}
|
uld be able to write the sample range at any time
prv_read_modify_write(BMI160_REG_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, (uint... | prv_run_command(BMI160_CMD_FIFO_FLUSH) | ; // clear any lingering entries
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;... |
/*
* 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... | graphics_context_set_fill_color(ctx, ring_color) | ;
graphics_fill_radial(ctx, grect_inset(DISP_FRAME, GEdgeInsets(-overdraw)),
GOvalScaleModeFitCircle, thickness + overdraw, 0, TRIG_MAX_ANGLE);
}
// 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_... |
f
typedef void (*EntryFunc)(void);
typedef enum {
ConnectionStateInvalid,
ConnectionStateChargingPlugged,
ConnectionStateDischargingPlugged,
ConnectionStateDischargingUnplugged
} ConnectionStateID;
typedef struct ConnectionState {
EntryFunc enter;
} ConnectionState;
static void prv_update_plugged_change(v... | if (charging) {
// Since we can't be charging and disconnected,
// just log a warning and pretend we aren't charging.
PBL_LOG(LOG_LEVEL_WARNING, "PMIC reported charging while unplugged - ignoring");
} |
return ConnectionStateDischargingUnplugged;
}
}
static void prv_update_state(void *force_update) {
const uint8_t MAX_SAMPLE_SKIPS = 5;
bool forced = (bool)force_update;
// Large current draws will cause the voltage supplied by the battery to
// droop. We try to only sample the battery when there is mini... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.