prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
eel, screen_frame); kino_reel_transform_set_global(reel, true); } else { prv_destructor(data); } return reel; } void kino_reel_scale_segmented_set_delay_lookup_creator( KinoReel *reel, GPointIndexLookupCreator creator, void *userdata, bool take_ownership) { ScaleSegmentedData *data = kino_reel_tran...
{ GRect frame = kino_reel_transform_get_to_frame(reel); kino_reel_transform_set_to_frame( reel, (GRect) { grect_center_point(&frame), SCALE_SEGMENTED_DOT_SIZE }); const Fixed_S16_3 to = Fixed_S16_3((2 * radius) << FIXED_S16_3_PRECISION); kino_reel_scale_segmented_set_to_stroke_width(reel, to, GStrokeWidt...
bitmap = gbitmap_create_blank(size, GBitmapFormat1BitPalette); if (bitmap) { // Perform conversion uint8_t *src_data = (uint8_t *)src_bitmap->addr; uint8_t *dest_data = (uint8_t *)bitmap->addr; for (int y = 0; y < bitmap->bounds.size.h; ++y) { for (int b = 0; b < bitmap->row_size_byt...
applib_resource_munmap_or_free(data)
; return result; } const bool mmapped = applib_resource_is_mmapped(data); if (prv_init_with_pbi_data(bitmap, data, data_size, mmapped)) { // in order to make memory-mapped bitmaps work, we need to decrement the reference counter // when we destroy it. This case is different from a sub-bitmap that sha...
handle_event(e); } if (stolen) { // we stole the buffer from the event, NULL it out *buf_ptr = NULL; } } // ------------------------------------------------------------------------------------------------- static bool prv_buffer_find(ListNode *found_node, void *data) { EventServiceBuffer *esb = (Event...
(&esb->intents_pending, ~task_bit)
; if (intents_pending) { // zero out buf_ptr so it won't be freed by cleanup. Other tasks are still waiting to use it void **buf_ptr = event_get_buffer(e); *buf_ptr = NULL; } else { // free the EventServiceBuffer and free the data list_remove((ListNode *)esb, (ListNode **)&s_event_...
t->icon_layer.layer, false); const bool take_ownership = true; KinoReel *new_reel = kino_reel_scale_segmented_create(from_reel, take_ownership, icon_from); kino_reel_transform_set_to_frame(new_reel, icon_to); kino_reel_transform_set_transform_duration(new_reel, duration / 2); kino_reel_scale_segmented_set_de...
(animation, interpolate)
; animation_set_handlers(animation, (AnimationHandlers) { .stopped = prv_up_down_stopped, }, layout); return animation; }
fer, sizeof(buffer)); } static void prv_receive_put(uint32_t cookie, const uint8_t *payload, uint32_t payload_size) { uint8_t buffer[sizeof(PutRequest) + payload_size]; PutRequest *put_msg = (PutRequest *)buffer; *put_msg = (PutRequest) { .cmd = CmdPut, .cookie = htonl(cookie), .payload_size = htonl...
{ ++s_nacks_received; }
} void test_put_bytes__initialize(void) { fake_pb_storage_mem_reset(); fake_pb_storage_mem_set_crc(EXPECTED_CRC); fake_comm_session_init(); fake_event_reset_count(); Transport *transport = fake_transport_create(TransportDestinationSystem, NULL, prv_system_msg_...
/* * 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...
GPoint(15, 100)
, 0, 3686400); PebbleEvent event = fake_event_get_last(); cl_assert_equal_i(event.type, PEBBLE_TOUCH_EVENT); cl_assert_equal_i(event.touch.type, PebbleTouchEvent_TouchesAvailable); TouchEvent *touch_event = touch_event_queue_get_event(0, 0); prv_test_touch_event(touch_event, 0, TouchEvent_Liftoff, &GPointZero...
comm_session_get_system_session()
, FACTORY_REGISTRY_ENDPOINT, data, length, COMM_SESSION_DEFAULT_TIMEOUT); } static void prv_send_color_response(void) { const uint8_t response[] = { 0x01, 0x04, 0x0, 0x0, 0x0, mfg_info_get_watch_color() }; prv_send_response(response, sizeof(response)); } static void prv_send_fail_response...
nager_get_task_context(void) { return &s_app_task_context; } bool app_manager_is_watchface_running(void) { return (app_manager_get_current_app_md()->process_type == ProcessTypeWatchface); } ResAppNum app_manager_get_current_resource_num(void) { return process_metadata_get_res_bank_num(s_app_task_context.app_md)...
analytics_inc(ANALYTICS_APP_METRIC_ROCKY_LAUNCH_COUNT, AnalyticsClient_App)
; } if (launch_reason == APP_LAUNCH_QUICK_LAUNCH) { analytics_inc(ANALYTICS_DEVICE_METRIC_APP_QUICK_LAUNCH_COUNT, AnalyticsClient_System); analytics_inc(ANALYTICS_APP_METRIC_QUICK_LAUNCH_COUNT, AnalyticsClient_App); } else if (launch_reason == APP_LAUNCH_USER) { analytics_inc(ANALYTICS_DEVICE_METRIC_...
/* * 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...
(bitmap, block_addr, dest_y)
, prv_get_8bit_x_from_1bit_x(dest_x)); dest_x = 0; dest_y = 50; block_addr = (uint32_t *)(uintptr_t)(((dest_y * row_1bit_size_words) + (dest_x / 32)) * 4); cl_assert_equal_i(prv_convert_1bit_addr_to_8bit_x(bitmap, block_addr, dest_y), prv_get_8bit_x_from_1bit_x(dest_x));...
h the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or...
prv_get_vsys_mv()
; PBL_ASSERTN(vsys_mv > 0); duty_cycle = (BOARD_CONFIG_VIBE.vsys_scale * duty_cycle) / vsys_mv; } return duty_cycle; } } static void prv_vibe_raw_ctl(bool on) { if (BOARD_CONFIG_VIBE.options & ActuatorOptions_Pwm) { const uint32_t duty_cycle = (on) ? s_vibe_duty_cycle : PWM_DUTY_CYCLE_OFF; ...
----------------- // Sample captured: 2015-10-05 20:31:39 local AccelRawData *activity_sample_walk_200_pbl_25675_11(int *len) { // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_200_pbl_25675_11 //> TEST_EXPECTED 200 //> TEST_EXPECTED_MIN 100 //> TEST_EXPECTED_MAX 230 //...
{ 1024, -152, -56}, { 1064, -128, -104}, { 1072, -72, -168}, { 1056, -32, -208}, { 1040, -24, -232}, // 5 seconds { 984, 8, -288}, { 952, 32, -320}, { 920, 72, -328}, { 928, 104, -360}, { 920, 120, -360}, { 936, 152, -368}, { 952, 168, -432}, { 976, 208, -464}, ...
e_spi_flash_init(0, 0x1000000); pfs_init(false); pfs_format(false); prv_activity_algorithm_erase_minute_data(); prv_activity_init_and_set_enabled(true); // Set default user settings activity_prefs_set_height_mm(ACTIVITY_DEFAULT_HEIGHT_MM); activity_prefs_set_weight_dag(ACTIVITY_DEFAULT_WEIGHT_DAG); ac...
ASSERT_NUM_ACTIVITY_SESSIONS(3)
; // 2 sleep sessions + 1 activity sessions ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&walk_activity); // The expected resting calories int minutes_today = 17 * MINUTES_PER_HOUR + 3 + wait_min; const int exp_resting_kcalories_now = ROUND(s_exp_full_day_resting_kcalories * minutes_today, ...
!prv_get_calendar_ongoing()); TimerID timer_id = stub_new_timer_get_next(); cl_assert_equal_i(timer_id, TIMER_INVALID_ID); cl_assert(!stub_new_timer_is_scheduled(timer_id)); cl_assert(timeline_add(&item1)); timeline_event_handle_blobdb_event(); cl_assert_equal_i(fake_event_get_count(), 2); cl_assert(!prv...
prv_get_calendar_ongoing()
); cl_assert(stub_new_timer_is_scheduled(timer_id)); cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000); rtc_set_time(20 * 60); cl_assert(stub_new_timer_fire(timer_id)); cl_assert_equal_i(fake_event_get_count(), 3); cl_assert(prv_get_calendar_ongoing()); cl_assert(stub_new_timer_is_schedul...
, 912, 240}, { -40, 912, 280}, { -40, 912, 272}, { -56, 912, 272}, { -48, 912, 280}, { -56, 920, 288}, { -48, 904, 272}, { -40, 912, 288}, { -48, 904, 272}, { -48, 912, 280}, { -48, 912, 280}, { -48, 904, 280}, { -48, 904, 280}, { -48, 912, 272}, { -48, 904, 280},...
{ -40, 928, 232}, { -48, 920, 232}, { -40, 920, 232}, { -48, 920, 240}, { -40, 920, 232}, { -48, 920, 232}, { -48, 928, 232}, { -48, 920, 232}, { -48, 920, 240}, { -48, 920, 240}, { -40, 920, 240}, { -48, 920, 232}, { -40, 920, 240}, { -40, 928, 232}, // 159 s...
{ -40, 920, 248}, { -40, 920, 240}, { -40, 920, 248}, { -40, 920, 248}, { -40, 920, 248}, { -40, 920, 248}, { -48, 920, 248}, { -40, 912, 240}, { -40, 920, 248}, { -48, 912, 248}, { -40, 920, 240}, { -40, 920, 248}, { -40, 920, 240}, { -40, 920, 248}, { -40, ...
_COMPLEX const int duration_a = 300; const int duration_b = 500; const int duration_c = 400; const int play_count_b = 2; int duration_total = duration_a + play_count_b * duration_b; const AnimationHandlers handlers = { .started = prv_started_handler, .stopped = prv_stopped_handler }; // Creat...
(prv_count_handler_entries(&s_stopped_handler_calls, a), 1)
; cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1)...
cy_watchdog_cb(void *data) { // offload handling onto KernelBG so we don't stall the timer thread // trying to get the bt lock system_task_add_callback(prv_bt_le_gateway_response_latency_watchdog_handler, data); } static bool prv_find_source(ListNode *found_node, void *data) { return (((ConnectionStateRequest ...
kernel_free(*info)
; *info = NULL; } void command_change_le_mode(char *mode) { // assume we only have one connection for debug GAPLEConnection *conn_hdl = gap_le_connection_any(); ResponseTimeState state = atoi(mode); conn_mgr_set_ble_conn_response_time( conn_hdl, BtConsumerPrompt, state, MAX_PERIOD_RUN_FOREVER); } sta...
, 64}, { 1104, 8, 56}, { 1088, -24, 64}, { 1040, -64, 0}, { 1080, -120, 32}, { 1200, -208, 16}, { 1104, -184, 16}, { 1056, -168, -32}, // 109 seconds { 848, -128, -104}, { 1072, -136, -120}, { 1184, -128, -136}, { 1032, -216, -64}, { 960, -208, -56}, { 976, -184, ...
{ 1024, -112, -32}, { 1120, -128, -16}, { 1472, -112, -48}, { 1304, -96, -48}, { 1144, -40, -160}, { 856, -16, -224}, { 976, 0, -248}, { 1160, -32, -168}, { 1080, -72, -128}, { 960, -64, -160}, { 936, -56, -168}, { 944, -56, -184}, { 952, -80, -192}, { 1000, -104,...
{ 968, -112, -72}, { 1024, -112, -104}, { 1096, -136, -120}, // 117 seconds { 1520, -160, -64}, { 1456, -136, -16}, { 1144, -16, -96}, { 832, 16, -208}, { 1056, 88, -264}, { 1136, 48, -168}, { 1072, -32, -104}, { 920, -48, -104}, { 928, -24, -112}, { 920, 0, -120...
insights_recalculate_stats(); // If the pin we loaded was created on the previous day, we don't bother loading the UUID const time_t midnight_today = time_util_get_midnight_of(now_utc); if (time_util_get_midnight_of(activity_pin_last_state.last_triggered_utc) == midnight_today) { s_activity_pin_state.uuid = ...
{ prv_trigger_activation_delay_insight(now_utc, &ACTIVATION_DELAY_INSIGHTS[i]); }
/* * 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(!memory_layout_is_pointer_in_region(&region, (void*) 2000))
; cl_assert(!memory_layout_is_pointer_in_region(&region, (void*) 9999)); } void test_memory_layout__cstring_in_region(void) { const char buffer[] = "yyyxxxstrstr\0badstrxxxyyy"; const char *valid_str = buffer + 6; // skip yyyxxx, equal to "strstr" const char *invalid_str = buffer + 6 + 7; // skip yyyxxx + strs...
/* * 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...
DIV_X(frame.size.h * MULT_X((cur - limit_b), (limit_c - limit_b)))
); } else if (cur <= limit_d) { // zone c - d return GPoint(frame.origin.x + DIV_X(frame.size.w * (1000 - MULT_X((cur - limit_c), (limit_d - limit_c)))), frame.origin.y + frame.size.h); } else if (cur <= limit_e) { // zone d - e return GPoint(frame.origin.x, ...
cess, bool *cb_completed, uint32_t timeout_sec) { // This call blocks on KernelBG, so it should only be called from an app or worker PebbleTask task = pebble_task_get_current(); PBL_ASSERTN(task == PebbleTask_App || task == PebbleTask_Worker); // Enqueue it for KernelBG to proc...
battery_is_usb_connected()
e law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "hrm_manager.h" ...
{ uint16_t avail_bytes = circular_buffer_get_read_space_remaining( &s_manager_state.system_task_event_buffer); return avail_bytes / sizeof(PebbleHRMEvent); }
#endif static void prv_handle_accel_data(void * data) { PBL_ASSERT_RUNNING_FROM_EXPECTED_TASK(PebbleTask_NewTimers); uint64_t timestamp_ms; uint32_t num_new_samples = sys_accel_manager_get_num_samples( s_manager_state.accel_state, &timestamp_ms); mutex_lock(s_manager_state.accel_data_lock); // Only...
e(BTBondingID bonding, BtPersistBondingOp op) { if (s_bonding_change_count <= ARRAY_LENGTH(s_bonding_change_ops)) { s_bonding_change_ops[s_bonding_change_count] = op; } ++s_bonding_change_count; } static void prv_reset_change_op_tracking(void) { s_bonding_change_count = 0; for (int i = 0; i < ARRAY_LENGT...
(s_bonding_change_ops[0], BtPersistBondingOpDidChange)
, num_entries); prv_test_new_order_with_filter_callback(watchface_order, num_entries, watchface_filter_callback); } } void test_app_menu_data_source__last_app_not_in_order_file(void) { // settings has to be at the beginning. The app_menu_data_source module enforces i...
(&data_source, i)
; cl_assert_equal_i(node->install_id, desired_order[i]); } app_menu_data_source_deinit(&data_source); } void test_app_menu_data_source__complete_sorted_order(void) { // Apps are sorted in the order of Quick Launch only, Override apps, Storage (smallest first), // Record (smallest first), and finally Insta...
, -4); cl_assert_equal_s(dstbuf, "There are 010 lights, fffffffc"); // Space padded minimum character output snprintf(dstbuf, 256, "There are %3x lights, %3x", 16, -4); cl_assert_equal_s(dstbuf, "There are 10 lights, fffffffc"); // Space for positive signed // No signed conversion occurs, so this is a no...
cl_assert_equal_s(dstbuf, "zero1")
/* * 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_reconnect_advert_job)
; } } static void prv_evaluate(ReconnectType prev_type) { ReconnectType cur_type = prv_current_reconnect_type(); if (cur_type == prev_type) { return; } if (cur_type != ReconnectType_None) { prv_unschedule_adv_if_needed(); #if CAPABILITY_HAS_BUILTIN_HRM const bool use_hrm_payload = (cur_type == ...
0 /* success */) { prv_copy_accel_sample_to_accel_data(&data, accel_data); prv_update_last_accel_data(&data); } mutex_unlock_recursive(s_accel_manager_mutex); return result; } DEFINE_SYSCALL(AccelManagerState*, sys_accel_manager_data_subscribe, AccelSamplingRate rate, AccelDataReadyCall...
syscall_assert_userspace_buffer(buffer, samples_per_update * sizeof(AccelRawData))
; } mutex_lock_recursive(s_accel_manager_mutex); { state->raw_buffer = buffer; state->samples_per_update = samples_per_update; state->num_samples = 0; prv_update_driver_config(); } mutex_unlock_recursive(s_accel_manager_mutex); return 0; } DEFINE_SYSCALL(uint32_t, sys_accel_manager_get_nu...
nst TimelineLayerStyle *style = prv_get_style(); const int16_t width = bounds->size.w - (style->left_margin + style->right_margin); switch (layout_mode) { default: case LayoutLayerModePinnedFat: *size = GSize(width, style->fat_pin_height); break; case LayoutLayerModePinnedThin: *size =...
(&layer->layouts_layer, (Layer *)layout)
; GRect icon_rect; timeline_layer_get_icon_frame(layer, index, &icon_rect); layer_set_frame((Layer *)&layout->icon_layer, &icon_rect); layer_add_child(&layer->layouts_layer, (Layer *)&layout->icon_layer); layer->layouts[index] = layout; layer->layouts_info[index] = info; } static void prv_destroy_layout(Ti...
0), 10, 2)); #endif setup_test(&context, true, 2, GColorBlack, GColorBlack, false); graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4); #if PBL_COLOR ASSERT_CALLED(prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, 2)); #else ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRec...
GRect(20, 80, 40, 10)
, 4, GCornersAll, GColorBlack)); } void test_graphics_context_${BIT_DEPTH_NAME}__fill_antialiased(void) { // Fill shape, antialiased (Stroke width/color N/A) setup_test(&context, true, 5, GColorBlack, GColorBlack, false); graphics_fill_rect(&context, &GRect(10, 20, 40, 10)); #if SCREEN_COLOR_DEPTH_BITS == 1 A...
sert_gpoint_precise(center, 4.5, 9.5); cl_assert_fixedS16_3(radius, 4.5); r = GRect(0, 0, -10, -20); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, -5.5, -10.5); cl_assert_fixedS16_3(radius, 4.5); } void test_graphics_circle__grect_polar_calc_values_square(void) { GP...
(s_radius_inner, 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...
{ // In a previous version of the code, the main FW would not know yet what address would be used // for pinning until the BT driver would give the address to pin when a pairing was added. // A single, persistent pinned address is now generated up front in bt_local_addr_init(). // Getting the address back in th...
void bt_local_addr_handle_bonding_change(BTBondingID bonding, BtPersistBondingOp op) { bool has_pinned_ble_pairings = bt_persistent_storage_has_pinned_ble_pairings(); if (has_pinned_ble_pairings != s_cycling_paused_due_to_dependent_bondings) { if (has_pinned_ble_pairings) { bt_local_addr_pause_cycling()...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
prv_process_and_assert_sent(expected_payload, sizeof(expected_payload))
l prv_light_allowed(void) { if (!s_backlight_allowed) { return false; } if (backlight_is_enabled()) { if (backlight_is_ambient_sensor_enabled()) { // If the light is off and it's bright outside, don't allow the light to turn on // (we don't need it!). Grab the mutex here so that the timer s...
{ prv_change_state(LIGHT_STATE_ON_TIMED); }
else { prv_change_state(LIGHT_STATE_OFF); // FIXME: PBL-24793 There is an edge case of when the backlight has timed off // or you're toggling it from no ambient (always light on buttons) to ambient, // you will see it turn on and immediately off if its bright out } mutex_unlock(s_mutex); } void li...
ervice_unregister_all(); fake_kernel_malloc_deinit(); prv_cleanup_callback_events(); } //////////////////////////////////////////////////////////////////////////////////////////////////// // app_inbox_create_and_register void test_app_inbox__app_inbox_create_and_register_zero_buffer_size(void) { void *result = ...
app_inbox_service_register(storage, sizeof(storage), test_message_handler, test_dropped_handler, AppInboxServiceTagUnitTest)
; cl_assert_equal_b(success, true); fake_kernel_malloc_mark(); uint8_t storage_alt[BUFFER_SIZE]; success = app_inbox_service_register(storage_alt, sizeof(storage_alt), test_alt_message_handler, test_alt_dropped_handler, AppInboxServi...
rt(list_get_next(&c) == NULL); } void test_list__prepend(void) { ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL, c = LIST_NODE_NULL; ListNode *head; head = list_prepend(&c, &b); cl_assert(head == &b); head = list_prepend(&b, &a); cl_assert(head == &a); cl_assert(list_get_prev(&a) == NULL); cl_assert(l...
list_find_prev(&bar[0].list_node, filter_odd, true, NULL)
== &bar[3].list_node); // Test wrap around matching last item, find '4' before '0': cl_assert(list_find_prev(&bar[0].list_node, filter_even, true, NULL) == &bar[4].list_node); // Make everything even: for (int i = 0; i < 5; ++i) { bar[i].value = i * 2; } // Wrap around once, find nothing and return NU...
/* * 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...
kernel_malloc_check(sizeof(AnalyticsNode))
; *node = (AnalyticsNode) { .metric = metric, }; s_analytics_list = list_prepend(s_analytics_list, (ListNode *)node); } // Stopwatch Node Functions static bool prv_compare_stopwatch(ListNode *found_node, void *data) { AnalyticsStopwatchNode *stopwatch = (AnalyticsStopwatchNode *)found_node; return (stop...
0, 10)); #if PBL_COLOR ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD)); #else ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD)); #endif setup_test(&context, true, SW_ODD, GColorBlack, GColorBlack, false); graphics_draw_circle(&context, GPoint(50, 5...
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4))
; setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, true); ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10))); ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10))); ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10)); ASSERT_NO_CHANGE(g...
ery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID); fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS, TEST_GATT_CONNECTION_ID); prv_assert_event(device, BTErrnoOK); } // Tests //////////////////////////////////////////////////////////...
(fake_gatt_is_service_discovery_running(), false)
; } // ------------------------------------------------------------------------------------------------- // Watchdog timeout tests static void prv_fire_watchdog_timeouts(const BTDeviceInternal *device, int retries) { for (int i = 0; i <= retries; ++i) { const int start_count = fake_gatt_is_service_discovery_sta...
/* * 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_t, sys_get_time, void)
{ return rtc_get_time(); } DEFINE_SYSCALL(void, sys_get_time_ms, time_t *t, uint16_t *out_ms) { if (PRIVILEGE_WAS_ELEVATED) { syscall_assert_userspace_buffer(t, sizeof(*t)); syscall_assert_userspace_buffer(out_ms, sizeof(*out_ms)); } rtc_get_time_ms(t, out_ms); } DEFINE_SYSCALL(RtcTicks, sys_get_tic...
on doesn't get called for 49 days we'll miss a rollover but that's // extremely unlikely. TickType_t rollover_amount = -1; s_coarse_ticks += rollover_amount; } s_last_freertos_tick_count = freertos_tick_count; RtcTicks ret_value = freertos_tick_count + s_coarse_ticks; if (ints_enabled) { __ena...
(&seconds, &ms)
; return seconds; } //! Tracks whether we've successfully initialized the wakeup functionality static bool s_rtc_wakeup_initialized = false; static const int RTC_WAKEUP_HZ = LSE_FREQUENCY_HZ / 2; void rtc_alarm_init(void) { RTC_ITConfig(RTC_IT_WUT, DISABLE); RTC_WakeUpCmd(DISABLE); // Make sure this in in ...
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2))
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax1_sw1_no_clip.${BIT_DEPTH_NAME}.pbi")); // Should not draw anything setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) /...
t = default_format; for (size_t i = 0; i < ARRAY_LENGTH(option_values); i++) { if ((option_values[i].format & mask) == 0) { // skip option values that are irrelevant continue; } if (rocky_str_equal(option_values[i].field, option_values[i].value)) { result = option_values[i].format; ...
(buffer, buffer_len, strftime_format, &tm)
; const bool strip_leading_char = buffer[0] == '0' && prv_strip_leading_zero(format, is_24h_style); if (strip_leading_char) { memmove(buffer, buffer + 1, str_len); } return str_len; } static jerry_value_t prv_to_locale_time_or_date_string(jerry_value_t this_val, ...
mSession *session, CommSessionCapability capability) { bool rv = false; bt_lock(); if (comm_session_is_valid(session)) { rv = (session->protocol_capabilities & capability) != 0; } bt_unlock(); return rv; } CommSessionCapability comm_session_get_capabilities(CommSession *session) { CommSessionCapabil...
{ // Allow PULSE transport to be opened alongside any other transport // Actually using PULSE at the same time as another transport may cause // undesirable behaviour however. if (!prv_is_transport_type(existing_system_session->transport, existing_system_...
} CommSession *session = kernel_malloc(sizeof(CommSession)); if (!session) { PBL_LOG(LOG_LEVEL_ERROR, "Not enough memory for new CommSession"); return NULL; } *session = (const CommSession) { .transport = transport, .transport_imp = implementation, .destination = destination, }; s_s...
argc, argv, prv_draw_rect_impl); } JERRY_FUNCTION(prv_clear_rect) { GContext *const ctx = rocky_api_graphics_get_gcontext(); const GColor prev_color = ctx->draw_state.fill_color; ctx->draw_state.fill_color = GColorBlack; JS_VAR result = prv_rect_call(argc, argv, graphics_fill_rect); ctx->draw_state.fill_colo...
(&head->node, (ListNode **)&s_canvas_context_2d_stored_states, NULL)
; task_free(head); } return jerry_create_undefined(); } JERRY_FUNCTION(prv_canvas_rendering_context_2d_constructor) { JS_VAR canvas = rocky_create_with_constructor(ROCKY_CANVAS_CONSTRUCTOR, /* no args: */ NULL, 0); jerry_set_object_field(this_val, ROC...
_t utc_sec) { // Update the metrics activity_metrics_prv_minute_handler(utc_sec); // Call the algorithm's minute handler. This gives it an opportunity to log minute data // to data logging. etc. In case the user settings have changed, pass the current ones in. ActivityGender gender = activity_prefs_get_gende...
for (uint32_t i = 0; finish || i < num_samples; i++, accel_data++) { // Init the record header now if necessary if (data->record.num_samples == 0) { data->record = (ActivityRawSamplesRecord) { .version = ACTIVITY_RAW_SAMPLES_VERSION, .session_id = s_activity_state.sample_collection_session...
ACTIVITY_RAW_SAMPLE_SET_RUN_SIZE(data->prev_sample, data->run_size); data->record.entries[data->record.num_entries++] = data->prev_sample; data->run_size = 0; } } else { // Finish the old run, start a new one ACTIVITY_RAW_SAMPLE_SET_RUN_SIZE(data->prev_sample...
tributes = NULL, }, .action_group = { .num_actions = 0, .actions = NULL, }, .allocated_buffer = NULL, } }; // items with long duration static TimelineItem s_long_items[] = { { .header = { .id = {0xaa}, .timestamp = 10000, .duration = 30, .type = TimelineI...
(&s_items[i])
, 0); } cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), num_net_allocs); } void test_timeline__cleanup(void) { fake_settings_file_reset(); fake_pbl_malloc_clear_tracking(); } // Tests /////////////////////////// void test_timeline__all_forwards(void) { Iterator iterator = {0}; TimelineIterState state ...
uint16_t src_line_number, const char *message) { MessageContents *contents = pulse_push_send_begin(PULSE_PROTOCOL_LOGGING); const size_t payload_length = prv_serialize_log( contents, log_level, prv_get_timestamp_ms(), pebble_task_get_current(), src_filename, src_line_number, message); pulse...
xTaskGetSchedulerState()
== taskSCHEDULER_SUSPENDED) { // We're in a state where we can't immediately send the message, save it to an internal buffer // instead for later sending. prv_enqueue_log_message(log_level, message); } else { // Send the log line inline prv_send_pulse_packet(log_level, src_filename, src_line_numb...
r.h" #include "applib/app.h" #include "applib/graphics/gtypes.h" #include "applib/preferred_content_size.h" #include "applib/ui/app_window_stack.h" #include "applib/ui/dialogs/dialog.h" #include "applib/ui/dialogs/expandable_dialog.h" #include "applib/ui/dialogs/simple_dialog.h" #include "applib/ui/ui.h" #include "ker...
if (id == ALARM_INVALID_ID) { return 0; }
AlarmNode *cur_node = data->alarm_list_head; // Starting at one because of the "+" cell int list_idx = 1; while (cur_node) { if (cur_node->id == id) { return list_idx; } list_idx++; cur_node = (AlarmNode* )list_get_next((ListNode*) cur_node); } return 0; } static void prv_update_menu...
/* * 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...
timeline_layer_reset(&timeline_layer)
; if (config->day_separator) { // Simulate showing the day separator int new_idx; bool has_new; cl_assert(timeline_model_iter_next(&new_idx, &has_new)); if (has_new) { timeline_layer_set_next_item(&timeline_layer, new_idx); } timeline_layer_move_data(&timeline_layer, 1); cl_asse...
/* * 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...
{ *D = *D + delta + SECONDS_PER_DAY; }
"system/logging.h" #include "util/math.h" //! Don't let users modify the list while callbacks are occurring. static PebbleMutex *s_list_mutex = NULL; static void prv_timer_callback(void* data); static RegularTimerInfo s_regular = { .cb = prv_timer_callback, }; // List of jobs sorted from soonest to farthest. stati...
list_init(&temp_job.list_node)
; temp_job.cb = new_job->cb; temp_job.cb_data = new_job->cb_data; *new_job = temp_job; // insert after in the list, which guarantees it gets executed after list_insert_after(&job->list_node, &new_job->list_node); PBL_LOG(LOG_LEVEL_DEBUG, "Cron job scheduled for %ld", job->cached_execute_time); mutex_unl...
/* * 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 RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET; }
static bool prv_clocksource_lse_configure(void) { if (prv_clocksource_is_lse_started()) { // LSE remains on through standby and resets so often don't need to do anything return true; } dbgserial_putstr("Starting LSE oscillator"); RCC_LSEConfig(RCC_LSE_ON); for (int i = 0; i < LSE_READY_TIMEOUT_MS; ...
ogress. // If not, the successive kicking of the suspend timer could starve it out completely psleep(100); task_watchdog_bit_set(s_erase.task); status_t status = flash_impl_erase_suspend(s_erase.address); PBL_ASSERT(PASSED(status), "Erase suspend failure: %" PRId32, status); if (status == S_NO_A...
pebble_task_get_current()
, .retries = retries, // FIXME: We should just assert that the address is already aligned. If // someone is depending on this behaviour without already knowing the range // that's being erased they're going to have a bad time. This will probably // cause some client fallout though, so tackle this later. ...
0, BANNER_PEEK_STATIC_Y, banner_movement_raw_offset); const int32_t banner_diameter = banner_radius * 2; const int32_t banner_center_y = prv_interpolate_linear(0, LAYOUT_TOP_BANNER_ORIGIN_Y, ...
{ case LayoutLayerModeCard: prv_card_render(layout, ctx, true); break; default: break; }
} static void prv_layout_init(NotificationLayout *layout, const LayoutLayerConfig *config); LayoutLayer *notification_layout_create(const LayoutLayerConfig *config) { NotificationLayout *layout = task_zalloc_check(sizeof(NotificationLayout)); if (!layout) { return NULL; } prv_layout_init(layout, config);...
DTH, .info.format = GBitmapFormat8Bit, .info.version = GBITMAP_VERSION_CURRENT, .bounds = (GRect){GPointZero, (GSize){TOTAL_WIDTH, TOTAL_HEIGHT}} }; GColor color = (GColor){ .a = 3, .r = 0, .g = 0, .b = 0 }; uint8_t src_data[] = { color.argb }; GBitmap src_bmp = (GBitmap){ .addr = src_data, ...
GRect(x, y_lower - LEGEND_HEIGHT, test_bmp.bounds.size.w, legend_height)
; GColor8 lower_legend[4] = { [0 ... 3] = lower_tint_color }; test_bmp.addr = lower_legend; bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, &test_bmp, lower_legend_rect, GPointZero, GCompOpAssign, GColorWhite); test_bmp.addr = test_blend_colors; bitblt_bitmap_into_bitmap_tiled(&dest_bitmap, &test_bmp,...
; *fdp = fd; return ((PFS_FD(fd).fd_status == FD_STATUS_IN_USE) ? FDBusy : FDAlreadyLoaded); } } } // a simple least-recently-accessed cache scheme int unref = -1; uint16_t curr_time_closed = 0; for (int fd = FD_INDEX_OFFSET; fd < FD_INDEX_OFFSET+PFS_FD_SET_SIZE; fd++) { if (PF...
(free_bytes_in_page(file->curr_page) - pg_offset, size - bytes_written)
; prv_flash_write(buf + bytes_written, bytes_to_write, prv_page_to_flash_offset(file->curr_page) + AVAIL_BYTES_OFFSET + pg_offset); bytes_written += bytes_to_write; file->offset += bytes_to_write; if (bytes_written == size) { break; } pg_offset = 0; // first usable byte next pa...
data->property + 1) % PROPERTY_MAX; layer_mark_dirty(s_canvas_layer); } static void down_handler(ClickRecognizerRef recognizer, void *context) { AppData *data = window_get_user_data(s_window); if (data->property == PROPERTY_FG_COLOR) { data->fg_color_index = (data->fg_color_index - 1) & 0x3F; data->fg_co...
(data->alpha_text)
); // Other properties s_color_table = color_table_hsv; data->alpha = ALPHA_100; data->fg_color.argb = s_color_table[data->fg_color_index] | ALPHA_100; data->bg_color = GColorBlack; set_text_layers(data); } static void main_window_unload(Window *window) { // Destroy Layer layer_destroy(s_canvas_layer)...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
cl_assert_passert(buffer_remove(b, 1, 4))
; cl_assert_equal_i(4, b->bytes_written); cl_assert_equal_i(b->data[0], b1); cl_assert_equal_i(b->data[1], b2); cl_assert_equal_i(b->data[2], b3); cl_assert_equal_i(b->data[3], b4); // moves removed remaining bytes to close the gap cl_assert_equal_i(2, buffer_remove(b, 1*sizeof(uint8_t), 2*sizeof(uint8_...
eader.id)); cl_assert(uuid_equal(&state.node->id, &multiday_item.header.id)); cl_assert(state.node->all_day); cl_assert_equal_i(state.node->timestamp, 1425369600); cl_assert_equal_i(state.node->duration, MINUTES_PER_DAY); cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY); // no m...
(!iter_next(&iterator))
; // 2 deletes 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)); cl_assert(!timeline_iter_remove_node_with_id(&head, &all_day_item.header.id)); } void test_timeline__24h_non_all_day_starting_midnight(void...
ion 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS...
(10, 15, 20, 10)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(iter->fd)
; if (file_size < 0) { return NULL; } int read_size = file_size; uint8_t *contents = kernel_calloc(1, read_size); while (contents == NULL && read_size > 0) { // If we can't allocate enough RAM to read the whole file, we should // at least try to read part of it. read_size /= 2; contents = ...
// We got this! Let's redirect this task to a spin function and tell the app manager to kill us. prv_return_to_landing_zone(stacked_pc, stacked_lr, stacked_args); // We can't get LR or PC, so just set to 0's. } // Hardware Fault Handlers /////////////////////////////////////////////////////////// extern void fa...
(buffer, stacked_args)
set_stroke_width(ctx, 2); graphics_draw_line(ctx, GPoint(30,30), GPoint(30,30)); graphics_context_set_antialiased(ctx, true); graphics_context_set_stroke_width(ctx, 2); graphics_draw_line(ctx, GPoint(40,40), GPoint(40,40)); graphics_context_set_antialiased(ctx, false); graphics_context_set_stroke_width(ct...
prv_draw_lines(&ctx, 2, CLIP_OFFSET, 0)
; // Draw lines around boundaries of clipping box - AA true, SW 3 prv_draw_lines(&ctx, 3, 0, CLIP_OFFSET); // Draw lines around boundaries of clipping box - AA true, SW 4 prv_draw_lines(&ctx, 4, CLIP_OFFSET, CLIP_OFFSET); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_clip_rect_aa...
layer_deinit(&summary_window->base_layer)
; window_deinit(&summary_window->window); i18n_free_all(summary_window); app_free(summary_window); } } //////////////////////////////////////////////////////////////////////////////////////////////////// //! Public API WorkoutSummaryWindow *workout_summary_window_create(ActivitySessionType activity_type...
408, 112}, { 1544, 432, 184}, { 1528, 304, 176}, { 1416, 96, 216}, { 1416, -72, 168}, { 1328, -64, 80}, { 1216, 0, -8}, { 984, 24, -16}, { 976, 8, 24}, { 920, -8, -8}, { 600, -96, -96}, { 776, -88, -112}, { 936, -16, -104}, { 1152, 56, -136}, { 1440, 96, -176}, ...
// 93 seconds { 1200, -16, 120}, { 1272, -56, 48}, { 1248, 8, -8}, { 1104, 40, 24}, { 1144, 0, -8}, { 1016, -144, 8}, { 760, -200, 0}, { 1056, -256, 80}, { 1344, -48, 16}, { 1392, 152, -200}, { 1264, 64, -64}, { 1240, 16, -232}, { 944, 64, -152}, { 856, 112, -...
{ 1352, 264, -24}, { 1320, 256, 0}, { 1152, 288, 8}, { 1312, 392, 128}, { 1128, 728, 296}, { 904, 648, 88}, // 96 seconds { 1032, 392, 8}, { 1104, 424, 0}, { 1304, 392, 88}, { 1576, 424, 176}, { 1680, 304, 112}, { 1464, 144, 128}, { 1376, -8, 160}, { 1312, -7...
t Running"); break; case FLASH_TEST_STATUS_STOPPED: snprintf(data->status_text, STATUS_TEXT_SIZE, "Test Stopped"); break; case FLASH_TEST_STATUS_PASSED: snprintf(data->status_text, STATUS_TEXT_SIZE, "Test Passed"); break; case FLASH_TEST_STATUS_FAILED: snprintf(data->stat...
(&data->test_window, animated)
; } static void up_click_handler(ClickRecognizerRef recognizer, void *unusued) { struct FlashTestData *data = app_state_get_user_data(); if (data->test_case_status != FLASH_TEST_STATUS_RUNNING) { flash_test_dismiss_window(); } } static void down_click_handler(ClickRecognizerRef recognizer, void *unusued) ...
art_row; dest_row != end_row; dest_row += delta) { src_bitmap->bounds = (GRect) { .origin.y = (dupe_row >= 0 ? dupe_row : dest_row) - shift_amount, .size = { DISP_COLS, 1 }, }; bitblt_bitmap_into_bitmap(dest_bitmap, src_bitmap, GPoint(0, dest_row), GCompOpAssign, GC...
prv_duplicate_framebuffer_row(&dest_bitmap, app_dupe_row, app_offset_y + app_dupe_row, &app_bitmap, app_dupe_row)
G decoding failed" #define APNG_MEMORY_ERROR "APNG memory allocation failed" #define APNG_FORMAT_ERROR "Unsupported APNG format, only APNG8 is supported!" #define APNG_LOAD_ERROR "Failed to load APNG" #define APNG_UPDATE_ERROR "gbitmap_sequence failed to update bitmap" #define APNG_ELAPSED_WARNING "invalid elapsed_ms f...
if (!gbitmap_png_is_format_supported(upng)) { APP_LOG(APP_LOG_LEVEL_ERROR, APNG_FORMAT_ERROR); goto cleanup; }
// Create a color palette in RGBA8 format from RGB24 + ALPHA8 PNG Palettes upng_format png_format = upng_get_format(upng); if (png_format >= UPNG_INDEXED1 && png_format <= UPNG_INDEXED8) { bitmap_sequence->png_decoder_data.palette_entries = gbitmap_png_load_palette(upng, &bitmap_sequence->png_decode...
(void) { prv_lock(); bool is_idle = (s_spi_transport.state == SPITransportState_Idle); prv_unlock(); if (is_idle) { prv_watchdog_start(); dialog_spi_indicate_data_ready_to_tx(); } } static void prv_host_transport_main(void *unused) { s_spi_transport.task_is_running = true; while (true) { xSe...
(&s_spi_transport.rx, s_spi_transport.rx_storage, HOST_TRANSPORT_HOST_RX_BUFFER_SIZE)
; circular_buffer_init(&s_spi_transport.tx, s_spi_transport.tx_storage, HOST_TRANSPORT_HOST_TX_BUFFER_SIZE); dialog_spi_init(prv_int_exti_cb); s_is_host_transport_initialized = true; return true; } void host_transport_deinit(void) { PBL_LOG(LOG_LEVEL_DEBUG, "BLE transport deinit"); ...
/* * 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...
(y < f->size.h)
; #if PLATFORM_SPALDING const GBitmapDataRowInfoInternal *row_infos = g_gbitmap_spalding_data_row_infos; const size_t offset = row_infos[y].offset; #else const size_t offset = y * f->size.w; #endif return f->buffer + offset; } inline size_t framebuffer_get_size_bytes(FrameBuffer *f) { PBL_ASSERTN(!gsize_equ...
AX_SIZE + 1), E_INVALID_ARGUMENT); } void test_app_glance_db__check_invalid_slice_total_sizes_blob_not_inserted(void) { cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, (uint8_t *)&s_app_glance_with_invalid_slice_total_si...
app_glance_db_read_glance(&APP_GLANCE_TEST_UUID, &read_back_glance)
, S_SUCCESS); cl_assert_equal_m(&glance, &read_back_glance, sizeof(AppGlance)); } void test_app_glance_db__reading_nonexistent_glance_returns_does_not_exist(void) { AppGlance glance = {}; cl_assert_equal_i(app_glance_db_read_glance(&UUID_INVALID, &glance), E_DOES_NOT_EXIST); } void test_app_...
(&iterator)
); } // 5am, no events passed void test_timeline__extra_case_none_backwards(void) { prv_insert_extra_case_items(); Iterator iterator = {0}; TimelineIterState state = {0}; TimelineNode *head = NULL; timeline_init(&head); cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionP...
+ delay_seq + 2 * MIN_FRAME_INTERVAL_MS); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1); cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX); cl_ass...
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, spawn), 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...
prv_schedule_evaluation()
art(s_erase_suspend_timer, 50, prv_erase_suspend_timer_cb, NULL, 0); while (buffer_size) { int written = flash_impl_write_page_begin(buffer, start_addr, buffer_size); PBL_ASSERT( #ifdef TEST_FLASH_LOCK_PROTECTION s_assert_write_error || #endif PASSED(written), "flash_impl_write_page_be...
on_complete_cb(context, status)
; return 0; } } // Returns non-zero expected remaining time if the erase has not finished. If the erase // has finished it will re-enable stop-mode, clear the in_progress flag and call the // completed callback before returning 0. static uint32_t prv_flash_erase_poll(void) { mutex_lock(s_flash_lock); status_...
(), 7); // Unschedule all animation_unschedule_all(); cl_assert_equal_i(prv_count_scheduled_animations(), 0); // Make sure just the setup and teardown handlers were called cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_ha...
(animation_get_implementation(h) != &implementation.base)
; cl_assert(animation_get_implementation(h) == &implementation2.base); // Custom Curve cl_assert(animation_get_custom_curve(h) != prv_custom_curve); animation_set_custom_curve(h, prv_custom_curve); cl_assert(animation_get_custom_curve(h) == prv_custom_curve); // Reverse cl_assert(animation_get_reverse...
imeEvent *set_time_info = &e->set_time_info; // The phone and watch time may be out of sync by a second or two (since // we don't account for the time it takes for the request to change the // time to propagate to the watch). Thus only update our alarm time if // the timezone has changed or a '...
PBL_LOG(LOG_LEVEL_INFO, "Not launching worker because of 2 strikes")
; } else { process_manager_launch_process(&(ProcessLaunchConfig) { .id = worker_manager_get_default_install_id(), .worker = true, }); } #endif notify_system_ready_for_communication(); serial_console_enable_prompt(); } void launcher_main_loop(void) { PBL_LOG(LOG_LEVEL_ALWAYS, "Starting La...
---------------- // Sample captured: 2015-09-29 15:22:20 local AccelRawData *activity_sample_walk_200_pbl_25299_9(int *len) { // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_200_pbl_25299_9 //> TEST_EXPECTED 200 //> TEST_EXPECTED_MIN 165 //> TEST_EXPECTED_MAX 230 //> T...
{ 1752, 368, 40}, // 5 seconds { 1000, 520, -64}, { 704, 344, 0}, { 952, 280, 152}, { 1024, 104, 168}, { 768, 112, 144}, { 688, 120, 112}, { 680, 128, 56}, { 712, 96, 80}, { 816, 88, 64}, { 912, 16, 104}, { 1184, 8, 64}, { 1200, 32, 80}, { 1616, 72, 104}, ...
{ 768, 224, 32}, { 768, 280, 48}, { 824, 352, -48}, { 800, 304, -96}, { 928, 368, -192}, // 8 seconds { 1216, 344, -184}, { 1232, 232, -80}, { 1936, 368, 0}, { 1368, 424, 24}, { 864, 336, -24}, { 992, 248, 112}, { 1208, 200, 128}, { 928, 144, 176}, { 792, 112...
cl_assert_fixedS16_3(radius, 4.5); } void test_graphics_circle__grect_polar_calc_values_square(void) { GPointPrecise center = {}; Fixed_S16_3 radius = {}; GRect r = GRect(0, 0, 5, 5); GOvalScaleMode mode = GOvalScaleModeFitCircle; // irrelevant as we deal with squares grect_polar_calc_values(&r, mode, &cen...
cl_assert_fixedS16_3(s_radius_outer, 4.5)
; cl_assert_fixedS16_3(s_radius_inner, 1.5); } void test_graphics_circle__DEG_TO_TRIGANGLE(void) { cl_assert_equal_i(DEG_TO_TRIGANGLE(720), TRIG_MAX_ANGLE * 2); cl_assert_equal_i(DEG_TO_TRIGANGLE(-720), -TRIG_MAX_ANGLE * 2); cl_assert_equal_i(DEG_TO_TRIGANGLE(360), TRIG_MAX_ANGLE); cl_assert_equal_i(DEG_TO_...
bool prv_check_serial_log_enabled(int level) { return (g_pbl_log_enabled) && (level == LOG_LEVEL_ALWAYS || (level <= g_pbl_log_level)); } #if !PULSE_EVERYWHERE #define TIMESTAMP_BUFFER_SIZE 14 static void prv_log_timestamp(void) { // Enough stack space to use sprintfs? uint32_t stack_space = ...
(buffer, buffer_size, fmt, ap)
; va_end(ap); kernel_pbl_log_from_fault_handler(src_filename, src_line_number, buffer); } // Serial Commands /////////////////////////////////////////////////////////// void command_log_level_set(const char* level) { char buffer[32]; g_pbl_log_level = atoi(level); prompt_send_response_fmt(buffer, 32, "Log l...
, 0x82, 0x00, 0xd0, 0x9e, 0xd0, 0x9a, 0x00, 0xd0, 0xa5, 0xd0, 0xb0, 0x2d, 0xd1, 0x85, 0xd0, 0xb0, 0x00, 0xd0, 0xa1, 0xd0, 0xbf, 0xd0, 0xb0, 0xd1, 0x81, 0xd0, 0xb8, 0xd0, 0xb1, 0xd0, 0xbe, 0x00, 0xd0, 0xa5, 0xd0, 0xbe, 0xd1, 0x80, 0xd0, 0xbe, 0xd1, 0x88, 0xd0, 0xbe, 0x00, 0xd0, 0x9e, 0xd1, 0x82, 0xd0, 0xbb, 0...
(attributes)
, .attr_list.attributes = attributes, .action_group.num_actions = ARRAY_LENGTH(actions), .action_group.actions = actions, }; uint8_t *buffer = malloc(sizeof(s_payload_complete)); timeline_item_serialize_payload(&item, buffer, sizeof(s_payload_complete)); cl_assert(memcmp(buffer, s_payload_complete,...
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5500)).argb); cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xaaaaaa)).argb); // // expectation as derived from Appfaces_generic_colors.psd cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x0000aa)).argb); cl_assert_equal_i(GColorWhiteARGB8...
cl_assert(gcolor_equal(lookup_table_out[2], GColorBrass))
void *context) { OptionMenu *option_menu = context; if (option_menu->callbacks.get_num_rows) { return option_menu->callbacks.get_num_rows(option_menu, option_menu->context); } return 0; } uint16_t option_menu_default_cell_height(OptionMenuContentType content_type, boo...
option_menu->callbacks.draw_row(option_menu, ctx, cell_layer, &remaining_rect, cell_index->row, is_selected, option_menu->context); } }
static void prv_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *context) { OptionMenu *option_menu = context; option_menu->choice = cell_index->row; layer_mark_dirty((Layer *)&option_menu->menu_layer); if (option_menu->callbacks.select) { option_menu->callbacks.select(option_menu, opti...
S OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "workout_active.h" #include "workout_dialog.h" #include "workout_summary.h" #include "workout.h" #include "applib/app.h" #include "applib/ui/action_menu_hiera...
prv_get_label_for_hr_metric(bpm)
t_battery_monitor__curve_doesnt_shift_too_far(void) { int charge_mv = battery_curve_lookup_voltage_by_percent(0, true); int charge_terminate_mv = battery_curve_lookup_voltage_by_percent(80, false); fake_battery_init(charge_mv, true, true); battery_monitor_init(); periodic_timer_trigger(1); fake_battery_s...
(standby_timer_get_timeout(), 30000)
; fake_battery_set_charging(true); fake_battery_set_connected(true); periodic_timer_trigger(1); standby_timer_trigger(1); cl_assert(!s_entered_standby); } void test_battery_monitor__increase_discharging(void) { int low_mv = battery_curve_lookup_voltage_by_percent(50, false); int high_mv = battery_curve_l...
/* * 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...
(0x808080)
}, {"white", GColorARGB8FromHEX(0xffffff)}, {"maroon", GColorARGB8FromHEX(0x800000)}, {"red", GColorARGB8FromHEX(0xff0000)}, // {"purple", GColorARGBFromHEX(0x800080)}, inconsistent with Pebble color {"fuchsia", GColorARGB8FromHEX(0xff00ff)}, // {"green", GColorARGBFromHEX(0x008000)}, inconsistent with Pebble...
ottom | GCornerTopRight), .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft} })); cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(90), TO_TRIG(360)), ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight}, .full_quadrants = (GCorne...
(270 + 45)
,GCornerTopLeft} })); // Ending quadrant filling up and starting quadrant finishing cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(90 + 45 - 360), TO_TRIG(360 + 45 - 360)), ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90 + 45),GCornerBottomRight}, .full_quadrants =...
{ MusicNoMusicWindow *window = app_malloc_check(sizeof(MusicNoMusicWindow)); window_init(&window->window, WINDOW_NAME("NoMusicWindow")); window_set_background_color(&window->window, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite)); window_set_window_handlers(&window->window, &(WindowHandlers) { .unload = ...
{ progress_layer_set_progress(&data->track_pos_bar, 0); }
else { unsigned int percent = MIN((data->track_pos * 100) / data->track_length, 100); progress_layer_set_progress(&data->track_pos_bar, percent); prv_copy_time_period(data->position_buffer, sizeof(data->position_buffer), data->track_pos / 1000); prv_copy_time_period(data->lengt...
se) { time_normalized = ANIMATION_NORMALIZED_MAX - time_normalized_raw; } else { time_normalized = time_normalized_raw; } AnimationProgress distance_normalized; if (animation->curve >= AnimationCurveCustomFunction) { if (animation->curve == AnimationCurveCustomFunction && animation->custom_curve_fun...
PBL_ASSERTN(animation->play_count != 0)
; // If this is the animation's first frame, call the 'started' handler: if (animation->handlers.started && !animation->started) { animation->handlers.started(animation->handle, animation->context); } animation->started = true; uint32_t time_normalized_raw = prv_get_time_normalized_raw(animation, now); ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
prv_get_analytic_id_for_session(session)
; analytics_stopwatch_start(analytic_id, AnalyticsClient_System); analytics_inc(ANALYTICS_DEVICE_METRIC_BT_SYSTEM_SESSION_OPEN_COUNT, AnalyticsClient_System); } session->open_ticks = rtc_get_ticks(); } void comm_session_analytics_close_session(CommSession *session, CommSessionCloseReason reason) { const ...
config->open_pin.uuid : NULL)); } // ------------------------------------------------------------------------------------------------ // Get the current step count metric static int32_t prv_get_step_count(void) { int32_t steps; activity_get_metric(ActivityMetricStepCount, 1, &steps); retu...
prv_get_variant(&s_tier_config[tier], variant)
; if (fmt == NULL) { return; } char *body = kernel_malloc_check(max_notif_length); snprintf(body, max_notif_length, i18n_get(fmt, body), steps_total, ABS(percentage)); i18n_free_all(body); const NotificationConfig config = { .notif_time = notif_time, .insight_type = ActivityInsightType_Activit...
/* * 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...
{ AlarmId id; id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true }); prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); cl_assert_equal_i(s_num_timeline_adds, 3); cl_assert_equal_i(s_num_timeline_removes, 0); // Set s...
void test_alarm_smart__trigger_30_min_early_vmc(void) { AlarmId id; id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true }); prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); cl_assert_equal_i(s_num_timeline_adds, 3); c...
prv_start_temp_notification_connection_delay_timer(void) { if (regular_timer_is_scheduled(&s_notification_connection_delay_timer)) { regular_timer_remove_callback(&s_notification_connection_delay_timer); } s_just_connected = true; const int post_connection_notification_ignore_seconds = 10; s_notification...
{ const bool is_first_message = !prv_is_reassembly_in_progress(); if (is_first_message) { if (s_ancs_client->state != ANCSClientStateRequestedNotification || !prv_reassembly_start(data, length)) { // Discard data if data is not the start of a new message or we didn't request it. return; ...
BLE_LOG_DEBUG("Incomplete response. Waiting for another DS notification."); return; } // Got all the data, pass up to parser! prv_reassembly_handle_complete_response(response_data, response_length); } static void prv_put_ancs_message(ANCSAttribute **app_attrs) { ancs_notifications_handle_message(s_an...
are higher priority - make this same or lower priority than a FreeRTOS ISR NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = (configMAX_SYSCALL_INTERRUPT_PRIORITY >> 4); NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure)...
(data->window, &(WindowHandlers) { .load = prv_window_load, .unload = prv_window_unload, })
/* * 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_state, id)
; } static void prv_release_button(ButtonId id) { getting_started_button_combo_button_released(&s_state, id); } void test_getting_started_button_combo__simple(void) { cl_assert(!prv_find_combo_timer()); prv_press_button(BUTTON_ID_UP); cl_assert(!prv_find_combo_timer()); prv_press_button(BUTTON_ID_SELECT)...
to.h" #include "drivers/display/ice40lp.h" #include "drivers/flash/s29vs.h" #include "drivers/gpio.h" #include "drivers/periph_config.h" #include "drivers/pmic.h" #include "drivers/spi.h" #include "flash_region.h" #include "stm32f4xx_gpio.h" #include "stm32f4xx_rcc.h" #include "stm32f4xx_spi.h" #include "system/passert...
prv_send_command_arg((param >> 8) & 0xff)
; prv_send_command_arg((param >> 16) & 0xff); prv_send_command_arg((param >> 24) & 0xff); prv_end_command(); } static uint8_t prv_read_version(void) { GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_RESET); delay_us(100); uint8_t version_num = display_write_and_read_byte(0); GPIO_WriteBit(DISP_GPIO, DISP_PIN...
/* * 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...
atoi(timestamp.second)
{ -24, 696, -1408}, { -32, 80, -1304}, { -32, -264, -968}, { -80, -240, -800}, { -152, -136, -752}, { -200, -120, -784}, { -192, -88, -880}, { -144, -80, -976}, { -152, -144, -1000}, { -232, -176, -1024}, { -168, -112, -1136}, { -280, -16, -1224}, { -152, 288, -1376},...
{ 1336, 384, 192}, { 1408, 640, 200}, { 976, 784, 152}, { 1024, 1216, 120}, { 816, 920, -120}, { 944, 544, -120}, { 1008, 576, -40}, { 1512, 640, 112}, { 1816, 568, 136}, { 1768, 376, 168}, { 1784, 232, 216}, { 1744, 200, 176}, { 1528, 232, 104}, { 1200, 224, 88}...
nt, AnalyticsClient_Worker); } analytics_read_count = 0; analytics_read_bytes_count = 0; analytics_write_bytes_count = 0; } struct FlashState { bool enabled; bool sleep_when_idle; bool deep_sleep; PebbleMutex * mutex; SemaphoreHandle_t dma_semaphore; } s_flash_state; static void flash_deep_sleep_en...
flash_send_and_receive_byte(FLASH_CMD_WAKE)
; flash_end_cmd(); // wait a sufficient amount of time to enter standby mode // It appears violating these timing conditions can lead to // random bit corruptions on flash writes! delay_us(100); s_flash_state.deep_sleep = false; } } void handle_sleep_when_idle_begin(void) { if (s_flash_sta...
ion format. static const char prv_NewLogHeader[] __attribute__((nocommon, used, section(".log_string.header"))) = NEW_LOG_HEADER "=<file>:<line>:<level>:<color>:<msg>," \ "CORE_ID=" str(CORE_ID_BLE) ",CORE_NAME=da1468x"; // Confirm the size calculations. If these fail, update tools/loghashing/...
(&s_log_buffer.circular_buffer, s_log_buffer_ram, circular_buffer_size, false /* auto_reset */)
; // Leave old data in the buffer for later debug static const adapter_call_backs_t s_ad_uart_pm_call_backs = { .ad_prepare_for_sleep = prv_pm_prepare_for_sleep, .ad_sleep_canceled = prv_pm_sleep_canceled, .ad_wake_up_ind = prv_pm_wake_up_ind, .ad_xtal16m_ready_ind = prv_pm_xtal16m_ready_ind, .ad...