prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
r_bound) { void *ram_start = NULL, *ram_end = NULL; if (task == PebbleTask_App) { ram_start = __APP_RAM__; ram_end = __APP_RAM_end__; } else if (task == PebbleTask_Worker) { ram_start = __WORKER_RAM__; ram_end = __WORKER_RAM_end__; } else { WTF; } // check for vulnerability: lower_bound...
process_metadata_get_app_sdk_type(sys_process_manager_get_current_process_md())
; return sdk_type == ProcessAppSDKType_Legacy3x; } DEFINE_SYSCALL(Version, sys_get_current_process_sdk_version, void) { return process_metadata_get_sdk_version(sys_process_manager_get_current_process_md()); } DEFINE_SYSCALL(PlatformType, process_manager_current_platform, void) { PebbleTask task = pebble_task_g...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(buffer + pos, buffer_size - pos, end_hours, end_minutes, false)
; } static void prv_set_deep_sleep(char *buffer, size_t buffer_size, int32_t sleep_duration, void *i18n_owner) { if (sleep_duration <= 0) { strncpy(buffer, EN_DASH, buffer_size); return; } health_util_format_hours_and_minutes(buffer, buffer_size, sleep_duration, i18n_owner...
osed without starting a workout, turn the HR sensor off hr_time_left = 0; } else { // We have ended a workout while the app was open. Make sure to keep the HR sensor on for at // least a little bit after the workout is finished const time_t now_ts = time_get_uptime_seconds(); const tim...
{ if (workout_service_is_paused() == should_be_paused) { // If no change in state, return early and successful return true; } if (!workout_service_is_workout_ongoing()) { PBL_LOG(LOG_LEVEL_WARNING, "Workout (un)pause requested but no workout in progress"); return false; } prv_lock(); { ...
// --------------------------------------------------------------------------------------- bool workout_service_stop_workout(void) { bool rv = true; prv_lock(); { if (!workout_service_is_workout_ongoing()) { PBL_LOG(LOG_LEVEL_WARNING, "No workout in progress"); rv = false; goto unlock; ...
ings_file_rewrite(&fd, prv_delete_all_pairings_itr, NULL); settings_file_close(&fd); } prv_unlock(); shared_prf_storage_erase_ble_pairing_data(); if (bt_driver_supports_bt_classic()) { shared_prf_storage_erase_bt_classic_pairing_data(); } } static void prv_dump_bonding_db_data(char display_buf[DISPL...
memcmp(key, IS_UNFAITHFUL_KEY, info->key_len)
== 0) { PBL_ASSERTN(info->val_len == sizeof(bool)); bool is_unfaithful; memcpy(&is_unfaithful, val, sizeof(bool)); prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "%s : %d", IS_UNFAITHFUL_KEY, (int)is_unfaithful); } else if (memcmp(key, ROOT_KEYS_KEY, info->key_len) ...
.start = &__cache_ram_zi_start__, .length = (uint32_t)__cache_ram_length, }, { .tag = MemoryRegionTag_RebootReason, .start = &__debug_region_start__, .length = (uint32_t)__debug_region_length, }, }; static uint16_t prv_timer_get_ticks(void) { return hw_timer0_get_on(); } static uint16_t prv_t...
(s_spi->bus_id, HW_SPI_FIFO_TX_ONLY)
(_y), \ .size.w.raw_value = (_w), \ .size.h.raw_value = (_h), \ } void test_rocky_api_util_args__grect_precise(void) { struct { jerry_value_t argv[5]; size_t argc; GRectPrecise expected_output; char *error_msg; } cases[] = { { .argv = { [0] = jerry_create_number(0.0), ...
ARRAY_LENGTH(cases)
; ++i) { jerry_value_t input = cases[i].input; JERRY_ARGS_MAKE(input); GColor output; memset(&output, 0x55, sizeof(output)); ROCKY_ARGS_ASSIGN(ROCKY_ARG(output)); ASSERT_JS_ERROR(error_value, cases[i].error_msg); if (!cases[i].error_msg) { cl_assert_equal_i(output.a, cases[i].expecte...
t expire_s = 30 * SECONDS_PER_MINUTE; HRMFeature features = HRMFeature_BPM; HRMSessionRef session_ref = sys_hrm_manager_app_subscribe(app_id, update_interval_s, expire_s, features); fake_system_task_callbacks_invoke_pending(); // Should start out enab...
(prv_can_turn_sensor_on())
path to directory containing sample files DIR *dp; // Directory pointer struct dirent *ep; // Entry we are currently processing FILE *file; // File we currently have open SampleFileType type; // type of samples } SampleDiscoveryState; #define A...
PBL_ASSERTN(state->test_entry.name[0] != 0)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ // Clear IT Pending bit EXTI->PR = prv_exti_line_to_bit(exti_line); prv_lock(); switch (trigger) { case ExtiTrigger_Rising: EXTI->RTSR |= prv_exti_line_to_bit(exti_line); EXTI->FTSR &= ~prv_exti_line_to_bit(exti_line); break; case ExtiTrigger_Falling: EXTI->RTSR &= ~prv_exti_line_to_bit(...
void exti_enable_other(ExtiLineOther exti_line) { prv_lock(); EXTI->IMR |= prv_exti_line_to_bit(exti_line); prv_unlock(); } void exti_disable_other(ExtiLineOther exti_line) { prv_lock(); uint32_t exti_bit = prv_exti_line_to_bit(exti_line); EXTI->IMR &= ~exti_bit; EXTI->PR = exti_bit; // No need ...
(gcolor_equal(test_value, start_value))
; property_animation_get_to_gcolor8(prop_h, &test_value); cl_assert(gcolor_equal(test_value, end_value)); GColor8 set_value; set_value = (GColor8) {.a=0, .r=1, .g=2, .b=3}; property_animation_set_from_gcolor8(prop_h, &set_value); property_animation_get_from_gcolor8(prop_h, &test_value); cl_assert(gcolor...
s_results_lengths[10]; static uint8_t s_results_count; static uint32_t s_max_results_count; static bool prv_result_callback(const char *value, uint32_t value_length, uint32_t index, void *context) { strcpy(s_results[s_results_count], value); s_results_lengths[s_results_count] = val...
("-2147483649", 1, false, 0)
; // succeeds: // "-2147483648" * 1 assert_float_parse("-2147483648", 1, true, -2147483648); assert_float_parse("2147483648", -1, true, -2147483648); } // ams_util_csv_parse() tests /////////////////////////////////////////////////////////// #define assert_result(idx, val, len); \ cl_assert_equal_i(len, s_...
ata) { app_menu_data_source_draw_row(&data->data_source, ctx, cell_layer, cell_index); } /////////////////// // Window callbacks static void prv_window_load(Window *window) { LauncherMenuData *data = window_get_user_data(window); GRect bounds = window->layer.bounds; status_bar_layer_init(&data->status_bar); ...
(window, WINDOW_NAME("Launcher Menu"))
; window_set_user_data(window, data); window_set_window_handlers(window, &(WindowHandlers) { .load = prv_window_load, .unload = prv_window_unload, }); const bool animated = false; app_window_stack_push(window, animated); } //////////////////// // App boilerplate static void s_main(void) { const L...
h" #include "applib/ui/content_indicator_private.h" #include "applib/ui/shadows.h" #include "applib/ui/window.h" #include "process_management/app_manager.h" #include "system/logging.h" #include "system/passert.h" #include "util/math.h" #include "animation_timing.h" #include <string.h> T_STATIC bool prv_scroll_layer_...
{ scroll_layer_init(layer, &frame); }
return layer; } bool scroll_layer_is_instance(const Layer *layer) { return layer && layer->property_changed_proc == scroll_layer_property_changed_proc; } void scroll_layer_deinit(ScrollLayer *scroll_layer) { animation_destroy(property_animation_get_animation(scroll_layer->animation)); content_indicator_destr...
------------------------------------------------------------------------- // fill a buffer, return it's CRC32 static uint32_t prv_get_random_buffer(uint8_t **buf, unsigned int size) { uint8_t *temp = calloc(size, sizeof(uint8_t)); for (unsigned int i = 0; i < size; i++) { temp[i] = (uint8_t)(rand() % 10); } ...
data_logging_create(i, DATA_LOGGING_UINT, item_size, false)
; cl_assert(logging_sessions[i]); fake_system_task_callbacks_invoke_pending(); } // Log Consume for (int i = 0; i < 10; i++) { prv_log_consume_random(logging_sessions[i], item_size, rand() % 12345); } } // ---------------------------------------------------------------------------------------- voi...
Tests 4-bit bitblt palettized to circular display buffer // Result: // - gbitmap matches platform loaded PBI void test_bitblt_circular__color_4_bit(void) { GBitmap *bitmap = setup_png_test(TEST_PNG_FILE); GBitmap *native_framebuffer = graphics_context_get_bitmap(ctx); cl_assert(native_framebuffer->info.format ...
cl_assert(native_framebuffer->info.format == GBitmapFormat8BitCircular)
cifier(state, macro_spec, value); if (i != macro_end - 1) { prv_append_string_i18n(state, s_splitters[add_units][i >= macro_end - 2]); } } break; } default: state->error->status = TemplateStringErrorStatus_InvalidConversionSpecifier; return input; } // Skip ...
{ prv_handle_escape_character(state); if (state->error->status != TemplateStringErrorStatus_Success) { return; } state->position++; }
if (*state->position == '\0') { state->error->status = TemplateStringErrorStatus_MissingClosingQuote; return; } // Skip the delimiter state->position++; } static void prv_filter_format(TemplateStringState *state) { bool match; bool previously_matched = false; bool did_output = false; // We ne...
{ 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_override, }, }, }; event_put(&event); } ...
bt_ctl_is_bluetooth_active()
) { system_task_add_callback(prv_bt_ctl_reset_bluetooth_callback, NULL); } else { PBL_LOG(LOG_LEVEL_DEBUG, "Bluetooth is disabled, reset aborted"); } } void command_bt_airplane_mode(const char* new_mode) { // as tests run using command_bt_airplane_mode, will retain nomenclature // but work as override ...
// Corner cases test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset); layer_render_tree(&canvas, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset.${BIT_DEPTH_NAME}.pbi")); ...
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_nx)
; layer_render_tree(&canvas, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_nx.${BIT_DEPTH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_x); layer_render_tree(&canvas, &ctx); cl_ch...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(0, 20 + max_size_1.h, scroll_bounds.size.w, 2000)
); text_layer_set_text(&data->text_layer_2, QUOTE_BUF_2); text_layer_set_background_color(&data->text_layer_2, GColorCyan); text_layer_set_font(&data->text_layer_2, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(&data->text_layer_2, GTextAlignmentCenter); // Add second text la...
break; case BUTTON_ID_DOWN: key = PREF_KEY_QUICK_LAUNCH_DOWN; break; case BUTTON_ID_SELECT: key = PREF_KEY_QUICK_LAUNCH_SELECT; break; case BUTTON_ID_BACK: key = PREF_KEY_QUICK_LAUNCH_BACK; break; case NUM_BUTTONS: break; } PBL_ASSERTN(key); prv_pref_set...
{ if (s_activity_activation_timestamp == 0) { s_activity_activation_timestamp = rtc_get_time(); prv_pref_set(PREF_KEY_ACTIVITY_ACTIVATED_TIMESTAMP, &s_activity_activation_timestamp, sizeof(s_activity_activation_timestamp)); } }
bool activity_prefs_has_activation_delay_insight_fired(ActivationDelayInsightType type) { return (s_activity_activation_delay_insight & (1 << type)); } void activity_prefs_set_activation_delay_insight_fired(ActivationDelayInsightType type) { s_activity_activation_delay_insight |= (1 << type); prv_pref_set(PREF...
lue); break; case RelationshipBarTypeBackToBack: prv_draw_rel_bar_line(timeline_layer, ctx, current, rel_bar_value); break; case RelationshipBarTypeNone: // Draw nothing break; } } } // Timer callback that displays the current relationship bar if user has stopp...
prv_rel_bar_reset_offsets(&layer->relbar_layer, RelationshipBarOffsetTypePrev)
; curr_anim_needed = true; } // Create previous rel bar animation Animation *prev_rel_bar_anim = NULL; if (prev_anim_needed) { prev_rel_bar_anim = prv_create_prev_rel_bar_animation(layer, duration, interpolate); } Animation *curr_rel_bar_anim = NULL; if (curr_anim_needed) { curr_rel_bar_an...
assert_result_invalid(app_smartstrap_attribute_read(NULL)); // destroy test attribute app_smartstrap_attribute_destroy(attr); } void test_app_smartstrap__check_ids(void) { // craete an attribute SmartstrapAttribute *attr = app_smartstrap_attribute_create(0x1111, 0x2222, 100); cl_assert(attr != NULL); // ...
(smartstrap_attribute_send_pending())
; // check that it was sent successfully SmartstrapRequest request = { .service_id = 0x1111, .attribute_id = 0x2222, .write_mbuf = NON_NULL_MBUF, .read_mbuf = NULL, .timeout_ms = SMARTSTRAP_TIMEOUT_DEFAULT }; // fake the ACK and expect a did_write handler call fake_smartstrap_profiles_ch...
_distance_mm(uint32_t steps, uint32_t ms) { if ((steps == 0) || (ms == 0)) { return 0; } // For a rough ballpack figure, according to // http://livehealthy.chron.com/determine-stride-pedometer-height-weight-4518.html // The average stride length in mm is: // men: 0.415 * height(mm) // women:...
{ k_constant_x1000 = 1002; }
uint64_t weight_dag = activity_prefs_get_weight_dag(); // 10 grams = 1 dag uint32_t calories = ROUND(k_constant_x1000 * (uint64_t)distance_mm * weight_dag, 1000 * MM_PER_METER * ACTIVITY_DAG_PER_KG); // Return calories ACTIVITY_LOG_DEBUG("Got delta active calories of %"PRIu32" "...
ion destination = session->destination; return (destination == TransportDestinationSystem || destination == TransportDestinationHybrid) && !prv_is_transport_type(session->transport, session->transport_imp, CommSessionTransportType_QEMU) && !prv_is_transport_type...
PBL_ASSERTN(s_session_head == NULL)
PBL_LOG(LOG_LEVEL_DEBUG, "setting accel rate:%d, num_samples:%"PRIu32, highest_rate, num_samples)
; } // Switch accelerometer into and out of low power mode. This function is // idempotent; calling it multiple times in a row with the same arguments must // have the same result as calling it once. void accel_manager_enable(bool on) { mutex_lock_recursive(s_mutex); bool prev = s_enabled; s_enabled = on; if (...
p1) { // Implementation of Wu-Xiang fast anti-aliased line drawing algorithm // Points over which we're going to iterate adjusted to drawing_box int16_t x1 = p0.x + ctx->draw_state.drawing_box.origin.x; int16_t y1 = p0.y + ctx->draw_state.drawing_box.origin.y; int16_t x2 = p1.x + ctx->draw_state.drawing_box...
(framebuffer, &ctx->draw_state.clip_box, x2, y2, MAX_PLOT_OPACITY, stroke_color)
-------------------------- //! Kills the app, giving it no chance to clean things up or exit gracefully. The app must //! already be in a state where it's safe to exit. //! Note that the app may not have ever been successfully started when this is called, so check //! your null pointers! static void prv_app_cleanup(voi...
while (text_height > max_text_height && name_len > min_text_len) { name_len--; sniprintf(text, DIALOG_MAX_MESSAGE_LEN, text_fmt, name_len, entry.name); dialog_set_text(dialog, text); text_height = text_layer_get_content_size(ctx, text_layer).h; }
#endif i18n_free_all(crash_dialog); PBL_LOG(LOG_LEVEL_DEBUG, "Watchface crashed, launching default."); crash_info = (AppCrashInfo) { 0 }; watchface_set_default_install_id(INSTALL_ID_INVALID); watchface_launch_default(NULL); #endif } // --------------------------------------------------------------------...
/* * 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 (ch >= 'a' && ch <= 'z') { ch = ch - 'a' + 10; } else { // This will catch '\0' break; }
if (ch >= base) { break; } value *= base; value += ch; if (do_errors) { if ((sign > 0) && (value > max)) { value = max; } else if ((sign < 0) && (-value < min)) { value = -min; } } nptr++; } if (endptr) { *endptr = (char*)nptr; } return va...
#define CMSIS_COMPATIBLE #include <mcu.h> #include <inttypes.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #if PULSE_EVERYWHERE #define PROF_LOG(buf, sz, fmt, ...) \ do { \ snprintf(buf, sz, fmt, ## __VA_ARGS__); \ PBL_LOG(LOG_LEVEL_DEBUG, "%s", buf);...
PROF_LOG(buf, sizeof(buf), "%-24s %-8s %-11s %-15s %-8s %-7s", "Name", "Count", "Cycles", "Time (us)", "Avg (us)", "% CPU")
; while (sorted != NULL) { ProfilerNode *node = (ProfilerNode *)sorted; uint32_t percent = (((int64_t)node->total) * 100) / total; PROF_LOG(buf, sizeof(buf), "%-24s %-8"PRIu32" %-11"PRIu32" %-15"PRIu32" %-8"PRIu32 " %-7"PRIu32, node->module_name, node->count, node->total, node...
reversed, laziness // 2x 128-bit UUIDs is not going to fit, expect false: cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 2), false); // Hand-construct expected raw advertisement data: uint8_t expected_ad_data[sizeof(Uuid) + 2 /* +1 Length, +1 Type bytes */] = { sizeof(Uuid) + 1 /* +1 for Type byte *...
ble_ad_create()
; uint8_t expected_ad_data[] = { 1 /* +1 for Type byte */ + 13 /* Company ID + data */, 0xff, // Manufacturer Specific data 0x34, 0x12, 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', }; // Should fit fine, expect true: cl_assert_equal_b(ble_ad_set_manufacturer_specific_data(ad, ...
tion_status.legacy_status; *status = (LegacyFwUpdateCompletionStatus) { .recovery_percent_completion = 0, .resource_percent_completion = 0, .firmware_percent_completion = 0 }; return true; } // End Legacy completion handlers bool firmware_update_is_in_progress(void) { return s_update_status == F...
if (prv_legacy_handle_progress(event)) { return; }
if (event->type != PebblePutBytesEventTypeProgress) { return; // Only progress events report bytes_transferred updates } FwUpdateCompletionStatus *status = &s_current_completion_status.status; status->bytes_transferred += event->bytes_transferred; } void firmware_update_pb_event_handler(PebblePutBytesEv...
imeString();\n" ); ASSERT_JS_GLOBAL_EQUALS_S("s", "20:04:05"); s_time += 4 * SECONDS_PER_HOUR; EXECUTE_SCRIPT( "var d = new Date();\n" "var s = d.toLocaleTimeString();\n" ); ASSERT_JS_GLOBAL_EQUALS_S("s", "00:04:05"); } void test_rocky_api_datetime__locale(void) { rocky_global_init(s_api); ...
EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: 'numeric'});")
; ASSERT_JS_GLOBAL_EQUALS_S("s", "25"); EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: '2-digit'});"); ASSERT_JS_GLOBAL_EQUALS_S("s", "25"); EXECUTE_SCRIPT("s = d.toLocaleDateString(undefined, {day: 'short'});"); ASSERT_JS_GLOBAL_EQUALS_S("s", "Mon"); EXECUTE_SCRIPT("s = d.toLocaleDateString(unde...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ prv_init(dev, true /* is_open_drain */, UARTCR1Flags_Duplex); }
void uart_init_tx_only(UARTDevice *dev) { prv_init(dev, false /* !is_open_drain */, UARTCR1Flags_TE); } void uart_init_rx_only(UARTDevice *dev) { prv_init(dev, false /* !is_open_drain */, UARTCR1Flags_RE); } void uart_deinit(UARTDevice *dev) { dev->periph->CR1 &= ~USART_CR1_UE; periph_config_disable(dev->pe...
(&s_items[s_correct_order[5]].header.id, &timeline_model_get_iter_state(1)->pin.header.id)
); cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_state_with_timeline_idx(4)); cl_assert(timeline_model_iter_prev(&new_idx, NULL)); cl_assert_equal_i(new_idx, 3); cl_assert_equal_i(timeline_model_get_num_items(), 2); cl_assert(uuid_equal(&s_items[s_correct_order[3]].header.id, &t...
s_phone_ui_data->call_status_text_layer.layer, false); layer_add_child(&s_phone_ui_data->core_ui_container, &s_phone_ui_data->call_status_text_layer.layer); // Shrink the bounds but not the frame size to allow for centering when action bar removed s_phone_ui_data->call_status_text_layer.layer.bo...
{ prv_set_status_text(DISCONNECTED); }
else { prv_set_status_text(DECLINED); } } prv_window_pop_with_delay(CALL_END_DELAY_MS); } void phone_ui_handle_call_hide(void) { // Just pop the window - it'll handle all the cleanup prv_window_pop(); } void phone_ui_handle_caller_id(PebblePhoneCaller *caller) { if (!s_phone_ui_data) { PBL_L...
TARGET_QEMU return S_SUCCESS; #endif qspi_use(dev->qspi); prv_write_enable(dev); prv_write_cmd_no_addr(dev, dev->state->part->instructions.block_unlock_all); qspi_release(dev->qspi); return S_SUCCESS; } #if !RELEASE #include "console/prompt.h" #include "drivers/flash.h" #include "kernel/pbl_malloc.h" #incl...
if (prv_flash_read_verify(dev, final_size, 3)) { ++passes; } else { ++failures; prompt_send_response("ERROR: flash_read_verify failed"); }
} qspi_release(QSPI); bool was_busy = false; // write a few bytes to the sector we're going to erase so it's not empty uint8_t dummy_data = 0x55; flash_write_bytes(&dummy_data, FLASH_REGION_FIRMWARE_SCRATCH_BEGIN, sizeof(dummy_data)); profiler_start(); status_t result = flash_impl_erase_sector_begin...
tructured_glance) { LauncherAppGlanceWorkout *workout_glance = launcher_app_glance_structured_get_data(structured_glance); return NULL_SAFE_FIELD_ACCESS(workout_glance, icon, NULL); } static const char *prv_get_title(LauncherAppGlanceStructured *structured_glance) { LauncherAppGlanceWorkout *workout_glance...
memset(workout_glance->subtitle, 0, sizeof(workout_glance->subtitle))
; glance_changed = true; } // Broadcast to the service that we changed the glance if it was changed if (glance_changed) { launcher_app_glance_structured_notify_service_glance_changed(structured_glance); } // Bail since no workout is going on return; } // Set icon for the ongoi...
/* * 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...
{ pfs_init(true); }
void services_normal_init(void) { persist_service_init(); app_install_manager_init(); blob_db_init_dbs(); app_cache_init(); phone_call_service_init(); music_init(); alarm_init(); timeline_event_init(); dls_init(); wakeup_init(); app_order_storage_init(); #if CAPABILITY_HAS_HEALTH_TRACKING ...
)((y) * FIXED_S16_3_FACTOR))) void test_rocky_api_graphics__fill_radial(void) { prv_global_init_and_set_ctx(); EXECUTE_SCRIPT( "ctx.rockyFillRadial(30, 40, 10, 20, 0, Math.PI);\n" ); cl_assert_equal_i(1, s_graphics_fill_radial_precise_internal.call_count); MockCallRecording *const lc = &s_graphics_fill...
cl_assert_equal_i(1, s_graphics_context_set_stroke_width.call_count)
; cl_assert_equal_i(8, s_graphics_context_set_stroke_width.last_call.width); ASSERT_JS_GLOBAL_EQUALS_I("w", s_graphics_context_set_stroke_width.last_call.width); EXECUTE_SCRIPT( "ctx.lineWidth = 2.1;\n" "var w = ctx.lineWidth;\n" ); ASSERT_JS_GLOBAL_EQUALS_I("w", 2); EXECUTE_SCRIPT_EXPECT_ERROR( ...
/* * 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_data)
; window_set_on_screen(window, true, true); window_render(window, &s_ctx); return window; } // Tests ////////////////////// void test_health_hr_detail_card__render_no_data(void) { prv_create_card_and_render(&(HealthData) {}); cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); } void test_health_h...
st_free_block(~0); s_log_internal__expected = NULL; rocky_runtime_context_init(); fake_app_timer_init(); jerry_init(JERRY_INIT_EMPTY); s_app_window_stack_get_top_window = (Window){}; s_context = (GContext){}; s_app_state_get_graphics_context = &s_context; s_app_event_loop_callback = NULL; s_graphic...
(GPoint(4, 5), lc->path.points[2])
; s_gpath_draw_filled.call_count = 0; EXECUTE_SCRIPT( "ctx.moveTo(7, 8);\n" "ctx.lineTo(9, 10);\n" "ctx.fill();\n" ); // still only the first part (before the .moveTo()) as the second only has two points cl_assert_equal_i(1, s_gpath_draw_filled.call_count); cl_assert_equal_i(3, lc->path.num_po...
nimation_get_duration(b, false, false), duration_b); cl_assert_equal_i(animation_get_duration(b, false, true), play_count_b * duration_b); cl_assert_equal_i(animation_get_duration(b, true, false), delay_b + duration_b); cl_assert_equal_i(animation_get_duration(b, true, true), total_duration_b); cl_assert_equal...
cl_assert(animation_set_auto_destroy(h, false) == true)
; // Handlers void *context = &value; animation_set_handlers(h, handlers, context); AnimationHandlers c_handlers = animation_get_handlers(h); cl_assert(memcmp(&c_handlers, &handlers, sizeof(AnimationHandlers)) == 0); // Context cl_assert(animation_get_context(h) == context); // Duration cl_assert(a...
/* * 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...
(&score->attr_list, VibeAttributeId_Pattern, score->attr_list_size)
; if (!notes_attribute || !pattern_attribute) { return false; } unsigned int num_note_types = prv_vibe_score_get_num_note_types(notes_attribute); if (notes_attribute->length != num_note_types * sizeof(VibeNote)) { return false; } VibeNoteIndex *pattern_list = prv_vibe_score_get_pattern_list(patter...
he erase has started const uint32_t busy_timeout_us = 500; const bool result = qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_status, dev->state->part->status_bit_masks.busy, true /* set */, busy_timeout_us); qspi_release(QSPI);...
qspi_use(dev->qspi)
; prv_write_enable(dev); qspi_indirect_write(dev->qspi, dev->state->part->instructions.page_program, addr, buffer, bytes_in_page); qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_status, dev->state->part->status_bit_masks.busy, false /* !set */, QSPI_NO_TIMEOUT);...
0; #endif } // ---------------------------------------------------------------------------------------------- static bool prv_should_smart_alarm_trigger(const AlarmConfig *config) { if (s_smart_snooze_counter >= SMART_ALARM_MAX_SMART_SNOOZE) { // The smart alarm has reached the end of its time range return ...
{ analytics_event_pin_updated(alarm_time, &entry->uuid); }
else { analytics_event_pin_created(alarm_time, &entry->uuid); } } } alarm_time = prv_get_alarm_time( alarm, cron_job_get_execute_time_from_epoch(cron, current_time + (i * SECONDS_PER_DAY))); } AlarmStorageKey key = { .id = alarm->id, .type = ALARM_DATA_PINS }; settings_fi...
sector_addr < FLASH_REGION_DEBUG_DB_END; sector_addr += ERASE_UNIT_SIZE) { prv_erase_unit(sector_addr); } } static uint8_t generation_to_log_file_id(int generation) { int log_id = (int)s_curr_state.log_file_id - generation; if (log_id < 0) { log_id += MAX_LOG_FILE_ID; } return (log_id); } //! Sc...
(&prev_log_id)
; if (first_used_region == UINT32_MAX) { // no logs exist so start at region 0 s_curr_state.page_start_addr = FLASH_REGION_DEBUG_DB_BEGIN; goto done; } bool new_log_region_found = false; bool multiple_gens_found = false; for (uint32_t offset = 0; offset < LOG_REGION_SIZE; offset += LOG_PAGE_SIZE) {...
, 1448}, { 568, 288, 1488}, { 776, 200, 1184}, { 992, 160, 888}, { 1392, 192, 888}, { 1832, 256, 872}, { 1688, 128, 648}, { 1664, 168, 520}, { 1776, -48, 624}, { 1760, -192, 552}, { 1528, 152, 320}, // 243 seconds { 1456, 360, 200}, { 944, -264, -584}, { 736, 296,...
{ 1480, 168, 248}, { 1632, -184, 328}, { 1792, -88, 648}, { 1888, 136, 1096}, { 1792, 336, 1176}, { 1880, 312, 672}, { 1416, 168, 1352}, { 720, 344, 1544}, { 480, 272, 1384}, { 544, 240, 1128}, { 744, 120, 928}, { 1168, 96, 904}, { 1720, 176, 848}, { 1696, 144, 64...
{ 1232, -32, 112}, { 904, -72, -616}, { 1048, -176, -632}, { 984, 208, -280}, { 1288, 328, 120}, // 251 seconds { 1288, 88, 240}, { 1496, 0, 328}, { 1704, 168, 536}, { 1880, 216, 760}, { 1880, 208, 1008}, { 1888, 264, 944}, { 1664, 416, 960}, { 1128, 480, 1496}, ...
1144, -88, -304}, { 1608, -200, -504}, { 896, 216, -248}, { 1040, 24, -424}, // 56 seconds { 1088, 112, -408}, { 864, 8, -336}, { 552, 16, -256}, { 424, 8, -192}, { 440, 88, -168}, { 608, 112, -208}, { 800, 256, -320}, { 1040, 304, -408}, { 1112, 240, -392}, { 153...
{ 824, -8, -88}, { 584, -24, -144}, { 464, -8, -184}, { 544, -16, -144}, { 728, -40, -176}, { 1016, -64, -208}, { 1256, -48, -264}, { 1688, -184, -312}, { 1056, 232, -256}, { 1112, 64, -368}, { 1104, 88, -384}, { 912, -8, -336}, { 528, -8, -240}, { 344, 32, -168},...
{ 1264, 176, -384}, { 1376, 184, -400}, { 1368, 184, -304}, { 1368, 112, -216}, { 1312, -8, -152}, { 976, -8, -152}, { 624, -16, -184}, { 432, -24, -176}, { 456, -32, -120}, { 576, -8, -168}, { 856, -72, -88}, { 1144, -72, -176}, { 1256, -8, -280}, { 1568, -128, ...
/* * 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(history_len, 1)
; if (metric == ActivityMetricSleepState) { *history = s_sleep_state; return true; } else if (metric == ActivityMetricSleepStateSeconds) { *history = s_sleep_state_seconds; return true; } else if (metric == ActivityMetricLastVMC) { *history = s_last_vmc; return true; } cl_assert(false...
false, prv_finished_failure_callback, data); } else { prv_finished_failure_callback(data); } } static void prv_animation_stopped_failure(Animation *animation, bool finished, void *context) { ProgressWindow *data = context; prv_show_peek_layer(data); } static void prv_...
prv_show_peek_layer(data)
; #endif } //////////////////////////// // Internal Helper Functions //////////////////////////// //! Used to clean up the application's data before exiting static void prv_cancel_fake_progress_timer(ProgressWindow *data) { if (data->fake_progress_timer != EVENTED_TIMER_INVALID_ID) { evented_timer_cancel(data->...
&expandable_dialog->scroll_layer, -1); } static void prv_config_provider(void *context) { ExpandableDialog *expandable_dialog = context; window_single_repeating_click_subscribe(BUTTON_ID_UP, 100, prv_up_click_handler); window_single_repeating_click_subscribe(BUTTON_ID_DOWN, 100, prv_down_click_handler); if (ex...
text_layer_get_content_size(ctx, header_layer)
; header_size.h += 4; // See PBL-1741 header_size.w = w; header_content_height = header_size.h; text_layer_set_size(header_layer, header_size); } // Set up the text. const uint16_t TEXT_OFFSET = 6; x = left_margin_px; y = (icon ? icon_offset + icon_size.h : -TEXT_OFFSET) + header_content_heig...
text) { uint32_t *num_activities_found = (uint32_t *)context; *num_activities_found += 1; char *activity_name = "unknown"; switch (activity) { case HealthActivityNone: activity_name = "none"; break; case HealthActivitySleep: activity_name = "sleep"; break; case HealthActivit...
if (num_minutes == 0) { 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...
(menu_layer, data, &(MenuLayerCallbacks) { .get_num_rows = prv_get_num_rows_callback, .get_cell_height = prv_get_cell_height_callback, .draw_row = prv_draw_row_callback, .select_click = prv_select_callback, .get_separator_height = prv_get_separator_height_callback })
; menu_layer_set_normal_colors(menu_layer, PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite), PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack)); menu_layer_set_highlight_colors(menu_layer, PBL_IF_COLOR_ELSE(SETTINGS_MENU_HIGHLIGHT_...
TagProtobufLogSession, DATA_LOGGING_BYTE_ARRAY, PLOG_DLS_RECORD_SIZE, buffered, resume, &system_uuid); if (!s_plog_state.dls_session) { // This can happen when you are not connected to the phone and have rebooted a number of ...
{ PBL_LOG(LOG_LEVEL_ERROR, "Error encoding payload"); }
/* * 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_last_blob = (AnalyticsEventBlob) {}; }
void test_analytics_event__cleanup(void) { } void test_analytics_event__analytics_event_app_crash(void) { const Uuid app_uuid = UuidMake(0xBE, 0x85, 0x14, 0x68, 0x70, 0x21, 0x43, 0xC6, 0xAB, 0x44, 0xB8, 0x36, 0xFC, 0xD0, 0x33, 0x04); const uint32_t pc = 0x8888888; const uint32...
16}, { -424, 752, 208}, { -440, 752, 216}, { -432, 752, 208}, { -424, 760, 208}, { -440, 752, 216}, { -432, 760, 200}, { -424, 744, 216}, { -432, 784, 216}, { -424, 744, 192}, { -424, 768, 216}, { -432, 744, 240}, { -432, 744, 224}, { -440, 752, 224}, { -440, 744,...
{ -440, 744, 208}, { -432, 752, 200}, { -440, 752, 200}, { -480, 672, 152}, // 163 seconds { -408, 808, 296}, { -400, 720, 200}, { -456, 760, 176}, { -448, 736, 200}, { -456, 752, 216}, { -464, 680, 176}, { -408, 840, 240}, { -392, 720, 200}, { -464, 768, 200}, ...
{ -464, 728, 216}, { -456, 728, 224}, { -464, 728, 224}, { -472, 720, 224}, { -464, 728, 216}, { -472, 736, 208}, { -472, 720, 224}, { -472, 720, 224}, { -464, 736, 224}, { -448, 744, 216}, { -448, 744, 216}, { -440, 736, 224}, // 166 seconds { -440, 744, 216}, ...
0); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 0); // The stopped handler for A should fire before the started handler for B cl_assert(prv_last_handler_entry(&s_stopped_handler_calls, a)->fire_ord...
(&s_stopped_handler_calls, seq)
, 1); // Everything should have been freed cl_assert_equal_i(prv_count_animations(), 0); #endif } // -------------------------------------------------------------------------------------- // Test a seeking in a basic sequence animation void test_animation__simple_sequence_set_elapsed(void) { #ifdef TEST_INCLUD...
/* * 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, "Selected menu item %d", index); // Here we just change the subtitle to a literal string s_app_data->menu_items[index].subtitle = "You've hit select here!"; // Mark the layer to be updated layer_mark_dirty(simple_menu_layer_get_layer(s_app_data->menu_layer)); // --------...
// Trigger it. This transfers control to our ISR handler OTG_FS_WKUP_IRQHandler NVIC_SetPendingIRQ(OTG_FS_WKUP_IRQn); } else if (index == 5) { PBL_LOG(LOG_LEVEL_INFO, "Entering infinite loop in non-FreeRTOS ISR."); NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = OTG_F...
_get_root_layer(&data->mic_window.window)->frame; GRect dot_frame = data->mic_window.mic_dot_layer.frame; grect_align(&dot_frame, root_frame, GAlignCenter, false); layer_set_frame(&data->mic_window.mic_dot_layer, &dot_frame); layer_set_hidden(&data->mic_window.mic_dot_layer, false); static const uint32_t ANI...
animation_unschedule((Animation *)data->mic_window.progress_anim)
; } void test_stats__avg(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_Average; int32_t result; stats_calculate_basic(op, data, num_data, NULL, NULL, &result); cl_assert_equal_i(result, 40); } void tes...
cl_assert_equal_i(result.first_streak, 1)
; cl_assert_equal_i(result.median, 34); } void test_stats__all_basic_ops_filtered_out(void) { const int32_t data[] = { 0, 0, 0, 0, 0 }; const size_t num_data = ARRAY_LENGTH(data); const StatsBasicOp op = (StatsBasicOp_Sum | StatsBasicOp_Average | StatsBasicOp_Min | StatsBasicOp_Max | StatsBasi...
ndow_stack, true); } static void prv_push_window_unload(Window *window) { WindowStack *stack = window->parent_window_stack; prv_window_unload(window); Window *new_window = window_create(); window_set_window_handlers(new_window, &(WindowHandlers){ .load = prv_window_load, .unload = prv_window_unload, ...
(window2->on_screen, false)
Deleted"); dialog_set_text(dialog, i18n_get(delete_text, dialog)); i18n_free(delete_text, dialog); dialog_set_icon(dialog, RESOURCE_ID_RESULT_SHREDDED_LARGE); dialog_set_background_color(dialog, ALARMS_APP_HIGHLIGHT_COLOR); dialog_set_timeout(dialog, DIALOG_TIMEOUT_DEFAULT); app_simple_dialog_push(simple_di...
menu_cell_layer_is_highlighted(cell_layer)
) { if (data->show_limit_reached_text) { // Trying to add a new alarm when list is already full const GFont font = system_theme_get_font_for_default_size(TextStyleFont_MenuCellSubtitle); box = GRect(0, 0, cell_layer->bounds.size.w, fonts_get_font_height(font)); ...
s_count; static uint32_t analytics_write_bytes_count; void analytics_external_collect_system_flash_statistics(void) { // TODO: Add support back to tintin } void analytics_external_collect_app_flash_read_stats(void) { analytics_set(ANALYTICS_APP_METRIC_FLASH_READ_COUNT, analytics_read_count, AnalyticsClient_App); ...
DMA_Cmd(FLASH_TX_DMA_STREAM, ENABLE)
; xSemaphoreTake(s_flash_state.dma_semaphore, portMAX_DELAY); stop_mode_enable(InhibitorFlash); xSemaphoreGive(s_flash_state.dma_semaphore); } void DMA2_Stream0_IRQHandler(void) { if (DMA_GetITStatus(FLASH_DMA_STREAM, DMA_IT_TCIF3)) { DMA_ClearITPendingBit(FLASH_DMA_STREAM, DMA_IT_TCIF3); NVIC_DisableI...
; memset(activity_private_state()->hr.samples, bpm, num_samples); memset(activity_private_state()->hr.weights, 100, num_samples); for (int i = 0; i < num_minutes; i++) { prv_minute_system_task_cb(NULL); } } static bool prv_is_hr_elevated(void) { return activity_private_state()->hr.metrics.is_hr_elevated...
activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &zone1_minutes)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(FLASH_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_...
0x17, 0x00, // Token TEST_DB_ID, // BlobDBDatabaseId: 0x01 0x01, // Size primary key: 1 byte // Primary Key: byte 0x6b // no value size }; void test_blob_db_endpoint__handle_insert_command_no_value_size(void) { // Ensure packet is too small cl_asse...
cl_assert(TEST_DB_ID == *(uint8_t*)cmd_ptr)
; cmd_ptr += sizeof(uint8_t); // check for a key size cl_assert(TEST_KEY_SIZE == *(uint8_t*)cmd_ptr); cmd_ptr += sizeof(uint8_t); // go past key_bytes cmd_ptr += TEST_KEY_SIZE; cl_assert((cmd_ptr - s_delete_cmd_success) == sizeof(s_delete_cmd_success)) ; // Process Command uint8_t *resp_ptr = proc...
c = 0; c < GAPLEClientNum; ++c) { GAPLEConnectionClient *client = &intent->client[c]; if (client->is_used) { *task_mask &= ~gap_le_pebble_task_bit_for_client(c); } } } //! extern'd for gatt.c, used to determine to what tasks a "Buffer Empty" event should be sent. //! Helper function to build a Pebb...
(e->device.address)
); goto unlock; } if (e->is_address_updated) { connection->device = e->new_device; PBL_LOG(LOG_LEVEL_INFO, "Updated address to "BT_DEVICE_ADDRESS_FMT". Updated IRK: %c", BT_DEVICE_ADDRESS_XPLODE(connection->device.address), e->is_resolved ? 'Y' : 'N'); } else if...
OOT_BIT_SOFTWARE_FAILURE_OCCURRED); // We have a "three strikes" algorithm: if the watch fails three times, return true // to tell the parent we should load the recovery firmware. A reset for any other reason // will reset this algorithm. if (boot_bit_test(BOOT_BIT_FW_START_FAIL_STRIKE_TWO)) { // Yikes, ou...
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE)
; boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO); } if (pmic_boot_due_to_charger_disconnect()) { dbgserial_putstr("PMIC woke from standby due to charger disconnect"); dbgserial_putstr("Putting PMIC back into standby"); pmic_power_off(); } flash_init(); button_init(); display_init()...
characteristics; ++c) { BLECharacteristic characteristic_ref = characteristic_refs[c]; const Characteristic *expected_characteristic = &expected_service->characteristics[c]; // Test gatt_client_characteristic_get_uuid(): const Uuid uuid = gatt_client_characteristic_get_uuid(characteristic_ref);...
fake_gatt_get_blood_pressure_service()
; // Get the reference to the Blood Pressure service: const uint8_t num_services = 1; BLEService service_refs[num_services]; gatt_client_copy_service_refs_matching_uuid(&device, service_refs, num_services, &bp_service->uuid); Uuid matching_uuids[3]; matching_u...
lse; } if (key < context->oldest_valid_key || key > context->newest_valid_key) { ACTIVITY_LOG_DEBUG("Dropping key %"PRIu32", record UTC of %"PRIu32"", key, val->hdr.time_utc); return false; } // This can take a while, so periodically tickle the KernelBG watchdog. if (context->...
{ if (sample_idx == 0) { // If first record, init the header prv_init_minute_record(&file_record->hdr, sample_utc, true /*to_file*/); } // Put in this minute file_record->samples[sample_idx].v5_fields = data->base; file_record->samples[sample_idx].heart_rate_bpm = data->heart_rate_bpm; file_record-...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ prv_test_plot_horizontal_line(&ctx.dest_bitmap, GRect(OFFSET_X, OFFSET_Y + i, STRIPE_WIDTH, STRIPE_HEIGHT), (GColor){.argb = color | alpha}); color++; }
// 66% alpha channel blend test color = 0x0; alpha = 0x80; for (int i=64; i < 128; i++) { prv_test_plot_horizontal_line(&ctx.dest_bitmap, GRect(OFFSET_X, OFFSET_Y + i, STRIPE_WIDTH, STRIPE_HEIGHT), (GColor){.argb = color | alpha}); c...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
prv_show_peek_layer(data)
nt(18, 0), 22); graphics_draw_vertical_line_dotted(&ctx, GPoint(20, 0), MAX_NUM_ROWS - 1); graphics_draw_vertical_line_dotted(&ctx, GPoint(22, 0), MAX_NUM_ROWS + 1 ); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_even_cols_no_clip"))); // Odd cols of di...
graphics_draw_vertical_line_dotted(&ctx, GPoint(10, 70), 10)
; graphics_draw_horizontal_line_dotted(&ctx, GPoint(5, 76), 5); // T facing right - even vert, odd horiz graphics_draw_vertical_line_dotted(&ctx, GPoint(50, 70), 10); graphics_draw_horizontal_line_dotted(&ctx, GPoint(45, 75), 5); // T facing right - odd vert, even horiz graphics_draw_vertical_line_dotted(...
e_allocated_buffer(reminder); return true; // continue iteration } if (reminder_info->filter_cb && !reminder_info->filter_cb(&header, context)) { timeline_item_free_allocated_buffer(reminder); return true; // continue iteration } reminder_info->match = true; return false; // stop iteration } bo...
(key, key_len, val, val_len, mark_synced)
FSET_DRAW_RECT_CLIP_NXNY); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi")); // AA = true, SW = 3 setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 3); graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP); cl_check(gbitmap_pbi_eq(&c...
(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw1_clip_nxny.${BIT_DEPTH_NAME}.pbi")); // SW = 2 setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 2); graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw2_...
{ menu_cell_basic_header_draw(ctx, cell_layer, (section_index == SectionData) ? "Results" : "Options"); }
static void draw_data_row(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { ScanResult *result = list_get_by_index(cell_index->row); // Build the title string: char title[32]; // Annotate with "HRM" if the device has a heart rate service: char *hrm_str =...
i18n_noop("Sun")
, i18n_noop("Mon"), i18n_noop("Tue"), i18n_noop("Wed"), i18n_noop("Thu"), i18n_noop("Fri"), ...
pfs_close(fd); } void test_app_cache__delete_binaries_for_id_with_no_entry(void) { // confirm binaries get created prv_create_file_for_id(17); cl_assert_equal_b(true, prv_file_for_id_exists(17)); // confirm binaries are deleted app_cache_remove_entry(17); cl_assert_equal_b(false, prv_file_for_id_exists(...
cl_assert(pfs_open("@00000000/res", OP_FLAG_READ, FILE_TYPE_STATIC, 0) < 0)
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
while (result) { ScanResult *next = result->next; free(result); result = next; }
s_head = NULL; } //------------------------------------------------------------------------------ // BLE Scan API callback static void ble_scan_handler(BTDevice device, int8_t rssi, const BLEAdData *ad_data) { const BTDeviceAddress address = bt_device_ge...
rgin(bool has_status_bar, int icon_height, int window_height) { const uint16_t status_layer_offset = has_status_bar ? 6 : 0; #if PLATFORM_ROBERT || PLATFORM_CALCULUS const uint16_t icon_top_default_margin_px = 42 + status_layer_offset; #else const uint16_t icon_top_default_margin_px = 18 + status_layer_offset; #e...
{ SimpleDialog *simple_dialog = context; if (!simple_dialog->buttons_disabled) { dialog_pop(&simple_dialog->dialog); } }
NG(...) \ do { \ cl_assert_equal_b(true, s_is_outbox_message_pending); \ /* The cursor must be updated! */ \ cl_assert(s_outbox_iterator.cursor != s_outbox_iterator.dictionary->head); \ Tuplet tuplets[] = { __VA_ARGS__ }; \ uint32_t buffer_size = dict_calc_buffer_size_from_tuplets(tuplets, ARRAY_L...
rocky_api_app_message_get_state()
, PostMessageStateAwaitingResetCompleteRemoteInitiated); } static void prv_init_and_goto_awaiting_reset_complete_local_initiated(void) { prv_init_and_goto_awaiting_reset_complete_remote_initiated(); RCV_DUMMY_CHUNK(); EXPECT_OUTBOX_RESET_REQUEST(); prv_rcv_app_message_ack(APP_MSG_OK); cl_...
.h); cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]); cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]); menu_layer_set_selected_index(&l, MenuIndex(0, 2), MenuRowAlignNone, false); // new center-focus behavior: adjust for changed row sizes depending on focu...
(&l, &GRect(10, 10, DISP_COLS, DISP_ROWS))
; menu_layer_set_center_focused(&l, true); menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks) { .draw_row = prv_draw_row, .get_num_rows = prv_get_num_rows, .selection_will_change = prv_skip_odd_rows, }); menu_layer_reload_data(&l); const int16_t basic_cell_height = menu_cell_basic_cell_heigh...
/* * 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(resource_id != UINT32_MAX)
; KinoReel *kino_reel = kino_reel_create_with_resource(resource_id); cl_assert(kino_reel); cl_assert(kino_reel_get_type(kino_reel) == KinoReelTypeGBitmapSequence); // We expect the default 0 because get_data_size hasn't been implemented for GBitmapSequence cl_assert_equal_i(kino_reel_get_data_size(kino_reel)...
r_volume_percent = s_music_ctx.player_volume_percent; mutex_unlock_recursive(s_music_ctx.mutex); return player_volume_percent; } static void prv_put_state_changed_event(MusicPlayState playback_state) { PebbleEvent event = { .type = PEBBLE_MEDIA_EVENT, .media = { .type = PebbleMediaEventTypePlayback...
func_ptr()
& capability); } bool music_is_playback_state_reporting_supported(void) { return prv_is_capability_supported(MusicServerCapabilityPlaybackStateReporting); } bool music_is_progress_reporting_supported(void) { // Check capability and that track length is greater than 0 uint32_t track_length_ms; mutex_lock_recu...
// First ack the read request itself BTErrno rv = BTErrnoOK; hc_protocol_enqueue_response(msg, (uint8_t *)&rv, sizeof(rv)); // ack the read // Assume an app using this emulated workaround is Android and supports V1 PPoGATTMetaV1 emulated_result = { .ppogatt_min_version = 1, .ppogatt_max_version = 1,...
memset(&s_ppogatt_ctx.svc, 0, sizeof(s_ppogatt_ctx.svc))
; // Register for callbacks with the dispatcher -- this only needs to happen once ble_service_add(&s_ppogatt_ctx.svc); } void ppogatt_service_register(uint16_t start_hdl) { PPoGattServiceCtx *ctx = &s_ppogatt_ctx; *ctx = (PPoGattServiceCtx) { .svc = { .read_req = prv_ppogatt_handle_read_request, ...
/* * 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...
(weather_glance)
; WeatherLocationForecast *forecast = weather_service_create_default_forecast(); // Update the icon for the forecast's weather type const WeatherType weather_type = NULL_SAFE_FIELD_ACCESS(forecast, current_weather_type, WeatherType_Unknown); const uint...
(void) { s_in_calendar_event = false; rtc_set_time(0); fake_event_init(); pin_db_init(); } void test_calendar__cleanup(void) { timeline_event_deinit(); stub_new_timer_cleanup(); fake_settings_file_reset(); } // Tests //////////////////////////////////////////////////////////////// void test_calendar__n...
timeline_event_handle_blobdb_event()
; cl_assert_equal_i(fake_event_get_count(), 2); cl_assert(!prv_get_calendar_ongoing()); cl_assert(!stub_new_timer_is_scheduled(timer_id)); cl_assert(timeline_remove(&item1.header.id)); timeline_event_handle_blobdb_event(); cl_assert_equal_i(fake_event_get_count(), 3); cl_assert(!prv_get_calendar_ongoing(...
////////////////////////////////////////////////////////// // Fakes //////////////////////////////////////////////////////////////// #include "fake_spi_flash.h" #include "fake_system_task.h" #include "fake_kernel_services_notifications.h" // Stubs //////////////////////////////////////////////////////////////// #incl...
fake_system_task_callbacks_invoke_pending()
; cl_assert_equal_i(contacts_db_get_len((uint8_t *)&contact, UUID_SIZE), 0); } void test_contacts_db__get_serialized_contact(void) { uint8_t contact[sizeof(s_contact_1)]; memcpy(contact, s_contact_1, sizeof(s_contact_1)); cl_assert_equal_i(contacts_db_insert((uint8_t *)&contact, UUID_SIZE, ...
(s_did_read)
; cl_assert(success == s_read_success); cl_assert(profile == s_read_profile); cl_assert(length == s_read_length); s_did_read = false; } void smartstrap_profiles_handle_notification(bool success, SmartstrapProfile profile) { s_notify_success = success; s_notify_profile = profile; s_did_notify = true; } v...
reaming_decode_start(&frame_decode_ctx, s_current_rx_frame, RX_MAX_FRAME_SIZE); while (true) { uint8_t timer_sequence_number; TickType_t timeout = prv_poll_timer(&timer_sequence_number); if (timeout && uxQueueMessagesWaiting(s_pulse_task_queue) == 0) { s_pulse_task_id...
if (buf == s_tx_buffer + COBS_OVERHEAD(FRAME_MAX_SEND_SIZE) + LINK_HEADER_LEN) { buf_valid = true; }
tate.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 = NULL; timeline_init(&head); cl_assert_equal_i(timel...
(state.node->duration, MINUTES_PER_DAY)
; cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY); // no more cl_assert(!iter_next(&iterator)); // 4 deletes cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id)); cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id)); cl_asser...
/* * 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...
LIKELY(c >= 0x20 && c < 127)
) { prompt_context_append_char(&s_prompt_context, c); } else if (UNLIKELY(c == 0xd)) { // Enter key system_task_add_callback_from_isr( prv_execute_command, &s_prompt_context, &should_context_switch); } else if (UNLIKELY(c == 0x3)) { // CTRL-C // FIXME: Clean this up so this logic doesn't need t...
701B_CHIP_ID); if (found) { PBL_LOG(LOG_LEVEL_DEBUG, "Found the as3701b"); } else { PBL_LOG(LOG_LEVEL_DEBUG, "Error: read as3701b whoami byte 0x%x, expecting 0x11", chip_id); } return found; } static void prv_set_sd1_voltage(void) { // STM32F4 running at 1.76V may trigger a Power Down Reset (PDR). Th...
prv_read_register(PmicRegisters_CHARGE_STATUS_1, &status)
) { #if defined (TARGET_QEMU) // NOTE: When running on QEMU, i2c reads return false. For now, just assume a failed // i2c read means we are charging return true; #else PBL_LOG(LOG_LEVEL_DEBUG, "Failed to read charging status 1 register."); return false; #endif } // ChargerStatus1 (Fig. 97) // ...
urn true; } //! Set up and start a transfer to a bus, wait for it to finish and clean up after the transfer //! has completed static bool prv_do_transfer(I2CBus *bus, TransferDirection direction, uint16_t device_address, uint8_t register_address, uint32_t size, uint8_t *data, ...
prv_do_transfer(slave->bus, Read, slave->address, register_address_start, read_size, result_buffer, SendRegisterAddress)
; if (!result) { PBL_LOG(LOG_LEVEL_ERROR, "Read failed on bus %s", slave->bus->name); } return result; } bool i2c_read_block(I2CSlavePort *slave, uint32_t read_size, uint8_t* result_buffer) { PBL_ASSERTN(slave); PBL_ASSERTN(result_buffer); bool result = prv_do_transfer(slave->bus, Read, slave->addre...
arate keys if (settings_file_exists(file, PREF_KEY_BACKLIGHT_BEHAVIOUR_DEPRECATED, sizeof(PREF_KEY_BACKLIGHT_BEHAVIOUR_DEPRECATED))) { bool temp; BacklightBehaviour backlight_behaviour = BacklightBehaviour_Auto; settings_file_get(file, PREF_KEY_BACKLIGHT_BEHAVIOUR_DEPRECATED, ...
prv_prefs_entry((const uint8_t *)key, strlen(key))
; // validate the key and value length PBL_ASSERT(entry != NULL, "Key %s not found", key); PBL_ASSERT(val_len == entry->value_len, "Attempt to set %s using invalid value_len of %"PRIu32"", entry->key, (uint32_t)val_len); // Call the update handler bool success = entry->handler(value, val_len); ...
e *property_animation = prv_find_property_animation(property_animation_h); if (!property_animation) { return; } uint32_t result = interpolate_uint32(distance_normalized, property_animation->values.from.uint32, property_animation->v...
( distance_normalized, property_animation->values.from.gtransform.a, property_animation->values.to.gtransform.a)
; result.b = interpolate_fixed32( distance_normalized, property_animation->values.from.gtransform.b, property_animation->values.to.gtransform.b); result.c = interpolate_fixed32( distance_normalized, property_animation->values.from.gtransform.c, property_animation->values.to.gtran...
PebbleProcessMd* system_app_state_machine_system_start(void) { return (PebbleProcessMd*) &s_launch_app; } const PebbleProcessMd* system_app_state_machine_get_last_registered_app(void) { return (PebbleProcessMd*) &s_root_app; } void system_app_state_machine_register_app_launch(const PebbleProcessMd* app) { } void ...
{ test_app_manager__start_third_party(); // Simulate a crash app_manager_get_task_context()->safe_to_kill = true; app_manager_close_current_app(false /* gracefully */); cl_assert(app_manager_get_current_app_md() == (PebbleProcessMd*) &s_root_app); }
/* * 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...
{ void** fw_vector_table; if (firmware_is_new_world(NULL)) { fw_vector_table = (void**) FIRMWARE_NEWWORLD_BASE; } else { fw_vector_table = (void**) FIRMWARE_OLDWORLD_BASE; } *initial_stack_pointer = fw_vector_table[0]; *reset_handler = fw_vector_table[1]; }
static void prv_hw_reset(void) { // Disable all interrupts, just in case. for (int i = 0; i < 8; ++i) { // Interrupt Clear-Enable Register NVIC->ICER[i] = 0xFFFFFFFF; // Interrupt Clear-Pending Register NVIC->ICPR[i] = 0xFFFFFFFF; } // Set the peripheral clock enable registers to their reset ...
zoneCBData *tz_data) { tz_data->utc_time = ntohl(tz_data->utc_time); tz_data->utc_offset_min = ntohs(tz_data->utc_offset_min); const char *region_name = tz_data->region_name; if (tz_data->region_name_len == 0) { region_name = "[N/A]"; } PBL_LOG(LOG_LEVEL_DEBUG, "set_timezone utc_time: %u offset: %d reg...
{ format = add_space ? "%u:%02u AM" : "%u:%02uAM"; }
else { format = add_space ? "%u:%02u PM" : "%u:%02uPM"; } } return sniprintf(buffer, size, format, time_util_get_num_hours(hours, is24h), minutes); } size_t clock_copy_time_string_timestamp(char *buffer, uint8_t size, time_t timestamp) { struct tm time; sys_localtime_r(&timestamp, &time); return c...
ubleFreeHandler double_free_handler) { heap->double_free_handler = double_free_handler; } void heap_set_corruption_handler(Heap *heap, CorruptionHandler corruption_handler) { heap->corruption_handler = corruption_handler; } void *heap_malloc(Heap* const heap, unsigned long nbytes, uintptr_t client_pc) { // Chec...
(heap, heap_info_ptr)
; /* If we are pointing at the end of the heap, then use the */ /* begin as the next segment. */ if(next_block == heap->end) { /* We can't combine the begin with the end, so just */ /* update the PrevSize field. */ heap->begi...