prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
ingFormatYear2Digit: // yes, we want to keep leading zeros in both cases for year as we control the format // exclusively via the strftime format return false; } return false; } static size_t prv_to_locale_buffer(jerry_value_t this_val, jerry_length_t argc, cons...
{ return prv_to_locale_time_or_date_string(this_val, argc, argv, ToStringFormatLocaleDate, ToStringFormatEmpty); }
JERRY_FUNCTION(prv_to_locale_string) { 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, ToStringFormatEm...
!s_running) { PBL_LOG(LOG_LEVEL_ERROR, "Accel Not Running"); return; } // accel output registers have adjacent addresses // MSB enables address auto-increment int num_bytes = 6 * num_samples; // Overflow bit doesn't get cleared until number of samples in fifo goes below // the watermark. Read an e...
vibes_get_vibe_strength()
== VIBE_STRENGTH_OFF) { PebbleEvent e = { .type = PEBBLE_CALLBACK_EVENT, .callback = { .callback = prv_handle_tap, .data = NULL } }; *should_context_switch = event_put_isr(&e); } } void accel_set_running(bool running) { s_running = running; } void accel_set_num_samp...
52, 216, -904}, { 112, 328, -872}, { 136, 328, -752}, { 144, 392, -744}, { 144, 456, -600}, { 56, 384, -408}, { 32, 760, -424}, { -128, 888, -184}, { -216, 944, 40}, { -272, 1008, 136}, { -256, 944, 296}, { -200, 1024, 416}, { -168, 952, 608}, { -48, 856, 560}, { ...
{ -1088, 96, 88}, { -1024, 88, 112}, { -960, 112, 112}, { -1064, 64, 128}, { -1008, -168, 144}, { -1040, -136, 48}, { -1280, 8, -32}, { -1264, 128, -144}, { -1464, 128, -184}, { -1424, -224, 16}, { -1320, -216, 56}, { -1232, 40, 8}, // 8 seconds { -1120, 208, 168}...
{ -1216, 208, -64}, { -1184, 224, 176}, { -1304, 344, -24}, { -1496, 656, -104}, { -1192, 1592, -192}, { -1192, 576, -408}, { -1056, 688, -328}, { -1432, 976, -144}, { -1400, 744, -16}, { -1368, 456, 32}, { -1576, 360, 160}, { -1696, 296, 240}, { -1536, 216, 176}, ...
/* * 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...
(system_flash_erase(FLASH_BASE, 1, NULL, NULL))
; cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector); cl_assert(flash_locked); } void test_system_flash__erase_one_byte_in_middle_of_sector(void) { cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL)); cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector); cl_assert(flash_locked); } void test_s...
_items[4] cl_assert_equal_i(pin_db_delete((uint8_t *)&s_items[0].header.id, sizeof(Uuid)), 0); // next item should be items 4, going back should skip over items[0] cl_assert(iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id)); cl_assert(!iter_prev(&iterator)); timelin...
(uuid_equal(&state.pin.header.id, &multiday_item.header.id))
; cl_assert(uuid_equal(&state.node->id, &multiday_item.header.id)); cl_assert(state.node->all_day); cl_assert_equal_i(state.node->timestamp, 1425369600); cl_assert_equal_i(state.node->duration, MINUTES_PER_DAY); cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY); // no more cl_a...
test_circular_buffer__copy(void) { CircularBuffer buffer; uint8_t storage[8]; circular_buffer_init(&buffer, storage, sizeof(storage)); const uint16_t data_out_size = 8; uint8_t data_out[data_out_size]; // Test copy when there is nothing in the buffer: cl_assert_equal_i(circular_buffer_copy(&buffer, data...
(copy_out, "234567", 6)
, 0); contiguous_num_bytes_left = circular_buffer_write_prepare(&buffer, &data_out); cl_assert_equal_i(contiguous_num_bytes_left, 2); memcpy(data_out, "AB", 2); circular_buffer_write_finish(&buffer, 2); cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_size), 8); cl_assert_equal_i(memcmp(...
/* * 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...
(validate_test, test_size)
; cl_assert_equal_p(result, false); s_test_transcription_example[26] = 5; // invalidate word length of first word in second sentence result = transcription_validate(validate_test, test_size); cl_assert_equal_p(result, false); s_test_transcription_example[26] = 4; // restore word length of first word in sec...
/* * 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...
perimeter_for_circle( (GRangeVertical) {.origin_y = y, .size_h = 0}, center, radius)
; // internally we use integer_sqrt, which causes precision loss // so we need to mirror some of the fixed point truncation here int16_t height = 90 - y; int16_t width = sqrt(radius * radius - height * height); int16_t test_origin = 90 - width; // Due to integer math and truncation, we nee...
/* * 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...
{ SettingsAppData *data = window_get_user_data(window); // Create the menu GRect bounds = data->window.layer.bounds; #if PBL_ROUND bounds = grect_inset_internal(bounds, 0, SETTINGS_CATEGORY_MENU_CELL_UNFOCUSED_ROUND_VERTICAL_PADDING); #endif MenuLayer *menu_layer = &data->menu...
erator *iter, const uint32_t key, const uint32_t value) { return dict_write_data_internal(iter, key, (const uint8_t * const) &value, sizeof(value), TUPLE_UINT); } DictionaryResult dict_write_int8(DictionaryIterator *iter, const uint32_t key, const int8_t value) { return dict_write_data_internal(iter, key, (const u...
{ return dict_write_data_internal(iter, tuple->key, (uint8_t*)tuple->value, tuple->length, tuple->type); }
DictionaryResult dict_write_tuplet(DictionaryIterator *iter, const Tuplet * const tuplet) { if (iter == NULL || iter->dictionary == NULL || iter->cursor == NULL) { return DICT_INVALID_ARGS; } switch (tuplet->type) { case TUPLE_BYTE_ARRAY: return dict_write_data_internal(iter, tuplet->k...
frame.size.w, frame.origin.y + DIV_X(frame.size.h * MULT_X((cur - limit_b), (limit_c - limit_b)))); } else if (cur <= limit_d) { // zone c - d return GPoint(frame.origin.x + DIV_X(frame.size.w * (1000 - MULT_X((cur - limit_c), (limit_d - limit_c)))...
(ctx, &path)
; #if PBL_COLOR graphics_context_set_stroke_color(ctx, color); gpath_draw_outline(ctx, &path); #else graphics_context_set_stroke_color(ctx, GColorWhite); GRect inner_bounds = grect_inset(outer_bounds, GEdgeInsets(fill_thickness)); graphics_draw_rect(ctx, &inner_bounds); inner_bounds = grect_inset(inner_bou...
r to be called. This will end up rescheduling us for // the right time once that gets handled. } else { animation_legacy2_scheduler->timer_handle = app_timer_register(interval_ms, (AppTimerCallback) animation_legacy2_timer_callback, animation_legacy2_scheduler); PBL_ASSE...
(AppTaskCtxIdxApp)
; } bool animation_legacy2_is_scheduled(AnimationLegacy2 *animation) { AnimationLegacy2Scheduler *animation_legacy2_scheduler = get_current_scheduler(); return list_contains(animation_legacy2_scheduler->head, &animation->list_node); } static void animation_legacy2_private_run(AnimationLegacy2Scheduler *animation_...
pio_output_set(&out_scl, true); bool recovered = false; for (int i = 0; i < MAX_TOGGLE_COUNT; ++i) { gpio_output_set(&out_scl, false); delay_ms(TOGGLE_DELAY); gpio_output_set(&out_scl, true); delay_ms(TOGGLE_DELAY); if (gpio_input_read(&in_sda)) { recovered = true; break; } }...
{ // Timeout, abort transfer i2c_hal_abort_transfer(bus); complete = true; PBL_LOG(LOG_LEVEL_ERROR, "Transfer timed out on bus %s", bus->name); break; }
} while (!complete); // Return semaphore token so another transfer can be started prv_semaphore_give(bus->state); // Wait for bus to to clear the busy flag before a new transfer starts // Theoretically a transfer could complete successfully, but the busy flag never clears, // which would cause the next t...
/* * 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...
(ADC1, ADC_FLAG_OVR)
== SET) { ADC_ClearFlag(ADC1, ADC_FLAG_OVR); ADC_ClearFlag(ADC1, ADC_FLAG_EOC); return false; } } return true; } void voltage_monitor_read(const VoltageMonitorDevice *device, VoltageReading *reading_out) { PBL_ASSERTN(device->adc == ADC1); mutex_lock(s_adc_mutex); periph_config_enable...
uint8_t stroke_width) { graphics_circle_quadrant_draw_stroked_non_aa(ctx, p, radius, stroke_width, GCornersAll); } // Lifted directly from: http://en.wikipedia.org/wiki/Midpoint_circle_algorithm void graphics_draw_circle(GContext* ctx, GPoint p, uint16_t radius) { ...
if (section & GCornersTop) { prv_fill_horizontal_line(ctx, GPoint(x0 - x, y0 - y), 2 * x + 1); prv_fill_horizontal_line(ctx, GPoint(x0 - y, y0 - x), 2 * y + 1); }
} } MOCKABLE void graphics_circle_fill_non_aa(GContext* ctx, GPoint p, uint16_t radius) { prv_fill_horizontal_line(ctx, GPoint(p.x - radius, p.y), 2 * radius + 1); graphics_fill_half_circle(ctx, p.x, p.y, radius, GCornersAll); } #if PBL_COLOR MOCKABLE void graphics_internal_circle_quadrant_fill_aa(GContext* ct...
GRect frame) { layer_set_frame(layer, &frame); } void layer_get_frame(const Layer *layer, GRect *frame) { *frame = layer->frame; } GRect layer_get_frame_by_value(const Layer *layer) { GRect frame; layer_get_frame(layer, &frame); return frame; } void layer_set_bounds(Layer *layer, const GRect *bounds) { ...
{ if (below_layer->parent == NULL) { return; } if (layer_to_insert->parent) { layer_remove_from_parent(layer_to_insert); } PBL_ASSERTN(layer_to_insert->next_sibling == NULL); layer_to_insert->parent = below_layer->parent; layer_set_window(layer_to_insert, below_layer->window); if (layer_to_inser...
// Above means lower down in the hierarchy so it gets drawn later, // and as a result the drawn on top of what's below it. void layer_insert_above_sibling(Layer *layer_to_insert, Layer *above_layer) { if (above_layer->parent == NULL) { return; } if (layer_to_insert->parent) { layer_remove_from_parent(la...
igured, false); cl_assert_equal_p(s_last_click_configured_window, windows[3][0]); // Add priority 3 transparent window 1 window_set_transparent(windows[3][1], true); window_stack_push(window_stacks[3], windows[3][1], false); // A transparent window is now the top window, and there is another transparent win...
cl_assert_equal_i(windows[2][1]->is_click_configured, false)
/* * 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...
grect_inset(DISP_FRAME, GEdgeInsets(-overdraw))
, GOvalScaleModeFitCircle, thickness + overdraw, 0, TRIG_MAX_ANGLE); } // piecewise interpolator between 0 and to for the first half of ANIMATION_NORMALIZED_MAX // and between -to and 0 for the second half static int16_t prv_interpolate_two_ways_int16(AnimationProgress normalized_progress, ...
.did_vibrate = false, .timestamp = start_ms }; } fake_accel_service_invoke_callbacks(accel_data, j); // Advance time fake_rtc_increment_time(1); fake_rtc_increment_ticks(configTICK_RATE_HZ); // Is it time to call the minute callback? utc_secs += 1; if ((utc_secs %...
{ if (s_health_sessions_count >= s_health_sessions_max) { return false; } // Update bed and awake time if appropriate if (activity == HealthActivitySleep) { if (s_health_sessions_sleep_time == 0) { s_health_sessions_sleep_time = time_start; } if ((s_health_sessions_awake_time == 0) || (ti...
static void prv_sleep_sessions_using_health_service(uint32_t *session_entries, ActivitySession *sessions, HealthIterationDirection direction) { time_t now = rtc_get_time(); s_health_sessions_count = 0; s_heal...
ibutes, 5); cl_assert_equal_i(s_num_ds_notifications_received, 5); } extern ANCSClientState prv_get_state(void); extern void prv_check_ancs_alive(void); void test_ancs__alive_check_disconnection(void) { prv_check_ancs_alive(); // check we're in the alive check state and we sent a single request cl_assert_equ...
ancs_invalidate_all_references()
; cl_assert_equal_i(fake_event_get_last().type, PEBBLE_ANCS_DISCONNECTED_EVENT); // Make sure that losing BT altogether sends the event ancs_destroy(); cl_assert_equal_i(fake_event_get_last().type, PEBBLE_ANCS_DISCONNECTED_EVENT); fake_event_clear_last(); } void test_ancs__unrequested_notifications(void) { ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
GPIO_WriteBit(BOARD_CONFIG.photo_en.gpio, BOARD_CONFIG.photo_en.gpio_pin, Bit_RESET)
((const jerry_char_t *)model_name)
; } else { // Assume we're running on QEMU const char *platform_name = prv_get_platform_name_string(); const char *qemu_prefix = "qemu_platform_"; char combined_string[strlen(qemu_prefix) + strlen(platform_name) + 1]; strcpy(combined_string, qemu_prefix); strcat(combined_string, platform_name)...
(angle); t_c = GTransform(GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO), GTransformNumberFromNumber(-(float)sine / TRIG_MAX_RATIO), GTransformNumberFromNumber((float)sine / TRIG_MAX_RATIO), GTransformNumberFromNumber((float)cosine / TRIG_MAX_RATIO...
(&t_new, &t_c)
); cl_assert(gtransform_is_equal(&t1, &t2)); // ensure t1 has not changed // Test pointer re-use gtransform_translate(&t1, &t1, GTransformNumberFromNumber(10), GTransformNumberFromNumber(200)); cl_assert(gtransform_is_equal(&t1, &t_c)); } void test_graphics_gtransform_${BIT_DEPTH_NAME}__rotation(void) { GT...
return true; } return false; } static bool prv_find_existing_notification(TimelineItem *notification, CommonTimelineItemHeader *existing_header_out) { // PBL-9509: iOS' Calendar app uses the timestamp of the ANCS notification for the time of the // event, not the ti...
(&app_id->pstr, app_id_buffer)
; PBL_LOG(LOG_LEVEL_INFO, "Ignoring notification from <%s>: Muted", app_id_buffer); analytics_inc(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_FILTERED_BECAUSE_MUTED_COUNT, AnalyticsClient_System); return true; } // filter out mail buggy mail messages if (prv_should_ignore_because_app...
; // Reminders come first, then everything else. More recent reminders should appear before older // reminders and more recent notifications should appear before older notifications if (type_b == NotificationReminder) { return 1; } else if (type_b != NotificationReminder && type_a != NotificationReminder) ...
(data->peek_layer)
nalytics_inc(ANALYTICS_DEVICE_METRIC_HRM_ACCEL_DATA_MISSING, AnalyticsClient_System); num_new_samples = MAX_BUFFERED_SAMPLES - s_manager_state.accel_data.num_samples; } void *write_ptr = &s_manager_state.accel_data.data[s_manager_state.accel_data.num_samples]; memcpy(write_ptr, s_manager_state.accel_manager_...
{ // If it's been past the tolerable startup time, we have a valid reading - even though it // may indicate off-wrist. s_manager_state.sensor_stable = true; s_manager_state.off_wrist_when_stable = (quality == HRMQuality_OffWrist); }
unt_handler_entries(&s_started_handler_calls, a), 2); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0); // Complete sequence ...
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0)
; cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 0); cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 0); cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX); #endif } // -------------------------------------------------------------------...
l_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX); #endif } // -------------------------------------------------------------------------------------- // Test a sequence animation with a component that has a play count of 0 void test_animation__sequence_with_0_component(void) { #ifdef TEST_INCLU...
(spawn, play_count_spawn)
; // Check the duration cl_assert_equal_i(animation_get_duration(spawn, true, true), play_count_spawn * duration_a); prv_clear_handler_histories(); uint64_t start_ms = prv_now_ms(); animation_schedule(spawn); // Start A prv_advance_to_ms_with_timers(start_ms + 1); cl_assert_equal_i(prv_count_handle...
t = LayoutIdCalendar, }, .attr_list = { .num_attributes = 1, .attributes = &title_attr, }, }; // not a calendar pin static TimelineItem s_weather_item = { .header = { .id = { 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, .timestamp...
(TIMELINE_PEEK_DEFAULT_SHOW_BEFORE_TIME_S)
; timeline_event_deinit(); stub_new_timer_cleanup(); fake_settings_file_reset(); } // Tests //////////////////////////////////////////////////////////////// typedef struct AddEventParams { TimelineItem *item; } AddEventParams; #define ADD_EVENT(...) ({ \ AddEventParams params = { __VA_ARGS__ }; \ cl_asse...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
NVIC_SystemReset()
; #endif __builtin_unreachable(); }
} StatusBarTextFormat; static ALWAYS_INLINE StatusBarTextFormat prv_get_text_format(void) { const PlatformType platform = process_manager_current_platform(); const char *font_key = PBL_PLATFORM_SWITCH(platform, /*aplite*/ FONT_KEY_GOTHIC_14, /*basalt*/ FONT_KEY_GOTHIC_14, /*chalk*/ FONT_KEY_GOTHI...
event_service_client_unsubscribe(&(status_bar_layer->tick_event))
-------------------------------------- // Test that we report the that multiple sessions are ongoing. void test_activity__activity_sessions_ongoing_multiple(void) { // Start activity tracking. This method assumes it can be called from any task, so we must // invoke system callbacks to handle its KernelBG callback. ...
(zone2_minutes, 0)
; activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes); cl_assert_equal_i(zone3_minutes, 0); // Add some "very elevated" heart rates. // The zone should wait 1 minute, move up 1 zone per minute, stop at the top prv_set_median_hr_for_minutes(185 /* BPM */, 5 /* minutes */); cl_assert_...
/* * 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...
mutex_is_owned_recursive(s_bt_lock)
; }
ob *) s_jobs->node.next; }; prv_increment_elapsed_time_for_job(&job, &force_update); prv_perform_next_job(force_update); } unlock: bt_unlock(); } // ----------------------------------------------------------------------------- //! Timer start / stop utilities //! bt_lock is expected to be taken! stat...
{ s_is_advertising = true; PBL_LOG(GAP_LE_ADVERT_LOG_LEVEL, "Airing advertising job: %s ", prv_string_for_debug_tag(next->tag)); // Use average interval ms. BT controller does not report back what it uses. const uint32_t interval_ms = (min_interval_ms + max_interval_ms) ...
ets menu_layer_insets = (GEdgeInsets) { .top = STATUS_BAR_LAYER_HEIGHT, .bottom = PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_HEIGHT) }; bounds = grect_inset(bounds, menu_layer_insets); menu_layer_init(menu_layer, &bounds); menu_layer_set_callbacks(menu_layer, data, &(MenuLayerCallbacks) { .get_num_rows = ...
(&data->title_text)
); GRect info_text_frame = (GRect) { .size = info_text_size }; info_text_frame.origin.y = title_text_frame.origin.y + title_text_size.h + vertical_spacing; text_layer_init_with_parameters(&data->info_text, &info_text_frame, prv_get_korea_kcc_id(), info_text_font, ...
mezoneInfo) { .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 }; memc...
for (int i = 0; i < link_count; i++) { const int link_offset = link_section_offset + (i * LINK_BYTES); char link_name[LINK_NAME_LENGTH + 1]; // + max length + null terminator prv_database_read(link_offset + LINK_REGION_LENGTH, link_name, LINK_NAME_LENGTH); link_name[sizeof(link_name) - 1] = '\0'; ...
tricHeartRateZone1Minutes; } else if (zone == HRZone_Zone2) { metric = ActivityMetricHeartRateZone2Minutes; } else if (zone == HRZone_Zone3) { metric = ActivityMetricHeartRateZone3Minutes; } else { // Don't store data for Zone 0 return; } SettingsFile *file = activity_private_settings_open();...
activity_private_state()
; return state->resting_calories; } // -------------------------------------------------------------------------------------------- uint32_t activity_metrics_prv_get_active_calories(void) { ActivityState *state = activity_private_state(); return state->active_calories; } // -----------------------------------...
/* * 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...
(a.alignment == b.alignment)
; cl_assert(a.colors.foreground.argb == b.colors.foreground.argb); cl_assert(a.colors.background.argb == b.colors.background.argb); } // Setup ///////////////////////////////// void test_content_indicator__initialize(void) { // Initialize the static buffer of content indicators content_indicator_init_buffer(c...
t_alarm__alarm_type_change_updates_timeout(void) { AlarmId id; id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKDAYS }); prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_WEEKDAYS, s_weekday_schedule); // 2 pins should be added (for Thursday / Friday) cl_assert_equal_i(s_n...
(id2, 10, 20, false, ALARM_KIND_JUST_ONCE, just_once_schedule_thursday)
; // Skip ahead of both alarms // One of the alarms should go off s_current_hour = 10; s_current_minute = 30; cron_service_wakeup(); cl_assert_equal_i(s_num_alarms_fired, 1); // The other alarm should not go off cron_service_wakeup(); cl_assert_equal_i(s_num_alarms_fired, 1); } // TODO: // - Test d...
/* * 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...
regular_timer_add_seconds_callback(&s_regular)
; } // ------------------------------------------------------------------------------------------- time_t cron_job_schedule(CronJob *job) { PBL_ASSERTN(s_list_mutex); mutex_lock(s_list_mutex); const time_t now = rtc_get_time(); // Always update the execution time. job->cached_execute_time = cron_job_get_ex...
{ GSize from; GSize to; } ScaleCBContext; T_STATIC bool prv_gdraw_command_scale(GDrawCommand *command, uint32_t index, void *context) { ScaleCBContext *scale = context; const uint16_t num_points = gdraw_command_get_num_points(command); for (uint16_t i = 0; i < num_points; i++) { command->points[i] = gpo...
(list, is_precise, &num_points)
; if (!points) { return NULL; } gpoint_sort(points, num_points, comparator, context, reverse); GPointIndexLookup *lookup = applib_malloc(sizeof(GPointIndexLookup) + num_points * sizeof(uint16_t)); if (!lookup) { applib_free(points); return lookup; } lookup->num_points = num_points; ...
/* * 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...
cursor_after_tuple_with_data_length(iter, data_length)
0); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 6), 1); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 8), 2); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 10), 3); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 12), 4); graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 14), 20...
(&ctx, GPoint(10, 0), 3)
; graphics_draw_vertical_line_dotted(&ctx, GPoint(12, 0), 4); graphics_draw_vertical_line_dotted(&ctx, GPoint(14, 0), 20); graphics_draw_vertical_line_dotted(&ctx, GPoint(16, 0), 21); graphics_draw_vertical_line_dotted(&ctx, GPoint(18, 0), 22); graphics_draw_vertical_line_dotted(&ctx, GPoint(20, 0), MAX_NUM_R...
utex.h" #include "stubs_passert.h" #include "stubs_prompt.h" #include "stubs_rand_ptr.h" #include "stubs_regular_timer.h" uint16_t gaps_get_starting_att_handle(void) { return 4; } BLEService gatt_client_att_handle_get_service( GAPLEConnection *connection, uint16_t att_handle, const GATTServiceNode **service_n...
for (int i = 0; i < max_times + 1; ++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; prv_cccd_write(true /* is_subscribing */); if (i < m...
} void test_gatt_service_changed_server__disconnect_during_delay(void) { gatt_service_changed_server_handle_fw_update(); prv_cccd_write(true /* is_subscribing */); // Grab the timer ID: TimerID t = s_connection->gatt_service_changed_indication_timer; s_connection->gatt_service_changed_indication_timer = TI...
prv_count_handler_entries(&s_teardown_handler_calls, a), 0); // The distance should always be at 0 cl_assert_equal_i(prv_last_update_distance(a), 0); // Destroy it animation_destroy(a); #endif } // -------------------------------------------------------------------------------------- // Test a simple seque...
(start_ms + duration_total + 5 * MIN_FRAME_INTERVAL_MS + 1)
; cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);...
int s_prv_api_init__callcount; static void prv_api_init(void) { s_prv_api_init__callcount++; } static int s_prv_api_add__callcount; static bool s_prv_api_add__result; static bool prv_api_add(const char *event_name, jerry_value_t handler) { s_prv_api_add__callcount++; return s_prv_api_add__result; } static int s...
ASSERT_JS_GLOBAL_EQUALS_B("eq", true)
; // from MDN docs: // Calling removeEventListener() with arguments that do not identify // any currently registered EventListener on the EventTarget has no effect. EXECUTE_SCRIPT( "_rocky.off('foo', f2);\n" "_rocky.off('unknownevent', f1);\n" ); cl_assert_equal_i(0, s_prv_api_remove__callcount); ...
/* * 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...
sys_smartstrap_unsubscribe()
; } #endif // Internal APIs //////////////////////////////////////////////////////////////////////////////// void app_smartstrap_cleanup(void) { #if USE_SMARTSTRAP prv_state_deinit(); #endif } // Exported APIs //////////////////////////////////////////////////////////////////////////////// SmartstrapResult app_...
tingsFile *file) { AlarmId id_out = ALARM_INVALID_ID; for (int i = 0; i < MAX_CONFIGURED_ALARMS; ++i) { AlarmStorageKey key = { .id = i, .type = ALARM_DATA_CONFIG }; if (settings_file_get_len(file, &key, sizeof(key)) == 0) { id_out = i; break; } } return id_out; } // -----------------...
{ // We have to re-calculate the correct day prv_set_day_for_just_once_alarm(config, ctx->hour, ctx->minute); }
config->hour = ctx->hour; config->minute = ctx->minute; return true; } void alarm_set_time(AlarmId id, int hour, int minute) { prv_assert_alarm_params(hour, minute); prv_alarm_operation(id, prv_set_alarm_time_op, &(SetAlarmTimeContext) { hour, minute }); } // -----------------------------------------------...
filter, &s_context, &result); cl_assert_equal_i(result, 3); } void test_stats__median(void) { const int32_t data[] = { 10, 40, 6, 32, 73, 80, 34, 25, 62 }; const size_t num_data = ARRAY_LENGTH(data); const StatsBasicOp op = StatsBasicOp_Median; int32_t result; stats_calculate_basic(op, data, num_data, NULL...
(result.count, 1)
; cl_assert_equal_i(result.max_streak, 1); cl_assert_equal_i(result.first_streak, 1); cl_assert_equal_i(result.median, 42); } void test_stats__all_basic_no_values(void) { const int32_t data[] = {}; const size_t num_data = 0; const StatsBasicOp op = (StatsBasicOp_Sum | StatsBasicOp_Average | StatsBa...
umber_font, TEXT_COLOR, container); active_window->workout_controller->metric_to_string(metric_type, (char *)number_text_node->text, buffer_size, i18n_owner, active_window->workout_data); if (strlen(number_text_node->text) > 5) ...
if (active_window->num_scrollable_metrics > 1) { action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, active_window->action_bar_next); }
} static void prv_update_ui(WorkoutActiveWindow *active_window) { if (window_manager_is_window_visible(&active_window->window)) { layer_mark_dirty(&active_window->base_layer); // Update the action bar in case another client updated the workout's status prv_set_action_bar_icons(active_window); } } st...
// Process the (N)ACK: switch (sent_msg_type) { case OutboxMsgTypeControl: { if (is_sent_successfully) { prv_control_message_queue_pop_head(); } else { if (s_state.out.failure_count >= CONTROL_MESSAGE_MAX_FAILURES) { MessageNode *node = s_state.out.control_msg_queue; ...
(s_state.state == PostMessageStateAwaitingResetCompleteRemoteInitiated || s_state.state == PostMessageStateAwaitingResetCompleteLocalInitiated)
; s_state.protocol_version = MIN(rc->max_supported_version, POSTMESSAGE_PROTOCOL_MAX_VERSION); // NOTE: Each end communicates it's OWN TX/RX max values. // This means that TX max on one end is bound by RX max on the other, and vice versa. s_state.tx_chunk_size_bytes = MIN(rc->max_rx_chunk_size, POSTMESSA...
d_handler, .stopped = prv_bg_animation_stopped_handler, }, health_card_view); animation_set_implementation(bg_anim, &prv_bg_animation_implementation); health_card_view->slide_animation = animation_spawn_create(curr_out, next_in, bg_anim, NULL); animation_schedule(health_card_view->slide_animation); he...
(window_root, &health_card_view->down_arrow_layer)
_args[6]); unsigned int stacked_psr = ((unsigned long) stacked_args[7]); PBL_LOG_FROM_FAULT_HANDLER_FMT(buffer, 80, "R0 = 0x%x", stacked_r0); PBL_LOG_FROM_FAULT_HANDLER_FMT(buffer, 80, "R1 = 0x%x", stacked_r1); PBL_LOG_FROM_FAULT_HANDLER_FMT(buffer, 80, "R2 = 0x%x", stacked_r2); PBL_LOG_FROM_FAULT_HANDLER_FM...
reboot_reason_set(&reason)
; // Yay, ripping stuff from the internet! // http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/ char buffer[80]; // To inspect the SCB in GDB: p (*((SCB_Type *) 0xE000ED00)) PBL_LOG_FROM_FAULT_HANDLER("\r\n\r\n[Hard fault handler - You dun goofed]"); PBL_LOG_FROM_FAULT_HANDLER_FMT( ...
eCondition_L: return (state->filter_state < *value); case PredicateCondition_LE: return (state->filter_state <= *value); default: WTF; } } static const char * const s_Tstrings[3][3] = { { "H", "M", "S", }, { "aH", "aM", "aS", }, { "uH", "uM", "uS", }, }; static const char * const ...
i18n_ctx_noop("TmplStringSing", " min")
, /// Plural suffix for minutes with abbreviated units i18n_ctx_noop("TmplStringPlur", " min")}, /// Singular suffix for minutes with full units { i18n_ctx_noop("TmplStringSing", " minute"), /// Plural suffix for minutes with full units i18n_ctx_noop("TmplStringPlur", " minutes")}, }; static const char...
frame; } //! Drawing function for our Window's base Layer. Draws the background, the label, and the value, //! which is everything on screen with the exception of the child ActionBarLayer void prv_update_proc(Layer *layer, GContext* ctx) { graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_rect(ctx,...
{ action_bar_layer_deinit(&number_window->action_bar); window_deinit(&number_window->window); }
void number_window_destroy(NumberWindow *number_window) { if (number_window == NULL) { return; } number_window_deinit(number_window); applib_free(number_window); } Window *number_window_get_window(NumberWindow *numberwindow) { return (&numberwindow->window); }
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(circular_cache_get(&s_test_cache, &s_test_item[1]), &s_cache_buffer[1])
////// //////////////////////////////////////////////////////////////// /// Fixed_S16_3 = 1 bit sign, 12 bits integer, 3 bits fraction //////////////////////////////////////////////////////////////// void test_math_fixed__S16_3_create(void) { Fixed_S16_3 num; int16_t test_num; cl_assert(FIXED_S16_3_PRECISION ==...
(num.integer == 0)
; cl_assert(num.fraction == 2); test_num = (int32_t)((float)0.375 * (1 << FIXED_S16_3_PRECISION)); num = (Fixed_S16_3){ .raw_value = test_num }; cl_assert(num.integer == 0); cl_assert(num.fraction == 3); test_num = (int32_t)((float)0.500 * (1 << FIXED_S16_3_PRECISION)); num = (Fixed_S16_3){ .raw_value...
al/alarms/alarm.h" #include "system/logging.h" #include "system/hexdump.h" #include "util/size.h" #include "util/string.h" #if !TINTIN_FORCE_FIT ////////////////////////////////////////// // Card Mode ////////////////////////////////////////// #define CARD_MARGIN_TOP PBL_IF_RECT_ELSE(3, 10) static void prv_until_ti...
(s_vertical_config_nodes)
, .container.nodes = (LayoutNodeConfig **)&s_vertical_config_nodes, .container.extent.offset.y = CARD_MARGIN_TOP, .container.extent.margin.h = CARD_MARGIN_TOP, }; return layout_create_text_node_from_config(&timeline_layout->layout_layer, &s_vertical_config.c...
a, b, c, d, GTransformNumberZero, GTransformNumberZero); } else { return GTransformIdentity(); } } ////////////////////////////////////// /// Evaluating Transforms ////////////////////////////////////// bool gtransform_is_identity(const GTransform * const t) { if (!t) { return false; } GTransform t_...
Fixed_S32_16_add3(tx_b, ty_d, t->ty)
; } void gtransform_rotate(GTransform *t_new, GTransform *t, int32_t angle) { if ((!t_new) || (!t)) { return; } // t_new = tr*t GTransform tR = gtransform_init_rotation(angle); gtransform_concat(t_new, &tR, t); } bool gtransform_invert(GTransform *t_new, GTransform *t) { if ((!t_new) || (!t)) { r...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ PBL_LOG(LOG_LEVEL_DEBUG, "RTC frequency invalid - Skipping calibration"); return (RTCCalibConfig) { .sign = RTC_CalibSign_Positive, .units = 0 }; }
// Difference in frequency in mHz (ex. 224 = .224 Hz off from target frequency) const int32_t rtc_freq_diff = target - frequency; // RTC_CoarseCalibConfig uses units of +4.069ppm or -2.035ppm. // Formula: // ppm = 1e6(target - frequency)/(target) // positive units = ppm / 4.069 // negative units = ppm ...
ORD minutes, but // the records that are not yet saved to flash should be correctly retrieved from RAM. time_t oldest_to_fetch = rtc_get_time() - (ALG_MINUTES_PER_FILE_RECORD * SECONDS_PER_MINUTE); uint32_t next_read_minute_idx = 0; for (int i = 0; i < ALG_MINUTES_PER_FILE_RECORD; i++, oldest_to_fetch += SECOND...
(session_entries, sessions)
; cl_assert_equal_i(sessions[0].type, ActivitySessionType_Sleep); } { // Create two 2 hour sessions, they should both be considered as separate naps ActivitySession sessions[] = { { .start_utc = start_of_today + (13 * SECONDS_PER_HOUR), // 1pm .length_min = 2 * MINUTES_PER_HOUR, ...
/* * 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_set(ANALYTICS_APP_METRIC_FLASH_READ_COUNT, s_analytics_read_count, AnalyticsClient_Worker)
; analytics_set(ANALYTICS_APP_METRIC_FLASH_READ_BYTES_COUNT, s_analytics_read_bytes_count, AnalyticsClient_Worker); analytics_set(ANALYTICS_APP_METRIC_FLASH_WRITE_BYTES_COUNT, s_analytics_write_bytes_count, AnalyticsClient_Worker); } s_analytics_read_count = 0; s_analy...
(2bitpalette)
); cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(2bitpalette))); cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat2BitPalette); } // Tests 4-bit transparent greyscale PNG loading into gbitmap // Result: // - gbitmap matches platform loaded PNG void test_png__greyscale_4_bit_transparent(void) { G...
et_fifo_frame_size(); // x,y,z accel data uint16_t max_num_samples = (BMI160_FIFO_LEN_BYTES / fifo_frame_size); max_num_samples = (max_num_samples / BMI160_FIFO_WM_UNIT_BYTES) * BMI160_FIFO_WM_UNIT_BYTES; if (num_samples > max_num_samples) { num_samples = max_num_samples; } uint16_t curr_sample_si...
(BMI160_REG_INT_TAP_0, tap_0_cfg)
{ 3, 0x79, 652, 235}, { 0, 0x66, 1480, 233}, { 0, 0x66, 2536, 209}, { 0, 0x66, 363, 214}, { 0, 0x66, 20, 218}, { 0, 0x66, 617, 215}, { 0, 0x66, 778, 215}, { 0, 0x66, 38, 231}, { 0, 0x66, 551, 214}, { 19, 0x57, 7073, 239}, { 95, 0x48, 3065, 240}, { 90, 0x48, 3577, 240}, { ...
{ 0, 0x54, 402, 204}, { 0, 0x54, 1875, 222}, { 0, 0x54, 335, 229}, // 990: Local time: 03:44:00 PM { 0, 0x54, 131, 230}, { 0, 0x44, 5, 216}, { 0, 0x44, 0, 214}, { 0, 0x44, 488, 233}, { 0, 0x44, 1322, 227}, { 0, 0x44, 1317, 226}, { 0, 0x44, 1301, 226}, { 0, 0x44, 852, 221}...
{ 0, 0x64, 1609, 207}, { 12, 0x65, 1233, 212}, { 0, 0x44, 1172, 203}, { 0, 0x34, 1161, 202}, { 0, 0x34, 792, 209}, { 0, 0x64, 2141, 205}, { 0, 0x44, 1749, 195}, { 0, 0x44, 113, 195}, { 0, 0x55, 678, 192}, // 1050: Local time: 04:44:00 PM { 0, 0x34, 241, 198}, { 0, 0x34, ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
time_get_uptime_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...
("var size = _rocky.userPreferences.contentSize")
; ASSERT_JS_GLOBAL_EQUALS_S("size", "medium"); } void test_rocky_api_preferences__large(void) { s_preferred_content_size = PreferredContentSizeLarge; rocky_global_init(s_preferences_api); EXECUTE_SCRIPT("var size = _rocky.userPreferences.contentSize"); ASSERT_JS_GLOBAL_EQUALS_S("size", "large"); } void tes...
ude "popups/phone_formatting.h" #include "clar.h" #include <string.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> // Stubs /////////////////////////////////////////////////////////// #include "stubs_logging.h" #include "stubs_passert.h" // Tests //////////////////////////////////////////////////////...
(dest, "+55 408\n555-1212")
; } void test_phone_formatting__phone_number_intl_parens(void) { char test_number[] = "+55 (408) 555-1212"; int dest_len = sizeof(test_number) + 1; char *dest = malloc(dest_len); // malloc'd memory is protected by DUMA phone_format_phone_number(test_number, dest, dest_len); cl_assert_equal_s(dest, "+55 (4...
//////////////////////////////////////////////////////// void test_rocky_api_util__initialize(void) { s_test_func_imp_call_count = 0; s_method_func_imp_call_count = 0; rocky_runtime_context_init(); jerry_init(JERRY_INIT_EMPTY); s_log_internal__expected = NULL; } void test_rocky_api_util__cleanup(void) { j...
(*s_log_internal__expected == NULL)
; } void test_rocky_api_util__eval_throw_string(void) { s_log_internal__expected = (const char *[]){ "Unhandled exception", " "ERROR_STRING, NULL }; prv_do_eval("throw '"ERROR_STRING"';"); cl_assert(*s_log_internal__expected == NULL); } void test_rocky_api_util__eval_throw_error(void) { s_log_i...
LE_NAME_PREFIX); return (strncmp(name, DLS_FILE_NAME_PREFIX, prefix_len) == 0); } // ----------------------------------------------------------------------------------------- // Given a session pointer, return how much larger we want to grow the file for it if/when // we decide to reallocate it static uint32_t prv_...
(name, op_flags, FILE_TYPE_STATIC, 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...
DEFINE_SYSCALL(size_t, sys_resource_size, ResAppNum app_num, uint32_t resource_id)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ s_path_num_points = num_points; GPoint *copied_points = malloc(num_points * sizeof(GPoint)); cl_assert(copied_points != NULL); for (int i = 0; i < num_points; i++) { copied_points[i] = gpoint_add(points[i], offset); } return copied_points; }
static bool prv_compare_points(GPoint *a, GPoint *b, uint16_t num_points) { return (memcmp(a, b, sizeof(GPoint) * num_points) == 0); } // Stubs void graphics_context_set_stroke_color(GContext* ctx, GColor color) { s_stroke_color = color; } void graphics_context_set_fill_color(GContext* ctx, GColor color) { 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...
{ device_t *dev = find_device_by_conn_idx(conn_idx); if (!dev) { success = false; goto release; } bool is_resolved = false; if (dev && dev->irk) { is_resolved = true; if (irk_out) { memcpy(irk_out, dev->irk->key, sizeof(*irk_out)); } } else { PBL_LOG(L...
release: storage_release(); return success; } static void handle_evt_gap_connected(ble_evt_gap_connected_t *evt) { PBL_LOG(LOG_LEVEL_DEBUG, "Connected, idx=%d!", (int)evt->conn_idx); prv_log_conn_params(&evt->conn_params); if (!evt->is_master) { // To be compliant with BT Core Spec section 7.8.9, stop ...
ion prv_write_to_current_page(data, true); } else 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 ...
if (local_device_name_out) { strncpy(local_device_name_out, data.name, max_size); local_device_name_out[max_size - 1] = 0; }
// Is not zero length? rv = (data.name[0] != 0); } unlock: prv_unlock(); return rv; } void shared_prf_storage_set_local_device_name(const char *local_device_name) { prv_lock(); { SprfLocalName data = {}; if (local_device_name) { strncpy(data.name, local_device_name, sizeof(data.name...
issions and * limitations under the License. */ #include "clar.h" #include "services/normal/blob_db/ios_notif_pref_db.h" #include "util/size.h" // Fixture //////////////////////////////////////////////////////////////// // Fakes //////////////////////////////////////////////////////////////// #include "fake_syste...
attribute_list_add_cstring(&attr_list, AttributeIdAppName, "GMail")
; TimelineItemActionGroup action_group = { .num_actions = 0, }; // Store them in the DB char *key = "key1"; int key_len = strlen(key); ios_notif_pref_db_store_prefs((uint8_t *)key, key_len, &attr_list, &action_group); // Make sure we can get the data back iOSNotifPrefs *notif_prefs = ios_notif_pre...
unded_end = *time_end + SECONDS_PER_MINUTE - 1; const uint32_t needed_partial_minutes = (upper_bounded_end - lower_bounded_start) / SECONDS_PER_MINUTE; num_records = MIN(num_records, needed_partial_minutes); } const bool success = sys_activity_get_minute_history(minute_data, &num_records, time_start)...
if (!callback(session_activity, session->start_utc, session->start_utc + (session->length_min * SECONDS_PER_MINUTE), context)) { // clients can interrupt the iteration at any time break; }
} } #endif } // ---------------------------------------------------------------------------------------------- bool health_service_private_get_yesterdays_sleep_activity(HealthValue *enter_sec, HealthValue *exit_sec) { return sys_activity_get_metric...
ack requirements during the minute handler (see PBL-38130) static void NOINLINE prv_update_step_derived_metrics(time_t utc_sec) { ActivityState *state = activity_private_state(); mutex_lock_recursive(state->mutex); { int minute_of_day = time_util_get_minute_of_day(utc_sec); // The "no-steps-during-sleep" ...
{ metric = ActivityMetricHeartRateZone1Minutes; }
else if (zone == HRZone_Zone2) { metric = ActivityMetricHeartRateZone2Minutes; } else if (zone == HRZone_Zone3) { metric = ActivityMetricHeartRateZone3Minutes; } else { // Don't store data for Zone 0 return; } SettingsFile *file = activity_private_settings_open(); if (!file) { return; ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(data->debug_card.dialog_text, title)
; // Get History int32_t values[7]; activity_get_metric(metric, ARRAY_LENGTH(values), values); for (int i = 0; i < 7; i++) { char temp[32]; snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)values[i]); safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text)); } prv_d...
//www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissi...
{ if (*attempt > 31) { return max_value; } uint32_t backoff_multiplier = 0x1 << (*attempt)++; uint32_t next_value = initial_value * backoff_multiplier; return MIN(next_value, max_value); }
int16_t my_orig = mag_data.y; mag_data.y = mag_data.x; mag_data.x = my_orig; mag_data.z = -mag_data.z; samples_collected++; // don't perform any calibration if the charger is plugged in if (!s_charger_plugged && (s_current_cal_status != CompassStatusCalibrated)) { // if we haven't tried to calibrate y...
accel_session_delete(s_accel_session)
; mag_release(); } //! Serial command for reading a single value from the compass. void command_compass_peek(void) { int32_t prev_heading = s_last_heading; launcher_task_add_callback(prv_ecompass_start_callback, NULL); // wait for last heading to be updated int retries = 50; // 5 seconds should be ample ti...
istry); } while (temp_address != registry->cursor->begin); } //////////////////////////////////////////////////////////// // Registry data structure //////////////////////////////////////////////////////////// static int registry_get_next_available_index(Registry* registry) { for (int i = 0; i < registry->num_reco...
{ r->active = false; registry->is_different_from_flash = true; }
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...
list_sorted_add(head, &bar1.list_node, (Comparator) sorting_comparator, true)
; cl_assert(head == &bar1.list_node); cl_assert(list_get_next(head) == &bar2.list_node); cl_assert(list_get_tail(head) == &bar3.list_node); } void test_list__sort_descending(void) { IntNode bar1 = { .value = 1 }; IntNode bar2 = { .value = 2 }; IntNode bar3 = { .value = 3 }; ListNode* head = 0; head =...
horizontal_inset)); if (draw_two_columns) { prv_menu_cell_basic_draw_custom_two_columns_round(ctx, &cell_layer_bounds, config, cell_is_selected); } else { prv_menu_cell_basic_draw_custom_one_column_round(ctx, &cell_layer_bounds, config, ...
if (is_legacy2) { // Update the text color to Black for legacy apps - this is to maintain existing behavior for // 2.x compiled apps - no need to restore original since original 2.x did not do any restore graphics_context_set_text_color(ctx, GColorBlack); }
GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD); GRect box = cell_layer->bounds; // Pixel nudging... box.origin.x += 2; box.origin.y -= 1; graphics_draw_text(ctx, title, font, box, GTextOverflowModeFill, 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_assert_equal_i(0b00010000, BITS_BETWEEN(4,4))
; } // Flash memory is organized into twelve sectors of unequal sizes. // Sectors 0-3 are 16 KiB. Sector 4 is 64 KiB. // The remaining sectors are 128 KiB. // Bitset of sectors that have been "erased" static uint32_t erased_sector; static bool flash_locked, flash_flags_set; static FLASH_Status return_status; uint8_t ...
/* * 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...
(sector - first_sector + 1, count, progress_context)
; } } FLASH_Lock(); return true; } bool system_flash_write( uint32_t address, const void *data, size_t length, SystemFlashProgressCb progress_callback, void *progress_context) { FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLA...
notifications_presented_list_current_idx()
+ 1, notif_count); } } static void prv_cleanup_timer(EventedTimerID *timer_id) { if (*timer_id != EVENTED_TIMER_INVALID_ID) { evented_timer_cancel(*timer_id); *timer_id = EVENTED_TIMER_INVALID_ID; } } static void prv_cancel_reminder_watchdog(NotificationWindowData *da...
-40}, { 616, 120, -104}, { 632, 112, -64}, { 672, 136, 0}, { 832, 128, -32}, { 1048, 32, -16}, { 1104, 88, -8}, { 1112, 104, -96}, { 1160, 144, -128}, { 1128, 136, -104}, { 1096, 144, -144}, { 1184, 176, -152}, // 13 seconds { 1296, 192, -136}, { 1144, 216, -128}...
{ 1064, 344, -184}, { 1008, 336, -176}, { 1136, 296, -128}, { 1216, 272, -32}, { 1088, 264, 48}, { 832, 192, 0}, { 776, 192, -32}, { 736, 136, 0}, { 776, 120, 16}, { 832, 128, 16}, { 912, 120, 0}, { 1048, 112, -40}, { 1104, 112, -40}, { 1096, 112, -88}, { 1192...
{ 1112, 200, 0}, { 1152, 168, 56}, { 1288, 168, 56}, // 21 seconds { 1184, 128, 24}, { 1056, 152, 0}, { 1232, 192, -88}, { 1296, 216, -144}, { 1040, 256, -176}, { 672, 208, -200}, { 480, 192, -176}, { 440, 200, -176}, { 480, 192, -176}, { 672, 224, -208}, { 9...
((void *)0x12345)
; cl_assert(prv_list_find_string("Music", (void *)0xdeadbeef)->translated_string == third); i18n_free_all((void *)0xdeadbeef); cl_assert(prv_list_find_string("Music", __FILE__) == NULL); // this should be a no-op i18n_free("Music", __FILE__); } void test_i18n__locale(void) { cl_assert(strcmp(i18n_get_local...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(vector, sizeof(vector))
; assert_decode_completed(SIZE_MAX); }
e except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF A...
printf("Setting key 10 times and verifying we get the same value back...\n")
; for (int i = 0; i < 10; i++) { snprintf((char *)val, 7, "val%03d", i); printf("Iteration %d val %s\n", i, val); set_and_verify(&file, key, key_len, val, val_len); } settings_file_close(&file); cl_must_pass(settings_file_open(&file, "test_file_set_get_one_many_times", 4096)); printf("Making su...
ay, March 12, 2015, 12:00 UTC static const int s_thursday_12_00 = 1426161600; // Thursday, March 12, 2015, 13:00 UTC static const int s_thursday_13_00 = 1426165200; // Friday, March 20, 2015, 12:00 UTC static const int s_friday_08_30 = 1426840200; // Friday, March 20, 2015, 23:30 UTC static const int s_friday_23_30 = 1...
(enabled == true)
; prv_assert_manually_dnd_setting_val(true); cl_assert_equal_i(s_num_dnd_events_put, 3); } void test_do_not_disturb__manually_enable_active(void) { bool active; active = do_not_disturb_is_active(); cl_assert(active == false); do_not_disturb_set_manually_enabled(true); active = do_not_disturb_is_active()...
ib/ui/kino/kino_layer.h" #include "applib/ui/ui.h" #include "applib/ui/window_manager.h" #include "apps/system_apps/timeline/text_node.h" #include "kernel/pbl_malloc.h" #include "resource/resource_ids.auto.h" #include "services/common/clock.h" #include "services/common/i18n/i18n.h" #include "services/normal/activity/ac...
("AVG PACE")
; #else /// Average Pace Label with units return active_window->workout_controller->get_distance_string(i18n_noop("AVG PACE (/MI)"), i18n_noop("AVG PACE (/KM)")); #endif case WorkoutMetricType_Pace: #if PBL_RECT /// Pace Label ...
nse_msg->response == ResponseAck) { ++s_acks_received; } else if (response_msg->response == ResponseNack) { ++s_nacks_received; } } void test_put_bytes__initialize(void) { fake_pb_storage_mem_reset(); fake_pb_storage_mem_set_crc(EXPECTED_CRC); fake_comm_session_init(); fake_event_reset_count(); ...
cl_assert_equal_i(event.put_bytes.progress_percent, 0)
; cl_assert_equal_b(event.put_bytes.failed, false); } void test_put_bytes__init_while_already_busy(void) { prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware); prv_receive_init(VALID_OBJECT_SIZE, ObjectFirmware); assert_nack_count(1); } void test_put_bytes__init_too_large(void) { prv_receive_init(UINT_MAX, ...
error->line_number = line; error->error_msg = error_msg; if (description != NULL) error->description = strdup(description); _clar.suite_errors++; _clar.total_errors++; if (should_abort) { if (!_clar.trampoline_enabled) { clar_print_onabort( "Fatal error: a cleanup method raised an e...
{ return; }
if (m1 == NULL || m2 == NULL) { char buf[4096]; snprint_eq(buf, 4096, "'%p' != '%p'", m1, m2); clar__assert(0, file, line, err, buf, should_abort); } for (int offset = 0; offset < n; offset++) { if (m1[offset] == m2[offset]) { continue; } int len = 4096; int off = 0; char b...
/* * 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...
Fixed_S64_32_mul(cb[0], state_x[0])
; for (int i = 1; i < num_input_coefficients; i++) { ytmp = Fixed_S64_32_add(ytmp, Fixed_S64_32_mul(cb[i], state_x[i])); } // Factor in the y * a coeficients for (int i = 0; i < num_output_coefficients; i++) { ytmp = Fixed_S64_32_sub(ytmp, Fixed_S64_32_mul(ca[i], state_y[i])); } // shift the y out...
and log the heartbeats using dls_log(). void analytics_logging_system_task_cb(void *ignored) { if (!s_device_heartbeat_session) { uint32_t size = analytics_heartbeat_kind_data_size(ANALYTICS_HEARTBEAT_KIND_DEVICE); s_device_heartbeat_session = prv_create_dls(ANALYTICS_BLOB_KIND_DEVICE_HEARTBEAT, size); i...
bt_lock_is_held()
) { // We run the risk of deadlocking if we hold the bt_lock at this point. If // it's the case then schedule a callback so the dls code runs while we no // longer hold the lock AnalyticsEventBlob *event_blob_copy = kernel_malloc_check(sizeof(AnalyticsEventBlob)); memcpy(event_blob_copy, eve...
.h" #include "services/common/comm_session/session_send_buffer.h" #include "services/common/comm_session/session_transport.h" #include "services/normal/data_logging/data_logging_service.h" #include "services/normal/data_logging/dls_private.h" #include "services/normal/data_logging/dls_list.h" #include "services/normal...
{ int num_bytes = item_size * num_items; while (num_bytes > 0) { unsigned int chunk_size; if (item_size > DLS_SESSION_MAX_BUFFERED_ITEM_SIZE) { // Must be unbuffered chunk_size = item_size; } else { chunk_size = MIN(num_bytes, DLS_SESSION_MAX_BUFFERED_ITEM_SIZE); chunk_size -= (c...
// ---------------------------------------------------------------------------------------- static void prv_check_session_data(DataLoggingSessionRef logging_session, uint32_t crc, unsigned int num_bytes) { uint8_t buffer[num_bytes]; uint32_t read_bytes = dls_test_read(logging_se...
vityMetricHeartRateZone1Minutes: case ActivityMetricHeartRateZone2Minutes: case ActivityMetricHeartRateZone3Minutes: PBL_LOG(LOG_LEVEL_WARNING, "Health DB doesn't know about typical metric %d", metric); return false; } return true; } bool health_db_get_monthly_average_value(ActivityMetric metr...
prv_file_open_and_lock(&file)
; if (rv != S_SUCCESS) { return 0; } int length = settings_file_get_len(&file, key, key_len); prv_file_close_and_unlock(&file); return length; } status_t health_db_read(const uint8_t *key, int key_len, uint8_t *value_out, int value_out_len) { if (!prv_key_is_valid(key, key_len)) { return E_INVAL...
rt_equal_i(s_sys_activity_get_metric_values.in.metric, ActivityMetricStepCount); cl_assert_equal_i(s_sys_activity_get_metric_values.in.history_len, ACTIVITY_HISTORY_DAYS); } #define cl_assert_equal_range(a, b) \ do { \ HealthServiceTimeRange r_a = (a); \ HealthServiceTimeRange r_b = (b); \ bool success...
cl_assert_equal_b(result, false)
; // start after end result = prv_calculate_time_range(now - 100, now - 200, NULL); cl_assert_equal_b(result, false); } void test_health__range_to_day_id_clamps_values(void) { const time_t now = rtc_get_time(); bool result; HealthServiceTimeRange range; // clamps value that goes into the future resu...
01 AM { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, { 0, 0x73, 0, 0x0}, ...
{ 0, 0x54, 112, 0x0}, { 0, 0x64, 0, 0x0}, { 0, 0x64, 0, 0x0}, { 0, 0x64, 0, 0x0}, { 0, 0x64, 0, 0x0}, { 0, 0x34, 235, 0x0}, { 0, 0x13, 0, 0x0}, { 0, 0x13, 0, 0x0}, { 0, 0x13, 0, 0x0}, { 0, 0x13, 0, 0x0}, // 870: Local time: 03:06:00 AM { 0, 0x13, 0, 0x0}, { 0, 0x13, 0...
{ 0, 0x5c, 0, 0x0}, { 0, 0x5c, 0, 0x0}, { 0, 0x5c, 0, 0x0}, { 0, 0x5c, 842, 0x0}, { 0, 0x4c, 0, 0x0}, { 0, 0x4c, 0, 0x0}, { 0, 0x4c, 0, 0x0}, { 0, 0x4c, 0, 0x0}, { 0, 0x4c, 20, 0x0}, { 0, 0x4c, 0, 0x0}, { 0, 0x4c, 0, 0x0}, // 930: Local time: 04:06:00 AM { 0, 0x4c, 0...