prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
andler }; memset(&layer, 0, sizeof(layer)); from_r = GRect(0, 0, 100, 200); // x, y, width, height to_r = GRect(1000, 2000, 100, 200); // x, y, width, height prop_h = property_animation_create_layer_frame(&layer, &from_r, &to_r); Animation *h = property_animation_get_animation(prop_h); void *context ...
prv_fire_animation_timer(); time_ms = prv_now_ms(); DPRINTF("%"PRIu64": frame at: %d, %d, %d %d\n", time_ms - start_ms, layer.frame.origin.x, layer.frame.origin.y, layer.frame.size.w, layer.frame.size.h); cl_assert(max_loops > 0); max_loops--; } // Make sure our starte...
// -------------------------------------------------------------------------------------- // Test that we can reschedule an animation from the stopped handler void test_animation__reschedule_from_stopped_handler(void) { #ifdef TEST_INCLUDE_BASIC PropertyAnimation *prop_h; Layer layer; GRect from_r; GRect to_...
t16_t rl_margin = PBL_IF_RECT_ELSE(4, 16); GRect drawing_rect = grect_inset(layer->bounds, GEdgeInsets(0, rl_margin)); const GSize icon_size = kino_reel_get_size(icon); const int icon_x = drawing_rect.origin.x + PBL_IF_RECT_ELSE(0, (rl_margin / 2)) + (drawing_rect.size.w / 2) - (icon_size.w /...
layer_set_frame(&status_layer->layer, &status_layer_bounds)
; #endif ActionBarLayer *action_bar = &summary_window->action_bar; action_bar_layer_init(action_bar); action_bar_layer_set_context(action_bar, summary_window); action_bar_layer_set_click_config_provider(action_bar, prv_click_config_provider); action_bar_layer_add_to_window(action_bar, window); summary_win...
/* * 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...
{ // Only create ReadResponseData node if length is not 0 ReadResponseData *read_response = kernel_malloc(sizeof(ReadResponseData) + val_len); if (!read_response) { *gatt_value_length = 0; return BLEGATTErrorLocalInsufficientResources; } *read_response = (const ReadResponseData) { ...
*gatt_value_length = val_len; return BLEGATTErrorSuccess; } static bool prv_ctx_in_client_event_ctxs(GattClientEventContext *context) { const bool exists = (list_contains(&s_client_event_ctxs[GAPLEClientApp]->node, &context->node) || list_contains(&s_client_event_ctxs[GAPLEClientKernel]->node, &con...
{ uint8_t status; prv_read_register(dev, dev->state->part->instructions.read_protection_status, &status, 1); return (status & dev->state->part->block_lock.protection_enabled_mask); } status_t qspi_flash_write_protection_enable(QSPIFlash *dev) { #if TARGET_QEMU return S_NO_ACTION_REQUIRED; #endif qspi_use(dev...
kernel_free(buffer_pol)
; kernel_free(buffer_mmap); return success; } struct FlashReadTestValues { int size; int offset; }; const struct FlashReadTestValues FLASH_READ_TEST_TABLE[] = { { .size = 1024, .offset = 0 }, { .size = 1025, .offset = 0 }, { .size = 1026, .offset = 0 }, { .size = 1027, .offset = 0 }, { .size = 1024...
/* * 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, success, data->context)
; } } /////////////////////////////// // Animation Related Functions /////////////////////////////// static void prv_animation_stopped_success(Animation *animation, bool finished, void *context) { ProgressWindow *data = context; const bool success = true; prv_finished(data, success); } static void prv_finis...
e { act->passed = true; printf("\nRESULTS for %s: exp: (NA), act: %d, error: NA, weighted_error: NA", name, (int)act->value); } return weighted_error; } // ========================================================================================= // Support for capturing sleep sessions detected b...
cl_assert(session->start_utc >= container_session->start_utc)
; cl_assert(session->start_utc < container_session->start_utc + container_session->len_m * SECONDS_PER_MINUTE); last_deep_session_len_m = session->len_m; // Accumulate restful sleep stats results->deep.value += session->len_m; if (deep_exit_utc == 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...
(LOG_LEVEL_INFO, "LSE oscillator started after %d ms", i)
; break; } delay_us(1000); watchdog_feed(); } if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { PBL_LOG(LOG_LEVEL_ERROR, "LSE oscillator did not start"); } } } bool clocksource_is_lse_started(void) { return (RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET); } void clockso...
_registers.core_reg[portCANONICAL_REG_INDEX_R4]) : "r0", "r1", "r2", "r3", "cc" ); } EXTERNALLY_VISIBLE void core_dump_handler_c(void) { // Locate the stack pointer where the processor state was stacked before the // NMI handler was executed so that the saved state can be copied into // s_saved_registers...
&& ((s_time_stamp - image_hdr.time_stamp) < CORE_DUMP_MIN_AGE_SECONDS)) { prv_debug_str("CD: Still fresh"); #ifndef IS_BIGBOARD prv_reset(); #else prv_debug_str("CD: BigBoard, forcing dump"); #endif } } // Get flash address to save new image to. This method also pre-...
// uint32_t registers[17]; // thread registers [r0-r12, sp, lr, pc, xpsr] // } // // Start at the core dump image header s_flash_addr = flash_base + sizeof(CoreDumpFlashRegionHeader); // Write out the core dump header ----------------------------------- s_flash_addr += prv_write...
*window, GContext *ctx) { PBL_ASSERTN(window); if (window->on_screen == false) { window->is_render_scheduled = false; return; } // workaround for 3rd-party apps // if a window is configured as non-fullscreen, it's frame needs to start at .origin={0,0} // to compensate for cases where clients conf...
PBL_ASSERT(window->in_click_config_provider, "Click %s must be set from click config provider (Window %p)", type, window)
bi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_across_x_origin_layer"))); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &across_nx_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_acr...
graphics_draw_horizontal_line_dotted(&ctx, GPoint(7, 24), 10)
tonId BUTTON_FORWARD = BUTTON_ID_DOWN; static const ButtonId BUTTON_BACKWARD = BUTTON_ID_UP; static const int16_t BOUNCEBACK_OFFSET = 6; // These offsets get rid of the empty space above the first line of text, // enabling neater animations by clipping immediately at the top of the text. static const int16_t TITLE_BOU...
prv_create_layer_upwards_animation(&data->title_text_layer.layer, TITLE_BOUNDS_OFFSET)
, prv_create_layer_upwards_animation(&data->position_text_layer.layer, TIME_BOUNDS_OFFSET), prv_create_layer_upwards_animation(&data->length_text_layer.layer, TIME_BOUNDS_OFFSET), NULL); } static const PropertyAnimationImplementation s_frame_layer_implementation = { .base = { .update = (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...
layer_add_child(&window->layer, &data->text_layer.layer)
; GSize size_used = text_layer_get_content_size(app_get_current_graphics_context(), &data->text_layer); PBL_LOG(LOG_LEVEL_DEBUG, "Max size used %d %d", size_used.w, size_used.h); } static void push_window(struct AppState *data) { Window* window = &data->window; ...
TICS_APP_METRIC_FLASH_READ_BYTES_COUNT, analytics_read_bytes_count, AnalyticsClient_App); analytics_set(ANALYTICS_APP_METRIC_FLASH_WRITE_BYTES_COUNT, analytics_write_bytes_count, AnalyticsClient_App); // The overhead cost of tracking whether each flash read was due to the foreground // or background app is large...
NVIC_DisableIRQ(FLASH_DMA_IRQn)
; signed portBASE_TYPE was_higher_priority_task_woken = pdFALSE; xSemaphoreGiveFromISR(s_flash_state.dma_semaphore, &was_higher_priority_task_woken); portEND_SWITCHING_ISR(was_higher_priority_task_woken); return; //notreached } } static void flash_deep_sleep_enter(void) { assert_usable_state(); ...
num_samples; *num_values = 0; *num_samples = 0; *num_types = 0; PLogTypesDecoderArg types_decoder_arg = { .max_num_types = max_num_types, .num_types = num_types, .types = types, }; PLogMeasurementsDecoderArg measurements_decoder_arg = { .max_num_samples = max_num_samples, .num_samples...
{ *payload_sender_v_major = payload.sender.version.major; *payload_sender_v_minor = payload.sender.version.minor; }
*type = ProtobufLogType_Events; return success; }
es unresponsive (PBL-40008). This timer watches to see if we have stopped receiving // sensor interrupts and will trigger logic to reset the sensor if necessary. static RegularTimerInfo s_as7000_watchdog_timer; // Incremented by s_as7000_watchdog_timer. Reset to 0 by our interrupt handler. static uint8_t s_missing_int...
(data->x * 2)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ struct tm apr_3_13_00 = { .tm_sec = 0, .tm_min = 0, .tm_hour = 13, .tm_mday = 3, .tm_mon = 3, // Apr .tm_year = 2015 - 1900, .tm_isdst = 1, }; // DST info for US/Canada 2015 TimezoneInfo tz_info = { .dst_start = 1425780000, // Sun, 08 Mar 2015 02:00 .dst_end = 1446343200 /...
1024, 488, -296}, { 1056, 576, -416}, { 1224, 520, -200}, { 1488, 536, -152}, { 1592, 448, -96}, { 1304, 432, -88}, { 1112, 416, -128}, { 1008, 304, -72}, { 928, 240, -56}, { 904, 176, -112}, { 808, 88, -48}, { 888, 96, -144}, { 896, 48, -120}, { 1040, 56, -160}, ...
{ 1160, 472, -328}, { 1320, 592, -424}, { 1448, 624, -384}, { 1432, 448, -144}, { 1368, 360, -136}, { 1064, 304, -216}, // 29 seconds { 872, 248, -160}, { 744, 200, -40}, { 688, 184, -128}, { 728, 200, -104}, { 864, 224, -112}, { 1096, 232, -112}, { 1072, 192, -80...
{ 144, -72, -840}, { 144, 0, -952}, { 224, 0, -952}, { 256, 8, -1040}, { 464, 40, -1088}, { 536, 264, -1160}, { 632, 176, -1192}, { 584, 160, -1040}, { 456, 88, -896}, { 280, -56, -656}, { 208, -40, -584}, { 176, -80, -472}, { 168, -40, -552}, { 240, -72, -768}, ...
compositing_mode); return; } #endif // Backup context color const GColor ctx_color = ctx->draw_state.stroke_color; if (grect_contains_point(&src->bounds, &src_ic)) { // TODO: Optimize further (PBL-15657) // If src_ic is within the bounds of the source image, do the following performance // o...
{ // more color thresh += (horiz_contrib[i+1] * vert_contrib[j+1]); }
else { // less color thresh -= (horiz_contrib[i+1] * vert_contrib[j+1]); } } } } if (thresh > 0) { ctx->draw_state.stroke_color = foreground; } else { ctx->draw_state.stroke_color = background; } if (!gcolor_is_tr...
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax2_aa_clip_nxny.${BIT_DEPTH_NAME}.pbi"))
; #endif } void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_corners(void) { GContext ctx; test_graphics_context_init(&ctx, fb); // TODO: Currently prv_fill_rect only supports up to radius 8, fix in PBL-15916 to support // arbitrary radius values - this affects all tests here setup_test_aa_sw(&ctx, fb,...
equal_i(context.draw_state.fill_color.argb, GColorOrange.argb); #else cl_assert_equal_i(context.draw_state.fill_color.argb, GColorDarkGray.argb); #endif color.a = 1; graphics_context_set_fill_color(&context, color); cl_assert_equal_i(context.draw_state.fill_color.argb, GColorClear.argb); color.a = 0; grap...
graphics_line_draw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10))
); setup_test(&context, false, 1, GColorBlack, GColorBlack, false); graphics_draw_rect(&context, &GRect(10, 20, 40, 10)); ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10))); setup_test(&context, false, 1, GColorBlack, GColorBlack, false); graphics_draw_circle(&context, GPoint(50, 50), 10); ASS...
doesn't mind if // we feed it CESU-8 encoded strings... Test this, so we know when this changes in the future: EXECUTE_SCRIPT("var pileOfPooCESU8 = '\xed\xa0\xbd\xed\xb2\xa9';"); // Expect a pair of surrogate code points: EXECUTE_SCRIPT_AND_ASSERT_RV_EQUALS_S("pileOfPooCESU8.charCodeAt(0).toString(16)", "d83d")...
JS_GLOBAL_GET_VALUE("str")
; const jerry_size_t utf8_size = jerry_get_utf8_string_size(s); // U+1F4A9 is expected to get encoded into 4 bytes of UTF-8: cl_assert_equal_i(utf8_size, cases[i].expected_utf_size); const size_t buffer_size = utf8_size ? (is_overflow_test ? (utf8_size - 1) : utf8_size) : 0; // malloc, ...
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 under the License is d...
if (is_set) { m->flags |= flag; } else { m->flags &= ~flag; }
} MBuf *mbuf_get_next(MBuf *m) { PBL_ASSERTN(m); return m->next; } uint32_t mbuf_get_length(MBuf *m) { PBL_ASSERTN(m); return m->length; } uint32_t mbuf_get_chain_length(MBuf *m) { uint32_t total = 0; while (m) { total += m->length; m = m->next; } return total; } // MBuf chain management /...
_sequence = gbitmap_sequence_create_with_resource(resource_id); cl_assert(bitmap_sequence); GBitmap *bitmap = gbitmap_create_blank(GSize(180, 180), GBitmapFormat8BitCircular); cl_assert(bitmap); // Since frame 1 has 0 delay, it renders then immediately we render frame 2 gbitmap_sequence_update_bitmap_by_ela...
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)))
; status = gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL); cl_assert_equal_b(status, true); cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3))); #endif } void test_gbitmap_sequence__1bit_to_1bit_notification(void) { uint32_t resource_id = sys_resource_load_file_as_resource(TEST_IMAGES_...
1); graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_origin_aa_r16_no_clip.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1); graphics_draw_circle(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_BIG);...
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_nx_offset_layer.${BIT_DEPTH_NAME}.pbi"))
; test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &across_y_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_y_offset_layer.${BIT_DEPTH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&lay...
nable_backlight_for_type(AlertMobile)); cl_assert(alerts_should_notify_for_type(AlertReminder)); cl_assert(!alerts_should_vibrate_for_type(AlertReminder)); alerts_set_notification_vibe_timestamp(); fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS); cl_assert(!alerts_should_enable_backligh...
cl_assert(alerts_should_vibrate_for_type(AlertReminder))
; alerts_set_notification_vibe_timestamp(); fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS); cl_assert(alerts_should_enable_backlight_for_type(AlertReminder)); cl_assert(alerts_should_notify_for_type(AlertOther)); cl_assert(alerts_should_vibrate_for_type(AlertOther)); alerts_set_notif...
/* * 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 HcProtocolMessagePairingRequestPayload *request = (const HcProtocolMessagePairingRequestPayload *)msg->payload; pairing_confirm_handle_request(&request->device); break; }
handler(Window *window, WindowHandlerOffset handler_offset) { if (window == NULL) { return; } WindowHandler handler = *(WindowHandler*)(((uint8_t*)&window->window_handlers) + handler_offset); if (handler) { handler(window); } } void window_schedule_render(Window *window) { window->is_render_schedul...
(window_manager_get_top_window(), "context")
; ClickManager *mgr = prv_get_current_click_manager(); ClickConfig *cfg = &mgr->recognizers[button_id].config; cfg->context = context; } void window_single_click_subscribe(ButtonId button_id, ClickHandler handler) { Window *window = window_manager_get_top_window(); prv_check_is_in_click_config_provider(wind...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
if (success) { s_last_send_time = rtc_get_time(); analytics_inc(ANALYTICS_DEVICE_METRIC_PING_SENT_COUNT, AnalyticsClient_System); }
PBL_LOG(LOG_LEVEL_DEBUG, "Sent ping idle=%d, success=%d", (int)idle, (int)success); } s_is_ping_kernel_bg_callback_scheduled = false; } // ------------------------------------------------------------------------------------------------------------ // If a ping is due to be sent, send it. // bt_lock() is held...
ASTER_MODE_SELECT, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED, I2C_EVENT_MASTER_BYTE_TRANSMITTED, I2C_EVENT_MASTER_MODE_SELECT, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED, I2C_EVENT_MASTER_BYTE_RECEIVED, I2C_EVENT_MASTER_BYTE_TRANSMITTING, I2C_EVENT_MASTER_BYTE_TRANSMITTED, }; static bool s_initialized = fa...
(BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_sda)
; BOARD_CONFIG.i2c_bus_configs[bus_idx].rail_ctl_fn(true); } //! Initialize the I2C peripheral //! Lock the bus and peripheral config access before initialization static void bus_init(uint8_t bus_idx) { // Initialize peripheral I2C_InitTypeDef i2c_init_struct; I2C_StructInit(&i2c_init_struct); if (BOARD_CO...
ddr, 0x00, sizeof(s_last_driver_addr)); } return cl_mock_type(void); } BTDeviceAddress s_last_bt_persist_pinned_addr; bool s_last_bt_persist_pinned_addr_is_null; bool bt_persistent_storage_get_ble_pinned_address(BTDeviceAddress *address_out) { if (s_last_bt_persist_pinned_addr_is_null) { return false; } ...
{ prv_init_no_pinnings_no_pinned_address(); // flip to make sure that bt_local_addr_pause_cycling() will set these again: s_last_driver_allow_cycling = true; s_last_driver_addr_is_null = false; cl_will_return(bt_driver_set_local_address, 0); bt_local_addr_pause_cycling(); cl_assert_equal_b(false, s_last...
void test_local_addr__pin_unpin(void) { prv_init_no_pinnings_no_pinned_address(); // Pin: cl_will_return(bt_driver_set_local_address, 0); cl_will_return(bt_persistent_storage_has_pinned_ble_pairings, true); bt_local_addr_pin(&TEST_PINNED_ADDR_1); bt_local_addr_handle_bonding_change(TEST_BONDING_ID, BtPer...
i(1, s_test_func_imp_call_count); rocky_add_function(prototype, "method", method_func_imp); EXECUTE_SCRIPT("var y = new _rocky.test(); y.method();"); cl_assert_equal_i(1, s_method_func_imp_call_count); } void test_rocky_api_util__error_print(void) { s_log_internal__expected = (const char *[]){ "Unhandled ...
jerry_release_value(getSeconds)
; jerry_release_value(now); } void test_rocky_api_util__ecma_date_make_day(void) { #ifdef EMSCRIPTEN printf("Skipping test %s", __FUNCTION__); #else cl_assert_equal_d(16861, ecma_date_make_day(2016, 2, 1)); // JerryScript's unit-test cl_assert_equal_d(-25294, ecma_date_make_day(1900, 9, 1)); // not a leap yea...
oken) + 1, "%d", &state->test_entry.in_sleep.min); } else if (strcmp(token, "TEST_IN_SLEEP_MAX") == 0) { sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.max); } else if (strcmp(token, "TEST_IN_DEEP_SLEEP") == 0) { sscanf(token + strlen(token) + 1, "%d", &state->test_ent...
(token, "//>")
== 0) { token = strtok(NULL, " \t\n"); if (strcmp(token, "TEST_VERSION") == 0) { sscanf(token + strlen(token) + 1, "%d", &state->test_entry.version); } else if (strcmp(token, "TEST_ACTIVITY_TYPE") == 0) { sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.value)...
}, { 776, 72, 160}, { 768, 80, 120}, { 784, 112, 40}, { 912, 128, 24}, { 1120, 168, 16}, { 1232, 56, 80}, { 1600, -56, 176}, { 1464, 128, 136}, { 672, 456, -216}, { 712, 256, -168}, { 848, 48, 96}, { 808, 112, 168}, { 816, 96, 144}, { 832, 184, 112}, { 792, 32...
{ 768, -40, 168}, { 992, 8, 144}, { 1288, 144, 136}, { 1496, 240, 136}, { 1872, 312, 152}, { 944, 920, -136}, { 848, 120, 152}, { 904, -88, 256}, { 760, -312, 256}, { 736, -264, 184}, { 664, 32, 32}, { 696, 144, 8}, { 744, 144, -48}, { 864, 256, -152}, { 920, ...
{ 816, 200, -8}, { 936, 208, 0}, { 1088, 208, 80}, // 56 seconds { 1376, 240, 120}, { 1816, 384, 136}, { 1352, 512, 80}, { 760, 320, -8}, { 1072, 200, -224}, { 952, -72, 408}, { 632, -424, 272}, { 920, 112, 128}, { 776, 160, 112}, { 728, 128, 120}, { 696, 88,...
ancs_invalidate_all_references(); } // Keep around the BLECharacteristic references: memcpy(s_ancs_client->characteristics, characteristics, sizeof(BLECharacteristic) * NumANCSCharacteristic); // Subscribe to Data, then to Notification characteristics: for (int c = ANCSCharacteristicData; c >= AN...
PBL_ASSERTN(data != NULL)
; analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_DS_COUNT, AnalyticsClient_System); if (length < 1) { PBL_LOG(LOG_LEVEL_ERROR, "Received ANCS DS notification of length 0"); return; } analytics_add(ANALYTICS_DEVICE_METRIC_NOTIFICATION_BYTE_IN_COUNT, length, AnalyticsClient_System); if (s_a...
s_in_received_is_called = false; static bool s_in_dropped_is_called = false; static bool s_ack_received_for_id_1 = false; static bool s_nack_received_for_id_2 = false; static AppMessageResult s_dropped_reason = APP_MSG_OK; static AppMessageCtx s_app_message_ctx; typedef void (*RemoteReceiveHandler)(uint16_t endpoint...
{ s_ack_sent_is_called = true; prv_send_ack_nack(endpoint_id, data, length, false); }
xt ctx; test_graphics_context_init(&ctx, fb); // No Clip, Angle 0 setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign); graphics_draw_rotated_bitmap(&ctx, test_image_bw, GPointZero, DEG_TO_TRIGANGLE(0), GPointZero); cl_check(gbitmap_pbi_e...
(&ctx.dest_bitmap, "draw_rotated_bitmap_origin_color_assign_0.Xbit.pbi")
); // Top-left corner rotation point, Angle 45 setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign); graphics_draw_rotated_bitmap(&ctx, test_image_color, GPointZero, DEG_TO_TRIGANGLE(45), GPointZero); cl_check(gbitmap_pbi_eq(&ctx.dest_bitma...
8, 592, -416}, { 1048, 608, -328}, { 1160, 624, -280}, { 1088, 584, -296}, { 1216, 544, -152}, { 1320, 528, -80}, // 122 seconds { 1512, 552, -80}, { 1464, 464, -16}, { 1320, 384, 24}, { 1144, 312, 0}, { 1008, 296, -72}, { 872, 256, -120}, { 736, 176, -144}, { 680...
{ -24, -128, -944}, { -16, -112, -960}, { -16, -104, -960}, { -24, -88, -968}, { -32, -80, -976}, { -32, -80, -976}, { -56, -96, -936}, { -72, -72, -952}, { -72, -56, -968}, { -56, -40, -984}, { -72, -48, -976}, { -72, -64, -952}, { -88, -56, -936}, { -88, -32, -9...
{ -144, 168, -952}, { -168, 240, -920}, { -176, 200, -920}, { -224, 240, -888}, { -216, 240, -888}, { -216, 224, -856}, { -176, 232, -856}, { -136, 280, -912}, { -80, 264, -912}, { -72, 224, -896}, { -80, 200, -864}, { -56, 208, -904}, { -40, 304, -928}, { 24, 11...
jobs should never // get unscheduled: cl_assert_equal_i(s_unscheduled_cb_count, 2); cl_assert_equal_b(s_unscheduled_completed, true); } free(ad_a); free(ad_b); free(ad_c); free(ad_d); } // Tests that the adv data is set when a job goes from a silent term to a non-silent one, and // another job's...
gap_le_is_advertising_enabled()
, true); assert_ad_data("A"); gap_le_assert_advertising_interval(advert_terms_a[0].min_interval_slots, advert_terms_a[0].max_interval_slots); // After A's first term, expect that B's second term will follow. B's first term was silent, so // this "ran" at the same time as A...
(pop_item->window)
) { window_from = pop_item->window; // If no transition is explicitly provided, use the one specified when pushed. transition = transition ?: pop_item->pop_transition_implementation; PBL_ASSERTN(transition); } else { // We don't intentionally clean up the .pop_transition of a previous element if ...
scheduled_days = &custom_schedule1 }); prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_CUSTOM, custom_schedule1); alarm_set_kind(id, ALARM_KIND_WEEKDAYS); prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_WEEKDAYS, s_weekday_schedule); } void test_alarm__alarm_set_custom(void) { AlarmId id; id = alar...
alarm_get_string_for_custom(schedule_9, alarm_day_text_9)
; cl_assert_equal_s(alarm_day_text_9, "Sundays"); } void test_alarm__alarm_set_get_enabled(void) { AlarmId id1, id2; id1 = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY }); cl_assert_equal_i(s_num_timeline_adds, 3); cl_assert_equal_i(s_num_timeline_removes, 0); alarm_set...
new_node->prev = node->prev; if (node->prev) { node->prev->next = new_node; } node->prev = new_node; return new_node; } ListNode* list_pop_head(ListNode *node) { if (node == NULL) { return NULL; } ListNode *head = list_get_head(node); ListNode *new_head = head->next; list_remove(head, NULL...
filter_callback(cursor, data)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
string_list_count(list)
); cl_assert_equal_s("ab", string_list_get_at(list, 0)); cl_assert_equal_s("c", string_list_get_at(list, 1)); // 3 strings (last two are is empty) list->serialized_byte_length = 4; list->data[0] = 'a'; list->data[1] = 'b'; list->data[2] = '\0'; list->data[3] = '\0'; // end of data list->data[4] = '\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...
{ ISCTYPE_TEST(isascii) }
[0] != 0); break; } } // Did we get samples? if (state->test_entry.num_samples > 0) { return true; } else { return false; } } // --------------------------------------------------------------------------------------- static bool prv_parse_activity_samples_file(ActivitySampleDiscoveryState...
strlen(token)
+ 1, "%d, 0x%x, %d, %d", &steps, &orientation, &vmc, &light); } else if (state->test_entry.version == 3) { sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d, %d", &steps, &orientation, &vmc, &light, &plugged_in); } else { cl_assert(false); } fflush(stdout); ...
/* * 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...
((HcTestUnmodTxStart *)&msg->payload[0])
; break; case HcMessageID_Test_UnmodulatedTxStop: rwip_prevent_sleep(false); hw_rf_stop_continuous_wave(); break; case HcMessageID_Test_Core_Dump: prv_handle_core_dump_request((BtleCoreDump) msg->payload[0]); break; default: PBL_LOG(LOG_LEVEL_ERROR, "HcTest: unhandl...
PIFlash *dev, uint32_t addr, bool is_subsector) { const uint32_t size_bytes = is_subsector ? SUBSECTOR_SIZE_BYTES : SECTOR_SIZE_BYTES; const uint32_t BUF_SIZE_BYTES = 128; const uint32_t BUF_SIZE_WORDS = BUF_SIZE_BYTES / sizeof(uint32_t); uint32_t buffer[BUF_SIZE_WORDS]; for (uint32_t offset = 0; offset < siz...
qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_status, dev->state->part->status_bit_masks.busy, false /* !set */, QSPI_NO_TIMEOUT)
size = PBL_IF_RECT_ELSE(TimelineResourceSizeSmall, TimelineResourceSizeLarge), .icon_pos = { ICON_POSITION_X, PBL_IF_RECT_ELSE(11, 22) }, .caller_id_pos_y = PBL_IF_RECT_ELSE(80, 88), .caller_id_height = 60, .status_pos_y = PBL_IF_RECT_ELSE(138, 144), .status_height = 20, .large_caller_id = true, }; static ...
kino_reel_scale_segmented_set_deflate_effect(kino_reel, UNFOLD_EXPAND)
; kino_layer_set_reel(&s_phone_ui_data->icon_layer, kino_reel, true); kino_layer_play(&s_phone_ui_data->icon_layer); s_phone_ui_data->current_icon = image; s_phone_ui_data->current_icon_id = resource; #else kino_layer_set_reel(&s_phone_ui_data->icon_layer, image, true); s_phone_ui_data->current_icon = image...
(StatusBarLayer *status_bar_layer, StatusBarLayerSeparatorMode mode) { PBL_ASSERTN(status_bar_layer); status_bar_layer->config.separator.mode = mode; layer_mark_dirty(&(status_bar_layer->layer)); } void status_bar_layer_set_separator_load_percentage(StatusBarLayer *status...
if (!gcolor_is_transparent(config->background_color)) { graphics_context_set_fill_color(ctx, config->background_color); graphics_fill_rect(ctx, bounds); }
// Set context text color and compositing mode graphics_context_set_text_color(ctx, config->foreground_color); graphics_context_set_compositing_mode(ctx, GCompOpSet); // update title buffer with time if in StatusBarLayerModeClock if (config->mode == StatusBarLayerModeClock) { clock_copy_time_string(con...
ata->line_p1); } else if (shape == SQUARE) { graphics_draw_rect(ctx, &data->square); } else if (shape == RECTANGLE) { graphics_draw_rect(ctx, &data->rect); } else if (shape == RECTANGLE_ROUND) { graphics_draw_round_rect(ctx, &data->rectr, data->rectr_radius); } else if (shape == CIRCLE...
GPoint(10, 80)
; gpath_move_to(data->triangle, data->triangle_offset); data->triangle_velocity_x = 1; data->triangle_velocity_y = 1; // Open bucket data->bucket = gpath_create(&s_bucket_path); data->bucket_offset = GPoint(20, 30); gpath_move_to(data->bucket, data->bucket_offset); data->bucket_velocity_x = 1; data->...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ HcProtocol_GapDeviceNameResponseHeader header; uint8_t name[evt->length]; }
HcProtocol_GapDeviceNameResponse; HcProtocol_GapDeviceNameResponse response; connection_get_address(connection, &response.header.addr); response.header.name_length = evt->length; memcpy(response.name, evt->value, evt->length); hc_protocol_enqueue_with_payload(HcEndpointID_GapService, ...
/* * 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...
{ NVIC_SystemReset(); __builtin_unreachable(); }
create a dummy with only the fields we need, but oh well. #include "applib/ui/animation_private.h" #include <stdarg.h> //! List of all animations that were created in the current test in order of creation. ListNode *s_animations; // Fake implementations of the real animation interface. /////////////////////////////...
{ AnimationPrivate *animation = (AnimationPrivate *)animation_h; if (!animation) { return false; } return animation->scheduled; }
uint32_t animation_get_duration(Animation *animation, bool include_delay, bool include_play_count) { if (!animation) { return 0; } return ((AnimationPrivate *)animation)->duration_ms; } static void prv_call_started(AnimationPrivate *animation, uintptr_t UNUSED context) { if (animation->implementation && ...
n_focus, true); cl_assert_equal_i(window1->on_screen, true); window_stack_remove(window1, true); cl_assert_equal_i(window1->on_screen, false); cl_assert_equal_i(window_stack_count(app_stack), 0); window_destroy(window1); window_destroy(window2); } // Tests modal and app transitions with an unfocusable ...
(prv_get_load_unload_count(), 1)
; // Ensure the appear handler was called cl_assert_equal_i(prv_get_appear_disappear_count(), 1); // Ensure the click config handler was called cl_assert_equal_i(window->is_waiting_for_click_config, false); window_stack_pop(stack, false); cl_assert_equal_i(window_stack_count(stack), 0); // Ensure the...
/* * 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...
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false)
; #endif window_render(&card->window, &s_ctx); cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); }
.id = {0x01}, .parent_id = {0}, .timestamp = 1421020800, // midnight jan 12, 2015 UTC .duration = MINUTES_PER_DAY, .type = TimelineItemTypePin, .all_day = 1, .layout = LayoutIdTest, }, .attr_list = { .num_attributes = 0, .attributes = NULL, }...
cl_assert(iter_next(&iterator))
; cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id)); // check sixth cl_assert(iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id)); // check rollover behaviour cl_assert(!iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].he...
e "util/hash.h" #include "util/math.h" #include "util/size.h" #include "clar.h" #include <stdio.h> static GContext s_ctx; // Fakes ///////////////////// #include "fake_content_indicator.h" #include "fake_spi_flash.h" #include "fixtures/load_test_resources.h" GContext *graphics_context_get_current_context(void) { ...
(GColorLightGray)
, GColorLightGray, NULL, RESOURCE_ID_ACTION_BAR_ICON_CHECK, NULL); // Scroll down to the last page where we will observe the orphan avoidance effect const uint32_t num_times_to_scroll_down = 2; prv_push_and_render_expandable_dialog(expandable_dialog, num_times_to_scroll_down); cl_check(gbitmap_pbi_eq(&s_c...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
if (len != 12) { return false; }
uint8_t* src = (uint8_t*) hex_str; uint8_t* dest = bd_addr + bd_addr_size - 1; for (unsigned int i = 0; i < bd_addr_size; ++i, src += 2, --dest) { *dest = ascii_hex_to_uint(src[0], src[1]); } return true; } uint32_t next_exponential_backoff(uint32_t *attempt, uint32_t initial_value, uint32_t max_valu...
/* * 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 (e) { list_remove(&e->node, (ListNode **) &s_head, NULL); free(e); return 0; } else { // Doesn't exist ++s_whitelist_error_count; return -1; }
} bool fake_HCIAPI_whitelist_contains(const BTDeviceInternal *device) { const WhitelistEntry model = { .Address_Type = device->is_random_address ? 0x01 : 0x00, .Address = BTDeviceAddressToBDADDR(device->address), }; return (prv_find_whitelist_entry(&model) != NULL); } uint32_t fake_HCIAPI_whitelist_cou...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
stop_mode_disable(InhibitorCommMode)
/* * 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 (device_name) { strncpy(device_name, connection->device_name, BT_DEVICE_NAME_BUFFER_SIZE); device_name[BT_DEVICE_NAME_BUFFER_SIZE - 1] = '\0'; }
unlock: bt_unlock(); return bonding_id; } void bt_driver_store_device_name_kernelbg_cb(void *ctx) { char device_name[BT_DEVICE_NAME_BUFFER_SIZE]; BTBondingID bonding_id = prv_get_bonding_id_and_name_from_address_safe(ctx, device_name); kernel_free(ctx); if (bonding_id == BT_BONDING_ID_INVALID) { ret...
ote that we'll destroy the attribute list's attributes below in the cleanup section // Advance the cursor by the serialized slice's total size glance_buffer_cursor += serialized_slice_total_size; } // Check that we fully populated the serialized glance buffer rv = (glance_buffer_cursor == glance_buffer_...
if (!serialized_glance_size) { return E_DOES_NOT_EXIST; } else if (serialized_glance_size < 0) { WTF; }
uint8_t *serialized_glance = kernel_zalloc((size_t)serialized_glance_size); if (!serialized_glance) { return E_OUT_OF_MEMORY; } status_t rv = app_glance_db_read(key, key_size, serialized_glance, serialized_glance_size); if (rv != S_SUCCESS) { goto cleanup; } rv = prv_deserialize_glance((Serial...
/* * 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...
contacts_db_free_serialized_contact(serialized_contact)
; return contact; } void contacts_free_contact(Contact *contact) { kernel_free(contact); }
--------------------------------------- // Test the logic that detects naps. This logic is performed by the // prv_sleep_sessions_post_process() method. void test_activity_algorithm_kraepelin__sleep_post_process(void) { // NOTE: All tests by default start at 5pm. Let's advance time to 9pm to give us more // time to...
ARRAY_LENGTH(sessions)
; activity_algorithm_post_process_sleep_sessions(session_entries, sessions); cl_assert_equal_i(sessions[0].type, ActivitySessionType_Sleep); cl_assert_equal_i(sessions[1].type, ActivitySessionType_RestfulSleep); } { // Create a 2h 39m session that starts at 11:59pm ==> should be regular sleep Acti...
moved to board-specific implementations // https://pebbletechnology.atlassian.net/browse/PBL-32232 #if CAPABILITY_HAS_PMIC void i2c_rail_ctl_pmic(I2CBus *bus, bool enable) { set_ldo3_power_state(enable); } #endif void i2c_rail_ctl_pin(I2CBus *bus, bool enable) { gpio_output_set(&bus->rail_gpio, enable); } static...
{ prv_bus_pins_cfg_input(bus); }
} //! Perform a soft reset of the bus //! Always lock the bus before reset static void prv_bus_reset(I2CBus *bus) { prv_bus_disable(bus); prv_bus_enable(bus); } /*---------------INIT/USE/RELEASE/RESET FUNCTIONS----------------------*/ void i2c_init(I2CBus *bus) { PBL_ASSERTN(bus); *bus->state = (I2CBusStat...
20, -912}, { -152, -224, -848}, { -136, -96, -920}, { -64, -160, -840}, { -280, -336, -824}, { -376, -168, -840}, { -408, 16, -712}, { -352, 144, -416}, { -560, 992, -288}, { -528, 1048, -328}, { -768, 1176, -152}, { -624, 1144, 224}, { -400, 696, -120}, { -512, 888, ...
// 92 seconds { 128, 800, 592}, { 104, 872, 536}, { 64, 904, 472}, { 64, 928, 416}, { 80, 768, 464}, { 160, 664, 472}, { 136, 640, 544}, { 160, 560, 728}, { 208, 400, 736}, { 208, 336, 680}, { 264, 264, 688}, { 280, 472, 696}, { 288, 640, 704}, { 320, 544, 624...
{ 232, 704, 536}, { 248, 728, 496}, { 288, 728, 488}, { 320, 648, 472}, { 328, 768, 552}, { 344, 736, 568}, // 95 seconds { 368, 704, 560}, { 392, 720, 568}, { 384, 712, 608}, { 360, 704, 576}, { 368, 792, 584}, { 312, 688, 608}, { 296, 664, 600}, { 264, 624,...
essage_queue_pop_head(); } else { if (s_state.out.failure_count >= CONTROL_MESSAGE_MAX_FAILURES) { MessageNode *node = s_state.out.control_msg_queue; PBL_LOG(LOG_LEVEL_ERROR, "Failed to send msg with key %"PRIu32, node ? node->key : 0); prv_control_message_queue_pop_head(); ...
MIN(rc->max_supported_version, POSTMESSAGE_PROTOCOL_MAX_VERSION)
; // NOTE: Each end communicates it's OWN TX/RX max values. // This means that TX max on one end is bound by RX max on the other, and vice versa. s_state.tx_chunk_size_bytes = MIN(rc->max_rx_chunk_size, POSTMESSAGE_PROTOCOL_MAX_TX_CHUNK_SIZE); s_state.rx_chunk_size_bytes = MIN(rc->max_tx_chunk_size, POSTM...
app_install_enumerate_entries(AppInstallEnumerateCb cb, void *data) { // Keep this off of the stack. This function presses the limits of our stack. AppInstallEntry *entry = kernel_malloc_check(sizeof(AppInstallEntry)); // Iterate over the registry for (uint32_t i = 0; i < ARRAY_LENGTH(APP_RECORDS); i++) { ...
app_install_id_from_app_db(cur_app_id)
))) { PBL_LOG(LOG_LEVEL_DEBUG, "close and delay callbacks for app closing"); s_install_callback_data.callback_paused_for_app = true; s_pending_app_deletion = cur_app_id; app_manager_close_current_app(true); } // Close the current worker if it is the one we are trying to rem...
/* * 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...
(window_layer, text_layer_get_layer(text_layer))
; } static void window_unload(Window *window) { text_layer_destroy(text_layer); } static void init(void) { window = window_create(); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); const bool animated = true; window_stack_push(window, animate...
/* * 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_data.option_menu, &option_menu_config)
; const OptionMenuCallbacks callbacks = { .draw_row = config->callbacks.draw_row ?: prv_menu_draw_row, .get_num_rows = config->callbacks.get_num_rows ?: prv_menu_get_num_rows, .get_cell_height = config->callbacks.get_cell_height ?: NULL, }; option_menu_set_callbacks(&s_data.option_menu, &callbacks, c...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
PBL_LOG(LOG_LEVEL_DEBUG, "argh %d %d", num_beers, status)
; menu_layer_reload_data(menu_layer); break; } case 2: { int num_beers = persist_read_int(COUNT_PKEY); persist_write_int(COUNT_PKEY, num_beers-1); menu_layer_reload_data(menu_layer); break; } } } static void select_long_callback(MenuLayer *menu_layer, MenuIndex *cell_i...
rray_size + 1) * 2; s_custom_res_list.custom_resources = realloc(s_custom_res_list.custom_resources, new_size); s_custom_res_list.array_size = new_size; } s_custom_res_list.custom_resources[s_custom_res_list.next_index] = *res; ++s_custom_res_list.next_index; } static void prv_custom_resource_remove(uin...
if (!s_resource_file) { printf("Error: Failed to open resources file\n"); return false; }
return true; } void emx_resources_deinit(void) { fclose(s_resource_file); } uint32_t emx_resources_register_custom(ResourceReadCb read_cb, ResourceGetSizeCb get_size_cb) { EmxCustomResource custom_res = { .resource_id = ++s_custom_res_list.last_id, .read = read_cb, .get_size = get_size_cb, }; ...
tc = mset.time_end_utc; *decoder_info->utc_to_local = mset.utc_to_local; return success; } typedef struct PLogEventsDecoderArg { uint32_t max_num_events; uint32_t *num_events; pebble_pipeline_Event *events; Uuid *event_uuids; uint32_t max_num_sessions; uint32_t *num_sessions; ActivitySession *sessio...
pb_istream_from_buffer(encoded_buf, encoded_buf_size)
; const uint32_t max_num_types = *num_types; const uint32_t max_num_values = *num_values; const uint32_t max_num_samples = *num_samples; *num_values = 0; *num_samples = 0; *num_types = 0; PLogTypesDecoderArg types_decoder_arg = { .max_num_types = max_num_types, .num_types = num_types, .type...
rmal/bluetooth/ble_hrm.h" #include "system/logging.h" #include "system/passert.h" #include "util/string.h" #include <bluetooth/bluetooth_types.h> #include <bluetooth/classic_connect.h> #include <bluetooth/reconnect.h> #include <bluetooth/sm_types.h> #include <btutil/bt_device.h> #include <stdio.h> #include <string.h>...
(addr, &active_addr, sizeof(*addr))
)) { remote->classic.connected = true; } else { remote->classic.connected = false; } add_remote(data, remote); } static void prv_add_bt_classic_remotes(SettingsBluetoothData *data) { bt_persistent_storage_for_each_bt_classic_pairing(prv_add_bt_classic_remote, data); } static bool dual_remote_filter(...
roing out any steps taken) static time_t s_kalg_sleep_start_utc; static uint16_t s_kalg_sleep_m; void kalg_get_sleep_stats(KAlgState *alg_state, KAlgOngoingSleepStats *stats) { time_t now = rtc_get_time(); if (s_kalg_sleep_start_utc == 0 || now < s_kalg_sleep_start_utc + SECONDS_PER_HOUR) { // We are before th...
{ fake_rtc_increment_time(SECONDS_PER_MINUTE); s_alg_next_steps = minute_data[i].base.steps; AccelRawData samples[100] = { }; uint64_t timestamp = 0; // Calling activity_algorithm_handle_accel() on our stub algorithm gives it the step // counts for this minute activity_algorithm_handle_accel...
} // ============================================================================================= // Start of unit tests void test_activity_algorithm_kraepelin__initialize(void) { time_t utc_sec = mktime(&s_start_time_tm); fake_rtc_init(100 /*initial_ticks*/, utc_sec); fake_spi_flash_init(0, 0x1000000); pf...
info->kind, .is_disabled = false, .is_smart = info->is_smart, }; if (info->kind == ALARM_KIND_CUSTOM && info->scheduled_days) { prv_set_alarm_custom_op(id, &config, (void *)info->scheduled_days); } else { prv_set_alarm_kind_op(id, &config, (void *)(uintptr_t)info->kind); } Alarm alarm = { .id...
(&config->scheduled_days, scheduled_days, sizeof(config->scheduled_days))
; return true; } void alarm_set_custom(AlarmId id, const bool scheduled_days[DAYS_PER_WEEK]) { prv_alarm_operation(id, prv_set_alarm_custom_op, (void *)scheduled_days); } // ---------------------------------------------------------------------------------------------- bool alarm_get_custom_days(AlarmId id, bool 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...
tick_timer_service_state_init(worker_state_get_tick_timer_service_state())
_handle_msg(uint16_t conn_idx, Connection *conn, const HcProtocolMessage *msg) { if (!ppogatt_emulated_server_wa_enabled(conn_idx)) { return false; } HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0]; uint16_t att_hdl = (msg->command_id == HcMessageID_Gatt_Read) ? ...
( PEBBLE_BT_PPOGATT_WATCH_SERVER_META_CHARACTERISTIC_UUID_32BIT)
}, &uuid); PBL_ASSERTN(ble_gatts_add_characteristic(&uuid, GATT_PROP_READ, ATT_PERM_READ, sizeof(PPoGATTMetaV1), enable_read_cb_flag, NULL, &ctx->att_hdl.meta) == BLE_STATUS_OK); prv_con...
tart_utc = utc_sec - time_elapsed, .length_min = time_elapsed, .type = ActivitySessionType_Walk, .ongoing = true, }; activity_sessions_prv_add_activity_session(&walk_activity); // Add a sleep session ActivitySession sleep_activity = { .start_utc = utc_sec - time_elapsed, .length_min = time_...
cl_assert_equal_b(prv_is_hr_elevated(), false)
; activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes); cl_assert_equal_i(zone1_minutes, 2); activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &zone2_minutes); cl_assert_equal_i(zone2_minutes, 2); activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes); c...
gsRecordInfo *info, void *context) { // Check if valid entry if (!context || info->key_len != sizeof(WakeupId)) { return; } bool struct_size_mismatch = info->val_len != sizeof(WakeupEntry); bool struct_migration = !clock_is_timezone_set() && struct_size_mismatch; if (struct_size_mismatch && !struct_mig...
version_compare(app_sdk_version, first_utc_version)
< 0) { return true; } return false; } DEFINE_SYSCALL(WakeupId, sys_wakeup_schedule, time_t timestamp, int32_t reason, bool notify_if_missed) { if (prv_compiled_without_utc_support()) { // Legacy apps get local time returned from the time() call. timest...
/* * 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; }
snprintf(dstbuf, 256, "%.-3ozero%.-3o", 0, 1)
; cl_assert_equal_s(dstbuf, "zero1"); // Minimum digits output (non-zero digits outputting zero) snprintf(dstbuf, 256, "%.1ozero%.1o", 0, 1); cl_assert_equal_s(dstbuf, "0zero1"); // Variable length character output snprintf(dstbuf, 256, "There are %*o lights", 3, 8); cl_assert_equal_s(dstbuf, "There are...
t = (mode << BMA255_FIFO_MODE_SHIFT) | (BMA255FifoDataSel_XYZ << BMA255_FIFO_DATA_SEL_SHIFT); prv_program_fifo_register(BMA255Register_FIFO_CONFIG_1, out); // If the fifo had overflowed, the write above will have cleared the flag s_fifo_overrun_detected = false; } static void prv_configure_fifo_interrupts(...
{ // the requested change matches what we already have! return; }
PBL_LOG(LOG_LEVEL_DEBUG, "%s shake detection", enable ? "Enabling" : "Disabling"); prv_update_accel_interrupts(enable, AccelOperatingMode_ShakeDetection); if (enable) { prv_enable_shake_detection(); } else { prv_disable_shake_detection(); } s_shake_detection_enabled = enable; } void accel_set_sh...
/* * 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(seedp != NULL)
; tinymt32_t state = {{0}}; prv_seed(&state, *seedp); *seedp = prv_next(&state) & 0x7FFFFFFF; return *seedp; } void srand(unsigned int seed) { prv_seed(prv_get_seed_ptr(), seed); }
st LayoutLayer *layout, const LayoutNodeTextConfig *config) { text_node->font = fonts_get_system_font(prv_get_font_key(config)); const int fixed_lines = config->fixed_lines; const int line_spacing_delta = config->line_spacing_delta; text_node->max_size.h = fixed_lines ? (fixed_lines * (fonts_get_font_height(tex...
(&text_node->text, layout, &config->text)
; } return text_node; } static GTextNodeText *prv_create_text_node_from_config( const LayoutLayer *layout, const LayoutNodeTextConfig *config) { GTextNodeText *text_node = prv_create_text_node_buffer(NULL); prv_set_text_node_text_parameters_from_config(text_node, layout, config); return text_node; } sta...
"PALO ALTO", .current_temp = 68, .today_high = 68, .today_low = 58, .current_weather_type = WeatherType_Sun, .current_weather_phrase = "Sunny", .tomorrow_high = 62, .tomorrow_low = 52, .tomorrow_weather_type = WeatherType_PartlyCloudy, }; prv_create_layout_for_forecast_and_render(&f...
gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)
); } void test_weather_app_layout__render_down_arrow(void) { const WeatherLocationForecast forecast = { .location_name = "PALO ALTO", .current_temp = -88, .today_high = -88, .today_low = -88, .current_weather_type = WeatherType_HeavySnow, .current_weather_phrase = "Heavy Snow", .tomorrow_...
s.c application task. Grab a mutex here so // that we don't ever get two instances of it at a time. mutex_lock(s_notification_window_mutex); if (s_in_use) { goto fail; } s_in_use = true; data->pop_timer_is_final = false; data->is_modal = is_modal; data->notification_app_id = UUID_INVALID; data->p...
(id, NotificationMobile)
; } //! The animate mode slides the notificaiton in from the top as if it was a new notification. void notification_window_focus_notification(Uuid *id, bool animated) { NotificationWindowData *data = &s_notification_window_data; if (animated) { #if PBL_RECT Uuid *second_id = notifications_presented_list_relat...
(EllipsisPartDrawConfig){TO_TRIG(30),GCornerTopRight}, .full_quadrants = GCornerNone, .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(60),GCornerTopRight} })); // Starting quadrant filling up and ending quadrant finishing cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(45), TO_TRIG(270 + 45))...
(prv_calc_draw_config_ellipsis(TO_TRIG(70), TO_TRIG(90)), ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(70),GCornerTopRight}, .full_quadrants = GCornerNone, .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight} }))
; }
(uint32_t ms) { RtcTicks delta_ticks = milliseconds_to_ticks(ms); fake_rtc_set_ticks(rtc_get_ticks() + delta_ticks); rtc_set_time(rtc_get_time() + ms / MS_PER_SECOND); } // Test that we handle different update intervals correctly void test_hrm_manager__update_interval(void) { AppInstallId app_id = 1; uint32_...
hrm_is_enabled(HRM)
); // Test the pref changes s_activity_prefs_heart_rate_is_enabled = false; hrm_manager_handle_prefs_changed(); cl_assert(!prv_can_turn_sensor_on()); fake_system_task_callbacks_invoke_pending(); cl_assert(!hrm_is_enabled(HRM)); s_activity_prefs_heart_rate_is_enabled = true; hrm_manager_handle_prefs_ch...
l handle the notifications for these return; } s_session_pin_state.start_utc = session->start_utc; prv_save_state(ActivitySettingsKeyInsightActivitySessionTime, &s_session_pin_state.start_utc, sizeof(s_session_pin_state.start_utc)); if (s_activity_session_settings.sessio...
{ s_activity_session_settings.enabled = false; // worst-case, we disable the insight }
s_pfs_cb_handle = activity_insights_settings_watch(prv_settings_file_changed_cb); } static void prv_settings_file_changed_cb(void *data) { system_task_add_callback(prv_reload_settings, data); } static void prv_blobdb_event_handler(PebbleEvent *event, void *context) { PebbleBlobDBEvent *blobdb_event = &event->...
MIN(bytes_remaining, write_sizes[j])
; int offset = log_len - bytes_remaining; rv = flash_logging_write((uint8_t *)&curr_msg[offset], addr, bytes_to_write); cl_assert(rv); bytes_remaining -= bytes_to_write; } // try to write something past the end to ensure it doesn't take uint8_t buf[128] = { 0 }; rv = ...
arbage(int16_t dest_origin_x) { const GBitmap src_bitmap = compositor_get_app_framebuffer_as_bitmap(); GBitmap dest_bitmap = compositor_get_framebuffer_as_bitmap(); // Patch garbage pixels using the first/last column, if necessary if (dest_origin_x != 0) { const bool offscreen_left = (dest_origin_x < 0); ...
interpolate_int16(distance_normalized, start, end)
; const int16_t delta_x_before_cut_diff = delta_x_before_cut - s_data.prev_delta_x_before_cut; const int16_t delta_x_after_cut = interpolate_int16(distance_normalized, -end, start); // This rect specifies where the launcher's selected row currently is in the system framebuffer const GRect selection_rect = GRec...
alloc_check(sizeof(OpenAppContext)); *ctx = (OpenAppContext) { .event_info = { .type = PEBBLE_RENDER_READY_EVENT, .handler = prv_app_render_ready, .context = ctx, }, .install_id = install_id, }; event_service_client_subscribe(&ctx->event_info); ...
for (int i = 0; i < (int) ARRAY_LENGTH(s_data_sources); i++) { if (uuid_equal(parent_id, &s_data_sources[i].id)) { return s_data_sources[i].name; } }
return NULL; } ///////////////// // Analytics typedef struct { unsigned int calendar; unsigned int other; } PinCount; typedef struct { time_t timestamp; PinCount visible_count; PinCount hourly_count; } PinAnalyticsInfo; static bool prv_count_each(SettingsFile *file, SettingsRecordInfo *info, void *cont...
sleep_session_callback(void *context, KAlgActivityType activity_type, time_t start_utc, uint32_t len_sec, bool ongoing, bool delete, uint32_t steps, uint32_t resting_calories, uint32_t active_calories, uint32_t distance_mm) ...
{ results->start_at.value = (enter_utc - test_start_utc) / SECONDS_PER_MINUTE; }
if (exit_utc != 0) { results->end_at.value = (exit_utc - test_start_utc) / SECONDS_PER_MINUTE; } // Figure out our current state if (exit_utc >= last_processed_utc - SECONDS_PER_MINUTE) { // We are sleeping results->in_sleep.value = true; int unprocessed_m = (test_end_utc - last_processed_utc...
_close(&file); cleanup: return (rv == S_SUCCESS); } bool shell_prefs_get_clock_24h_style(void) { return s_is_24h_style; } void shell_prefs_set_clock_24h_style(bool is_24h_style) { mutex_lock(s_mutex); if (prv_pref_set(PREF_KEY_CLOCK_24H, &s_is_24h_style, sizeof(s_is_24h_style))) { s_is_24h_style = is_24h_...
{ return 0; }
void activity_prefs_set_gender(ActivityGender gender) { } ActivityGender activity_prefs_get_gender(void) { return ActivityGenderOther; } void activity_prefs_set_age_years(uint8_t age_years) { } uint8_t activity_prefs_get_age_years(void) { return 0; } bool activity_prefs_heart_rate_is_enabled(void) { return ...
/* * 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 (msg->command_id != HcMessageID_Hci_Cmd) { PBL_LOG(LOG_LEVEL_ERROR, "Unhandled HCI command id: 0x%x", (int)msg->command_id); } PBL_LOG(LOG_LEVEL_DEBUG, "HCI CMD Received:"); PBL_HEXDUMP(LOG_LEVEL_DEBUG, (uint8_t *)msg, msg->message_length); hci_cmd_msg_t *hci_cmd = (hci_cmd_msg_t *)&msg->payload[0]...
void hc_endpoint_enqueue_hci_evt(const uint8_t *hci_evt, uint8_t payload_len) { uint8_t hc_message_len = sizeof(HcProtocolMessage) + 1 /* for HCI_EVT_MSG */ + payload_len; uint8_t hc_protocol_message[hc_message_len]; HcProtocolMessage *hc_msg = (HcProtocolMessage *)&hc_protocol_message[0]; memset(hc_msg, 0x0...
_min, health_sessions[i].length_min); } } // ============================================================================================= // Start of unit tests void test_activity__initialize(void) { TimezoneInfo tz_info = { .tm_zone = "UTC", .tm_gmtoff = 0, }; time_util_update_timezone(&tz_info); ...
(ActivityMetricStepCount, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){100, 0, 0, 0, 0, 0, 0}))
; ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricSleepTotalSeconds, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){2 * SECONDS_PER_MINUTE, 0, 0, 0, 0, 0, 0})); ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricSleepRestfulSeconds, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){1 * SECONDS_PER_MINUTE, 0, 0, 0, 0, 0, 0})); /...
_size - erase_size) / page_size; char *log = malloc(100); for (int i = 0; i < 533; i++) { flash_logging_init(); // Write the new message snprintf(log, 100, "Generation 0x%x", i); setup_and_test_expected_msg(&log, 0, 0, 1); for (int gen = 0; gen < MIN(gens_avail, i); gen++) { // Check to...
(addr != FLASH_LOG_INVALID_ADDR)
; char *curr_msg = logs[i]; bool rv; for (int j = 0; j < ARRAY_LENGTH(write_sizes); j++) { int bytes_to_write = MIN(bytes_remaining, write_sizes[j]); int offset = log_len - bytes_remaining; rv = flash_logging_write((uint8_t *)&curr_msg[offset], addr, bytes_to_write); cl_as...
/* * 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...
(circular_buffer_get_write_space_remaining(&buffer), 0)
; // Try a wrapped read cl_assert(circular_buffer_read(&buffer, 6, &out_buffer, &out_length)); cl_assert_equal_i(out_length, 4); cl_assert(memcmp(out_buffer, (uint8_t*) "5678", 4) == 0); cl_assert(circular_buffer_consume(&buffer, 4)); // Get the rest of the wrapped read cl_assert(circular_buffer_read(&b...
if (strlen(result->local_name)) { snprintf(title, sizeof(title), "%s %s", result->local_name, hrm_str); } else { const BTDeviceAddress address = bt_device_get_address(result->device); snprintf(title, sizeof(title), BT_DEVICE_ADDRESS_FMT " %s", BT_DEVICE_ADDRESS_XPLODE(address), hrm_str); }
// Build the subtitle string: char subtitle[UUID_STRING_BUFFER_LENGTH]; if (result->has_services) { // Make a displayable string of the first Service UUID: uuid_to_string(&result->first_service_uuid, subtitle); } else { // If advertisement did not contain Service UUIDs: strncpy(subtitle, "No S...
s_notification); } static void prv_send_notification(const uint8_t *ancs_notification_dict) { prv_send_notification_with_event_flags(ancs_notification_dict, 0); } static uint8_t *prv_serialize_timeline_item(TimelineItem *item, size_t *size_out) { size_t payload_size = timeline_item_get_serialized_payload_size(ite...
ARRAY_LENGTH(s_message_app_info_dict)
, (uint8_t *)s_message_app_info_dict); } return BTErrnoOK; } // else: notif request uint32_t uid = ((GetNotificationAttributesMsg *)buffer)->notification_uid; s_num_requested_notif_attributes++; if (uid == comple_dict_uid) { prv_fake_receiving_ds_notifica...