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...
{ res += det; }
else { res -=det; } } return (res / down_samp); } static bool sphere_fit(int16_t *solution) { bool rv = false; int32_t **matrix = kernel_malloc(sizeof(int32_t *) * N_SAMPS); for (int i = 0; i < N_SAMPS; i++) { matrix[i] = kernel_malloc(sizeof(int32_t) * N_AXIS); } // determine average v...
IN(session->start_utc, stats->enter_utc) : session->start_utc; if ((session_exit_utc > stats->today_exit_utc) && (session_exit_utc <= max_end_utc)) { stats->today_exit_utc = session_exit_utc; } } stats->last_exit_utc = MAX(session_...
// We are still sleeping if (stats.last_deep_exit_utc == stats.last_exit_utc) { sleep_data->cur_state = ActivitySleepStateRestfulSleep; } else { sleep_data->cur_state = ActivitySleepStateLightSleep; } sleep_data->cur_state_elapsed_minutes = (stats.last_session_len_sec + now...
unlock: mutex_unlock_recursive(state->mutex); } // -------------------------------------------------------------------------------------------- void activity_sessions_prv_get_sleep_bounds_utc(time_t now_utc, time_t *enter_utc, time_t *exit_utc) { // Get useful UTC ...
/* * 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_CROAK("Metric kind does not match heartbeat kind! %d %d", metric_kind, heartbeat->kind); }
rnel/pbl_malloc.h" #include "kernel/ui/system_icons.h" #include "resource/resource_ids.auto.h" #include "services/common/analytics/analytics.h" #include "services/common/bluetooth/bluetooth_persistent_storage.h" #include "services/common/bluetooth/local_id.h" #include "services/common/bluetooth/pairability.h" #include ...
{ return; }
ndler = prv_handle_hrm_data, }; event_service_client_subscribe(&app_data->hrm_event_info); // TODO: Let the mobile app control this? const uint32_t update_time_s = 1; app_data->session = sys_hrm_manager_app_subscribe( APP_ID_HRM_DEMO, update_time_s, SECONDS_PER_HOUR, HRMFeature_BPM | HRMFeature_L...
{ prv_init(); app_event_loop(); prv_deinit(); }
const PebbleProcessMd* hrm_demo_get_app_info(void) { static const PebbleProcessMdSystem s_hrm_demo_app_info = { .name = "HRM Demo", .common.uuid = { 0xf8, 0x1b, 0x2a, 0xf8, 0x13, 0x0a, 0x11, 0xe6, 0x86, 0x9f, 0xa4, 0x5e, 0x60, 0xb9, 0x77, 0x3d }, .common.main_func = &prv_main, }; ...
amebuffer, GColorWhite)); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &outside_nx_ny_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("outside_nx_ny_offset_layer", ctx.parent_framebuffer, GColorWhite)); } void test_graphics_draw_pixel_${BIT_DEPTH_...
(&ctx, fb)
; if (clipped_glyph_target.size.h == 0 || clipped_glyph_target.size.w == 0) { return; } #if SCREEN_COLOR_DEPTH_BITS == 8 // NOTE: Since all calculations are based on 1-bit calculation - use the row size from // the 1-bit frame buffer const int row_size_bytes = 4 * ((dest_bitmap->bounds.size.w / 32) + ...
(dest_block < dest_block_end, "DB=<%p> DBE=<%p>", dest_block, dest_block_end)
; PBL_ASSERTN(dest_block >= (uint32_t*) base_addr); PBL_ASSERTN(dest_block < (uint32_t*) base_addr + row_size_bytes * (dest_bitmap->bounds.origin.y + dest_bitmap->bounds.size.h)); // bitblt part of glyph_block: const uint8_t number_of_bits = MIN(32 - dest_shift, MIN(glyph_line...
MENU_CELL_ROUND_FOCUSED_SHORT_CELL_HEIGHT : MENU_CELL_ROUND_UNFOCUSED_TALL_CELL_HEIGHT)); } static uint16_t prv_information_get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index, void *context) { return SystemIn...
grect_inset(bounds, menu_layer_insets)
under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "clar.h" #include "services/normal/audio_endpoint.h" #include "service...
{ // add a huge number of frames (1 kB) to the buffer to cause it to overflow for (unsigned int i = 0; i < 1024 / (sizeof(DataTransferMsg) + sizeof(s_test_frame)); i++) { audio_endpoint_add_frame(s_session_id, s_test_frame, sizeof(s_test_frame)); } fake_transport_set_sent_cb(s_transport, prv_test_data_trans...
void test_audio_endpoint__remote_stop_transfer(void) { StopTransferMsg *msg = (StopTransferMsg *)malloc(sizeof(StopTransferMsg)); msg->msg_id = MsgIdStopTransfer; msg->session_id = s_session_id; audio_endpoint_protocol_msg_callback(s_session, (uint8_t *)msg, sizeof(StopTransferMsg)); fake_system_task_callba...
nts - 1; i > 0; --i) { rot_points[i] = rot_start = rotate_offset_point(&path->points[i], path->rotation, &path->offset); if (min_x > rot_points[i].x) { min_x = rot_points[i].x; } if (max_x < rot_points[i].x) { max_x = rot_points[i].x; } if (min_y > rot_points[i].y) { min_y = rot_points[i].y; } if (m...
{ return; }
// Convert precise points to normal points and draw filled path with converted points // (no real support for filled paths with GPointPrecise, yet) GPoint *imprecise_points = applib_malloc(sizeof(GPoint) * num_points); if (!imprecise_points) { APP_LOG(APP_LOG_LEVEL_ERROR, GPATH_ERROR); return; } ...
00, Manual and Scheduled DND both OFF DoNotDisturbSchedule schedule = { .from_hour = 0, .from_minute = 30, .to_hour = 12, .to_minute = 30, }; active = do_not_disturb_is_active(); cl_assert(active == false); // both OFF do_not_disturb_set_schedule(WeekdaySchedule, &schedule); do_not_disturb_...
do_not_disturb_is_manually_enabled()
== false); active = do_not_disturb_is_active(); cl_assert(active == false); // Scheduled ON } void test_do_not_disturb__smart_dnd(void) { bool active; calendar_init(); cl_assert(do_not_disturb_is_smart_dnd_enabled() == false); do_not_disturb_toggle_smart_dnd(); // Only smart DND is on cl_assert(do_not_...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
bt_dialog->connected_handler(true, bt_dialog->context)
; } // handler to NULL so it won't be called again during the unload bt_dialog->connected_handler = NULL; dialog_pop(&bt_dialog->dialog.dialog); } } static void prv_bt_dialog_unload(void *context) { BtConnDialog *bt_dialog = context; event_service_client_unsubscribe(&bt_dialog->pebble_app_event_s...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ return ctx->enabled ? ActionToggleState_Disabled : ActionToggleState_Enabled; }
prv_get_appear_disappear_count()
, 0); cl_check(((WindowStackItem *)stack->list_head)->window != window); window_stack_pop_all(stack, false); cl_assert_equal_i(window_stack_count(stack), 0); cl_assert_equal_i(prv_get_load_unload_count(), 0); cl_assert_equal_i(prv_get_appear_disappear_count(), 0); } // Description: // This test ensures th...
_add_client(&state->isr_buffer, &state->isr_buffer_client); // Allocate buffer for the received message state->msg_buffer = kernel_malloc_check(QEMU_MAX_DATA_LEN); state->msg_buffer_bytes = 0; } // ----------------------------------------------------------------------------------------- // Helper function tri...
("got header: protocol: %d, len: %d", state->hdr.protocol, state->hdr.len)
; state->recv_state = QemuRecvState_WaitingData; } } break; case QemuRecvState_WaitingData: { uint16_t bytes_needed = state->hdr.len - state->msg_buffer_bytes; shared_circular_buffer_read_consume(&state->isr_buffer, &state->isr_buffer_client, MIN(bytes_...
/* * 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_tap_recognizer_impl, &data, sizeof(data), event_cb, user_data)
; } const TapRecognizerData *tap_recognizer_get_data(const Recognizer *recognizer) { return recognizer_get_impl_data((Recognizer *)recognizer, &s_tap_recognizer_impl); } void tap_recognizer_set_num_taps_required(Recognizer *recognizer, int num_taps) { TapRecognizerData *data = recognizer_get_impl_data(recognizer,...
epeat for a positive offset center point with 0.5 fractions GPointPrecise p3 = GPointPreciseFromGPoint(GPoint(5, 5)); p3.x.raw_value += FIXED_S16_3_HALF.raw_value; p3.y.raw_value += FIXED_S16_3_HALF.raw_value; // GRectZero + standardize cl_assert_equal_grect(GRect(6, 6, 0, 0), grect_centered_internal(&p3, GS...
(0, 0, 10, 10)
ler granted_handler) { ConnectionMgrInfo *conn_mgr_info; if (!hdl || !((conn_mgr_info = hdl->conn_mgr_info))) { PBL_LOG(LOG_LEVEL_ERROR, "GAP Handle not properly intialized"); return; } bt_lock(); // remove the watchdog timer if it was already scheduled since we are // going to recompute RegularT...
prv_mode_chaos_monkey_stop()
; goto unlock; } ResponseTimeState requested_state; do { requested_state = bounded_rand_int(ResponseTimeMax, ResponseTimeMin); } while (requested_state == s_chaos_monkey_last_state); s_chaos_monkey_last_state = requested_state; conn_mgr_set_ble_conn_response_time(hdl, BtConsumerPrompt, ...
s_curr_state = (CurrentLoggingState){}; uint8_t prev_log_id = 0; uint32_t first_used_region = prv_validate_flash_log_region(&prev_log_id); if (first_used_region == UINT32_MAX) { // no logs exist so start at region 0 s_curr_state.page_start_addr = FLASH_REGION_DEBUG_DB_BEGIN; goto done; } bool new...
if ((s_curr_state.bytes_remaining < read_length) || !s_flash_logging_enabled) { return (false); }
e(icon)}; grect_align(&icon_rect, box, GAlignTop, true); icon_rect.origin.y += 4; gdraw_command_image_draw(ctx, icon, icon_rect.origin); // more box by icon + some margin const int16_t icon_space = icon_rect.origin.y + icon_rect.size.h - 12; // manually inset to save stack space, instead of ...
{ return 0; }
// add one for the CLEAR ALL at the top return list_count((ListNode *)notifications_data->notification_list) + 1; } static int16_t prv_get_cell_height(struct MenuLayer *menu_layer, MenuIndex *cell_index, void *data) { #if PBL_ROUND MenuIndex selected_index = menu_layer_get_s...
{ 616, 632, -144}, { 672, 384, 184}, { 832, 472, 120}, { 920, 416, 200}, { 1160, 304, 232}, // 5 seconds { 1208, 312, 208}, { 1416, 344, 224}, { 1408, 824, 40}, { 896, 664, -40}, { 760, 280, 0}, { 888, 72, 336}, { 928, 80, 312}, { 824, 136, 208}, { 736, 184, 8}...
{ 1024, 280, -48}, { 1192, 128, 88}, { 1848, 168, 280}, { 1624, 392, 240}, { 1160, 440, 48}, { 912, 456, -296}, { 816, -144, 216}, { 712, 24, 192}, // 11 seconds { 768, 184, 104}, { 776, 96, 136}, { 728, 80, 128}, { 640, 64, 152}, { 632, 16, 168}, { 720, 48, 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...
analytics_heartbeat_get(heartbeat, ANALYTICS_APP_METRIC_LAUNCH_COUNT)
; cl_assert(val8 == 80); // uint16_t overflow analytics_heartbeat_set(heartbeat, ANALYTICS_APP_METRIC_MSG_DROP_COUNT, 70000); analytics_heartbeat_set(heartbeat, ANALYTICS_APP_METRIC_MSG_DROP_COUNT, 70001); uint16_t val16 = analytics_heartbeat_get(heartbeat, ANALYTICS_APP_METRIC_MSG_DROP_COU...
rrnoNotEnoughResources); fake_kernel_malloc_mark_assert_equal(); prv_assert_no_event(); } void test_gatt_client_subscriptions__subscribe_cccd_write_error(void) { s_write_descriptor_cccd_result = -1; fake_kernel_malloc_mark(); // Try to subscribe for indications to the indicatable characteristic: BTErrno e...
(BLEGATTErrorSuccess)
; // Expect one event for both Kernel + App: prv_assert_subscription_event(characteristic, BLESubscriptionIndications, BLEGATTErrorSuccess, true /* kernel */, true /* app */); } void test_gatt_client_subscriptions__unsubscribe_last_subscriber(void) { BTErrno e; BLECharacteristic characteris...
GColorOrangeARGB8); cl_assert_equal_i(s_stroke_width, 1); cl_assert_equal_i(s_path_num_points, 1); cl_assert_equal_b(s_radius, 300); cl_assert_equal_i(s_circle_fill_count, 1); cl_assert_equal_i(s_circle_stroke_count, 1); cl_assert(prv_compare_points(&center, s_stroke_points, s_path_num_points)); cl_asser...
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_radius, 0); cl_assert_equal_i(s_circle_fill_count, 0); cl_assert_equal_i(s_circle_stroke_count, 0); cl_assert_equal_p(s_stroke_points, NULL); cl_assert_equal_p(s_fill_points, NULL); free(command); } st...
A255_INT_MAP_1_INT2_DATA; en_value = BMA255_INT_EN_1_DATA; } else { map_value = BMA255_INT_MAP_1_INT2_FIFO_WATERMARK; en_value = BMA255_INT_EN_1_FIFO_WATERMARK; } bma255_write_register(BMA255Register_INT_MAP_1, map_value); bma255_write_register(BMA255Register_INT_EN_1, en_value); prv_update_acce...
bma255_write_register(BMA255Register_INT_6, BOARD_CONFIG_ACCEL.accel_config.shake_thresholds[AccelThresholdLow])
string_parse_negative_number_nothing_before_separator(void) { // "-.1" * 30 assert_float_parse("-.1", 30, true, -3); } void test_ams_util__float_string_parse_multiple_minusses(void) { // "--.1" * 30 assert_float_parse("--.1", 30, false, 0); } void test_ams_util__float_string_parse_null(void) { // NULL * 3 ...
(one_value, sizeof(one_value), NULL, prv_result_callback)
event) { bt_lock(); const bool is_encrypted = (event->encryption_enabled); if (!is_encrypted) { // The "Encryption Change" event can only enable encryption, there's no inverse, // so there must be an error: PBL_LOG(LOG_LEVEL_ERROR, "Encryption change failed: %u", event->status); goto unlock; } ...
__typeof__(&HCI_LE_Add_Device_To_White_List)
mutator = (is_adding ? HCI_LE_Add_Device_To_White_List : HCI_LE_Remove_Device_From_White_List); const int r = mutator(stack_id, addr_type, BTDeviceAddressToBDADDR(device->address), &status); if (r) { PBL_LOG(LOG_LEVEL_ERROR, "HCI_LE_..._Device_To_White_List (is_addin...
_layer.h" #include "menu_layer_private.h" #include "applib/applib_malloc.auto.h" #include "applib/preferred_content_size.h" #include "applib/graphics/graphics.h" #include "applib/graphics/text.h" #include "util/trig.h" #include "applib/fonts/fonts.h" #include "applib/ui/animation_timing.h" #include "applib/ui/click.h"...
if (menu_layer->callbacks.select_click) { window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler)prv_menu_select_click_handler); }
if (menu_layer->callbacks.select_long_click) { window_long_click_subscribe(BUTTON_ID_SELECT, 0, (ClickHandler)prv_menu_select_long_click_handler, NULL); } window_single_repeating_click_subscribe(BUTTON_ID_DOWN, 100 /*ms*/, (ClickHandler)menu_down_click_handler); } static inline uint16_t prv_me...
_assert_equal_i(app_glance_db_read_glance(&UUID_INVALID, &glance), E_DOES_NOT_EXIST); } void test_app_glance_db__reading_glance_with_invalid_arguments_fails(void) { // NULL UUID fails AppGlance glance_out = {}; cl_assert_equal_i(app_glance_db_read_glance(NULL, &glance_out), E_INVALID_ARGUMENT); // NULL glance...
(fake_event_get_count(), 1)
; PebbleEvent e = fake_event_get_last(); cl_assert_equal_i(e.type, PEBBLE_APP_FETCH_REQUEST_EVENT); cl_assert(!e.app_fetch_request.with_ui); cl_assert_equal_i(e.app_fetch_request.id, 10); } void test_app_glance_db__insert_app_in_cache(void) { cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST...
{ 1616, 488, 16}, { 1504, 296, -24}, { 1440, 200, -16}, { 1496, 88, 64}, { 1512, 152, 48}, { 1408, 248, -32}, { 1168, 264, -56}, // 5 seconds { 1184, 208, -88}, { 1200, 128, -184}, { 944, -48, -256}, { 1016, -232, 112}, { 1224, 104, -96}, { 1168, 232, -216}, ...
{ 1152, 272, -288}, { 816, 144, -280}, { 888, 112, -136}, { 1072, -16, -96}, { 1464, -8, -280}, { 1912, 144, -216}, { 1568, 360, -320}, { 904, 520, -568}, { 776, 352, -448}, { 960, 280, -224}, { 1128, 256, -96}, { 1016, 320, -96}, { 1040, 392, -104}, { 1320, 528, ...
// 13 seconds { 1008, 1032, -152}, { 1448, 520, -168}, { 888, 416, -168}, { 1024, 536, -16}, { 1448, 576, -8}, { 1520, 456, -40}, { 1416, 320, 40}, { 1152, -304, 184}, { 1160, 184, -112}, { 1064, 96, -56}, { 896, 256, -144}, { 816, 256, -72}, { 1112, 200, -40}, ...
ense. * 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 implied....
(&(AppLaunchEventConfig) { .id = APP_ID_TIMELINE, .common.args = &s_timeline_args, .common.transition = animation, }, recognizer)
; } static void prv_configure_click_handler(ButtonId button_id, ClickHandler single_click_handler) { ClickConfig *cfg = &s_click_manager.recognizers[button_id].config; cfg->long_click.delay_ms = QUICK_LAUNCH_HOLD_MS; cfg->long_click.handler = prv_quick_launch_handler; cfg->click.handler = single_click_handler;...
&prv_double_tap_remove_subscriber_cb); // we always listen for motion events to decide whether or not to enable the backlight // TODO: KernelMain could probably subscribe to the motion service to accomplish this? prv_shake_add_subscriber_cb(PebbleTask_KernelMain); analytics_external_collect_accel_xyz_d...
(s_accel_manager_mutex)
; state->sampling_interval_us = (US_PER_SECOND / rate); prv_update_driver_config(); mutex_unlock_recursive(s_accel_manager_mutex); // TODO: doesn't look like our API specifies what this routine should return. return 0; } uint32_t accel_manager_set_jitterfree_sampling_rate(AccelManagerState *state, ...
eeds samples at the right rate into the s_latest_reading // global (for peek mode) and into the accel driver. static void prv_timer_cb(void *data) { mutex_lock(s_accel_mutex); if (s_current_rcv_sample < s_num_rcv_samples) { s_latest_reading = s_rcv_buffer[s_current_rcv_sample++]; } // Keep it simple; this...
(s_accel_mutex)
; } int accel_peek(AccelDriverSample *data) { prv_construct_driver_sample(data); return 0; } void accel_enable_shake_detection(bool on) { } bool accel_get_shake_detection_enabled(void) { return false; } void accel_enable_double_tap_detection(bool on) { } bool accel_get_double_tap_detection_enabled(void)...
lts_card; HeartRateCard hr_card; uint32_t steps_offset; uint32_t cur_steps; uint32_t lap_steps; time_t bed_time_utc; time_t awake_time_utc; uint32_t cur_hr_bpm; uint32_t resting_hr_bpm; uint32_t num_hr_alerts; HealthMetricAlert *hr_alert; } HealthAPITestAppData; static HealthAPITestAppData *s_data;...
(data->hr_window, true)
" #include "clar_asserts.h" #include "util/list.h" #include <string.h> extern void fake_system_task_callbacks_invoke_pending(void); typedef struct CommSession { ListNode node; Transport *transport; const TransportImplementation *transport_imp; bool is_send_next_call_pending; TransportDestination destinat...
circular_buffer_init(&session->send_buffer, session->storage, max_pp_msg_size)
; s_session_head = (CommSession *) list_prepend((ListNode *) s_session_head, &session->node); return session; } size_t comm_session_send_queue_get_length(const CommSession *session) { cl_assert(list_contains((const ListNode *) s_session_head, &session->node)); return circular_buffer_get_read_space_remaining(&...
set_and_next(); } else { prv_get_app_attributes(app_id); } } // ----------------------------------------------------------------------------- // GATT Characteristic update & subscribe static ANCSCharacteristic prv_get_id_for_characteristic(BLECharacteristic characteristic_to_find) { const BLECharacteristic ...
for (int c = 0; c < NumANCSCharacteristic; ++c) { if (s_ancs_client->characteristics[c] == characteristic) { return true; } }
return false; } // ------------------------------------------------------------------------------------------------- // Handling inbound GATT Notifications static void prv_handle_ns_notification(uint32_t length, const uint8_t *notification) { PBL_ASSERTN(notification != NULL); analytics_inc(ANALYTICS_DEVICE_M...
10), 4); #if PBL_COLOR ASSERT_CALLED(prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_EVEN)); #else ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_EVEN)); #endif } void test_graphics_context_${BIT_DEPTH_NAME}__draw_antialiased_stroke_width_odd(void) { // S...
(graphics_draw_circle(&context, GPoint(50, 50), 10))
; ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4)); setup_test(&context, false, 2, 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_CH...
{ -456, 792, 216}, { -560, 896, 288}, { -424, 1168, 248}, { -288, 1208, 272}, { -392, 1232, 352}, { -320, 1104, 288}, { -296, 1056, 432}, { -256, 1080, 312}, { -88, 880, 128}, { -152, 592, 0}, { -192, 592, -80}, { -168, 688, -32}, { -104, 848, 32}, { -56, 936, 104...
{ -256, 936, 208}, { -264, 1088, 144}, { -248, 1200, 128}, { -288, 1080, 32}, { -256, 824, -80}, { -296, 616, -16}, { -320, 568, 40}, { -376, 536, 136}, { -480, 592, 192}, { -600, 736, 256}, { -720, 800, 480}, { -616, 968, 208}, { -680, 1088, 368}, { -624, 1168, ...
cense. * 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 implied...
while (length) { uint32_t chunk_size = MIN(length, 128); flash_read_bytes(buffer, address, chunk_size); PBL_LOG(LOG_LEVEL_ALWAYS, "Data at address 0x%"PRIx32, address); hexdump_log(LOG_LEVEL_ALWAYS, buffer, chunk_size); address += chunk_size; length -= chunk_size; }
// Go back to the prompt. serial_console_set_state(SERIAL_CONSOLE_STATE_PROMPT); } void command_crc_flash(const char* address_str, const char* length_str) { int32_t address = str_to_address(address_str); if (address == -1) { prompt_send_response("Invalid address"); return; } int length = atoi(le...
*/ #include "progress_window.h" #include "applib/applib_malloc.auto.h" #include "applib/fonts/fonts.h" #include "applib/ui/app_window_stack.h" #include "applib/ui/window_private.h" #include "applib/ui/window_stack.h" #include "kernel/pbl_malloc.h" #include "services/common/compositor/compositor_transitions.h" #includ...
(data, success)
; #endif } static void prv_schedule_progress_failure_animation(ProgressWindow *data, uint32_t timeline_res_id, const char *message, uint32_t delay) { // Initialize the peek layer if (timeline_res_id || message) { Layer *root_layer = window_get_root_layer(&dat...
itySleepStateAwake); ASSERT_EQUAL_METRIC_HISTORY(ActivityMetricStepCount, ((const uint32_t [ACTIVITY_HISTORY_DAYS]){0, 1000, 0, 0, 0, 0, 0})); // Feed in 100 steps/min over 20 minutes, for a total of 2000 steps for today prv_feed_cannned_accel_data(20 * SECONDS_PER_MINUTE, 100, Act...
(params->exp_distance_m * k_elapsed_sec, params->seconds)
/* * 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...
{ // We store the mask_row_infos first in the .data buffer, followed by the pixel_mask_data *result = (GDrawMask) { .mask_row_infos = (GDrawMaskRowInfo *)result->data, .pixel_mask_data = ((uint8_t *)result->data) + num_bytes_needed_for_mask_row_infos, }; // Initialize the mask according to ...
return result; #else return NULL; #endif } bool graphics_context_mask_record(GContext *ctx, GDrawMask *mask) { #if CAPABILITY_HAS_MASKING if (!ctx) { return false; } if (ctx->draw_state.draw_mask && !mask) { // TODO PBL-33766: Update the ctx->draw_state.draw_mask's .mask_row_infos } const GDr...
*/ if (heap_info_ptr->is_allocated || (heap_info_ptr->Size < n_units)) { /* If the requested size is larger than the limit then*/ /* search backwards for an available buffer, else go */ /* forward. This will hopefully help to reduce */ /* fragmentataion problems. ...
(heap, size, client_pc)
; if (ptr) { memset(ptr, 0, size); } return ptr; } void* heap_calloc(Heap* const heap, size_t count, size_t size, uintptr_t client_pc) { return heap_zalloc(heap, count * size, client_pc); } uint32_t heap_get_minimum_headroom(Heap *heap) { return (heap_size(heap) - heap->high_water_mark); } // Serial Co...
t when we push windows onto modal window stacks, that // only the appropriate window is visible at a given time. void test_window_stack__modal_priority(void) { Window *windows[NumModalPriorities]; WindowStack *window_stacks[NumModalPriorities]; ModalPriority idx = ModalPriorityInvalid; do { ++idx; wind...
(windows[2][0]->on_screen, false)
; cl_assert_equal_i(windows[2][0]->is_click_configured, false); cl_assert_equal_p(s_last_click_configured_window, windows[2][1]); // Add priority 3 opaque window 0 cl_assert(NumModalPriorities > 3); window_stack_push(window_stacks[3], windows[3][0], false); // An opaque top window of a different stack is ...
576}, { -128, 1216, 816}, { 96, 992, 1056}, { 288, 1048, 624}, { 16, 664, 352}, { -32, 464, 496}, { -96, 464, 456}, { -192, 544, 432}, { -184, 656, 440}, { -192, 624, 424}, // 5 seconds { -232, 712, 344}, { -256, 792, 360}, { -304, 816, 464}, { -360, 944, 592}, ...
{ 1760, 56, 160}, { 928, 624, -320}, { 640, 96, -168}, { 976, 128, 136}, { 712, 328, 168}, { 696, 104, 256}, { 688, 176, 160}, { 712, 280, 96}, { 744, 408, -104}, { 800, 296, 16}, { 904, 328, 0}, { 1152, 288, 16}, { 1352, 256, 72}, { 1856, 216, 168}, { 1624, 3...
{ 1072, 472, 48}, { 680, 320, 72}, { 976, 208, 120}, { 992, 112, 208}, { 872, 120, 176}, { 824, 128, 112}, { 840, 80, 136}, { 800, 80, 136}, { 768, 80, 80}, { 768, 72, 64}, { 832, 128, -40}, { 968, 56, -120}, { 1232, 8, -160}, { 1736, -296, 88}, { 1456, 152, ...
sition_render(WindowTransitioningContext *context, GContext *ctx) { const WindowTransitionRoundImplementation *implementation = (WindowTransitionRoundImplementation *)context->implementation; Window *window_to = context->window_to; if (window_to) { // move framebuffer by amount of pixels the window_to mov...
animation_set_curve(animation, AnimationCurveEaseInOut)
; animation_set_duration(animation, PORT_HOLE_TRANSITION_DURATION_MS); return animation; } const WindowTransitionRoundImplementation g_window_transition_default_push_implementation_round = { .implementation = { .create_animation = prv_window_transition_create_animation, .render = prv_window_transition_...
k.h" #include "stubs_logging.h" #include "stubs_passert.h" #include "stubs_pbl_malloc.h" static int s_app_install_timestamp_update_count; void app_install_mark_prioritized(AppInstallId install_id, bool can_expire) { ++s_app_install_timestamp_update_count; } AppInstallId app_manager_get_current_app_id(void) { retu...
(session, length)
; } } #define assert_consumed(expected_last_status, expected_consumed_count) \ { \ cl_assert_equal_i(expected_last_status, s_last_status_code); \ cl_assert_equal_i(expected_consumed_count, s_consumed_count); \ } #define assert_not_consumed() \ cl_assert_equal_i(0, s_consumed_count); // Tests ////////////////...
connected); // Trigger a reset update to the state machine. Delay the update to allow the battery voltage to // settle and to debounce reconnection events prv_schedule_update(RECONNECTION_DELAY_MS, true); } PreciseBatteryChargeState prv_get_precise_charge_state(const BatteryState *state) { PreciseBatteryCharg...
{ if (!strcmp("disable", option)) { prv_set_forced_charge_state(false); } else if (!strcmp("enable", option)) { prv_set_forced_charge_state(true); } }
(0, 0, 10, 10)
; grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, 4.5, 4.5); cl_assert_fixedS16_3(radius, 4.5); r = GRect(1, 1, 9, 9); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, 5, 5); cl_assert_fixedS16_3(radius, 4); r = GRect(2, 2, 8, ...
lue, end_value); #endif } // -------------------------------------------------------------------------------------- // Test a basic uint32_t property animation void test_animation__property_uint32(void) { #ifdef TEST_INCLUDE_BASIC PropertyAnimation *prop_h; uint32_t value; uint32_t start_value, end_value, mid_...
(test_value, set_value)
); property_animation_set_from_gcolor8(prop_h, &start_value); // Start, we should start at the start values prv_advance_to_ms_with_timers(start_ms + 1); cl_assert(gcolor_equal(value, start_value)); // Halfway through prv_advance_to_ms_with_timers(start_ms + duration/2); cl_assert(gcolor_equal(value, mi...
return true; } return false; } // Stored struct setters static void prv_write_to_current_page(SharedPRFData *data, bool write_metadata) { if (data) { if (write_metadata) { data->magic = SprfMagic_ValidEntry; data->version = SPRF_CUR_VERSION; } flash_write_bytes((uint8_t *)data, prv_cur...
if ((old_crc == new_crc) && same_data) { // We are trying to write the same data, ignore the write goto cleanup; } else if (old_crc != SPRF_UNWRITTEN_CRC) { // We are writing different data. Clear the field, write the struct again, and later write // the new data in the empty field memset(((uint8_...
PBL_LOG(LOG_LEVEL_DEBUG, "Overwriting SPRF field at offset %d, size %d", (int)offset, (int)field_size); // write the crc first so it's easier to detect a non empty field (we can just read if the CRC is // not 0xFFFFFFFF instead of comparing all bytes. *(uint32_t *)field = new_crc; flash_write_by...
r_destroy(layer); } static void prv_layout_will_appear_handler(SwapLayer *swap_layer, LayoutLayer *layout, void *context) { } static void prv_layout_did_appear_handler(SwapLayer *swap_layer, LayoutLayer *layout, int8_t rel_change, voi...
if (notif.icon_id != 0) { attribute_list_add_uint32(&attr_list, AttributeIdIconTiny, notif.icon_id); }
if (notif.title) { attribute_list_add_cstring(&attr_list, AttributeIdTitle, notif.title); } if (notif.subtitle) { attribute_list_add_cstring(&attr_list, AttributeIdSubtitle, notif.subtitle); } if (notif.body) { attribute_list_add_cstring(&attr_list, AttributeIdBody, notif.body)...
ia have been met, show reward prv_push_reward(now_utc, &SLEEP_REWARD_NOTIF_CONFIG); } // ----------------------------------------------------------------------------------------- // Format a time given in seconds after midnight static void prv_strcat_formatted_time(int32_t time_seconds, char *out_buf, size_t buf_len...
("%s of sleep", &pin_attr_list)
source(resource_id); cl_assert(bitmap_sequence); GBitmap *bitmap = gbitmap_create_blank(gbitmap_sequence_get_bitmap_size(bitmap_sequence), GBitmapFormat8Bit); cl_assert(bitmap); gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL); cl_check(gbitm...
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)))
; // Frame 2 has delay 1000 ms, so at time 1000 ms, we expect frame 3 gbitmap_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_...
timer_fire(wakeup_get_current()); wakeup_dispatcher_system_task((void *)(uintptr_t)late_wakeup_id); // There should now be no scheduled wakeups cl_assert_equal_i(sys_wakeup_query(late_wakeup_id), E_DOES_NOT_EXIST); } void test_wakeup__time_jump(void) { sys_wakeup_cancel_all_for_app(); // Schedule 1 event i...
(final_timeout, initial_timeout - time_jump_seconds * 1000)
ion->storage.read_offset, FSeekSet)) { consumed_bytes = -1; // error goto exit; } if (!prv_pfs_read(logging_session->storage.fd, &chunk_hdr, sizeof(chunk_hdr))) { consumed_bytes = -1; // error goto exit; } if (chunk_hdr.valid && chunk_hdr.num_bytes ==...
PBL_LOG(LOG_LEVEL_ERROR, "Expected name of %s, got %s", head->name, name)
; pfs_remove(head->name); goto bad_session; } // We need to figure out how many bytes of data are unread and the offset of the // last byte of data (which becomes the write offset). We pass NULL into the buffer argument // of dls_storage_read() to tell it to compute these for us. uint32...
{ PairingCountItrData itr_data = { .count = 0, .type = type, }; prv_file_each(prv_get_num_pairings_by_type_itr, &itr_data); return itr_data.count; } /////////////////////////////////////////////////////////////////////////////////////////////////// //! BLE Pairing Info void gap_le_connection_handle_b...
if (key == BT_BONDING_ID_INVALID) { // This is an add, not an update op = BtPersistBondingOpDidAdd; key = prv_get_free_key(); if (key == BT_BONDING_ID_INVALID) { // We are out of keys.... return BT_BONDING_ID_INVALID; } } else { // If we add any optional fields a load will have to ...
BtPersistBondingData new_data; new_data = (BtPersistBondingData) { .type = BtPersistBondingTypeBLE, .ble_data.is_gateway = is_gateway, .ble_data.flags = flags, // This is defaulting to "is_gateway" for now because it is currently being used as the flag // for the pairing that we want to reconn...
304, -768, -576}, { -296, -768, -584}, { -296, -776, -600}, { -296, -768, -592}, { -296, -760, -560}, { -312, -752, -576}, { -312, -768, -608}, { -320, -792, -576}, { -312, -824, -536}, { -296, -800, -560}, { -280, -792, -576}, { -288, -816, -536}, { -280, -808, -560}, ...
{ -144, -584, -784}, { -152, -584, -832}, { -144, -576, -832}, { -112, -576, -840}, { -128, -584, -840}, { -112, -584, -816}, { -136, -576, -800}, { -72, -568, -832}, // 219 seconds { -48, -560, -864}, { -120, -568, -848}, { -136, -552, -840}, { -128, -552, -848}, ...
/* * 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...
(tuple != NULL)
; cl_assert(iter.dictionary->count == 3); } void test_dict__tuplets_utils(void) { Tuplet tuplets[] = { TupletBytes(SOME_DATA_KEY, SOME_DATA, sizeof(SOME_DATA)), TupletCString(SOME_STRING_KEY, SOME_STRING), TupletInteger(SOME_UINT32_KEY, (uint32_t) 32), }; const uint32_t size = dict_calc_buffer_size...
{ RecognizerEvent event_type = -1; NEW_RECOGNIZER(r) = test_recognizer_create(&s_test_impl_data, &event_type); // Test that manager state change handler is called when not called from a touch event handler recognizer_transition_state(r, RecognizerState_Failed); cl_assert_equal_i(r->state, RecognizerState_Fai...
recognizer_transition_state(r, RecognizerState_Cancelled)
/* * 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...
services_normal_early_init()
159 * 180; // atan2 returns in range [-pi, +pi], but we have [0,2pi]. if (theirs < 0) theirs += 360; cl_assert(abs(ours - (int) theirs) < 3); // Allow 3 degrees difference max } static double log_two(uint32_t n) { return (log(n) / log(2)); } static void check_ceil_log_two(uint32_t n) { int ours = ceil_log_...
WITHIN(-5, min, max)
/* * 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 (!notification_storage_get(&last_notification_received_id, &notification)) { // We couldn't load the notification for some reason; just bail out with the subtitle cleared notifications_glance->subtitle[0] = '\0'; return; }
const char *title = attribute_get_string(&notification.attr_list, AttributeIdTitle, ""); const char *subtitle = attribute_get_string(&notification.attr_list, AttributeIdSubtitle, ""); const char *body = attribute_get_string(&notification.attr_list, AttributeIdBody, ""); // Determine which string we should us...
r = {}; TimelineIterState state = {}; TimelineNode *head = NULL; cl_assert_equal_i(timeline_init(&head), S_SUCCESS); const time_t time_21_00_march_1_pst = 1425272400; cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, time_21_00_...
cl_assert_equal_i(timeline_init(&head), S_SUCCESS)
; cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1430236800 - 60 * 60), S_SUCCESS); const time_t midnight_apr_28_pst = 1430208000; cl_assert_equal_i(state.node->timestamp, midnight_apr_28_pst); } void test_timeline__all_day_ios_bug_2(void) { TimelineItem item...
fctl.x_offset; png_decoder_data->previous_yoffset = fctl.y_offset; png_decoder_data->previous_width = fctl.width; png_decoder_data->previous_height = fctl.height; fctl.delay_den = (fctl.delay_den == 0) ? APNG_DEFAULT_DELAY_UNITS : fctl.delay_den; // Update the current_frame_delay_ms for this frame...
{ return false; }
// If animation has started and specified time is in the past if (bitmap_sequence->current_frame_delay_ms != 0 && elapsed_ms <= bitmap_sequence->elapsed_ms) { APP_LOG(APP_LOG_LEVEL_WARNING, APNG_ELAPSED_WARNING); return false; } bool retval = false; bool frame_updated = true; while (frame_updated...
/* * 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...
{ *head = node->next; }
if (tail && *tail == node) { *tail = node->prev; } if (node->next) { node->next->prev = node->prev; } if (node->prev) { node->prev->next = node->next; } node->prev = NULL; node->next = NULL; } ListNode* list_append(ListNode* node, ListNode* new_node) { return list_insert_after(list_get_t...
= QSPI_ComConfig_IMode_4Line; qspi_com_config.QSPI_ComConfig_Ins = MT25QCommand_ResetEnable; QSPI_ComConfig_Init(&qspi_com_config); prv_wait_for_qspi_transfer_complete(QSPIFlag_ClearTC); QSPI_ComConfig_StructInit(&qspi_com_config); qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;...
{ write_ptr[i] = QSPI_ReceiveData8(); }
QSPI_ClearFlag(QSPI_FLAG_TC); prv_wait_for_qspi_not_busy(); prv_disable_qspi_clock(); }
/* * 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(size == sizeof(Dictionary) + (3 * sizeof(Tuple)) + 10 + 100 + 1000)
; } struct SerializeTestResult { bool okay; uint16_t expected_size; }; static void serialize_callback(const uint8_t * const data, const uint16_t size, void *context) { struct SerializeTestResult *result = context; result->okay = true; result->expected_size = size; // Read back: DictionaryIterator iter;...
bus->i2c->CR2 |= I2C_CR2_ITBUFEN; bus->transfer.state = TRANSFER_STATE_READ_DATA; break; case TRANSFER_STATE_READ_DATA: bus->transfer.data[bus->transfer.idx] = bus->i2c->DR; bus->transfer.idx++; if (bus->transfer.idx + 1 == bus->transfer.size) { // Last byte, we want t...
if(!strcmp("on", arg)) { bus_rail_power_up(1); } else { bus_rail_power_down(1); }
}
icense. * 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 implie...
(LOG_LEVEL_ERROR, "ble_gap_adv_start: status = 0x%x", rv)
; } else { PBL_LOG(LOG_LEVEL_DEBUG, "Adverts (re)started"); } return rv; } static ble_error_t prv_advert_disable(void) { ble_error_t rv = ble_gap_adv_stop(); if (rv != BLE_STATUS_OK) { PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_adv_stop: status = 0x%x", rv); } return rv; } static ble_error_t prv_try_to_e...
heap_util.h" #include "kernel/pbl_malloc.h" #include "process_management/app_manager.h" #include "system/passert.h" #include "syscall/syscall.h" #include "syscall/syscall_internal.h" #include "code_space_reservation.h" const RockySnapshotHeader ROCKY_EXPECTED_SNAPSHOT_HEADER = { .signature = {'P', 'J', 'S', 0}, // ...
(SYSTEM_APP, resource_id)
; } bool rocky_event_loop_with_resource(uint32_t resource_id) { return prv_rocky_event_loop_with_resource(sys_get_current_resource_num(), resource_id); }
qual_i(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_e...
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 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...
(sequence_reel->render_bitmap)
; bounds.origin = gpoint_add(bounds.origin, offset); // Save compositing mode GCompOp prev_compositing_mode = ctx->draw_state.compositing_mode; graphics_context_set_compositing_mode(ctx, GCompOpSet); // Enable compositing graphics_draw_bitmap_in_rect_processed(ctx, sequence_reel->render_bitmap, &bounds, ...
, GColorBlack); graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NULL_W, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); cl_check(framebuffer_is_empty("draw_text_null_w", fb, GColorWhite)); setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1); graphics_context...
setup_test_aa_sw(&ctx, fb, GRect(0, 0, 144, 168), GRect(0, 0, 144, 168), false, 1)
; graphics_context_set_fill_color(&ctx, GColorRed); graphics_fill_rect(&ctx, &GRect(0, 0, 144, 168)); graphics_context_set_text_color(&ctx, GColorBlue); graphics_draw_text(&ctx, "blue100", &s_font_info, GRect(10, 10, 100, 30), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); ...
/* * 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_will_return(gack, 573)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
flash_prf_set_protection(false)
; bool saved_sleep_when_idle = flash_get_sleep_when_idle(); flash_sleep_when_idle(false); FirmwareDescription description = firmware_storage_read_firmware_description(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN); if (!firmware_storage_check_valid_firmware_description(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN, ...
ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1); graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1, GCornerTopRight); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_rmax_topright.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO...
(prv_clamp_corner_radius(GSize(0, 0), GCornersAll, 8), 0)
; cl_assert_equal_i(prv_clamp_corner_radius(GSize(0, 5), GCornersAll, 8), 0); cl_assert_equal_i(prv_clamp_corner_radius(GSize(4, 0), GCornersAll, 8), 0); cl_assert_equal_i(prv_clamp_corner_radius(GSize(4, 8), GCornerNone, 8), 0); // Test minimum of width and height is taken as radius cl_assert_equal_i(prv_cl...
10), 4, GCornersAll)); setup_test(&context, true, 1, 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)); ASS...
graphics_capture_frame_buffer_format(&ctx, GBitmapFormat8BitCircular)
; cl_assert_equal_p(bmp, &ctx.dest_bitmap); cl_assert(ctx.lock == true); }; void test_graphics_context_${BIT_DEPTH_NAME}__lock_framebuffer_fails_from_8BitCircular(void) { // Test for locking of 8Bit Circular framebuffer when framebuffer is regular 8Bit GContext ctx = {.dest_bitmap.info.format = GBitmapFormat8B...
w_stroke_precise_same_point_offset_layer_aa.${BIT_DEPTH_NAME}.pbi")); #endif } void test_graphics_draw_stroke_precise_${BIT_DEPTH_NAME}__offset_layer_non_aa(void) { GContext ctx; test_graphics_context_init(&ctx, fb); setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 10); graphics_lin...
test_graphics_context_init(&ctx, fb)
; setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 10); graphics_line_draw_precise_stroked_non_aa(&ctx, CLOSE_POINTS_LESS_THAN_1PX_START, CLOSE_POINTS_LESS_THAN_1PX_END, 10); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_close_points_less_than_1px_non_aa.${BIT_DEPTH_NA...
/* * 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...
strlen(str)
; ANCSAttribute *attr = malloc(sizeof(ANCSAttribute) + len); attr->length = len; memcpy(&attr->value, str, len); return attr; } static void prv_destroy_ancs_attr(ANCSAttribute *attr) { free(attr); } void test_ancs_notifications_util__parse_timestamp(void) { struct tm apr_3_13_00 = { .tm_sec = 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...
pb_ostream_from_buffer(buffer, 30)
; pb_encode(&s, SimpleMessage_fields, &msg); PBL_LOG(LOG_LEVEL_DEBUG, "Encoded message, size: %u bytes", s.bytes_written); PBL_HEXDUMP(LOG_LEVEL_DEBUG, buffer, s.bytes_written); app_state_set_user_data(buffer); } static void prv_deinit(void) { SimpleMessage msg = {0}; uint8_t *buffer = app_state_get_user_d...
config.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &tim_config); periph_config_disable(TIM4, RCC_APB1Periph_TIM4); } static bool prv_check_timer_enabled(void) { // We're only enabled if all the configuration is correct. return (TIM4->CR1 & TIM_CR1_CEN) && // TIM_Cmd (TIM4->DIER & TI...
{ // What stable state is the button in, according to the debouncing algorithm? bool debounced_button_state = bitset32_get(&s_debounced_button_state, i); // What is the current physical state of the button? bool is_pressed = button_is_pressed(i); if (is_pressed == debounced_button_state) { //...
#if !defined(MANUFACTURING_FW) // Now that s_debounced_button_state is updated, check to see if the user is holding down the reset // combination. static uint32_t s_hard_reset_timer = 0; if ((s_debounced_button_state & RESET_BUTTONS) == RESET_BUTTONS) { s_hard_reset_timer += 1; can_power_down_tim4 = f...
/* * 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...
(0, NULL, 0)
, message, 14), CRC32_RESIDUE); } void test_crc32__null_residue(void) { uint8_t data[4] = {0, 0, 0, 0}; crc = crc32(crc, data, 4); assert_equal_hex(crc, CRC32_RESIDUE); }
window_destroy(window); } void test_window_stack__basic_window_pop(void) { Window *window1 = window_create(); Window *window2 = window_create(); // Switch to app state to push windows to the Application window stack stub_pebble_tasks_set_current(PebbleTask_App); cl_check(app_state_get_window_stack()); cl...
cl_assert_equal_i(window2->on_screen, false)
; window_destroy(window1); window_destroy(window2); } // Description: // During the push of a window, we push another window in the load handler of // the window being pushed. This causes the loading window to disappaer from // the screen (before it even appeared) and become subverted by the new window. void tes...
on id: %"PRIu8, session_id); return; } mutex_lock(s_endpoint_data.mutex); switch (logging_session->comm.state) { case DataLoggingSessionCommStateIdle: case DataLoggingSessionCommStateOpening: //Currently, these messages never get NACK'd PBL_LOG(LOG_LEVEL_ERROR, "Unexpected NACK"); b...
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Phone reported session %u opened", session_id)
; // If the phone thinks we're open and we're not, send a close message. if (logging_session == NULL) { dls_endpoint_close_session(session_id); } } // If the bluetooth connection is flaky, a session reopen could take a few seconds, so we will chain them // and only do 1 re-open per system call...
til_get_minute_of_day(sleep_exit_utc) * SECONDS_PER_MINUTE; s_data.metric_history[ActivityMetricSleepTotalSeconds][0] = total_seconds; } void activity_sessions_prv_get_sleep_bounds_utc(time_t now_utc, time_t *enter_utc, time_t *exit_utc) { ActivitySession activity_sessions[MAX_ACTIVITY_SESSIONS]; uint32_t num_s...
{ // No more room break; }
time_t session_end = s_data.activity_sessions[i].start_utc + s_data.activity_sessions[i].length_min * SECONDS_PER_MINUTE; if (session_end >= sleep_earliest_end_utc) { // This session should be included in today's sessions sessions[num_sessions_returned++] = s_data.activity_se...
lyticsMetric metric, int64_t value, AnalyticsClient client) { analytics_set_for_uuid(metric, value, analytics_uuid_for_client(client)); } void analytics_max(AnalyticsMetric metric, int64_t val, AnalyticsClient client) { const Uuid *uuid = analytics_uuid_for_client(client); analytics_storage_take_lock(); Anal...
PBL_LOG(LOG_LEVEL_DEBUG, "Analytics stopwatch for metric %d already started!", metric)
; goto unlock; } AnalyticsStopwatchNode *stopwatch = kernel_malloc_check(sizeof(*stopwatch)); *stopwatch = (AnalyticsStopwatchNode) { .metric = metric, .starting_ticks = rtc_get_ticks(), .count_per_sec = count_per_sec, .client = client, }; list_init(&stopwatch->node); s_stopwatch_list ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(app_is_destination)
, compositor_port_hole_transition_app_get(direction)); } const CompositorTransition *shell_get_close_compositor_animation(AppInstallId current_app_id, AppInstallId next_app_id) { const CompositorTransition *res = NULL; AppIn...
/* * 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...
("Default_Handler")
/* * 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...
resource_init()
; // Setup content indicator ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer(); content_indicator_init_buffer(buffer); } void test_health_hr_detail_card__cleanup(void) { } // Helpers ////////////////////// static Window* prv_create_card_and_render(HealthData *health_data) { Window *wi...
if (val == MAX14690_WHOAMI) { PBL_LOG(LOG_LEVEL_DEBUG, "Found the max14690"); return true; } else { PBL_LOG(LOG_LEVEL_DEBUG, "Error reading max14690 WHOAMI byte"); return false; }
} static void prv_set_pin_config(void) { periph_config_acquire_lock(); // Initialize the GPIOs for the 4V5 & 6V6 rails gpio_output_init(&BOARD_CONFIG_POWER.rail_4V5_ctrl, GPIO_OType_OD, GPIO_Speed_50MHz); if (BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio) { gpio_output_init(&BOARD_CONFIG_POWER.rail_6V6_ctrl, GPI...
/* * 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...
distance_to_mod_boundary(origin.x, DISP_COLS)
, distance_to_mod_boundary(origin.y, DISP_ROWS)); } static void prv_window_transition_render(WindowTransitioningContext *context, GContext *ctx) { const WindowTransitionRoundImplementation *implementation = (WindowTransitionRoundImplementation *)context->implementation; Window *window_to = context...
ke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(5, -5)); } void outside_x_y_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(15, 15)); } void outside_nx_y_layer_update_callback(Layer* me, GContext* ctx) { graphic...
layer_render_tree(&layer, &ctx)
/////////////////////////////////////////////////// void test_list__initialize(void) { } void test_list__cleanup(void) { } void test_list__insert_after(void) { ListNode *tail = NULL; ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL; tail = list_insert_after(tail, &a); cl_assert(tail == &a); tail = list_inse...
(head == &bar3.list_node)
s(h, handlers, context); animation_set_duration(h, duration); animation_set_auto_destroy(h, false); prv_clear_handler_histories(); animation_schedule(h); uint64_t start_ms = prv_now_ms(); uint64_t unschedule_time = 0; uint64_t time_ms; for (int num_loops = 0; num_loops < 10; num_loops++) { prv_...
animation_destroy(h)
(radius, 1); grect_polar_calc_values(NULL, mode, &center, &radius); cl_assert_gpoint_precise(center, 1, 2); cl_assert_fixedS16_3(radius, 1); } void test_graphics_circle__grect_polar_calc_values_edge_cases(void) { GPointPrecise center = {}; Fixed_S16_3 radius = {}; const GOvalScaleMode mode = GOvalScaleMod...
(s_angle_start, 0)
; cl_assert_equal_i(s_angle_end, TRIG_MAX_ANGLE); graphics_fill_oval(NULL, GRect(10, 12, -10, -12), GOvalScaleModeFitCircle); cl_assert_gpoint_precise(s_center, 4.5, 5.5); cl_assert_fixedS16_3(s_radius_outer, 4.5); cl_assert(s_radius_inner.integer <= 0); cl_assert_equal_i(s_angle_start, 0); cl_assert_eq...
(health_data)
, card_data); HealthDetailSubtitle *subtitle = &card_data->subtitles[card_data->num_subtitles++]; *subtitle = (HealthDetailSubtitle) { .label = app_zalloc_check(buffer_len), .fill_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack), }; prv_set_avg(subtitle->label, buffer_len, card_data->daily_avg, c...
geconnected_postmessagedisconnected_init(false /* start_connected */); ASSERT_JS_GLOBAL_EQUALS_I("d", 1); prv_simulate_transport_connection_event(true /* is_connected */); ASSERT_JS_GLOBAL_EQUALS_I("c", 0); ASSERT_JS_GLOBAL_EQUALS_I("d", 1); prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_s...
task_free(buffer)
; } void test_rocky_api_app_message__postmessage_just_before_connected(void) { prv_init_api(false /* start_connected */); EXECUTE_SCRIPT("var x = " SIMPLE_TEST_OBJECT ";" "var hasError = false;" "_rocky.on('postmessageerror', function() { hasError = true; });" "_...
_VALUE_LENGTH) { PBL_LOG(LOG_LEVEL_ALWAYS, "Invalid value length %"PRIu16, evt->length); } return rv; } static void prv_pps_handle_write_request(ble_service_t *svc, const ble_evt_gatts_write_req_t *evt) { att_error_t rv = ATT_ERROR_INVALID_HANDLE; if (evt->handle == s_pps_ctx.att_hdl.trigger_pairing) { ...
(&uuid, GATT_PROP_READ | GATT_PROP_WRITE, ATT_PERM_RW, sizeof(uint8_t), enable_read_cb_flag, NULL, &ctx->att_hdl.trigger_pairing)
== BLE_STATUS_OK); // GATT MTU characteristic + CCCD: prv_convert_uuid_to_little_endian( (const uint8_t[]){PEBBLE_BT_PAIRING_SERVICE_GATT_MTU_UUID}, &uuid); PBL_ASSERTN(ble_gatts_add_characteristic(&uuid, GATT_PROP_READ | GATT_PROP_NOTIFY | GATT_PROP_WRITE, ...
ction_menu_window_private.h" #include "applib/ui/dialogs/dialog.h" #include "applib/ui/dialogs/dialog_private.h" #include "applib/ui/dialogs/expandable_dialog.h" #include "applib/ui/dialogs/simple_dialog.h" #include "applib/ui/progress_window.h" #include "applib/ui/window.h" #include "applib/ui/window_manager.h" #inclu...
evented_timer_exists(data->response.timer)
) { evented_timer_cancel(data->response.timer); } } static void prv_cleanup_action_result(ActionResultData *data, bool succeeded) { if (!data) { return; } // report to analytics the result of the action if (data->response.attribute.id == AttributeIdTitle && data->response.attribute.cstring) { ...