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...
battery_state_reset_filter()
; // Force a state machine update battery_state_handle_connection_event(s_usb_connected); }
{ LayoutLayer *new_previous = prv_fetch_next_layout(swap_layer, -1); // if there is no layout to swap up to, abort if (!new_previous) { return false; } swap_layer->previous = new_previous; GRect prev_frame = swap_layer->previous->layer.frame; const GRect *current_frame = &swap_layer->current->layer...
prv_scroll(swap_layer, offset, AnimationCurveEaseOut)
_attribute_get_service_id(attr) == 0x1111); cl_assert(app_smartstrap_attribute_get_attribute_id(attr) == 0x2222); // destroy the attribute app_smartstrap_attribute_destroy(attr); // verify that we can no longer get the ids cl_assert(app_smartstrap_attribute_get_service_id(attr) == 0); cl_assert(app_smarts...
(&request)
; prv_prepare_for_did_write(attr); smartstrap_attribute_send_event(SmartstrapDataReceivedEvent, SmartstrapProfileGenericService, SmartstrapResultOk, 0x1111, 0x2222, 100); cl_assert(!s_pending_did_write.active); // destroy the attribute app_smartstrap_attribute_destroy(attr);...
8}, { 1328, 352, -88}, { 840, 488, -264}, { 864, 216, 72}, { 704, 72, 144}, { 728, 40, 112}, { 784, 136, 112}, { 920, 376, -72}, { 776, 304, 0}, { 888, 360, -192}, { 960, 224, -128}, { 1128, 248, -120}, { 1336, 200, -72}, { 1704, 184, 32}, { 1592, 312, 24}, { ...
{ 1120, 240, -96}, { 1272, 224, -112}, { 1752, 216, 16}, { 1656, 376, 24}, { 936, 368, -72}, { 904, 280, -48}, { 1112, 160, 128}, { 1008, 136, 152}, { 904, 88, 128}, { 848, 96, 152}, { 752, 72, 80}, { 704, 0, 136}, { 704, 0, 112}, { 776, 8, 64}, { 968, -32, -8...
{ 1736, -96, 208}, // 19 seconds { 1456, 208, -24}, { 1272, 288, -176}, { 1008, 416, -64}, { 760, 224, 56}, { 824, 168, 72}, { 832, 88, 144}, { 872, 304, -32}, { 736, 320, -32}, { 904, 440, -192}, { 1008, 280, -88}, { 1200, 312, -208}, { 1328, 248, -80}, { 18...
ut(HRMSubscriberState *state, PebbleHRMEvent *event) { bool success; if (state->queue) { PebbleEvent e = { .type = PEBBLE_HRM_EVENT, .hrm = *event, }; success = xQueueSendToBack(state->queue, &e, 0); } else { prv_queue_system_task_event(event); success = system_...
prv_remove_and_free_subscription(expired_state)
; } } // Update the HRM enable state. If no subscribers need an update for a while, we can turn off the // HR sensor and set a timer to turn it on again later. To avoid this overhead on every callback, // we only check it once every HRM_CHECK_SENSOR_DISABLE_COUNT times if (++s_manager_state.check_disable...
cl_assert(iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id)); cl_assert(!iter_prev(&iterator)); timeline_iter_deinit(&iterator, &state, &head); } void test_timeline__skip_deleted_item(void) { Iterator iterator = {0}; TimelineIterState state = {0}; TimelineNode *head ...
(state.node->timestamp, 1425369600)
c metric, uint32_t count_per_sec) { AnalyticsStopwatchNode *stopwatch = kernel_malloc_check(sizeof(AnalyticsStopwatchNode)); *stopwatch = (AnalyticsStopwatchNode) { .metric = metric, .count_per_sec = count_per_sec, .starting_ticks = rtc_get(), }; s_stopwatch_list = list_prepend(s_stopwatch_list, (Li...
mutex_destroy((PebbleMutex *)s_analytics_lock)
; }
96, -200}, { 800, 264, -200}, { 576, 240, -192}, { 520, 192, -120}, { 552, 184, -96}, { 672, 264, -120}, { 840, 264, -192}, { 960, 296, -168}, { 1032, 328, -256}, { 1064, 360, -240}, { 1240, 384, -200}, { 1088, 400, -256}, { 1120, 400, -232}, { 1216, 352, -176}, {...
ARRAY_LENGTH(samples)
; return samples; } // ---------------------------------------------------------------- // Sample captured: 2015-10-05 16:08:41 local AccelRawData *activity_sample_walk_200_pbl_25656_10(int *len) { // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_200_pbl_25656_10 //> TE...
/* * 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...
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 10)
; graphics_line_draw_precise_stroked_aa(&ctx, START_ON_ORIGIN_RECT_NXNY, END_ON_ORIGIN_RECT_NXNY, 10); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_across_nxny_origin_layer_aa.${BIT_DEPTH_NAME}.pbi")); // TODO: Fix offset calculation and reenable this: - PBL-16509 setup_test_aa_sw(&ctx, fb, O...
T_STRING_MAX_LENGTH]; memset(string_buffer, '~', sizeof(string_buffer)); cl_assert_equal_i( persist_read_string(0, string_buffer, sizeof(string_buffer)), E_DOES_NOT_EXIST); for (size_t i = 0; i < sizeof(string_buffer); ++i) { if (string_buffer[i] != '~') { char error_msg[132]; snprin...
cl_assert_equal_i(persist_write_data(i, &buffer, sizeof(buffer)), sizeof(buffer))
; } // Don't be too strict about preventing apps from using more persist than they // had available under the old implementation. // cl_assert_equal_i(persist_write_data(n + 1, &buffer, sizeof(buffer)), // E_OUT_OF_STORAGE); }
e(0) == timeline_model_get_iter_state_with_timeline_idx(1)); cl_assert(timeline_model_get_iter_state(1) == timeline_model_get_iter_state_with_timeline_idx(2)); cl_assert(timeline_model_iter_next(&new_idx, &has_next)); cl_assert(has_next); cl_assert_equal_i(new_idx, 3); cl_assert_equal_i(timeline_model_get_nu...
cl_assert(uuid_equal(&s_items[s_correct_order[3]].header.id, &timeline_model_get_iter_state(0)->pin.header.id))
; cl_assert(uuid_equal(&s_items[s_correct_order[4]].header.id, &timeline_model_get_iter_state(1)->pin.header.id)); cl_assert(uuid_equal(&s_items[s_correct_order[5]].header.id, &timeline_model_get_iter_state(2)->pin.header.id)); cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_stat...
/* * 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_buffer, 0, BUFFER_LENGTH)
; while (callback(context)) { cl_assert(s_did_send_byte); } } void fake_accessory_get_buffer(uint8_t **buffer, int *length) { *buffer = s_buffer; *length = s_buffer_index; }
raphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN)); #endif setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false); graphics_draw_rect(&context, &GRect(10, 20, 40, 10)); #if PBL_COLOR ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN)); ...
(&context, GPoint(50, 50), 10, GCornersAll)
); #else ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10)); #endif setup_test(&context, true, 5, GColorBlack, GColorBlack, false); graphics_fill_round_rect(&context, &GRect(20, 80, 40, 10), 4, GCornersAll); #if SCREEN_COLOR_DEPTH_BITS == 1 ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GR...
/* * 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 (!s_comm_is_running) { return; } stop_mode_disable(InhibitorCommMode); #if CAPABILITY_HAS_BUILTIN_HRM ble_hrm_deinit(); #endif gap_le_deinit(); // Should be the last thing to happen that touches the Bluetooth controller directly bt_driver_stop(); stop_mode_enable(InhibitorCommMode); analytic...
static void prv_send_state_change_event(void) { PBL_LOG(LOG_LEVEL_DEBUG, "----> Sending a BT state event"); PebbleEvent event = { .type = PEBBLE_BT_STATE_EVENT, .bluetooth = { .state = { .airplane = s_comm_airplane_mode_on, .enabled = s_comm_enabled, .override = s_comm_overri...
// Activity Event if (event->type == pebble_pipeline_Event_Type_ActivitySessionEvent) { const pebble_pipeline_ActivitySession *session = &event->activity_session; LOG(" Activity Type: %d, Start Reason: %d", session->type.type.internal_type, session->start_reason); // TODO: Add...
(&log_config, transport_cb, 0)
; cl_assert(session_ref != NULL); return session_ref; } static TestPLParsedMsg *prv_flush_get_record(TestPLParsedMsg *input, bool use_data_logging, ProtobufLogRef session_ref) { // Flush it out now, this should end up in our transport method being called input->payl...
ue; head->offset_bytes = 0; prv_start_session_closed_object_queue_timer(); } PBL_ASSERTN(s_state.state != PostMessageStateSessionOpen); prv_emit_post_message_connection_event(false /* is_connected */); } static void prv_session_open__exit_and_initiate_reset(void) { prv_awaiting_reset_complete_local_in...
if (tuple) { if (!prv_is_tuple_valid_reset_complete(tuple)) { // TODO: document this in statechart prv_send_unsupported_protocol_error_and_enter_await_reset_req(PostMessageErrorMalformedResetComplete); return; } const PostMessageResetCompletePayload *rc = (const PostMessageResetCom...
} //////////////////////////////////////////////////////////////////////////////// // Awaiting Reset Complete Local Initiated //////////////////////////////////////////////////////////////////////////////// static void prv_awaiting_reset_complete_local_initiated__inbox_received(DictionaryIterator *it, ...
that the // bootloader leaves behind. This includes disabling the PLL. // GPIOs are not reset here: resetting them would change their output values, // which could unintentionally turn of e.g. PMIC power rails. // The backup domain is not reset; that would be foolish. const uint32_t ahb1_periphs = RCC_AH...
(BOOT_BIT_RESET_LOOP_DETECT_THREE)
; break; case 5: boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE); break; case 6: boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE); boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO); break; case 7: boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE); break; default: PBL_CROAK("reset loop boot ...
bool s_assert_write_error = false; void flash_expect_program_failure(bool expect_failure) { s_assert_write_error = expect_failure; } #endif void flash_write_bytes(const uint8_t *buffer, uint32_t start_addr, uint32_t buffer_size) { mutex_lock(s_flash_lock); stop_mode_disable(InhibitorFlash...
flash_impl_erase_sector_begin(addr)
1); cl_assert_equal_i(sign_extend(-1, 32), -1); cl_assert_equal_i(sign_extend(-1, 3), -1); cl_assert_equal_i(sign_extend(7, 32), 7); cl_assert_equal_i(sign_extend(7, 3), -1); } void test_math__serial_distance32(void) { { int32_t dist = serial_distance32(0x0, 0x1); cl_assert_equal_i(dist, 1); } ...
gcd(8, 27)
); } void test_math__gcd_basic(void) { cl_assert_equal_i(9, gcd(9, 18)); } void test_math__gcd_basic_reversed(void) { cl_assert_equal_i(9, gcd(18, 9)); } void test_math__gcd_of_number_and_itself(void) { cl_assert_equal_i(10, gcd(10, 10)); }
ecompass_handle_battery_state_change_event(e->battery_state.new_state); #endif return; case PEBBLE_RENDER_READY_EVENT: compositor_app_render_ready(); return; case PEBBLE_ACCEL_SHAKE_EVENT: analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_SHAKE_COUNT, AnalyticsClient_System); if (ba...
#endif return; } case PEBBLE_BLE_SCAN_EVENT: case PEBBLE_BLE_CONNECTION_EVENT: case PEBBLE_BLE_GATT_CLIENT_EVENT: kernel_le_client_handle_event(e); return; case PEBBLE_COMM_SESSION_EVENT: { PebbleCommSessionEvent *comm_session_event = &e->bluetooth.comm_session_event; ...
} //! Tasks that have to be done in between each event. static void event_loop_upkeep(void) { modal_manager_event_loop_upkeep(); } // NOTE: Marking this as NOINLINE saves us 150+ bytes on the KernelMain stack static void NOINLINE prv_handle_event(PebbleEvent *e) { prv_minimal_event_handler(e); // FIXME: This ...
/* * 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_uuid, uuid)
; } void app_message_inbox_receive(CommSession *session, AppMessagePush *push_message, size_t length, AppInboxConsumerInfo *consumer_info) { // Test if the data is long enough to contain a push message: if (length < sizeof(AppMessagePush)) { PBL_LOG(LOG_LEVEL_ERROR, "Too short");...
int i = 0; i < NUM_SUPPORTED_PARAM_COUNT; ++i) { // Consume leading whitespace while (buffer <= buffer_end && *buffer == ' ') { ++buffer; } if (buffer >= buffer_end) { args.num_args = i; return args; } // Yay, a param! args.args[i] = buffer; // Skip over the param and...
dbgserial_putstr("")
prv_try_read_token(const uint8_t *data, uint32_t length) { if (length < sizeof(BlobDBToken)) { return 0; } return *(BlobDBToken*)data; } static void prv_handle_database_insert(CommSession *session, const uint8_t *data, uint32_t length) { if (length < MIN_INSERT_LENGTH) { prv_send_response(session, pr...
PBL_LOG(LOG_LEVEL_ERROR, "BlobDB Command not implemented")
; // Fallthrough default: PBL_LOG(LOG_LEVEL_ERROR, "Invalid BlobDB message received, cmd is %u", cmd); prv_send_response(session, prv_try_read_token(data, data_length), BLOB_DB_INVALID_OPERATION); break; } } void blob_db_protocol_msg_callback(CommSession *session, const uint8_t* data, siz...
= 0; i < ARRAY_LENGTH(metrics); i++) { printf("| ---------------------- "); } float weighted_sum = 0.0; int pass_count = 0; int fail_count = 0; ActivityFileTestEntry *entry = &test_entry[0]; ActivityTestResults *results; for (int i = 0; i < num_tests; i++, entry++, results++) { results = &test_r...
for (int i = start_idx; i < start_idx + len; i++) { samples[i] = (KAlgTestActivityMinute) { .steps = session->steps / len, .active_calories = session->active_calories / len, .resting_calories = session->resting_calories / len, .distance_mm = session->distance_mm / len, }; }
} // ----------------------------------------------------------------------------------- // Feed activity minute data into the kalg_activities_update method static void prv_feed_activity_minutes(KAlgTestActivityMinute *samples, int samples_len) { time_t now = rtc_get_time(); for (int i = 0; i < samples_len; 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...
(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_EVERYDAY })
; prv_assert_alarm_config(id, 4, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); id = alarm_create(&(AlarmInfo) { .hour = 5, .minute = 14, .kind = ALARM_KIND_EVERYDAY }); prv_assert_alarm_config(id, 5, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); id = alarm_create(&(AlarmInfo) { .hour = 6, .min...
return __jerryRefs.ref(Boolean($0)); }, value); } jerry_value_t jerry_create_error(jerry_error_t error_type, const jerry_char_t *message_p) { return jerry_create_error_sz(error_type, message_p, strlen((const char *)message_p)); } #define JERRY_ERROR(type, msg, sz) (jerry_value_t)(EM_ASM_INT({ \ retur...
__jerryRefs.get($0)
Since // current Pebble hardware (at the time of writing) can only have code // in one of a few small ranges, a pointer can be packed into much fewer // than 28 bits while still being able to address a function anywhere in // memory that exists. // // For reference, those ranges are: // 0x0000 0000 - 0x0001 FFFF - I...
serial_distance32(now, animation->abs_start_time_ms)
; const uint32_t interval_ms = MAX(delta_ms, 0) + rate_control_delay_ms; if (animation_legacy2_scheduler->timer_handle != NULL) { app_timer_reschedule(animation_legacy2_scheduler->timer_handle, interval_ms); // Ignore the return value of reschedule. If it fails it probably means the callback is already ...
akeup event has been missed time_t timestamp; //!< The time at which this entry will wake up at bool utc; //!< If timezone has been set, the this is UTC time } WakeupEntry; typedef struct PACKED { WakeupId current_wakeup_id; WakeupId next_wakeup_id; time_t timestamp; } WakeupState; struct prv_missed_events_...
new_timer_scheduled(s_current_timer_id, NULL)
) { new_timer_stop(s_current_timer_id); } mutex_lock(s_mutex); { // Find the next event to occur SettingsFile wakeup_settings; if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) == S_SUCCESS) { // Reset wakeup state to use for the search s_wakeup_state.cu...
Callbacks callbacks = { .tx_power_level_cb = tx_power_level_cb, }; ble_ad_parse_ad_data(ad, &callbacks, &ctx); return ctx.included; } // ----------------------------------------------------------------------------- //! ble_ad_copy_local_name() wrapper and helper function: struct LocalNameCtx { char *buffe...
{ if (prv_ad_is_finalized(ad_data)) { // Already finalized return; } ad_data->scan_resp_data_length = BLE_AD_DATA_FINALIZED; }
// ----------------------------------------------------------------------------- //! Helper to calculate whether a number of bytes will still fit when appended. //! @param length Pointer to the length of the part for which to try to fit in //! size_to_write number of bytes. //! @param size_to_write The number of byte...
464, 448, -632}, { -464, 576, -608}, { -440, 520, -576}, { -432, 520, -584}, { -448, 312, -792}, { -512, 448, -592}, { -600, 488, -616}, { -632, 344, -584}, // 142 seconds { -608, 384, -672}, { -720, 496, -544}, { -664, 432, -472}, { -768, 456, -336}, { -832, 792, -22...
{ -784, 576, -24}, { -736, 528, -128}, { -792, 632, -368}, { -696, 416, -224}, { -736, 888, -168}, { -744, 736, -64}, { -752, 656, -136}, { -616, 416, -320}, { -648, 440, -320}, { -632, 488, -288}, { -568, 616, -432}, { -480, 696, -344}, { -512, 696, -176}, { -552...
{ -376, 656, -728}, { -344, 728, -688}, { -416, 656, -736}, { -416, 552, -712}, { -344, 376, -648}, { -280, 176, -736}, { -232, 144, -824}, { -184, 56, -856}, { -176, 176, -1000}, // 150 seconds { -152, 104, -960}, { -80, 16, -848}, { -64, 0, -944}, { -16, -56, -...
NULL)); cl_assert_equal_i(BITS_BETWEEN(0, 7), erased_sector); cl_assert(flash_locked); } void test_system_flash__erase_sector_0(void) { cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, NULL, NULL)); cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector); cl_assert(flash_locked); } void test_system_flash__era...
{ flash_written_data[address - flash_data_start] = data; }
return return_status; } extern void dbgserial_print(char *str) { fprintf(stderr, "%s", str); } extern void dbgserial_print_hex(uint32_t num) { fprintf(stderr, "0x%.08x", num); } extern void dbgserial_putstr(char *str) { fprintf(stderr, "%s\n", str); }
u Mar 17 14:40:51 2016 PDT const uint16_t cur_millis = 123; fake_time_init(cur_time, cur_millis); jerry_value_t now = rocky_util_create_date(NULL); jerry_value_t getSeconds = jerry_get_object_field(now, "getSeconds"); jerry_value_t getMinutes = jerry_get_object_field(now, "getMinutes"); jerry_value_t getHo...
cl_assert_equal_d(jerry_get_number_value(result_hours), 18.0)
; cl_assert_equal_d(jerry_get_number_value(result_date), 30.0); cl_assert_equal_d(jerry_get_number_value(result_month), 9.0); cl_assert_equal_d(jerry_get_number_value(result_year), 116.0); jerry_release_value(result_year); jerry_release_value(result_month); jerry_release_value(result_date); jerry_release...
/* * 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(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos)
; // union with .palette bmp = gbitmap_create_blank(s10, GBitmapFormat2BitPalette); cl_assert(NULL != bmp); cl_assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette bmp = gbitmap_create_blank(s10, GBitmapFormat4BitPalette); cl_assert(NULL != bmp); cl_assert(g_gbitmap_spa...
/* * 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...
{ init(); app_event_loop(); }
(also triggers the app to start) prv_log_running_apps(dev); // HRM app is ready, enable handshake interrupts prv_interrupts_enable(dev, true); // We are now fully enabled dev->state->enabled_state = HRMEnabledState_Enabled; // Enable the watchdog prv_enable_watchdog(dev); goto done; failed: prv_d...
{ PBL_LOG(LOG_LEVEL_ERROR, "Failed to read AS7000 version info after flashing!"); goto cleanup; }
vity_prefs_workout_app_opened = version; prv_pref_set(PREF_KEY_ACTIVITY_WORKOUT_APP_OPENED, &s_activity_prefs_workout_app_opened, sizeof(s_activity_prefs_workout_app_opened)); } } bool activity_prefs_activity_insights_are_enabled(void) { return s_activity_preferences.activity_insights_enabled;...
{ return s_timeline_settings_opened; }
notification for which we'll get a "Loading..." response: prv_send_notification((uint8_t *)&s_loading_response); cl_assert_equal_i(s_num_requested_notif_attributes, 1); cl_assert_equal_i(s_num_ds_notifications_received, 1); // Assert it got filtered out: cl_assert_equal_i(fake_kernel_services_notifications_a...
cl_assert_equal_i(s_num_ds_notifications_received, 2)
; ns_notification.uid = s_invalid_param_uid; // This will return with an error ANCS_INVALID_PARAM // Should not get re-requested prv_fake_receiving_ns_notification(sizeof(ns_notification), (uint8_t*) &ns_notification); cl_assert_equal_i(s_num_requested_notif_attributes, 3); cl_assert_equal_i(s_num_ds_notif...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
jerry_create_string((jerry_char_t *) field)
; const bool has_property = jerry_has_property(object, prop_name); JS_VAR value = (has_property) ? jerry_get_property(object, prop_name) : jerry_create_undefined(); return jerry_acquire_value(value); } bool rocky_str_equal(jerry_value_t str_js, const char *str) { char buffer[40] = {0}; PBL_ASSERTN(strlen(str...
bitmap here is the bitmap we specified in the .pre function cl_assert_equal_p(bitmap_used, BITMAP_TO_SPECIFY_IN_PRE_FUNCTION); // Check that the rect here is the clipped version of the rect we specified in the .pre function cl_assert_equal_rect(*global_clipped_grect_used, EXPECTED_CLIPPED_RECT_AFTER_DRAWING_BITM...
(s_bitblt_bitmap_into_bitmap_tiled_calls.call_count, 0)
; // Check that the .post function was called even though the .pre function makes some change // that causes no bitmap to be drawn cl_assert(processor.post_func_called); } static void post_function_called_even_if_pre_function_specifies_null_bitmap__pre( GBitmapProcessor *processor, GContext *ctx, const GBitma...
sizeof(Uuid))); cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) == 0); // add 1 back so it's clean cl_assert(S_SUCCESS == reminder_db_insert_item(&item1)); TimelineItem temp = {{{0}}}; cl_assert(S_SUCCESS == reminder_db_read((uint8_t*)&item1.header.id, sizeof(Uuid), (uint8_t*)&temp,...
cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) > 0)
; cl_assert(reminder_db_get_len((uint8_t *)&item2.header.id, sizeof(Uuid)) > 0); // remove the two that share a parent cl_assert_equal_i(reminder_db_delete_with_parent(parent_id), S_SUCCESS); // confirm the two are gone cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) == 0); cl_asser...
lude "timezone_database.h" #include "resource/resource.h" #include "resource/resource_ids.auto.h" #include "services/common/clock.h" #include "system/passert.h" #include <util/attributes.h> #include <util/size.h> #include <string.h> // The format of the database is as follows // Header // 2 bytes - Region count ...
if (!prv_database_read(region_offset + 1 + TIMEZONE_CITY_LENGTH, &tz_data, sizeof(tz_data))) { *tz_info = (TimezoneInfo) { .dst_id = 0 }; return false; }
*tz_info = (TimezoneInfo) { .dst_id = tz_data.dst_id, .timezone_id = region_id, .tm_gmtoff = tz_data.gmt_offset_minutes * SECONDS_PER_MINUTE, // Leave the dst_start and dst_end timestamps uninitialized .dst_start = 0, .dst_end = 0 }; memcpy(tz_info->tm_zone, tz_data.tz_abbr, sizeof(tz_da...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
health_detail_card_create(config)
; window_set_on_screen(window, true, true); window_render(window, &s_ctx); return window; } // Tests ////////////////////// void test_health_detail_card__render_no_data(void) { prv_create_card_and_render(&(HealthDetailCardConfig) {}); cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); } void test...
mand_list); } void test_gdraw_command__validate_image(void) { size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) + (sizeof(GPoint) * 6); GDrawCommandImage *image = malloc(size); GDrawCommandList *command_list = prv_create_command_list_3(); memcpy(&image->command_list, command_list, siz...
gdraw_command_frame_draw(ctx, NULL, frame, GPoint(-1, 1))
; cl_assert_equal_i(s_path_num_points, 2); points[0] = GPoint(0, 2); points[1] = GPoint(1, -1); cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points)); cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points)); free(frame); } static int s_iterations = 0; static bool prv_it...
/* * 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...
gpath_draw_stroke(ctx, &path, command->path_open)
; } } static void prv_draw_circle(GContext *ctx, GDrawCommand *command) { // draw all values of alpha, except fully transparent if ((command->fill_color.a != 0) && (command->radius > 0)) { graphics_context_set_fill_color(ctx, command->fill_color); graphics_fill_circle(ctx, command->points[0], command->ra...
GColorBlack); graphics_context_set_antialiased(ctx, false); graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40)); } void white_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_antialiased(ctx, false); graphics_draw_line(ctx, GPoint(...
layer_set_update_proc(&layer, &across_ny_layer_update_callback)
; layer_render_tree(&layer, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_across_ny_offset_layer"))); } void test_graphics_draw_line__clear(void) { GContext ctx; Layer layer; test_graphics_context_init(&ctx, fb); layer_init(&layer, &GRect(0, 0, 60, 60)); layer_se...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ graphics_context_set_antialiased(ctx, false); graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_round_rect(ctx, &GRect(4, -5, 18, 10), 4, GCornersAll); }
void corners_all_update_callback(Layer* me, GContext* ctx) { graphics_context_set_antialiased(ctx, false); graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_round_rect(ctx, &GRect(2, 2, 28, 20), 4, GCornersAll); } void white_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_se...
tions | ModalProperty_RenderRequested); cl_assert_equal_i(windows[3][1]->on_screen, true); cl_assert_equal_i(windows[3][1]->is_click_configured, false); cl_assert_equal_i(windows[2][1]->on_screen, false); cl_assert_equal_i(windows[2][1]->is_click_configured, false); cl_assert_equal_i(windo...
(modal_stack)
, 1); cl_assert_equal_i(window2->on_screen, true); cl_assert_equal_p(s_last_click_configured_window, window2); // Switch to modal happens via the compositor compositor_transition(NULL); // Call the upkeep function so the change in state is handled modal_manager_event_loop_upkeep(); // The app is now obs...
prv_handle_set_utc_and_timezone_msg(timezone_data)
; break; } default: PBL_LOG(LOG_LEVEL_WARNING, "Invalid message received. First byte is %u", data[0]); break; } } // TODO: Using a regular timer is pretty gross... static void prv_watch_dst(void* user) { const bool was_dst = (bool)user; const bool is_dst = time_get_isdst(rtc_get_time())...
(&iterator)
); cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id)); // check third cl_assert(iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id)); // check second again cl_assert(iter_prev(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id...
ndication( GAPLEConnection *connection, GATTService *service, BTErrno error) { // We experienced some kind of conversion error, pass it on if (error != BTErrnoOK) { prv_send_services_added_event(connection, error); return; } GATTServiceNode *node = kernel_zalloc_check(sizeof(GATTServiceNode)); n...
{ GAPLEConnection *connection = gap_le_connection_by_device(device); if (connection) { if (connection->gatt_is_service_discovery_in_progress) { // Remove any partial jobs which may be pending // since we are going to rediscover everything gatt_client_cleanup_discovery_jobs(connecti...
bt_unlock(); return ret_val; }
ather_glance->icon); } app_free(weather_glance); } static uint32_t prv_get_weather_icon_resource_id_for_type(WeatherType type) { AppResourceInfo res_info; const bool lookup_success = timeline_resources_get_id_system(weather_type_get_timeline_resource_id(type), Timel...
if (!node) { return NULL; }
LauncherAppGlanceWeather *weather_glance = app_zalloc_check(sizeof(*weather_glance)); // Copy the name of the Weather app as a fallback title const size_t fallback_title_size = sizeof(weather_glance->fallback_title); strncpy(weather_glance->fallback_title, node->name, fallback_title_size); weather_glance->f...
reGive(s_send_semaphore); s_blocked_lock = mutex_create_recursive(); prv_initialize_hardware(); accessory_set_power(false); accessory_enable_input(); } void accessory_block(void) { prv_lock(); accessory_send_stream_stop(); uart_deinit(ACCESSORY_UART); } void accessory_unblock(void) { // We want to res...
prv_lock()
; if (s_sent_data) { // wait for the TC flag to be set uart_wait_for_tx_complete(ACCESSORY_UART); // wait a little for the lines to settle down const uint32_t us_to_wait = (1000000 / s_baudrate) * 2; delay_us(us_to_wait); s_sent_data = false; } // Read data and throw it away to clear the ...
// Mask out the unsupported type bits: *subscription_type &= supported; return (*subscription_type != BLESubscriptionNone); } // ------------------------------------------------------------------------------------------------- static void prv_remove_subscription(GAPLEConnection *connection, ...
{ // Write failed, bail out! if (did_create_new_subscription) { // Clean up... prv_remove_subscription(connection, subscription); } else { // ... or restore previous state: subscription->subscriptions[client] = previous_type; } return ret_val; }
y make sense if the insights are enabled // // Now we shouldn't see another notification for the next 6 days // for (int i = 0; i < 6; ++i) { // rtc_set_time(rtc_get_time() + SECONDS_PER_DAY); // activity_insights_recalculate_stats(); // activity_insights_process_sleep_data(rtc_get_time()); // cl_assert_e...
{ prv_set_step_history_avg(); activity_insights_init(rtc_get_time()); // Make sure we don't trigger in the default state (not above median, not active) s_data.steps_per_minute = 0; s_data.metric_history[ActivityMetricStepCount][0] = AVERAGE_STEPS; prv_minute_update(ACTIVE_MINUTES); cl_assert_equal_i(fake...
void test_activity_insights__activity_reward_no_trigger_below_avg(void) { prv_set_step_history_avg(); activity_insights_init(rtc_get_time()); // Make sure that when we are active, we don't trigger without being above average s_data.steps_per_minute = 80; s_data.metric_history[ActivityMetricStepCount][0] = ...
// First point from bottom will be +0, second +1, third +0, etc. separator_start_point.y--; separator_start_point.x += i & 1; graphics_draw_horizontal_line_dotted(ctx, separator_start_point, separator_width); separator_start_point.x -= i & 1; } } } static int16_t prv_get_header_height...
(ctx, &arrow_rect, ContentIndicatorDirectionDown, fg_color, bg_color, GAlignBottom)
; } } #endif } static void prv_update_aml_cache(ActionMenuLayer *aml, int selected_index) { prv_unschedule_item_animation(aml); if (aml->layout_cache.item_heights != NULL) { applib_free(aml->layout_cache.item_heights); aml->layout_cache.item_heights = NULL; } if (aml->num_items > 0) { // Up...
out, &device_out, NULL /* name */); cl_assert(ret); cl_assert_equal_m(&irk_out, &pairing_1.irk, sizeof(irk_out)); cl_assert_equal_m(&device_out, &pairing_1.identity, sizeof(device_out)); // Store another pairing SMPairingInfo pairing_2; memset(&pairing_2, 0x00, sizeof(pairing_2)); pairing_2 = (SMPairingI...
fake_shared_prf_storage_get_ble_store_count()
, 2); // Read all three pairings back ret = bt_persistent_storage_get_ble_pairing_by_id(id_1, &irk_out, &device_out, NULL /* name */); cl_assert(ret); cl_assert_equal_m(&irk_out, &pairing_1.irk, sizeof(irk_out)); cl_assert_equal_m(&device_out, &pairing_1.identity, sizeof(device_out)); ret = bt_persistent_...
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 ...
(validate_test, test_size)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
display_boot_splash()
; delay_ms(1000); } } #endif void display_init(void) { display_start(); if (!prv_reset_fpga()) { dbgserial_putstr("FPGA configuration failed."); return; } // enable the power rails display_power_enable(); // start with the screen off prv_screen_off(); // Work around an issue which some...
/* * 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...
("123", 3)
; update("4567", 4); update("8", 1); assert_checksum(0xfefc54f9); } void test_legacy_checksum__start_and_finish_with_partial(void) { update("12", 2); update("3456", 4); update("78", 2); assert_checksum(0xfefc54f9); } void test_legacy_checksum__long_input(void) { update("1234567890abcdefghijklmnopqrstu...
/* * 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 (s_is_ping_kernel_bg_callback_scheduled) { return; }
// Only send if we haven't sent within the last PING_MIN_PERIOD_SECS time_t current_time = rtc_get_time(); if (current_time < s_last_send_time + PING_MIN_PERIOD_SECS) { return; } // Offload to KernelBG, because we cannot use comm_session_send_data() with bt_lock held. system_task_add_callback(prv_sen...
iting if not held down any longer return false; } delay_ms(1); } return true; } void *reset_vector, *initial_sp; prv_get_fw_reset_vector(&reset_vector, &initial_sp); if ((uintptr_t)reset_vector == 0xffffffff || (uintptr_t)initial_sp == 0xffffffff) { dbgserial_putstr("Firm...
display_error_code(0xdeadbeef)
; delay_us(200000); display_boot_splash(); delay_us(1000000); } #endif if (is_button_stuck()) { sad_watch(ERROR_STUCK_BUTTON); } if (is_flash_broken()) { sad_watch(ERROR_BAD_SPI_FLASH); } boot_bit_dump(); // If the recovery firmware crashed at start-up, the watch is now a // $150...
*)(((uint8_t*)shadow_sublayer) - offsetof(ScrollLayer, shadow_sublayer)); const GPoint content_offset = scroll_layer_get_content_offset(scroll_layer); const GSize content_size = scroll_layer_get_content_size(scroll_layer); const GSize frame_size = scroll_layer->layer.frame.size; GBitmap *shadow_top = shadow_ge...
{ return scroll_layer->content_sublayer.bounds.origin; }
#define STM32F2_COMPATIBLE #define STM32F4_COMPATIBLE #include <mcu.h> #include "bma255_private.h" #include "bma255_regs.h" #define BMA255_SPI SPI3 static const uint32_t BMA255_PERIPH_CLOCK = RCC_APB1Periph_SPI3; static const SpiPeriphClock BMA255_SPI_CLOCK = SpiPeriphClockAPB1; static const AfConfig BMA255_SCLK_CO...
bma255_send_and_receive_byte(data)
h_data_bytes, glyph->data, glyph_size_bytes); glyph = text_resources_get_glyph(&s_font_cache, 0x4E50 /* 乐 */, &s_font_info); // the chinese pbpack contains the letter 你, it should succeed cl_assert(glyph != NULL); glyph_size_bytes = glyph_get_size_bytes(glyph); cl_assert_equal_m(chinese_glyph_data_bytes, gly...
FONT_VERSION(font_info_compressed.base.md.version)
, 3); cl_assert(HAS_FEATURE(font_info_compressed.base.md.version, VERSION_FIELD_FEATURE_RLE4)); // For each glyph in the font, get both the compressed and uncompressed bit field & header, and // assert that they are identical (ignoring any possible garbage after the bitmap). // Load the uncompressed glyph into...
continue; } // End of a sample if (strcmp(token, "}") == 0) { PBL_ASSERTN(state->test_entry.name[0] != 0); break; } } // Did we get samples? if (state->test_entry.num_samples > 0) { return true; } else { return false; } } // ---------------------------------------------...
if (!state->common.file) { if (!prv_sample_discovery_next_file(&state->common)) { return false; } }
// Parse next set of samples in the current file bool success = prv_parse_activity_samples_file(state); if (success) { *entry = state->test_entry; return true; } else { // No more in this file fclose(state->common.file); state->common.file = NULL; } } } // -------...
ine_in_perimeter_space.y; if (distance_to_page_end < line->height_px + TEXT_LINE_DESCENDER_LINE(line)) { // If this line would exceed the page_height, shift the line origin to the next page line->origin.y += distance_to_page_end; continue; // skip rendering this round, bypasses iter_next...
{ *current_word_ref = prev_line_word; prv_apply_orphan_state(&orphan_state, line); avoiding_orphans = false; // prevent infinte loops goto render_line; }
} if (callbacks->render_line_cb) { callbacks->render_line_cb(ctx, line, text_box_params); } } prev_line_word = word_before_rendering; if (callbacks->layout_update_cb) { callbacks->layout_update_cb(layout, line, text_box_params); } if (callbacks->stop_condition_cb) ...
/* * 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...
(af_config->gpio)
; GPIO_Init(af_config->gpio, &init); GPIO_WriteBit(af_config->gpio, af_config->gpio_pin, asserted? Bit_SET : Bit_RESET); gpio_release(af_config->gpio); } void gpio_input_init(const InputConfig *input_config) { if (input_config->gpio == NULL) { // TODO: PBL-15063 return; } gpio_inpu...
t); } static void prv_cancel_dictation(VoiceUiData *data) { if ((data->state != StateStart) && (data->state != StateFinished) && (data->state != StateExiting) && (data->state != StateError)) { VOICE_LOG("Cancel dictation session"); sys_voice_cancel_dictation(data->session_id); data->session_id = VO...
{ text_layer_set_text(&data->mic_window.text_layer, ""); layer_set_hidden((Layer *)&data->mic_window.text_layer, true); }
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ return; }
GPath path = { .num_points = command->num_points, .points = command->points }; // draw all values of alpha, except fully transparent if ((command->fill_color.a != 0)) { graphics_context_set_fill_color(ctx, command->fill_color); gpath_draw_filled(ctx, &path); } if ((command->stroke_color.a !...
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 "comm/ble/gatt_service_changed.h" #include "comm/ble/gap_le_connection.h" #include "bluetop...
(true /* is_subscribing */)
it->it.should_continue = false; it->did_change_selection = true; } } static void prv_menu_layer_iterator_update_selection(MenuIterator *iterator) { MenuLayer *menu_layer = iterator->menu_layer; if (menu_index_compare(&iterator->cursor.index, &menu_layer->selection.index) == 0) { menu_layer->selectio...
(state.menu_layer, MenuRowAlignCenter, false)
; prv_menu_layer_update_selection_highlight(state.menu_layer, state.up, false, false); state.menu_layer->inverter.layer.frame.size.h += abs_content_offset; state.menu_layer->inverter.layer.bounds.size = state.menu_layer->inverter.layer.frame.size; // when scrolling up, bounce back at the top (otherwise...
prv_process_sent_data()
; cl_assert_equal_i(s_out_sent_call_count, 0); cl_assert_equal_i(s_out_failed_call_count, 1); cl_assert_equal_i(s_failure_result, APP_MSG_SEND_TIMEOUT); // Check the state is reset properly cl_assert_equal_b(app_message_is_accepting_outbound(), true); } void test_app_message__send_rejected(void) { // Sen...
aw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw3_clip_nxny.${BIT_DEPTH_NAME}.pbi")); // TODO: Fix offset calculation and reenable this: - PBL-16509 #if SCREEN_COLOR_DEPTH_BITS == 8 // AA = true, SW = 4 setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP...
(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi")); // SW = 3 setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 3); graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw3_...
ssian.net/browse/PBL-20406 #define DICTATION_TIMEOUT (15 * 1000) // 15s timeout for each dictation #define SPEECH_DETECTION_TIMEOUT (3 * 1000) // Session must last at least 600ms before reporting an error to the user #define MIN_ELAPSED_DURATION (600) #define TEXT_PADDING (4) #define MIC_DOT_MAX_RADIUS (9) #de...
prv_put_analytics_event(data, (result == DictationSessionStatusSuccess))
; } sys_light_reset_to_timed_mode(); prv_teardown(data); } static void prv_handle_error_retries(VoiceUiData *data) { if (data->error_count < MAX_ERROR_COUNT) { VOICE_LOG("Restarting dictation after error"); prv_start_dictation(data); } else { VOICE_LOG("Too many errors! Exiting..."); prv_ex...
/* * 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_encode_tag_for_field(stream, field)
) { return false; } const char *str = *(char **)arg; return pb_encode_string(stream, (uint8_t *)str, strlen(str)); } bool protobuf_log_util_encode_packed_varints(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) { PLogPackedVarintsEncoderArg *enc...
f(GPath)); if (path) { gpath_init(path, init); } else { APP_LOG(APP_LOG_LEVEL_ERROR, GPATH_ERROR); } return path; } void gpath_destroy(GPath* gpath) { applib_free(gpath); } static GPoint rotate_offset_point(const GPoint *orig, int32_t rotation, const GPoint *offset) { int32_t cosine = cos_lookup(r...
{ max_x = path->points[i].x; }
if (path->points[i].x < min_x) { min_x = path->points[i].x; } if (path->points[i].y > max_y) { max_y = path->points[i].y; } if (path->points[i].y < min_y) { min_y = path->points[i].y; } } return GRect(min_x, min_y, (max_x - min_x), (max_y - min_y)); } #if PBL_COLOR void p...
value, &value_length, &has_more); if (handler) { handler(object_ref, value, value_length, 0 /* value_offset (future proofing) */, gatt_error); } value_length = next_value_length; } applib_free(value); } static void pr...
(&ble_app_state->gatt_client_service_info)
; } } } return BTErrnoOK; } BTErrno ble_client_set_service_filter(const Uuid service_uuids[], uint8_t num_uuids) { // TODO return 0; } BTErrno ble_client_set_service_change_handler(BLEClientServiceChangeHandler handler) { const off_t offset = offsetof(BLEAppSt...
, .draw_text.color = ctx->draw_state.text_color, }; strncpy(s_graphics_draw_text.last_call.draw_text.text, text, sizeof(s_graphics_draw_text.last_call.draw_text.text)); } static MockCallRecordings s_graphics_text_attributes_destroy; void graphics_text_attributes_destroy(GTextAttributes *text_attribut...
EXECUTE_SCRIPT("_rocky.on('draw', function() {});")
; cl_assert_equal_b(true, rocky_global_has_event_handlers("draw")); } void test_rocky_api_graphics__draw_event_has_ctx(void) { rocky_global_init(s_graphics_api); EXECUTE_SCRIPT( "var event = null;\n" "_rocky.on('draw', function(e) {event = e;});" ); const jerry_value_t event_null = prv_js_global_ge...
/* * 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...
(7, 18, 36, 44)
, grect_inset_internal(rect, -3, -2)); } void test_gtypes__grect_inset_standardizes(void) { GRect rect = GRect(100, 100, -30, -40); cl_assert_equal_grect(GRect(70, 60, 30, 40), grect_inset_internal(rect, 0, 0)); cl_assert_equal_grect(GRect(72, 63, 26, 34), grect_inset_internal(rect, 2, 3)); } void test_gtypes__...
bs/stubs_passert.h" InterpolateInt64Function s_animation_private_current_interpolate_override; InterpolateInt64Function animation_private_current_interpolate_override(void) { return s_animation_private_current_interpolate_override; } void test_animation_interpolate__initialize(void) { s_animation_private_current...
(0, -20000, 20000, &s_custom_moook)
); // mid frame is closer to end due to more end frames cl_assert_equal_i(6683, interpolate_moook_custom(ANIMATION_NORMALIZED_MAX / 2, -20000, 20000, &s_custom_moook)); cl_assert_equal_i(20000, interpolate_moook_custom(ANIMATION_NORMALIZED_MAX, -20000, 20000, ...
orizontal Alignment"), [DisplayCalibrationState_Y_Adjust] = i18n_noop("Vertical Alignment"), [DisplayCalibrationState_Confirm] = i18n_noop("Confirm Alignment") }; const char *instructions[] = { [DisplayCalibrationState_X_Adjust] = i18n_noop("Up/Down to adjust\nSelect to proceed"), [DisplayCalibratio...
if ((data->state == DisplayCalibrationState_Y_Adjust) || (data->state == DisplayCalibrationState_Confirm)) { prv_draw_border_stripe(layer, ctx, GAlignTop); prv_draw_border_stripe(layer, ctx, GAlignBottom); }
tionNode)); BTErrno e = gatt_client_subscriptions_subscribe(prv_get_indicatable_characteristic(), BLESubscriptionIndications, GAPLEClientKernel); cl_assert_equal_i(e, BTErrnoNotEnoughResources); fake_kernel_malloc_...
cl_assert_equal_i(e, BTErrnoOK)
; // Should not be written again, because BLESubscriptionIndications was already written: cl_assert_equal_i(s_last_cccd_value, (uint16_t) ~0); fake_event_clear_last(); // Simulate getting confirmation from remote: prv_confirm_cccd_write(BLEGATTErrorSuccess); // Expect one event for both Kernel + App: p...
the end of each row const int bytes = bitmap->row_size_bytes - 2; uint8_t *const left_pixel = buf; uint8_t *const right_pixel = buf + delta_bytes; const uint8_t fill_byte = (delta_neg ? (buf[bytes - 1] & 0x80) : buf[0] & 1) ? 0xFF : 0; if (pixels_to_move <= 0) { // ...
(bitmap, y)
; switch (bpp) { case 1: { // Note: this doesn't care about the bounding, because we don't have any round 1bpp // devices to support, and it simplifies the code. #if PBL_ROUND WTF; #endif memmove(dst_row_info.data, src_row_info.data, bitmap->row_size_bytes); break; ...
/* * 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((void*)&bmp->palette == (void*)&bmp->data_row_infos)
; // union with .palette cl_assert(NULL != g_gbitmap_spalding_data_row_infos); // make sure unit-test fixture is ok #ifdef PLATFORM_TINTIN cl_assert(!process_manager_compiled_with_legacy2_sdk()); bmp = gbitmap_create_blank(s10, GBitmapFormat1Bit); cl_assert(NULL != bmp); cl_assert(NULL == bmp->data_row_info...
s: case ActivityMetricSleepStateSeconds: case ActivityMetricLastVMC: case ActivityMetricHeartRateRawBPM: case ActivityMetricHeartRateRawQuality: case ActivityMetricHeartRateRawUpdatedTimeUTC: case ActivityMetricHeartRateFilteredBPM: case ActivityMetricHeartRateFilteredUpdatedTimeUTC: cas...
{ return rv; }
rv = settings_file_set(&file, key, key_len, val, val_len); prv_file_close_and_unlock(&file); } prv_notify_health_listeners((const char *)key, key_len, val, val_len); return rv; } int health_db_get_len(const uint8_t *key, int key_len) { if (!prv_key_is_valid(key, key_len)) { return E_INVALID_ARG...
void prv_action_system_task_callback(void *data) { InvokeActionMsgCbData *action = data; comm_session_send_data(comm_session_get_system_session(), TIMELINE_ACTION_ENDPOINT, (uint8_t *)&action->msg, action->length, COMM_SESSION_DEFAULT_TIMEOUT); kernel_free(action); } static ActionResultType prv_get_act...
system_task_add_callback(prv_action_system_task_callback, invoke_action_data)
; } else { comm_session_send_data(comm_session_get_system_session(), TIMELINE_ACTION_ENDPOINT, (uint8_t *)&invoke_action_data->msg, invoke_action_data->length, COMM_SESSION_DEFAULT_TIMEOUT); kernel_free(invoke_action_data); } } void timeline_action_endpoint_protocol_msg_callback(CommSession...
/* * 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_valid_page_idx)
; } static SprfMagic prv_get_magic_for_page(uint32_t page) { SprfMagic magic; flash_read_bytes((uint8_t *)&magic, SPRF_PAGE_FLASH_ADDR(page), sizeof(magic)); return magic; } // // Struct validators // //! Pass a field (starting at address of CRC) and a field size. Return whether the field is valid. //! A valid...
ent, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0, &GPoint(13, 13), 40, 6, true); touch_handle_update(0, TouchState_FingerUp, &GPoint(18, 5), 0, 3686440); // Test the same event (event at index 1): it should update to reflect the difference between this // and the first event and ...
touch_event_queue_get_event(0, 0)
a255_write_register(BMA255Register_EXTENDED_MEMORY_MAP, BMA255_EXTENDED_MEMORY_MAP_OPEN); bma255_write_register(BMA255Register_TEMPERATURE_SENSOR_CTRL, BMA255_TEMPERATURE_SENSOR_DISABLE); bma255_write_register(BMA255Register_EXTENDED_MEMORY_MAP, BMA255_EXTENDED_MEMORY_MAP_CLOSE); exti_configure_pin(BOARD_CONFIG_...
{ uint8_t buf[BMA255_FIFO_FRAME_SIZE_BYTES]; for (int j = 0; j < BMA255_FIFO_FRAME_SIZE_BYTES; ++j) { buf[j] = bma255_send_and_receive_byte(0); } prv_convert_accel_raw_data_to_mgs(buf, &data[i]); }
bma255_end_txn(); // Timestamp & Dispatch data for (int i = 0; i < num_samples_available; ++i) { // Make a timestamp approximation based on the current time, the sample // being processed and the sampling interval. data[i].timestamp_us = timestamp_us - ((num_samples_available - i) * sampling_interva...
c; uint32_t miliseconds = seconds * 1000 + now_ms; uint32_t rotation = miliseconds * TRIG_MAX_ANGLE / (60 * 1000); GPointPrecise p0; GPointPrecise p1; p0.x.raw_value = (data->canvas_layer->bounds.size.w / 2) * FIXED_S16_3_ONE.raw_value; p0.y.raw_value = (data->canvas_layer->bounds.size.h / 2) ...
layer_destroy(data->debug_layer)
; } static void init(void) { AppData *data = task_zalloc(sizeof(AppData)); if (!data) { return; } s_window = window_create(); window_set_user_data(s_window, data); window_set_fullscreen(s_window, true); window_set_window_handlers(s_window, &(WindowHandlers) { .load = main_window_load, .unloa...
/* * 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...
gap_le_connection_add(&s_device, NULL, false /* local_is_master */)
; s_connection = gap_le_connection_by_device(&s_device); cl_assert(s_connection); s_connection->gatt_connection_id = s_connection_id; } void test_gatt_service_changed_server__cleanup(void) { if (s_connection) { gap_le_connection_remove(&s_device); s_connection = NULL; } gap_le_connection_deinit(); ...
*error) { JS_VAR locale = argc >= 1 ? jerry_acquire_value(argv[0]) : jerry_create_undefined(); JS_VAR options = argc >= 2 ? jerry_acquire_value(argv[1]) : jerry_create_object(); if (!prv_matches_system_locale(locale)) { if (error) { *error = rocky_error_argument_invalid("Unsupported locale"); } ...
{ jerry_value_t error = jerry_create_undefined(); char buffer[BUFFER_LEN_DATETIME] = {0}; // we allow users to pick from any option to here const size_t total_len = prv_to_locale_buffer(this_val, argc, argv, ToStringFormatEmpty, ...
// static void prv_rocky_add_date_functions(jerry_value_t global) { JS_VAR date_constructor = jerry_get_object_field(global, "Date"); JS_VAR date_prototype = jerry_get_object_field(date_constructor, "prototype"); JS_VAR locale_time_string = jerry_create_external_function(prv_to_locale_time_string); jerry_set_...
oredump_flash_base(uint32_t *addr, uint32_t *size) { CoreDumpFlashHeader flash_hdr; CoreDumpFlashRegionHeader region_hdr; uint32_t max_last_used = 0; uint32_t base_address; uint32_t last_used_idx = 0; // First, see if the flash header has been put in place flash_read_bytes((uint8_t *)&flash_hdr, CORE_DUM...
flash_write_bytes(request->data, request->address, length)
; } static void prv_handle_flash_read_request(const void *payload, uint32_t length) { if (length < sizeof(FlashReadRequest)) { PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length); return; } const FlashReadRequest *request = payload; if (request->length > MAX_DATA_LENGTH) { PBL_LOG(LOG_L...
bitmap, "fill_rect_origin_r1_aa_no_clip.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1); graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 2, GCornersAll); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r2_aa_no_clip.${BIT_DEPTH_NAME}.p...
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, 1, GCornersAll)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r1_aa_clip_xy.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1); graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, 2, GCornersAll); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_or...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ PBL_LOG(LOG_LEVEL_WARNING, "Received stop message from phone after audio session " "stopped/cancelled"); return; }
// TODO: Handle this better: there is no feedback to the UI that we've stopped recording s_state = SessionState_WaitForSessionResult; prv_stop_recording(); prv_start_result_timeout(); } static void prv_start_recording(void) { #if !defined(TARGET_QEMU) // TODO: reenable // PBL_ASSERTN(mic_start(MIC, &prv_...
uration = 30, }; frame->command_list = (GDrawCommandList) { .num_commands = 1 }; command = gdraw_command_list_get_command(&frame->command_list, 0); points2[0].x++; // increment x value to distinguish draw command from command in previous frame *command = (GDrawCommand) { .type = GDrawCommandTypePath...
(sequence, 0)
56}, { -448, 736, 248}, { -456, 728, 248}, { -448, 728, 264}, { -448, 728, 256}, { -440, 736, 256}, { -448, 736, 256}, { -448, 744, 248}, { -416, 688, 288}, { -504, 784, 304}, { -424, 704, 224}, { -472, 736, 224}, { -480, 728, 240}, { -456, 720, 272}, { -472, 768,...
{ -472, 728, 232}, { -464, 728, 232}, { -472, 712, 256}, { -464, 720, 248}, { -464, 720, 240}, // 155 seconds { -464, 728, 240}, { -480, 712, 240}, { -456, 720, 240}, { -456, 720, 232}, { -464, 736, 248}, { -456, 736, 232}, { -472, 720, 256}, { -456, 728, 232}, ...
from 8 bits in a byte, taking care to round up to the next whole byte. const uint32_t required_row_size_bytes = (required_row_size_bits + 7) / 8; if (data_size != required_total_size_bytes || required_row_size_bytes > bitmap->row_size_bytes) { PBL_LOG(LOG_LEVEL_WARNING, "Bitmap metadata is inconsistent!...
(!process_manager_compiled_with_legacy2_sdk())
onger return false; } delay_ms(1); } return true; } void *reset_vector, *initial_sp; prv_get_fw_reset_vector(&reset_vector, &initial_sp); if ((uintptr_t)reset_vector == 0xffffffff || (uintptr_t)initial_sp == 0xffffffff) { dbgserial_putstr("Firmware is erased"); return...
{ if (!fw_copy_switch_to_recovery_fw()) { // We've failed to load recovery mode too many times. prv_sad_watch(ERROR_CANT_LOAD_FW); } }
// Lookup app, and if installed, launch if (app_id != INSTALL_ID_INVALID) { PebbleLaunchAppEventExtended* data = kernel_malloc_check(sizeof(PebbleLaunchAppEventExtended)); *data = (PebbleLaunchAppEventExtended) { .common.reason = APP_LAUNCH_WAKEUP, .wakeup.wakeup_id = wakeup...
// next catchup_enabled state before modifying time_difference s_catchup_enabled = (time_difference < 0) ? true : false; // Enforces the catchup gap to be at least WAKEUP_CATCHUP_WINDOW gap time_difference = MAX(time_difference, WAKEUP_CATCHUP_WINDOW); } // timers are in milliseconds, s...
static void prv_migrate_events_callback(SettingsFile *old_file, SettingsFile *new_file, SettingsRecordInfo *info, void *utc_diff) { if (!utc_diff || info->key_len != sizeof(WakeupId) || info->val_len != sizeof(WakeupEntry)) { return; } WakeupId wakeup_id; info->get_val(old_file, (uint8_t*)&wakeup_id...