prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
/* * 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(10, grect_shortest_side(GRect(0, 0, 20, 10)))
; cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, 10, -20))); cl_assert_equal_i(10, grect_shortest_side(GRect(0, 0, -20, 10))); } void test_gtypes__grect_inset(void) { GRect rect = GRect(10, 20, 30, 40); cl_assert_equal_grect(GRect(12, 23, 26, 34), grect_inset_internal(rect, 2, 3)); cl_assert_equal_gre...
CENTER_OF_ORIGIN_RECT GPoint(20, 25) #define CENTER_OF_ORIGIN_RECT_NXNY GPoint(10, 15) void test_graphics_draw_circle_${BIT_DEPTH_NAME}__origin_layer_aa(void) { GContext ctx; test_graphics_context_init(&ctx, fb); // Big circles setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1...
layer_render_tree(&layer, &ctx)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi")); 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, "draw_circle_across_nx_of...
0x17, 0xa2, 0x89, 0x46, 0x5c, 0xbe, 0xf1, 0x5b, 0x98, 0x0d, 0xfd, 0xb0, 0x8a, 0x02, // attribute type - transcription 0x2F, 0x00, // attribute length // Transcription 0x01, // Transcription type 0x02, // Sentence count // Sentence #1 0x02, 0x00, // Word co...
((uint8_t*)next, data_out + sizeof(data_out))
; expected = (GenericAttribute) { .id = VEAttributeIdAppUuid, .length = sizeof(Uuid) }; cl_assert_equal_m(&expected, &data_out[offset], sizeof(GenericAttribute)); offset += sizeof(GenericAttribute); cl_assert_equal_m(&uuid, &data_out[offset], sizeof(uuid)); }
/* * 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...
time_ms(&seconds, &milliseconds)
; return (seconds * 1000) + milliseconds; } inline static bool action_bar_is_highlighted(ActionBarLayer *action_bar, uint8_t index) { PBL_ASSERTN(index < NUM_ACTION_BAR_ITEMS); return (bool) (action_bar->is_highlighted & (1 << index)); } static void prv_register_redraw_timer(ActionBarLayer *layer); static void...
/* * 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...
VOICE_LOG("%s", 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...
list_insert_after(&a, &b)
; cl_assert(tail == &b); } void test_list__insert_before(void) { ListNode *head = NULL; ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL; head = list_insert_before(head, &a); cl_assert(head == &a); head = list_insert_before(&b, &a); cl_assert(head == &a); } void test_list__pop_head(void) { ListNode a =...
l timeline_item_storage_exists_with_parent(TimelineItemStorage *storage, const Uuid *parent_id) { mutex_lock(storage->mutex); FindChildrenInfo info = { .parent_id = *parent_id, .num_children = 0, .find_all = false, }; status_t rv = settings_file_each(&storage->file, prv_each_find_children, &info); ...
mutex_unlock(storage->mutex)
; return rv; } status_t timeline_item_storage_read(TimelineItemStorage *storage, const uint8_t *key, int key_len, uint8_t *val_out, int val_len) { if (key_len != UUID_SIZE) { return E_INVALID_ARGUMENT; } mutex_lock(storage->mutex); status_t rv = settings_file_get(&storage->file, key, key_len, val_o...
tabaseChanged); // Put one, expect one: prv_simulate_and_assert_discovery_of_one_service(&device); } extern void gatt_client_discovery_discover_range(GAPLEConnection *connection, ATTHandleRange *hdl_range); void test_gatt_client_discovery__multiple_jobs_pending(vo...
fake_gatt_is_service_discovery_start_count()
); // nothing should still be running cl_assert_equal_b(fake_gatt_is_service_discovery_running(), false); } // ------------------------------------------------------------------------------------------------- // Test vectors static void prv_assert_blood_pressure_service(const GATTService *service) { const Serv...
/* * 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 (r == 0 || strncmp(buf, "05", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"d\": %s", buf); }
r = strftime(buf, buf_size, "%D", &good_data); if (r == 0 || strncmp(buf, "05/05/15", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"D\": %s", buf); } r = strftime(buf, buf_size, "%e", &good_data); if (r == 0 || strncmp(buf, " 5", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error ...
addr)); } FlashAddress flash_impl_get_sector_base_address(FlashAddress addr) { if (addr < BOTTOM_BOOT_REGION_END) { return addr & ~(BOTTOM_BOOT_SECTOR_SIZE - 1); } return addr & ~(SECTOR_SIZE_BYTES - 1); } FlashAddress flash_impl_get_subsector_base_address(FlashAddress addr) { return flash_impl_get_secto...
prv_issue_command_argument(0, 0)
; ((__IO uint16_t*) (FMC_BANK_1_BASE_ADDRESS))[0] = data; prv_issue_command(0, S29VSCommand_BufferToFlash); prv_software_reset(); } // Use the "Sector Lock Range Command" (section 8.2 of data sheet) to block // writes or erases to the PRF image residing on the flash. The only way to undo // this is to issue a H...
_enable_shake_detection(void) { bma255_write_register(BMA255Register_INT_EN_0, BMA255_INT_EN_0_SLOPE_X_EN | BMA255_INT_EN_0_SLOPE_Y_EN | BMA255_INT_EN_0_SLOPE_Z_EN); bma255_write_register(BMA255Register_INT_MAP_0, BMA...
prv_read_axis(axis, &new_negative)
/* * 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...
(expected)
-= radius; } if (corner_mask & GCornerBottomRight) { circle_func(ctx, GPoint(rect->origin.x + rect->size.w - radius - 1, rect->origin.y + rect->size.h - radius - 1), radius, GCornerBottomRight); bottom_rect_size_w -= radius; } // Top Rect ...
GPoint(rect->origin.x, rect->origin.y)
; const GPoint tr = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y); const GPoint bl = GPoint(rect->origin.x, rect->origin.y + rect->size.h - 1); const GPoint br = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y + rect->size.h - 1); graphics_line_draw_stroked_non_aa(ctx, tl, tr, stroke_width...
* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in...
(VibeClient_Notifications)
; break; } case VibeSettingsRow_PhoneCalls: { score = vibe_client_get_score(VibeClient_PhoneCalls); break; } case VibeSettingsRow_Alarms: { score = vibe_client_get_score(VibeClient_Alarms); break; } case VibeSettingsRow_System: { // Vibe a short pulse so the u...
752}, { -560, -144, -728}, { -400, -112, -712}, { -504, -208, -768}, { -432, -96, -704}, { -472, -200, -728}, { -480, -72, -760}, { -480, -200, -672}, { -488, -64, -800}, { -472, -200, -744}, { -560, -56, -824}, { -552, -120, -744}, { -608, -120, -888}, { -648, 24, -7...
{ -520, -128, -920}, { -536, -8, -856}, { -624, -168, -920}, { -624, 80, -800}, { -600, -224, -808}, { -664, 32, -848}, { -504, -184, -792}, { -584, -120, -832}, { -488, -128, -784}, { -536, -208, -840}, { -456, 0, -792}, { -464, -288, -824}, { -496, 16, -800}, { ...
{ -512, -312, -832}, { -608, -24, -688}, { -488, -240, -784}, { -600, -144, -784}, { -512, -128, -712}, { -632, -184, -848}, { -584, -48, -736}, { -544, -272, -744}, { -608, -56, -744}, { -552, -240, -712}, { -624, -64, -816}, { -512, -224, -824}, { -608, -152, -776}...
imelineItemAction); } else { ((AddressList *) group_ptr)->num_addresses = num_group_type_elements; ((AddressList *) group_ptr)->addresses = (Address *)*buffer; *buffer += num_group_type_elements * sizeof(Address); } for (int i = 0; i < num_group_type_elements; i++) { AttributeList *...
if (!attribute_deserialize_list((char**)&buffer, (char *)buf_end, &cursor, payload_end, *group_type_element_attribtue_list)) { return false; }
} return true; } bool attribute_group_deserialize(AttributeGroupType type, AttributeList *attr_list, void *group_ptr, uint8_t *buffer, uint8_t *buf_end, ...
; conn_mgr_set_ble_conn_response_time( &s_hdl, BtConsumerUnitTests, ResponseTimeMiddle, 30); state = conn_mgr_get_latency_for_le_connection(&s_hdl, &secs_to_wait); cl_assert_equal_i(state, ResponseTimeMin); cl_assert_equal_i(secs_to_wait, 100); cl_assert_equal_i(fake_gap_le_connect_params_get_last_reque...
conn_mgr_handle_desired_state_granted(&s_hdl, ResponseTimeMin)
; cl_assert_equal_i(s_granted_count, 1); conn_mgr_set_ble_conn_response_time_ext(&s_hdl, BtConsumerLeServiceDiscovery, ResponseTimeMin, 1, prv_granted_handler); cl_assert_equal_i(s_granted_count, 2); conn_mgr_set_ble_conn_response_time_ext(&s_hdl, BtConsumerLeServiceD...
/* * 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_ERROR, "Invalid order storage file"); delete_file = true; goto cleanup; }
// Read the number of AppInstallId's listed in the file uint8_t list_length; if (pfs_read(fd, &list_length, sizeof(uint8_t)) != sizeof(uint8_t)) { PBL_LOG(LOG_LEVEL_ERROR, "Could not read app menu order file"); delete_file = true; goto cleanup; } // Allocate room for the order list array. Free'...
STATIC MemorySegment prv_get_app_ram_segment(void) { return (MemorySegment) { __APP_RAM__, __APP_RAM_end__ }; } T_STATIC size_t prv_get_stack_guard_size(void) { return (uintptr_t)__stack_guard_size__; } // --------------------------------------------------------------------------------------------- //! @return Tr...
APP_LOG(APP_LOG_LEVEL_ERROR, "Checksum for resources differs or insufficient meta data for JavaScript app.")
; return false; } } // Synchronously handle process start since its new state is needed for app state initialization timeline_peek_handle_process_start(); const ProcessAppSDKType sdk_type = process_metadata_get_app_sdk_type(app_md); // The rest of app_ram is available for app_state to use as it s...
te; static void prv_cb_before_write(void) { prv_receive_put(s_last_response_cookie, (uint8_t *)&s_next_value_to_write, VALID_OBJECT_SIZE); } void test_put_bytes__receive_batched_messages(void) { uint8_t max_batched_ops = prv_put_bytes_get_max_batched_pb_ops(); int num_ops = 500; if (max_batched_ops < 2) { // ...
assert_nack_count(1)
mand_assert_fail(void) { prompt_command_finish(); RtcTicks ticks = rtc_get_ticks(); PBL_ASSERT(false, "The world doesn't make sense anymore! Tick count: 0x%08" PRIx32 "%08" PRIx32, SPLIT_64_BIT_ARG(ticks)); } void command_croak(void) { prompt_command_finish(); PBL_CROAK("You asked for this!");...
(button, 0, NUM_BUTTONS - 1)
) { goto error; } const ButtonId button_id = (ButtonId)button; uint32_t num_presses = 1; // If presses is NULL, default to 1; otherwise convert the char string to an integer if (presses) { char *end; num_presses = MAX(0, strtol(presses, &end, 10)); // Validate the num_presses value if (*...
void) { cl_assert_equal_p(gdraw_command_image_clone(NULL), NULL); size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) + (sizeof(GPoint) * 6); GDrawCommandImage *image = malloc(size); memset(image, 0, size); GDrawCommandList *command_list = prv_create_command_list_3(); mem...
free(command_list)
; } typedef struct { GDrawCommandProcessor processor; GColor stroke_color; } SetStrokeColorProcessor; static void prv_set_stroke_color(GDrawCommandProcessor *processor, GDrawCommand *processed_command, const size_t processed_command_max_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...
if (custom_node) { custom_node->node.offset.y = 11; custom_node->node.margin.h = 12; return &custom_node->node; } else { return NULL; }
} static GTextNode *prv_card_view_constructor(TimelineLayout *timeline_layout) { static const LayoutNodeExtentConfig s_icon_config = { .node.type = LayoutNodeType_TimelineIcon, #if PBL_RECT .offset.x = -1, // icon offset x .margin.w = 9, // icon margin width #endif .margin.h = PBL_IF_RECT_ELSE(-2, 2...
, 584, 392}, { -704, 568, 376}, { -696, 560, 392}, { -696, 560, 392}, // 225 seconds { -696, 560, 384}, { -696, 560, 400}, { -696, 568, 392}, { -704, 568, 384}, { -704, 568, 392}, { -696, 560, 384}, { -696, 568, 376}, { -704, 560, 392}, { -704, 552, 392}, { -704, ...
{ -880, 312, -424}, { -872, 304, -440}, { -872, 296, -440}, { -880, 304, -440}, { -872, 296, -440}, { -880, 296, -448}, { -872, 304, -432}, { -880, 312, -432}, { -864, 312, -432}, { -872, 296, -424}, { -872, 304, -440}, { -872, 320, -440}, { -872, 304, -424}, { -8...
} else { time_fmt = i18n_noop("Yesterday"); } break; case FullStyleLower24h: case FullStyleCapital24h: if (with_fulltime) { time_fmt = i18n_noop("Yesterday, %R"); } else { time_fmt = i18n_noop("Yesterday"); } break; } } else...
{ str_fmt = i18n_noop("In %lu hours"); }
/* * 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(1, buffer_remove(b, 0, 1))
/* * 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...
(buffer, size)
; // This tests to make sure analysis continues through good_syscall hidden_bad_syscall(buffer, size); } bool cond(const char *font_key) { return &cond == font_key; } void conditional_syscall(const char *font_key) { syscall_internal_elevate_privilege(); if (font_key) { if (!cond(font_key)) { do...
r the specific language governing permissions and * limitations under the License. */ #include "board/board.h" #include "drivers/flash/flash_impl.h" #include "drivers/flash/qspi_flash.h" #include "drivers/flash/qspi_flash_part_definitions.h" #include "flash_region/flash_region.h" #include "system/passert.h" #include...
(QSPI_FLASH)
; return S_SUCCESS; } status_t flash_impl_get_erase_status(void) { return qspi_flash_is_erase_complete(QSPI_FLASH); } status_t flash_impl_erase_subsector_begin(FlashAddress subsector_addr) { return qspi_flash_erase_begin(QSPI_FLASH, subsector_addr, true /* is_subsector */); } status_t flash_impl_erase_sector_be...
/* * 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_render_tree(&layer, &ctx)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_y_origin_layer.${BIT_DEPTH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &across_ny_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_ny_or...
(cron_service_get_job_count(), 0)
; } void test_cron__1_basic(void) { CronJob test_cron = { .cb = prv_cron_callback, .cb_data = (void*)0, .minute = CRON_MINUTE_ANY, .hour = CRON_HOUR_ANY, .mday = CRON_MDAY_ANY, .month = CRON_MONTH_ANY, .may_be_instant = true, }; prv_basic_test(&s_timezone_gmt, &test_cron, s_2015_no...
/* * 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...
(num.integer == -1)
; cl_assert(num.fraction == 2); test_num = (int32_t)((float)-0.625 * (1 << FIXED_S16_3_PRECISION)); num = (Fixed_S16_3){ .raw_value = test_num }; cl_assert(num.integer == -1); cl_assert(num.fraction == 3); test_num = (int32_t)((float)-0.500 * (1 << FIXED_S16_3_PRECISION)); num = (Fixed_S16_3){ .raw_valu...
.stroke_color = GColorBlack, .fill_color = GColorBlack, .text_color = GColorWhite, .tint_color = GColorWhite, .compositing_mode = GCompOpAssign, .clip_box = bitmap->bounds, .drawing_box = bitmap->bounds, #if PBL_COLOR .antialiased = !process_manager_compiled_with_legacy2_sdk(), #endif ....
graphics_context_get_bitmap(ctx)
/* * 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...
_Static_assert(sizeof(RoundFlipTransitionAnimationConfiguration) == sizeof(void *), "")
(state.current_day, midnight_march_2_pst)
; // no more cl_assert(!iter_next(&iterator)); // 1 delete cl_assert(timeline_iter_remove_node_with_id(&head, &all_day_item.header.id)); cl_assert(!timeline_iter_remove_node_with_id(&head, &all_day_item.header.id)); } void test_timeline__all_day_multiday(void) { TimelineItem multiday_item = { .header...
x.parent_framebuffer, GColorWhite)); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &outside_x_ny_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("outside_x_ny_offset_layer", ctx.parent_framebuffer, GColorWhite)); test_graphics_context_reset(&ctx,...
prv_draw_box(ctx, GPoint((4 + (BOX_OFFSET_X * color_col) + (COLUMN_OFFSET_X * column)), (BOX_OFFSET_Y + ((color_index - (32 * color_col)) * 4 ))))
; } } #define ORIGIN_RECT_NO_CLIP GRect(0, 0, 144, 168) void test_graphics_draw_pixel_8bit__transparent(void) { GContext ctx; test_graphics_context_init(&ctx, fb); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1); graphics_context_set_fill_color(&ctx, GColorBlack); gra...
CENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under...
(data->debug_card.dialog_text)
PBL_IF_BW_ELSE(1,2)
); #elif defined(PLATFORM_SNOWY) cl_assert_equal_i(2, PBL_IF_BW_ELSE(1,2)); #elif defined(PLATFORM_SPALDING) cl_assert_equal_i(2, PBL_IF_BW_ELSE(1,2)); #else #error "unknown platform" #endif } void test_gtypes__pbl_if_color_else(void) { #if defined(PLATFORM_TINTIN) cl_assert_equal_i(2, PBL_IF_COLOR_ELSE(1,2)); #...
'include_delay' animation_set_elapsed(seq, animation_get_duration(seq, false /*delay*/, true /*play_count*/) - leftover_seq); // Verify that a finished and that a's stop handler got called before B's start handler cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_...
prv_last_update_distance(a)
, ANIMATION_NORMALIZED_MAX); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1); cl_assert_equal_i(prv_count_handler_entries(&s_s...
* limitations under the License. */ #include "applib/pbl_std/pbl_std.h" #include "applib/pbl_std/locale.h" #include "clar.h" // Stubs ////////////////////////////////////////////////////////// #include "stubs_heap.h" #include "stubs_hexdump.h" #include "stubs_logging.h" #include "stubs_mutex.h" #include "stubs_pass...
(str, STR_SIZE, "abc %Lf%s", "a", 1.0, "b")
; cl_assert_equal_s(str, fp_msg); pbl_snprintf(str, STR_SIZE, "abc %Ld%s", 42, "b"); cl_assert_equal_s(str, "abc 42b"); //---------------------------------------------------- pbl_snprintf(str, STR_SIZE, "abc %hf%s", "a", 1.0, "b"); cl_assert_equal_s(str, fp_msg); pbl_snprintf(str, STR_SIZE, "abc %hd%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...
(health_app_data->health_data)
; } health_card_view_mark_dirty(health_app_data->health_card_view); } //////////////////////////////////////////////////////////////////////////////////////////////////// // Initialization and Termination // //! Initialize application static void prv_finish_initilization_cb(bool in_focus) { if (in_focus) { ...
.h" #include "services/normal/persist.h" #include "services/normal/process_management/app_storage.h" #include "system/logging.h" #include "system/passert.h" #include "util/circular_cache.h" #include "util/size.h" #include <os/mutex.h> #include <util/attributes.h> typedef struct PACKED RecentApp { AppInstallId id; ...
(s_recent_apps.mutex)
; { const time_t cur_time = time_get_uptime_seconds(); RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id); if (app) { app->last_activity = cur_time; app->can_expire = can_expire; } else { RecentApp app = { .id = install_id, .last_activity = cur_tim...
can_decline) { s_last_phone_ui_event = PhoneEventType_Start; } void phone_ui_handle_call_end(bool call_accepted, bool disconnected) { s_last_phone_ui_event = PhoneEventType_End; } void phone_ui_handle_call_hide(void) { s_last_phone_ui_event = PhoneEventType_Hide; } void phone_ui_handle_caller_id(PebblePhoneCal...
prv_put_comm_session_event(false /* app_connected */)
; ASSERT_LAST_EVENT(PhoneEventType_End); } // --------------------------------------------------------------------------------------- // Basic test for incoming calls over ANCS on iOS 8 and below void test_phone_call__ancs_legacy_incoming(void) { // We should only allow the incoming call if we're connected to 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...
(BUTTON_ID_UP, (ClickHandler) confirm_click_handler)
; window_long_click_subscribe(BUTTON_ID_UP, 1200, (ClickHandler) confirm_long_click_handler, NULL); window_single_click_subscribe(BUTTON_ID_DOWN, (ClickHandler) decline_click_handler); (void)window; } static void prv_window_load(Window *window) { ConfirmUIData *data = window_get_user_data(window); const GRec...
/* * 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...
{ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); RCC_RTCCLKCmd(ENABLE); RTC_InitTypeDef rtc_init_struct; RTC_StructInit(&rtc_init_struct); rtc_init_struct.RTC_AsynchPrediv = RTC_CLOCK_ASYNC_PRESCALER; rtc_init_struct.RTC_SynchPrediv = RTC_CLOCK_SYNC_PRESCALER; RTC_Init(&rtc_init_struct); }
RTC_WaitForSynchro(); periph_config_release_lock(); #ifdef PBL_LOG_ENABLED char buffer[TIME_STRING_BUFFER_SIZE]; PBL_LOG(LOG_LEVEL_DEBUG, "Current time is <%s>", rtc_get_time_string(buffer)); #endif } void rtc_calibrate_frequency(uint32_t frequency) { // Nothing to do here! (yet) } void rtc_init_timers(...
(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_100; set_text_layers(data); } else if (data->property == PROPERTY_COLOR_TABLE) { if (s_color_table == ...
(data, 0x00, sizeof(AppData))
; s_window = window_create(); window_set_user_data(s_window, data); window_set_fullscreen(s_window, true); window_set_window_handlers(s_window, &(WindowHandlers) { .load = main_window_load, .unload = main_window_unload, }); window_set_click_config_provider(s_window, click_config_provider); cons...
ULL, command); cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8); cl_assert_equal_i(s_fill_color.argb, GColorBlueARGB8); cl_assert_equal_i(s_stroke_width, 0); cl_assert_equal_i(s_path_num_points, 2); cl_assert_equal_b(s_path_open, false); cl_assert_equal_i(s_path_fill_count, 1); cl_assert_equal_i(s...
(command, true)
; cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8); cl_assert_equal_i(s_fill_color.argb, GColorClearARGB8); cl_assert_equal_i(s_stroke_width, 0); cl_assert_equal_i(s_path_num_points, 0); cl_assert_equal_b(s_path_open, false); cl_assert_equal_i(s_path_fill_count, 0); cl_assert_equal_i(s_path_stroke...
text.draw_state.fill_color.argb, GColorClear.argb); // Fill Color - 2-bit graphics_context_set_fill_color_2bit(&context, GColor2White); cl_assert(gcolor_equal(context.draw_state.fill_color, GColorWhite)); // Compositing Mode graphics_context_set_compositing_mode(&context, GCompOpOr); cl_assert(context.dra...
ASSERT_CALLED(graphics_circle_draw_1px_non_aa(&context, GPoint(50, 50), 10))
; setup_test(&context, false, 1, GColorBlack, GColorBlack, false); graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4); ASSERT_CALLED(prv_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4)); } void test_graphics_context_${BIT_DEPTH_NAME}__draw_stroke_width_2(void) { // Stroke width 2, non-antialia...
((button < 0 || button > NUM_BUTTONS)) { return; } switch(*click_type) { case 's': offset = ClickHandlerOffsetSingle; break; case 'm': offset = ClickHandlerOffsetMulti; break; case 'l': offset = ClickHandlerOffsetLong; break; case 'r': offset = ClickH...
{ if (reset_using_event) { return; } }
_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 1 * 1000); cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3))); // Frame 3 has delay 1000 ms, frame 4 and 5 have zero delay, so at time 2000 ms == frame 5 gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 2 * 1000); cl_check(gbitmap_pbi...
(resource_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...
(result, 0)
ot sending anything return true; } CommSession *session = comm_session_get_system_session(); if (!session) { return false; } mutex_lock(s_endpoint_data.mutex); if (logging_session->comm.state != DataLoggingSessionCommStateIdle) { mutex_unlock(s_endpoint_data.mutex); // logging_session is w...
(LOG_LEVEL_ERROR, "Unexpected NACK")
; break; case DataLoggingSessionCommStateSending: //Maybe queue a resend logging_session->comm.num_bytes_pending = 0; if (++logging_session->comm.nack_count > MAX_NACK_COUNT) { PBL_LOG(LOG_LEVEL_ERROR, "Too many nacks. Flushing..."); dls_storage_consume(logging_session, loggi...
// Device busy or no suspended erase to resume. status = E_INVALID_OPERATION; } flash_impl_release(); return status; } // It is dangerous to leave this built in by default. #if 0 status_t flash_impl_erase_bulk_begin(void) { flash_s29vs_use(); prv_issue_command(0, S29VSCommand_EraseSetup); prv_iss...
if (start_addr & 0x1 || bytes_in_page & 0x1) { ++num_shorts; }
const FlashAddress sector_addr = flash_impl_get_sector_base_address(start_addr); flash_impl_use(); prv_issue_command(sector_addr, S29VSCommand_ClearStatusRegister); // Some sanity checks { status_t error = S_SUCCESS; const uint8_t sr = prv_read_status_register(sector_addr); if ((sr & S29VS...
ck at the top (otherwise at the bottom) if (!state.up) { state.menu_layer->inverter.layer.frame.origin.y -= abs_content_offset; } } layer_mark_dirty(&state.menu_layer->scroll_layer.layer); } void prv_center_focus_animation_update_in_and_out(Animation *animation, ...
animation_set_curve(anim, AnimationCurveEaseInOut)
settings_file_open(&file, "test_file_used_space_tracking", 4096)
); uint8_t key[5]; int key_len = 4; uint8_t val[5]; int val_len = 4; // First, fill half the file up with random keys and values. This reduces // our usable space to slightly less than 2048 bytes. for (int i = 0; i < 128; i++) { snprintf((char *)key, sizeof(key), "k%03d", i); snprintf((char *)val...
istory[ActivityMetricSleepState][0] = ActivitySleepStateAwake; s_data.metric_history[ActivityMetricSleepExitAtSeconds][0] = 7 * SECONDS_PER_HOUR; s_data.metric_history[ActivityMetricSleepStateSeconds][0] = 30 * SECONDS_PER_MINUTE; activity_insights_process_sleep_data(rtc_get_time()); cl_assert_equal_i(s_data.pi...
rtc_get_time()
); // Common metrics s_data.metric_history[ActivityMetricSleepState][0] = ActivitySleepStateAwake; s_data.metric_history[ActivityMetricSleepStateSeconds][0] = 30 * SECONDS_PER_MINUTE; s_data.metric_history[ActivityMetricSleepEnterAtSeconds][0] = 0; // Push a pin rtc_set_time(rtc_get_time() + 5 * SECONDS_PE...
ALARM_DAY_LIST_CELL_HEIGHT; } static void prv_day_picker_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context) { AlarmEditorData *data = (AlarmEditorData *)callback_context; AlarmKind kind = prv_index_to_alarm_kind(cell_index->row); c...
("Check something first.", &data->custom_day_picker_window)
, fonts_get_system_font(FONT_KEY_GOTHIC_18), box, GTextOverflowModeFill, GTextAlignmentCenter, NULL); return; } else { // row highlighted and no days selected new_resource_id = RESOURCE_ID_CHECKMARK_ICON_DOTTED; } } ...
_START_FAIL_STRIKE_ONE); } return false; } static bool check_force_boot_recovery(void) { if (boot_bit_test(BOOT_BIT_FORCE_PRF)) { boot_bit_clear(BOOT_BIT_FORCE_PRF); return true; } if (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)) { dbgserial_putstr("Hold down UP + BACK ...
delay_us(200000)
; display_error_code(0x89abcdef); delay_us(200000); display_error_code(0xcafebabe); delay_us(200000); display_error_code(0xfeedface); delay_us(200000); display_error_code(0x8badf00d); delay_us(200000); display_error_code(0xbad1ce40); delay_us(200000); display_error_code(0xbee...
buf, "May", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"b\": %s", buf); } r = strftime(buf, buf_size, "%B", &good_data); if (r == 0 || strncmp(buf, "May", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"B\": %s", buf); } r = strftime(buf, buf_size, "%c", &good_data); ...
(buf, buf_size, "%W", &good_data)
; if (r == 0 || strncmp(buf, "18", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"W\": %s", buf); } r = strftime(buf, buf_size, "%x", &good_data); if (r == 0 || strncmp(buf, "05/05/15", buf_size) != 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"x\": %s", buf); } r = strftime(buf, b...
nTagCount] = { { .tag = MemoryRegionTag_Text, // .text is first so it's easily excluded on crc check .start = &__text_start, .length = (uint32_t)__text_length, }, { .tag = MemoryRegionTag_VectorTable, .start = (void *)DATA_RAM_BASE_ADDRESS, .length = (uint32_t)__vector_table_length, }, { .tag...
hw_watchdog_set_pos_val(0xFF)
(&intent->device); } static bool prv_has_intents_for_disconnected_devices(void) { return list_find(&s_intents->node, prv_intent_filter_disconnected, NULL); } static uint32_t prv_intents_count(void) { return list_count(&s_intents->node); } static bool prv_is_intent_used(const GAPLEConnectionIntent *intent) { re...
gap_le_connection_by_device(&request->bonding.device)
; } } if (connection) { is_already_connected = true; is_already_encrypted = connection->is_encrypted; local_is_master = connection->local_is_master; connected_device = &connection->device; } intent = prv_get_intent_by_bonding_id(request->bonding.id); } else { is_alre...
/* * 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 (input_config->gpio == NULL) { // TODO: PBL-15063 return; }
gpio_input_init_pull_up_down(input_config, GPIO_PuPd_NOPULL); } void gpio_input_init_pull_up_down(const InputConfig *input_config, GPIOPuPd_TypeDef pupd) { GPIO_InitTypeDef gpio_init = { .GPIO_Mode = GPIO_Mode_IN, .GPIO_PuPd = pupd, .GPIO_Pin = input_config->gpio_pin }; prv_init_common(input_con...
init(); // The dbgserial input support requires timer support, so it is initialized here, much later // than the core dbgserial_init(). dbgserial_input_init(); serial_console_init(); voltage_monitor_init(); battery_init(); vibe_init(); #if CAPABILITY_HAS_ACCESSORY_CONNECTOR accessory_init(); #endif...
mfg_info_is_hrm_present()
amples == 0) { accel_reset_pending_accel_event(); return; } accel_manager_dispatch_data(); } uint64_t accel_get_latest_timestamp(void) { return s_latest_timestamp; } static void lis3dh_IRQ1_handler(bool *should_context_switch) { // It's possible that this interrupt could be leftover after turning acc...
{ accel_stop(); }
ude "drivers/rtc.h" #include "kernel/events.h" #include "kernel/pbl_malloc.h" #include "services/common/comm_session/session.h" #include "services/common/i18n/i18n.h" #include "services/common/regular_timer.h" #include "services/normal/alarms/alarm.h" #include "services/normal/timezone_database.h" #include "services/no...
mktime(&time_tm)
; gmtime_r(&uxtime, &time_tm); } if (rule->flag & TIMEZONE_FLAG_STANDARD_TIME) { // Standard time (not wall time) time_tm.tm_gmtoff = tz_info->tm_gmtoff; time_tm.tm_isdst = 0; } else if (rule->flag & TIMEZONE_FLAG_UTC_TIME) { // UTC time_tm.tm_gmtoff = 0; time_tm.tm_isdst = 0; } else { // W...
(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 IS" BA...
(&layer, &outside_x_y_layer_update_callback)
; layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("outside_x_y_origin_layer", ctx.parent_framebuffer, GColorWhite)); } void test_graphics_draw_pixel_${BIT_DEPTH_NAME}__offset_layer(void) { GContext ctx; Layer layer; test_graphics_context_init(&ctx, fb); layer_init(&layer, &GRect(10, 10, 10, ...
e "stubs_logging.h" #include "stubs_modal_manager.h" #include "stubs_mutex.h" #include "stubs_passert.h" #include "stubs_pbl_malloc.h" #include "stubs_pebble_tasks.h" #include "stubs_prompt.h" #include "stubs_rand_ptr.h" #include "stubs_regular_timer.h" #include "stubs_session.h" #include "stubs_sleep.h" #include "stub...
(pin_db_get(&id, &item_temp), -9)
; } void test_timeline_api__item_attributes_pin_to_timeline(void) { AttributeList list = {0}; attribute_list_add_cstring(&list, AttributeIdTitle, "title"); attribute_list_add_cstring(&list, AttributeIdSubtitle, "subtitle"); TimelineItem *item = timeline_item_create_with_attributes(0, 0, TimelineItemTypePin, ...
ession->data-mutex, it is OK to grab s_list_mutex bool dls_lock_session(DataLoggingSession *session) { mutex_lock_recursive(s_list_mutex); if (session->status != DataLoggingStatusActive) { mutex_unlock_recursive(s_list_mutex); return false; } PBL_ASSERTN(session->data); // Incrementing open_count in...
(s_list_mutex)
; return (iter); } iter = iter->next; } mutex_unlock_recursive(s_list_mutex); return (NULL); } void dls_list_remove_session(DataLoggingSession *logging_session) { if (uuid_is_system(&logging_session->app_uuid)) { PBL_LOG(LOG_LEVEL_WARNING, "Deleting the system data logging session with tag %...
andle empty ranges range.num_days = 0; prv_adjust_value_boundaries(values, ARRAY_LENGTH(values), &range); cl_assert_equal_i(values[0], 1000); cl_assert_equal_i(values[1], 1000); cl_assert_equal_i(values[2], 1000); // ensure we correctly handle the day index range = (HealthServiceTimeRange){ .num_days...
(HealthMetricHeartRateBPM, now + 10, now + 20)
; cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskNotAvailable); // normal value is available accessible = health_service_metric_accessible(HealthMetricHeartRateBPM, now - 10, now); cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable); // values that partly are in unsupported r...
ystem_task_callbacks_invoke_pending(); cl_assert_equal_b(false, app_cache_entry_exists(app1.id)); cl_assert_equal_b(false, app_cache_entry_exists(app2.id)); cl_assert_equal_b(false, app_cache_entry_exists(app3.id)); } static const uint32_t SIZE_SUM = 7210515; static const AppData t_data[] = { // hi...
cl_assert_equal_i(S_SUCCESS, app_cache_app_launched(t_data[i].id))
; // increment time so everything won't happen in the same second } for (int i = 0; i < 50; i++) { cl_assert_equal_b(true, app_cache_entry_exists(t_data[i].id)); } cl_assert_equal_i(SIZE_SUM, app_cache_get_size()); } void prv_cleanup(void) { app_cache_flush(); prv_load_lotta_apps(); } void test_...
/* * 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...
{ static const PebbleProcessMdSystem s_alarms_app_info = { .common = { .main_func = NULL, // UUID: 67a32d95-ef69-46d4-a0b9-854cc62f97f9 .uuid = {0x67, 0xa3, 0x2d, 0x95, 0xef, 0x69, 0x46, 0xd4, 0xa0, 0xb9, 0x85, 0x4c, 0xc6, 0x2f, 0x97, 0xf9}, }, .name = "Alarms", }; ret...
// This stub isn't needed on tintin as it uses a different launcher #if !PLATFORM_TINTIN && !CAPABILITY_HAS_SDK_SHELL4 #include "apps/system_apps/launcher/launcher_app.h" const LauncherDrawState *launcher_app_get_draw_state(void) { return NULL; } #endif void analytics_external_update(void) { } bool shell_prefs_ge...
et_time(jun10th_noon_2015); // Our test event is at June 9th 2015, 16:00:00 // Now - one day const time_t event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR); time_t format_time; clock_set_24h_style(true); // June 9th 2015, 12:00:00 (-07:00:00) format_time = event_time + SECONDS_PE...
(tomorrow_afternoon, daypart_string)
; // (6pm tomorrow) time tomorrow between 6pm and 9pm is tomorrow evening daypart_string = clock_get_relative_daypart_string(timestamp, 38 /* hours_in_the_future */); cl_assert_equal_s(tomorrow_evening, daypart_string); // (9pm tomorrow) time tomorrow between 9pm and 9am the next day is tomorrow night daypa...
/* * 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 (left_edge_bits_count) { mask = 0xffffffff << left_edge_bits_count; *(block) = (*(block) & ~mask) | (pattern & mask); block++; width -= (32 - left_edge_bits_count); } if (right_edge_bits_count) { mask = 0xffffffff >> (32 - right_edge_bits_count); *(block + (width / 3...
} // ## 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 transparency // on the drawn line (beside edges) T_STATIC void prv_assign_horizontal_line_raw(GContext *ctx, in...
s_get_mask() == AlertMaskAllOn); // Should allow all notifications to go through cl_assert(alerts_should_notify_for_type(AlertMobile)); cl_assert(alerts_should_notify_for_type(AlertReminder)); cl_assert(alerts_should_notify_for_type(AlertPhoneCall)); // Should not allow invalid Notifications though cl_ass...
(AlertPhoneCall)
w or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "switch_worker_ui.h"...
(DIALOG_MAX_MESSAGE_LEN)
; sniprintf(msg_buffer, DIALOG_MAX_MESSAGE_LEN, fmt, new_entry.name, old_entry.name); confirmation_dialog_set_click_config_provider(confirmation_dialog, prv_click_config_provider); dialog_set_background_color(dialog, GColorCobaltBlue); dialog_set_text_color(dialog, GColorWhite); dialog_set_text(dialog, msg_...
Y: strncpy(data->duration_string, new_tuple->value->cstring, sizeof(data->duration_string)); break; case SPORTS_LABEL_KEY: { const bool is_pace = MIN(new_tuple->value->uint8, 1); WorkoutMetricType metric_type = is_pace ? WorkoutMetricType_Pace : WorkoutMetricType_Speed; if (metric_...
{ SportsAppData *data = app_state_get_user_data(); switch (type) { case WorkoutMetricType_Hr: return data->current_bpm; default: return 0; } }
static const char *prv_get_distance_string(const char *miles_string, const char *km_string) { SportsAppData *data = app_state_get_user_data(); const Tuple *metric_tuple = app_sync_get(&data->sync, SPORTS_UNITS_KEY); uint8_t is_metric = 1; if (metric_tuple != NULL) { is_metric = MIN(metric_tuple->value->u...
/* * 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...
ancs_util_is_complete_notif_attr_response(s_chunked_dict_part_one, sizeof(s_chunked_dict_part_one), &error)
); cl_assert(!error); } void test_ancs_util__should_not_parse_malformed_notif_attr_dict(void) { bool error = false; cl_assert(!ancs_util_is_complete_notif_attr_response(s_chunked_dict_part_two, sizeof(s_chunked_dict_part_two), &error)); cl_assert(error); } void test_ancs_util__should_extract_dict_from...
const uint8_t *attributes_per_actions) { attribute_group_init(GROUP_TYPE, attr_list, action_group, buffer, num_attributes, num_actions, attributes_per_action...
PBL_LOG(LOG_LEVEL_ERROR, "Error deep-copying pin attribute list")
; return false; } } if (src_action_group && dest_action_group) { rv = prv_action_group_copy(dest_action_group, src_action_group, buffer + attr_list_size, buf_end); if (!rv) { PBL_LOG(LOG_LEVEL_ERROR, "Error deep-copying pin action group"); return false; ...
1); // For the first sample, it will be identical cl_assert_equal_i(battery_get_charge_state().charge_percent, high_percent); // ...and should stay that way periodic_timer_trigger(10); cl_assert_equal_i(battery_get_charge_state().charge_percent, high_percent); // Then, when the voltage drops, the percenta...
cl_assert(!s_in_low_power)
; cl_assert_equal_i(s_power_state, PowerStateGood); // good -> critical fake_battery_set_millivolts(critical_mv); fake_battery_set_charging(false); fake_battery_set_connected(false); periodic_timer_trigger(20); cl_assert(battery_monitor_critical_lockout()); cl_assert_equal_i(s_power_state, PowerStateCr...
tx, 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...
(&layer, &ctx)
; cl_check(framebuffer_is_empty("outside_ny_offset_layer", ctx.parent_framebuffer, GColorWhite)); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &outside_x_y_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("outside_x_y_offset_layer", ctx.parent_fra...
k(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi")); 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, "draw_round_rect_across_nx_offse...
gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw2_clip_xy.${BIT_DEPTH_NAME}.pbi")
); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 2); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi")); #endif // AA = true, SW = 3 setup_...
/* * 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...
(dci_reel->image)
ip if no buffer to free. return; } if (session->data->buffer_in_kernel_heap) { kernel_free(session->data->buffer_storage); } else { // The subscriber's buffer was allocated on its unprivileged process heap (app or worker). It // is unsafe to free it from here in privileged mode because a corrupte...
{ next = cur->next; if (cur->data) { mutex_destroy(cur->data->mutex); kernel_free(cur->data); } kernel_free(cur); cur = next; }
s_logging_sessions = NULL; mutex_unlock_recursive(s_list_mutex); } //! Insert logging session with known id void dls_list_insert_session(DataLoggingSession *logging_session) { mutex_lock_recursive(s_list_mutex); DataLoggingSession **iter = &s_logging_sessions; for (int i = 0; i < logging_session->comm.ses...
_line_dotted(&ctx, GPoint(101, 11), 5); graphics_draw_horizontal_line_dotted(&ctx, GPoint(96, 16), 10); // cross - even vert, even horiz graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 32), 10); graphics_draw_horizontal_line_dotted(&ctx, GPoint(4, 36), 10); // cross - odd vert, odd horiz graphics_draw...
graphics_draw_line(ctx, GPoint(100,100), GPoint(100,100))
; } void test_graphics_draw_line__same_point(void) { GContext ctx; test_graphics_context_init(&ctx, fb); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1); draw_lines_same_point(&ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_same_point"))); #if ...
/* * 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...
(vector, sizeof(vector))
; assert_decode_completed(SIZE_MAX); assert_buffer_not_touched(6); } void test_cobs_decode__output_too_small_2(void) { const char vector[] = { 0x05, 'a', 'b', 'c', 'd', 0x01, 0x01 }; decode_start(5); assert_decode_fails(vector, sizeof(vector)); assert_decode_completed(SIZE_MAX); assert_buffer_not_touched...
nt_init(); gap_le_connection_init(); } void test_gatt_client_discovery__cleanup(void) { gap_le_connection_deinit(); // make sure we haven't leaked any memory! fake_pbl_malloc_check_net_allocs(); } // ----------------------------------------------------------------------------- // Edge cases void test_gatt_c...
fake_gatt_is_service_discovery_stop_count()
; // Fire the watchdog timer: const TimerID watchdog_timer = bt_driver_gatt_get_watchdog_timer_id(); stub_new_timer_fire(watchdog_timer); // Check whether GATT_Stop_Service_Discovery has been called: cl_assert_equal_i(stop_count + 1, fake_gatt_is_service_discovery_stop_count()); if (i < GATT_...
ndle_battery_state_change_event(PreciseBatteryChargeState new_state) { if (new_state.is_plugged) { s_charger_plugged = true; s_current_cal_status = CompassStatusDataInvalid; memset(s_active_corr, 0x00, sizeof(s_active_corr)); prv_reset_saved_sample(); } else if (s_charger_plugged) { // we have u...
if (s_high_freq_calib_active) { prv_calibration_time_expired_cb(NULL); }
prv_save_calibration_values(s_active_corr); s_current_cal_status = CompassStatusCalibrated; } } // get the most recent accel readings AccelRawData accel_data = s_accel_data; int32_t roll = 0, pitch = 0; prv_get_roll_and_pitch(&accel_data, &roll, &pitch); PebbleEvent e = { .type = PEBB...
/* * 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...
(hr_util_is_elevated(120), true)
; cl_assert_equal_b(hr_util_is_elevated(240), true); }
/* * 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 E_BUSY; }
else { *file = (SettingsFile){}; s_settings_file.open = true; return S_SUCCESS; } } void settings_file_close(SettingsFile *file) { cl_assert(s_settings_file.open); s_settings_file.open = false; } bool settings_file_exists(SettingsFile *file, const void *key, size_t key_len) { const uint8_t key_cr...
btain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licens...
((char *)dest, NIHAO_FIRST_CHARACTER)
; } void test_utf8__copy_last_character(void) { utf8_t dest[5]; memset(dest, 0, 5); size_t copied = utf8_copy_character(dest, (utf8_t *)NIHAO_FIRST_CHARACTER, 5); cl_assert_equal_i(copied, NIHAO_FIRST_CHARACTER_BYTES); cl_assert_equal_s((char *)dest, NIHAO_FIRST_CHARACTER); } void test_utf8__copy_invalid_...
/* * 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(data != NULL)
; PBL_ASSERTN(string_alloc_size != NULL); // Determine string buffer allocation size based on serialized data uint8_t attributes_per_action[num_actions]; bool r = attributes_actions_parse_serial_data(num_attributes, num_actions, data, size, string_alloc_size, att...
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed ...
layer_mark_dirty(&image->layer)
; } void rot_bitmap_set_compositing_mode(RotBitmapLayer *image, GCompOp mode) { if (mode == image->compositing_mode) { return; } image->compositing_mode = mode; layer_mark_dirty(&image->layer); }
rt_equal_i(circular_buffer_copy(&buffer, data_out, data_out_size), 8); cl_assert(memcmp("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...
circular_buffer_init(&buffer, storage, sizeof(storage))
; uint8_t *data_out = NULL; bool caller_should_free = false; cl_assert_equal_b(false, circular_buffer_read_or_copy(&buffer, &data_out, sizeof(storage) + 1, malloc, &caller_should_free)); } void test_circular_buffer__read_or_copy_doesnt_copy_when_already_con...
id battery_vusb_interrupt_handler(bool *should_context_switch); static void battery_conn_debounce_callback(void* data) { s_debounced_is_usb_connected = battery_is_usb_connected_raw(); if (!s_debounced_is_usb_connected) { // disconnection event // - put the watch charger into a sane state // - disable ...
if (BOARD_CONFIG_POWER.has_vusb_interrupt) { // Prime the debounced state. s_debounced_is_usb_connected = battery_is_usb_connected_raw(); }
} bool battery_charge_controller_thinks_we_are_charging_impl(void) { periph_config_acquire_lock(); gpio_use(BOARD_CONFIG_POWER.chg_stat.gpio); bool state = !GPIO_ReadInputDataBit(BOARD_CONFIG_POWER.chg_stat.gpio, BOARD_CONFIG_POWER.chg_stat.gpio_pin); gpio_release(BOARD_CONFIG_POWER.chg_stat.gpio); periph_c...
NumModalPriorities - 1; idx >= ModalPriorityMin; idx--) { ModalContext *context = &s_modal_window_stacks[idx]; if (!prv_has_visible_window(context, NULL)) { continue; } else if (iter.first_visible_idx == ModalPriorityInvalid) { iter.first_visible_idx = idx; } if (prv_has_transition_windo...
window_render(window, ctx)
on't modify the // second byte as bits are only allowed to be written from 1 -> 0. 1s will // stay 1s, and 0s will stay 0s. const uint16_t trailing_short_value = *buffer | 0xFF00; *flash_write_dest = trailing_short_value; } // Buffer writing is complete, issue the buffer to flash command to actuall...
flash_impl_use()
; // get system clock tick speed RCC_ClocksTypeDef clocks; RCC_GetClocksFreq(&clocks); uint32_t h_clock = clocks.HCLK_Frequency; // frequency in hertz uint32_t time_per_cycle = ((uint64_t)(10000000000)) / h_clock; // period in 1/10th ns FMC_NORSRAMTimingInitTypeDef nor_timing_init = { // time...
name_in, &platform_bits_in); prv_fire_writeback_timer(); cl_assert(id != BT_BONDING_ID_INVALID); // And delete is again bt_persistent_storage_delete_bt_classic_pairing_by_addr(&addr_in); // Try to read it back ret = bt_persistent_storage_get_bt_classic_pairing_by_id(i...
(&pairing_1, true /* is_gateway */, NULL, false /* requires_address_pinning */, false /* auto_accept_re_pairing */)
; prv_fire_writeback_timer(); cl_assert(id_3 != BT_BONDING_ID_INVALID); // There should now be an active BLE gateway ret = bt_persistent_storage_get_active_gateway(&id_out, &type_out); cl_assert(!ret); ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding(); cl_assert(!ret); ret = bt_persis...
mationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL /* callback data */); PropertyAnimation *a_rev = property_animation_clone(a); animation_set_handlers((Animation*) a_rev, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, ...
s_animation = animation_spawn_create(seq, (Animation *)c, prv_create_custom_animation(), NULL); animation_schedule(s_animation); }
--------------------------------------------------------- static void prv_assert_alarm_params(int hour, int minute) { PBL_ASSERT(hour < 24 && hour >= 0, "Invalid hour value, %d", hour); PBL_ASSERT(minute < 60 && minute >= 0, "Invalid minute value, %d", minute); } // ------------------------------------------------...
(&config->scheduled_days, weekends, sizeof(weekends))
{ -1344, 136, -344}, { -1416, 104, -160}, { -1432, -176, -120}, { -1544, 24, -56}, { -1384, 120, 336}, { -1416, 392, 200}, { -1336, 488, 8}, { -1208, 512, -48}, { -1048, 368, -16}, { -912, 544, -128}, { -1000, 608, -104}, { -1176, 640, -64}, { -1232, 680, -96}, { -9...
// 37 seconds { -168, 672, -80}, { -168, 632, -72}, { -144, 544, -48}, { -80, 472, -8}, { -40, 464, -8}, { -8, 560, -32}, { -48, 792, 0}, { -128, 1128, 56}, { -184, 1448, 144}, { -216, 1624, 168}, { -192, 1304, 176}, { -72, 1056, 104}, { -72, 992, 160}, { -152...
{ -272, 1040, 664}, { -248, 840, 792}, { -280, 920, 792}, { -328, 880, 824}, { -272, 664, 648}, { -248, 504, 528}, { -240, 360, 464}, { -216, 224, 360}, // 40 seconds { -160, 136, 264}, { -176, 96, 208}, { -288, 112, 224}, { -544, 112, 224}, { -1432, 648, 672}, ...
1111, // Active K Calories 2222, // Resting K Calories 3333, // Distance 4444, // Active Time }; static uint32_t s_future_movement_data[] = { 1, // Version NOW + SECONDS_PER_DAY, 1234, // Steps 1111, // Active K Calories 2222, // Res...
health_db_insert((uint8_t *)key, strlen(key), (uint8_t *)s_movement_data, sizeof(s_movement_data))
, S_SUCCESS); cl_assert_equal_i(s_metric_updated_count, NUM_CURRENT_MOVEMENT_METRICS); // check typicals (not stored) int32_t val_out; cl_assert(!health_db_get_typical_value(ActivityMetricStepCount, Monday, &val_out)); cl_assert(!health_db_get_typical_value(ActivityMetricActiveSeconds,...