prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
do_not_disturb_is_active()
); } /////////////////////////////////////////////////////////////////////////////////////////////////// //! Helper Functions static void prv_assert_settings_value(const void *key, size_t key_len, const void *expected_value, size_t value_len) { SettingsFile file; char buffer[...
t* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(15, 5)); } void outside_nx_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_draw_pixel(ctx, GPoint(-5, 5)); } void outside_y_layer_update_callback(Layer...
(&layer, &outside_nx_y_layer_update_callback)
; layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("outside_nx_y_offset_layer", ctx.parent_framebuffer, GColorWhite)); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &outside_x_ny_layer_update_callback); layer_render_tree(&layer, &ctx); cl_check(framebuffer_is_empty("out...
/* * 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...
syscall_failed()
/* * 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...
{ Window *window = (Window *)health_hr_detail_card_create(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_hr_detail_card__render_zones(void) { HealthData health_data = { .hr_zone1_minutes = 21, ...
55Axis_X: axis_bits = 0x01; break; case BMA255Axis_Y: axis_bits = 0x02; break; case BMA255Axis_Z: axis_bits = 0x03; break; default: WTF; } // g-range should be 4g for self-test bma255_set_scale(BMA255Scale_4G); psleep(2); // wait for a new sample uint8...
prompt_send_response_fmt(buf, 64, " lowpower_mode: 0x%"PRIx8, (lp & (1 << 6)) != 0)
; prompt_send_response_fmt(buf, 64, " sleeptimer_mode: 0x%"PRIx8, (lp & (1 << 5)) != 0); prompt_send_response_fmt(buf, 64, "(0x30) FIFO Config 0: 0x%"PRIx8, fifo_cfg0); prompt_send_response_fmt(buf, 64, " Watermark: 0x%"PRIx8, fifo_cfg0 & 0b111111); prompt_send_response_fmt(buf, 64, "(0x3e) FIFO Config 1: 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...
(LOG_LEVEL_DEBUG, "Received Discovery Stop Request")
; uint16_t conn_idx = connection_get_idx(conn); ble_error_t e = ble_gattc_discover_cancel(conn_idx); if (e != BLE_STATUS_OK) { PBL_LOG(LOG_LEVEL_DEBUG, "ble_gattc_discover_cancel: %u", e); } } void hc_endpoint_discovery_send_service_found( const HcProtocolDiscoveryServiceFoundPayload *payload, uint32...
Z = 1, } AppStatus; typedef struct { HRMSessionRef session; EventServiceInfo hrm_event_info; Window window; TextLayer bpm_text_layer; TextLayer quality_text_layer; char bpm_string[BPM_STRING_LEN]; bool ready_to_send; DictionaryIterator *out_iter; } AppData; static char *prv_get_quality_string(HRMQu...
prv_send_msg()
guage governing permissions and * limitations under the License. */ #include "clar.h" #include "services/normal/timezone_database.h" #include "services/common/clock.h" #include "../timezone_fixture.auto.h" #include "stubs_logging.h" #include "stubs_passert.h" #include <string.h> //! Find a region ID for the giv...
{ const int almaty_region = FIND_REGION("Asia/Almaty"); TimezoneInfo tz_info; bool result = timezone_database_load_region_info(almaty_region, &tz_info); cl_assert(result); cl_assert_equal_i(tz_info.dst_id, 0); // No DST cl_assert_equal_i(tz_info.tm_gmtoff, 6 * 60 * 60); // +6 hours }
/* * 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_phone_ui_event = PhoneEventType_Outgoing; }
void phone_ui_handle_missed_call(void) { s_last_phone_ui_event = PhoneEventType_Missed; } void phone_ui_handle_call_start(bool can_decline) { s_last_phone_ui_event = PhoneEventType_Start; } void phone_ui_handle_call_end(bool call_accepted, bool disconnected) { s_last_phone_ui_event = PhoneEventType_End; } vo...
ctor_calls = 0; test_reel_impl = malloc(sizeof(KinoReelImpl)); *test_reel_impl = (KinoReelImpl) { .destructor = prv_destructor, .set_elapsed = prv_elapsed_setter, .get_elapsed = prv_elapsed_getter, .get_duration = prv_duration_getter }; test_reel = kino_reel_custom_create(test_reel_impl, test_...
kino_player_create_play_animation(test_player)
; cl_assert_equal_i(animation_is_scheduled(animation), false); animation_schedule(animation); animation_set_elapsed(animation, 20); animation_set_duration(animation, 300); prv_play_animation_update(animation, 0); // intentionally bad value cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20); } void ...
e minute handler, which computes the minute stats and saves them to data logging // as well as the sleep PFS file. for (int i = 0; i < num_sec; i++) { fake_rtc_set_ticks(rtc_get_ticks() + configTICK_RATE_HZ); rtc_set_time(rtc_get_time() + 1); if ((s_hrm_manager_update_interval == 1) || force_continuous...
{ int32_t median, total_weight; // Start activity tracking. This method assumes it can be called from any task, so we must // invoke system callbacks to handle its KernelBG callback. activity_start_tracking(false /*test_mode*/); fake_system_task_callbacks_invoke_pending(); // Reset the median activity_m...
prv_advance_time_hr(1 /*sec*/, 51 /*hr*/, HRMQuality_Good, true /*force_continuous*/); prv_advance_time_hr(8 /*sec*/, 120 /*hr*/, HRMQuality_Worst, true /*force_continuous*/); prv_minute_system_task_cb(NULL); activity_metrics_prv_get_median_hr_bpm(&median, &total_weight); cl_assert_equal_i(median, 51); //...
perty; GColor bg_color; GColor fg_color; uint8_t alpha; TextLayer *alpha_text; char alpha_text_buffer[30]; TextLayer *fg_text; char fg_text_buffer[5]; TextLayer *fg_color_text; char fg_color_text_buffer[20]; uint8_t fg_color_index; TextLayer *bg_text; char bg_text_buffer[5]; TextLayer *bg_co...
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1))
; } else if (alpha == ALPHA_33) { graphics_context_set_stroke_color(ctx, fg_color); graphics_draw_pixel(ctx, point); graphics_context_set_stroke_color(ctx, bg_color); graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y)); graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1)); graphics_draw_p...
enable(bus); } /*---------------INIT/USE/RELEASE/RESET FUNCTIONS----------------------*/ void i2c_init(I2CBus *bus) { PBL_ASSERTN(bus); *bus->state = (I2CBusState) {}; i2c_hal_init(bus); if (bus->rail_gpio.gpio) { gpio_output_init(&bus->rail_gpio, GPIO_OType_PP, GPIO_Speed_2MHz); } prv_bus_rail_pow...
if (!prv_wait_for_not_busy(bus)) { // Bus did not recover after reset PBL_LOG(LOG_LEVEL_ERROR, "I2C bus did not recover after reset (%s)", bus->name); return 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...
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_RESET)
saved_lr = lr; return prv_event_put_isr(s_kernel_event_queue, "kernel", saved_lr, event); } void event_put_from_process(PebbleTask task, PebbleEvent* event) { register uintptr_t lr __asm("lr"); uintptr_t saved_lr = lr; QueueHandle_t queue = event_get_to_kernel_queue(task); prv_event_put(queue, "from app", ...
{ return (void **)(&event->hrm.debug); }
uto_accept_re_pairing */); cl_assert(id != BT_BONDING_ID_INVALID); // Read it back ret = bt_persistent_storage_get_ble_pairing_by_addr(&pairing.identity, &irk_out, NULL); cl_assert(ret); cl_assert_equal_m(&irk_out, &pairing.irk, sizeof(irk_out)); } void test_bluetooth_persistent_storage__delete_ble_pa...
bonding_sync_add_bonding(&ble_bonding)
; BTBondingID id = bt_persistent_storage_store_ble_pairing(&pairing, true /* is_gateway */, NULL, false /* requires_address_pinning */, false /* auto_accept_re_pairing */); cl_assert(id != BT_BONDIN...
---------------------- // Sample captured: 2015-09-29 15:14:08 local AccelRawData *activity_sample_walk_100_pbl_25296_5(int *len) { // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_100_pbl_25296_5 //> TEST_EXPECTED 100 //> TEST_EXPECTED_MIN 80 //> TEST_EXPECTED_MAX 120 ...
{ 1168, 368, -168}, { 816, 344, -264}, { 912, 176, 8}, { 760, 184, 24}, // 5 seconds { 664, 152, 120}, { 720, 224, 80}, { 800, 368, 0}, { 752, 352, -56}, { 824, 304, -88}, { 952, 280, -96}, { 1192, 304, -112}, { 1312, 256, -40}, { 1904, 312, 40}, { 1344, 432, ...
{ 1104, 192, 168}, { 960, 152, 144}, { 800, 104, 128}, { 752, 168, 88}, { 720, 104, 72}, { 688, 40, 88}, { 744, 72, 40}, { 840, 16, 40}, { 1040, 40, -24}, // 8 seconds { 1208, -24, 16}, { 1864, -88, 272}, { 1456, 248, -8}, { 944, 392, -312}, { 912, 224, -88},...
/* * 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_ALWAYS, "Not enough resources to allocate analytics heartbeat")
; data_size = 0; goto done; } data->count = DialogAnalyticMetric_Count; analytics_each(prv_analytic_each_cb, data); analytics_reset_nodes(); done: hc_protocol_enqueue_response(msg, (uint8_t *)data, data_size); kernel_free(data); } #endif static void prv_handle_get_connection_event_stats(const Hc...
ommon/analytics/analytics.h" #include "services/common/comm_session/session.h" #include "services/common/event_service.h" #include "services/common/evented_timer.h" #include "services/common/i18n/i18n.h" #include "services/normal/blob_db/reminder_db.h" #include "services/normal/bluetooth/ble_hrm.h" #include "services/n...
window_stack_remove(data->chaining_data.action_chaining_window, true)
; data->chaining_data.action_chaining_window = NULL; } if (data->voice_data) { prv_cleanup_voice_data(data->voice_data); data->voice_data = NULL; } if (data->chaining_data.notif) { timeline_item_destroy(data->chaining_data.notif); data->chaining_data.notif = NULL; } if (data->progress...
e_to_ms_with_timers(start_ms + duration_a - 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); 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), 0); cl_assert_equal_i(prv_count_ha...
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0)
; // Complete spawn prv_advance_to_ms_with_timers(start_ms + duration_total + 5 * MIN_FRAME_INTERVAL_MS + 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 2); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 2); cl_assert_equal_i(prv_count_handler_entries...
the phone call static TimerID s_call_watchdog = TIMER_INVALID_ID; static void prv_handle_call_end(bool disconnected); static bool prv_call_is_ancs(void) { return (s_call_source == PhoneCallSource_ANCS_Legacy) || (s_call_source == PhoneCallSource_ANCS); } static void prv_poll_phone_for_status(void *context) { pp...
phone_ui_handle_missed_call()
{ return; }
GBitmapFormat src_fmt = gbitmap_get_format(src_bitmap); GBitmapFormat dest_fmt = gbitmap_get_format(dest_bitmap); if (dest_fmt != GBitmapFormat1Bit) { return; } switch (src_fmt) { case GBitmapFormat1Bit: bitblt_bitmap_into_bitmap_tiled_1bit_to_1bit(dest_bitmap, src_bitmap, dest_rect, ...
you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRA...
memcpy(response_buf, &status, sizeof(status))
; return sizeof(status); } static uint8_t prv_handle_gatt_mtu_read(uint16_t conn_idx, uint8_t response_buffer[READ_RESPONSE_BUFFER_SIZE]) { uint16_t mtu = ATT_DEFAULT_MTU; ble_error_t e = ble_gattc_get_mtu(conn_idx, &mtu); if (e != BLE_STATUS_OK) { PBL_LOG(LOG_LEVEL_...
E HRM sharing permission"); BLEHRMSharingRequest *const sharing_request = kernel_zalloc_check(sizeof(*sharing_request)); sharing_request->connection = connection; launcher_task_add_callback(prv_push_sharing_request_window_kernel_main_cb, sharing_request); } static void prv_put_sharing_state_updated_event(int sub...
bt_unlock()
; analytics_event_ble_hrm(BleHrmEventSubtype_SharingRevoked); } static void prv_revoke_gap_le_connection_for_each_cb(GAPLEConnection *connection, void *unused) { prv_update_permission(connection, HrmSharingPermission_Declined); prv_disconnect_to_kill_subscription(connection); } void ble_hrm_revoke_all(void) { ...
"Saturdays"); bool schedule_9[7] = {true, false, false, false, false, false, false}; char alarm_day_text_9[32] = {0}; alarm_get_string_for_custom(schedule_9, alarm_day_text_9); cl_assert_equal_s(alarm_day_text_9, "Sundays"); } void test_alarm__alarm_set_get_enabled(void) { AlarmId id1, id2; id1 = alarm_cr...
alarm_get_string_for_kind(ALARM_KIND_CUSTOM, all_caps)
ad(void) { AlarmId id; id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_JUST_ONCE }); // It's currently Thursday @ 00:00 bool just_once_schedule_thursday[7] = {false, false, false, false, true, false, false}; prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_JUST_ONCE, just_on...
{ AlarmId id1; bool schedule_1[7] = {true, false, false, true, false, false, true}; id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 }); prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_CUSTOM, schedule_1); // It's currently Thursday ...
void test_alarm__custom_alarm_partial_weekdays(void) { AlarmId id1; bool schedule_1[7] = {false, true, true, true, true, false, false}; id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &schedule_1 }); prv_assert_alarm_config(id1, 10, 30, false, ALARM_KI...
#include "services/common/comm_session/session.h" #include "system/bootbits.h" #include "system/passert.h" #include "system/reset.h" #include "system/logging.h" #include "system/version.h" #include "util/attributes.h" #include "util/build_id.h" #include "util/math.h" #include "util/net.h" #include "util/size.h" #incl...
(buffer_ptr, start_addr, buffer_size)
; } else { flash_write_bytes(buffer_ptr, start_addr, buffer_size); return buffer_size; } } static void prv_flash_erase_region(uint32_t start_addr, uint32_t total_bytes) { if (s_use_cd_flash_driver) { cd_flash_erase_region(start_addr, total_bytes); } else { uint32_t end = start_addr + total_byte...
ng: // Discard event VOICE_LOG("Ignoring event"); break; default: WTF; } } static void prv_start_dictation(VoiceUiData *data) { VOICE_LOG("Start dictation session"); PBL_ASSERTN(data->session_id == VOICE_SESSION_ID_INVALID); data->session_id = sys_voice_start_dictation(data->session...
if (!expand) { goto cleanup; }
animation_set_delay((Animation *) expand, delay_duration); // If overshoot > 0 shrink to min size, otherwise shrink from max to min int16_t current_size = (overshoot != 0) ? overshoot + max : max; shrink = prv_create_int16_prop_anim(current_size, min, stage_duration, &s_animated_dot_impl, data); if (!...
/* * 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...
(level, src_filename, src_line_number, "%s", line_buffer)
; } void hexdump_log_src(const char *src_filename, int src_line_number, int level, const uint8_t *data, size_t length, HexdumpLineCallback cb) { hexdump(src_filename, src_line_number, level, data, length, cb); }
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
if (time < 0) { // set the sign bit conv.representation[1] |= (1 << 31); // sign bit takes care of positive vs negative time *= -1; }
uint32_t significand = (uint32_t)time; // In order to normalize the significand, we shift off all the leading 0s // plus the msb which is implicitly included int shift = __builtin_clz(time) + 1; significand <<= shift; // top 20 bits fit into the upper 32 bits of the double conv.representation[1] |= (...
S OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <kernel/events.h> #include "shell/shell_event_loop.h" #include "shell/prefs_private.h" #include "apps/system_app_ids.h" #include "apps/system_ap...
(&e->timeline_peek)
; return; case PEBBLE_BLOBDB_EVENT: { // Calendar should only handle pin_db events PebbleBlobDBEvent *blobdb_event = &e->blob_db; if (blobdb_event->db_id == BlobDBIdPins) { timeline_event_handle_blobdb_event(); } else if (blobdb_event->db_id == BlobDBIdPrefs) { pre...
impl.def" #undef RESOURCE_IMPL }; // Check if our offset+length is within the resource entry's bounds. // Truncate the length if we overrun the ending. static uint32_t prv_check_resource_bounds(ResourceStoreEntry *entry, uint32_t store_offset, size_t num_bytes) { // If we ha...
(LOG_LEVEL_WARNING, "Calculated the CRC again, got 0x%"PRIx32, calculated_crc_again)
; return calculated_crc_again == manifest->version.crc; } return true; } static void prv_get_store_entry(ResAppNum app_num, uint32_t resource_id, ResourceStoreEntry *entry) { *entry = (ResourceStoreEntry){ .id = resource_id, .length = ENTRY_LENGTH_UNSET, }; for (...
: new_timer_stop(dev->state->timer); // Delay a bit so that we don't deassert the enable GPIO while in // the loader and unintentionally activate force loader mode. psleep(LOADER_READY_MAX_DELAY_MS); // fallthrough case HRMEnabledState_Enabled: gpio_output_set(&dev->en_gpio, fals...
{ return false; }
} prv_log_running_apps(dev); return true; } static uint64_t prv_get_time_ms(void) { time_t time_s; uint16_t time_ms; rtc_get_time_ms(&time_s, &time_ms); return ((uint64_t)time_s) * 1000 + time_ms; } static bool prv_wait_for_loader_ready(HRMDevice *dev) { uint64_t end_time_ms = prv_get_time_ms() + LOA...
* 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 permissions and * limitations under the License....
accessory_use_dma(true)
; s_timeout_timer = new_timer_create(); new_timer_start(s_timeout_timer, TIMEOUT_MS, prv_timeout_timer_cb, NULL, 0 /* flags */); PBL_LOG(LOG_LEVEL_DEBUG, "Starting accessory imaging"); } static void prv_stop(void *context) { if (s_no_buffer_count > 0) { PBL_LOG(LOG_LEVEL_ERROR, "Ran out of buffers %d times...
vent_loop.h" #include "kernel/pbl_malloc.h" #include "kernel/pebble_tasks.h" #include "kernel/util/sleep.h" #include "resource/resource.h" #include "resource/resource_ids.auto.h" #include "services/common/comm_session/app_session_capabilities.h" #include "services/common/i18n/i18n.h" #include "services/normal/app_cache...
mutex_lock_recursive(s_recent_apps.mutex)
; { RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id); if (app) { app->last_activity = RECENT_APP_LAST_ACTIVITY_INVALID; } } mutex_unlock_recursive(s_recent_apps.mutex); } void app_install_mark_prioritized(AppInstallId install_id, bool can_expire) { if (install_id == INST...
/* * 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...
{ // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_100_pbl_25471_5 //> TEST_EXPECTED 100 //> TEST_EXPECTED_MIN 80 //> TEST_EXPECTED_MAX 120 //> TEST_WEIGHT 1.0 static AccelRawData samples[] = { // 0 seconds // elapsed: 0 minutes { -176, -104, -1008}, {...
rse_priority[] = { PebbleTask_KernelBackground, PebbleTask_KernelMain, PebbleTask_PULSE, PebbleTask_NewTimers }; for (unsigned int i = 0; i < ARRAY_LENGTH(tasks_in_reverse_priority); ++i) { const uint8_t task_index = tasks_in_reverse_priority[i]; const PebbleTaskBitset task_mask = (1 << tas...
reboot_reason_set(&reason)
; // If getting reset by the watchdog timer is imminent (it will reset the // CPU if not fed at least once every 7 seconds), then just coredump now if (s_ticks_since_successful_feed >= (6 * TIMER_INTERRUPT_HZ)) { #if defined(NO_WATCHDOG) PBL_LOG(LOG_LEVEL_DEBUG, "Would have coredumped i...
D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "After compaction: size: %d, num_bytes: %d, write_offset:%d", (int)new_size, (int)session->storage.num_bytes, (int)session->storage.write_offset); success = true; exit: kernel_free(tmp_buf); if (new_storage.fd != DLS_INVALID_FILE) { pfs_clos...
{ const uint8_t* read_ptr; uint16_t bytes_read; success = shared_circular_buffer_read(&session->data->buffer, &session->data->buffer_client, bytes_remaining, &read_ptr, &bytes_read); PBL_ASSERTN(success); success = p...
exit: if (got_session_file) { prv_release_session_file(session); } if (!success) { PBL_LOG(LOG_LEVEL_ERROR, "Nuking storage for session %d", session->comm.session_id); dls_storage_delete_logging_storage(session); } return success; } // ---------------------------------------------------------...
GRect(0, 0, DISP_COLS, 400)
; const GRect to_area = GRect(0, 0, DISP_COLS, 200); unobstructed_area_service_will_change(from_area.size.h, to_area.size.h); fake_event_service_handle_last(); unobstructed_area_service_did_change(to_area.size.h); fake_event_service_handle_last(); cl_assert_equal_i(s_data.num_did_change_calls, 1); } void ...
prv_free_serialzed_prefs(serialized_prefs)
; kernel_free(notif_prefs); return NULL; } prv_free_serialzed_prefs(serialized_prefs); return notif_prefs; } void ios_notif_pref_db_free_prefs(iOSNotifPrefs *prefs) { kernel_free(prefs); } status_t ios_notif_pref_db_store_prefs(const uint8_t *app_id, int length, AttributeList *attr_list, ...
/ // Note that `is_strict` is currently unsupported by emscripten jerry_value_t jerry_eval(const jerry_char_t *source_p, size_t source_size, bool is_strict) { return (jerry_value_t)EM_ASM_INT({ // jerry_eval() uses an indirect eval() call, // so the global execution context is used. // Also see ECM...
Module.lengthBytesUTF8(__jerryRefs.get($0))
; }, value); } jerry_size_t jerry_string_to_utf8_char_buffer(const jerry_value_t value, jerry_char_t *buffer_p, jerry_size_t buffer_size) { const jerry_size_t str_size = jerry_get_utf8_string_size(value); if (str_size =...
0; } if (samples_in_minute >= KALG_SAMPLE_HZ * SECONDS_PER_MINUTE) { ref_minute_stats(&orientation, &vmc); samples_in_minute = 0; } } // leftover data, if any if (chunk_size > 0) { steps = ref_accel_data_handler(accel_buf, chunk_size); } steps = ref_finish_epoch(); ref_minute_st...
strcmp(token, "TEST_NAME")
== 0) { sscanf(token + strlen(token) + 1, "%s", state->test_entry.name); } } // If this is a "static AccelRawData samples[] = {" line, skip it if (strcmp(token, "static") == 0) { continue; } // Grab a sample if (strcmp(token, "{") == 0) { PBL_ASSERTN(state->test_entr...
i")); gbitmap_destroy(src_bitmap); } // Setup: // - Source is 40 x 30. // - Source has 2 columns, 4 rows of black, rest is white. // - Dest is all blue. // - Source offset (2, 4) past black. // - Destination is 100 x 100 // - Destination rect is size of white portion of source. // Result: // - Blue bi...
("test_bitblt__1bit_to_8bit_src_origin_offset_wrap2.1bit.pbi")
; uint8_t dest_data[100*100]; GBitmap dest_bitmap = { .addr = dest_data, .row_size_bytes = 100, .info.format = GBitmapFormat8Bit, .info.version = GBITMAP_VERSION_CURRENT, .bounds = { { 0, 0 }, { 100, 100 } } }; memset(dest_data, GColorBlue.argb, sizeof(dest_data)); GRect dest_rect = GRect...
!= HRZone_Zone0 && state->hr.num_samples < ACTIVITY_MIN_NUM_SAMPLES_FOR_HR_ZONE) { // There wasn't enough data in the past minute to give us confidence that // the new HR zone will represents that minute, default to Zone0 new_hr_zone = HRZone_Zone0; } bool new_hr_elevated = hr_util_is_elevated(hr_media...
ARRAY_LENGTH(s_hr_quality_weights_x100)
; i++) { if (quality == s_hr_quality_weights_x100[i].quality) { return s_hr_quality_weights_x100[i].weight_x100; } } return 0; } // -------------------------------------------------------------------------------------------- HRZone activity_metrics_prv_get_hr_zone(void) { ActivityState *state = act...
f, 256, "There are %#X lights, %#X", 16, -4); cl_assert_equal_s(dstbuf, "There are 0X10 lights, 0XFFFFFFFC"); // Zero padded minimum character output snprintf(dstbuf, 256, "There are %03X lights, %03X", 16, -4); cl_assert_equal_s(dstbuf, "There are 010 lights, FFFFFFFC"); // Space padded minimum character o...
cl_assert_equal_s(dstbuf, "You know Bagu? Then I can let you cross")
; // Variable length character output snprintf(dstbuf, 256, "You know Bagu? %*s", 25, "Then I can let you cross"); cl_assert_equal_s(dstbuf, "You know Bagu? Then I can let you cross"); // Left align snprintf(dstbuf, 256, "You know Bagu? %-26s", "Then I can let you cross"); cl_assert_equal_s(dstbuf, "You ...
ngth) { off_t o = offsetof(__typeof__(s_music_ctx), title); prv_update_string_and_put_event(title, title_length, o); } void music_update_track_artist(const char *artist, size_t artist_length) { off_t o = offsetof(__typeof__(s_music_ctx), artist); prv_update_string_and_put_event(artist, artist_length, o); } vo...
{ mutex_lock_recursive(s_music_ctx.mutex); s_music_ctx.playback_state = state->playback_state; s_music_ctx.playback_rate_percent = state->playback_rate_percent; s_music_ctx.track_pos_ms = state->elapsed_time_ms; s_music_ctx.track_pos_updated_at = rtc_get_ticks(); mutex_unlock_recursive(s_music_ctx.mutex); ...
void music_update_player_volume_percent(uint8_t volume_percent) { mutex_lock_recursive(s_music_ctx.mutex); s_music_ctx.player_volume_percent = volume_percent; mutex_unlock_recursive(s_music_ctx.mutex); PebbleEvent event = { .type = PEBBLE_MEDIA_EVENT, .media = { .type = PebbleMediaEventTypeVolu...
igin_r4_sw4_clip_xy.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 4); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi")...
(&ctx.dest_bitmap, "draw_round_rect_origin_rmax2_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi")
); // AA = true, SW = 11 setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 11); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 0); // TODO: Fix offset calculation and reenable this: - PBL-16509 #if SCREEN_COLOR_DEPTH_BITS == 8 cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "dra...
ialog *dialog, WindowStack *window_stack) { window_stack_push(window_stack, &dialog->window, DIALOG_IS_ANIMATED); } void app_dialog_push(Dialog *dialog) { dialog_push(dialog, app_state_get_window_stack()); } // Loads the core dialog. Should be called from each dialog window's load callback. void dialog_load(Dialo...
(&status_layer->layer, status_layer_frame)
/* * 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...
GSize(bitmap_bounds_size->w * 4 / 5, bitmap_bounds_size->h / 2)
; const GRect bottom_rect = (GRect) { .origin = GPoint((bitmap_bounds_size->w - bottom_rect_size.w) / 2, bitmap_bounds_size->h / 2), .size = bottom_rect_size }; GColor bottom_rect_color = GColorBlue; bottom_rect_color.a = 2; prv_draw_hlines_in_rect(ctx, draw_func, &bottom_rect, bottom_rect_color); ...
/* * 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_APP, 0, &entry, &SYSTEM_RESOURCE_VERSION)
) { PBL_LOG(LOG_LEVEL_INFO, "Valid system resources found!"); s_valid_resources_found = true; return; } } // Welp, we found nothing. Leave s_valid_resources_found as false and when resource_storage_check // is called as part of system_resource_init we'll complain and handle missing resource...
ME, filename_buf); app_storage_get_file_name(filename_buf, sizeof(filename_buf), 1, PebbleTask_Worker); load_fixture_on_pfs(APP1_WORKER_FIXTURE_NAME, filename_buf); resource_storage_get_file_name(filename_buf, sizeof(filename_buf), 1); load_fixture_on_pfs(APP1_RESOURCES_FIXTURE_NAME,...
app_install_get_uuid_for_install_id(INSTALL_ID_INVALID, &uuid)
); cl_assert_equal_uuid(uuid, UUID_INVALID); cl_assert_equal_b(true, app_install_get_uuid_for_install_id(tictoc_id, &uuid)); cl_assert_equal_uuid(uuid, tictoc_uuid); cl_assert_equal_b(true, app_install_get_uuid_for_install_id(music_id, &uuid)); cl_assert_equal_uuid(uuid, music_uuid); cl_assert_equal_b(tru...
ct_a = GRect(0, 0, 60, 60); GRect to_rect_a = GRect(84, 92, 60, 60); GRect from_rect_b = GRect(84, 0, 60, 60); GRect to_rect_b = GRect(0, 92, 60, 60); GRect tmp; if (toggle) { tmp = to_rect_b; to_rect_b = from_rect_b; from_rect_b = tmp; } toggle = !toggle; animation_destroy(s_animation); ...
animation_set_delay((Animation*) a_rev, 400)
; animation_set_duration((Animation*)a_rev, DURATION); animation_set_reverse((Animation*) a_rev, true); Animation *seq = animation_sequence_create((Animation *)a, (Animation *)a_rev, NULL); // Animate text layer b from top-right to bottom-left PropertyAnimation *c = property_animation_create_layer_frame( ...
nch, parent_id)) { return; } // Format the event specifc info in the blob. The analytics_logging_log_event() method will fill // in the common fields AnalyticsEventBlob event_blob = { .event = AnalyticsEvent_PinAppLaunch, .pin_app_launch.time_utc = timestamp, .pin_app_launch.parent_id = *parent...
(&event_blob)
; } // ------------------------------------------------------------------------------------------ // Log a bluetooth disconnection event void analytics_event_bt_connection_or_disconnection(AnalyticsEvent type, uint8_t reason) { AnalyticsEventBlob event_blob = { .event = type, }; event_blob.bt_connection_dis...
/* * 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...
process_metadata_get_app_sdk_platform(&md.common)
; cl_assert_equal_i(type, LEGACY_PLATFORM_AFTER_4); } void test_pebble_process_md__SDK4_stored_but_ignored(void) { // stored platform will be ignored unless SDK version is >= 4.2 PebbleProcessMdFlash md = { .common.process_storage = ProcessStorageFlash, .common.is_unprivileged = true, .common.stored...
: low power mode) static bool s_backlight_allowed = false; //! Mutex to guard all the above state. We have a pattern of taking the lock in the public functions and assuming //! it's already taken in the prv_ functions. static PebbleMutex *s_mutex; static void prv_change_state(BacklightState new_state); static void l...
{ s_light_state = LIGHT_STATE_OFF; s_current_brightness = BACKLIGHT_BRIGHTNESS_OFF; s_timer_id = new_timer_create(); s_num_buttons_down = 0; s_user_controlled_state = false; s_mutex = mutex_create(); }
void light_button_pressed(void) { mutex_lock(s_mutex); s_num_buttons_down++; if (s_num_buttons_down > 4) { PBL_LOG(LOG_LEVEL_ERROR, "More buttons were pressed than have been released."); s_num_buttons_down = 0; } // set the state to be on; releasing buttons will start the timer counting down if ...
; memset(dest, 0, 5); size_t copied = utf8_copy_character(dest, (utf8_t *)"hello", 5); cl_assert_equal_i(copied, 1); cl_assert_equal_s((char *)dest, "h"); } void test_utf8__copy_multibyte_char(void) { utf8_t dest[5]; memset(dest, 0, 5); size_t copied = utf8_copy_character(dest, (utf8_t *)NIHAO, 5); ...
(output_buffer, 5)
; cl_assert_passert(utf8_truncate_with_ellipsis("Hello", output_buffer, 6)); free(output_buffer); }
{ Window *window = modal_manager_get_top_window(); if (window) { GContext ctx; memset(&ctx, 0, sizeof(GContext)); modal_manager_render(&ctx); } }
void app_click_config_setup_with_window(ClickManager *click_manager, struct Window *window) { s_last_click_configured_window = window; } // Helpers //////////////////////////////////// static int16_t prv_get_load_unload_count(void) { return s_load_count - s_unload_count; } static int16_t prv_get_appear_disappea...
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.change, prv_change); const GRect area = GRect(0, 0, DISP_COLS, 200); const AnimationProgress progress = ANIMATION_NORMALIZED_MAX / 2; unobstructed_area_service_change(area.size.h, to_area.size.h, progress); fake_event_service_handle_last(); ...
GRect(0, 0, 400, 400)
; Layer root_layer = { .bounds = GRect(210, 220, 300, 300), }; GRect unobstructed_bounds; layer_get_unobstructed_bounds(&root_layer, &unobstructed_bounds); cl_assert_equal_grect(unobstructed_bounds, GRect(210, 220, 190, 180)); } void test_unobstructed_area_service__layer_clip_nx_ny(void) { app_state_g...
ss interval_start, AnimationProgress interval_end) { return interval_end; } KinoReel *kino_reel_scale_segmented_create(KinoReel *from_reel, bool take_ownership, GRect screen_frame) { return NULL; } void kino_reel_scale_segmented_...
(dialog, RESOURCE_ID_BATTERY_ICON_FULL_LARGE)
; prv_push_and_render_simple_dialog(dialog); cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)); } void test_simple_dialog__battery_warning(void) { SimpleDialog *simple_dialog = simple_dialog_create("Battery Status"); Dialog *dialog = simple_dialog_get_dialog(simple_dialog); uint32_t percent = 20; dia...
status; } void firmware_update_init(void) { vSemaphoreCreateBinary(s_firmware_update_semaphore); PBL_ASSERTN(s_firmware_update_semaphore != NULL); } static void prv_initialize_completion_status(PebbleSystemMessageEvent *event) { if (prv_legacy_completion_status_init(event)) { return; } s_current_comple...
{ return; // not my pb transfer }
switch (event->type) { case PebblePutBytesEventTypeStart: s_is_recovery_fw = (event->object_type == ObjectRecovery); prv_handle_progress(event); break; case PebblePutBytesEventTypeProgress: prv_handle_progress(event); break; case PebblePutBytesEventTypeCleanup: if (...
/* * 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->text_layer, GTextOverflowModeTrailingEllipsis)
; } static void click_handler(ClickRecognizerRef recognizer, Window *window) { AppState *data = window_get_user_data(window); ButtonId button = click_recognizer_get_button_id(recognizer); GRect frame = data->text_layer.layer.frame; if (button == BUTTON_ID_UP) { if (data->select_index == SelectIndexPixels)...
gdraw_command_get_stroke_color(command); color.a = 0; gdraw_command_set_stroke_color(command, color); gdraw_command_draw(NULL, command); cl_assert_equal_i(s_stroke_color.argb, GColorClearARGB8); cl_assert_equal_i(s_fill_color.argb, GColorRedARGB8); cl_assert_equal_i(s_stroke_width, 0); cl_assert_equal_i(s...
cl_assert_equal_i(s_path_fill_count, 1)
; cl_assert_equal_i(s_circle_stroke_count, 0); cl_assert_equal_i(s_circle_fill_count, 0); prv_reset(); free(command_list); command_list = prv_create_command_list_3(); gdraw_command_list_draw(ctx, command_list); cl_assert_equal_i(s_path_stroke_count, 2); cl_assert_equal_i(s_path_fill_count, 2); cl_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...
__builtin_popcount(n)
== 1; // if not exact power of two, use the next power of two // we want to err on the side of caution and want to // always round up return ((power_of_two) ? msb : (msb + 1)); }
l_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time()); } void test_alarm__recurring_weekends_alarm_timeout_ahead(void) { AlarmId id; id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKENDS }); prv_assert_alarm_config(id, 10, 30, false, ALARM_KIND_WEEKENDS, ...
{ AlarmId id; s_current_hour = 11; s_current_minute = 30; 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); // Only 1 pin should be added (for Friday) cl_assert_equal_i(s_num_timel...
void test_alarm__recurring_weekday_alarm(void) { AlarmId id1, id2; id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_WEEKDAYS }); prv_assert_alarm_config(id1, 10, 30, false, ALARM_KIND_WEEKDAYS, s_weekday_schedule); // 2 pins should be added (for Thursday / Friday) cl_assert_equ...
/* * 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...
(title, BUFFER_SIZE, "Title %i/%i ", cell_index->section, cell_index->row)
; sniprintf(subtitle, BUFFER_SIZE, "Subtitle %i/%i", cell_index->section, cell_index->row); menu_cell_basic_draw(ctx, cell_layer, title, subtitle, (GBitmap*)&s_music_launcher_icon_bitmap); break; default: case 1: sniprintf(title, BUFFER_SIZE, "Only Title %i/%i", cell_index->section, cel...
eIdNameAway + 1 == AttributeIdNameHome, "Sports layout requires that all Home attributes are directly after Away"); _Static_assert(AttributeIdRecordAway + 1 == AttributeIdRecordHome, "Sports layout requires that all Home attributes are directly after Away"); _Static_assert(AttributeIdScore...
{ const SportsLayout *layout = (SportsLayout *)layout_ref; const int num_teams = 2; const int num_nodes = num_teams + 1; // two team nodes and one line node GTextNodeHorizontal *game_node = graphics_text_node_create_horizontal(num_nodes); graphics_text_node_container_add_child( &game_node->container, ...
static GTextNode *prv_broadcaster_header_constructor( const LayoutLayer *layout_ref, const LayoutNodeConstructorConfig *config) { const char *broadcaster = attribute_get_string(layout_ref->attributes, AttributeIdBroadcaster, ""); if (IS_EMPTY_STRING(broadcaster)) { return NULL; } static const La...
(data, TIMELINE_RESOURCE_GENERIC_WARNING, msg, succeeded)
; } static void prv_progress_window_finished(ProgressWindow *window, bool success, void *context) { ActionResultData *data = context; if (success) { prv_show_result_window(data, data->dialog.icon, data->dialog.message, data->dialog.success); } else { prv_cleanup_action_result(data, success); } } stati...
_too_many_slices[] = { // Version APP_GLANCE_DB_CURRENT_VERSION, // Creation time 0x14, 0x13, 0x4E, 0x57, // 1464734484 (Tue, 31 May 2016 22:41:24 GMT) // Slice 1 0x0B, 0x00, // Total size 0x00, // AppGlanceSliceType - AppGlanceSliceType_IconAndSubtitle 0x01, ...
(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, (uint8_t *)&s_app_glance_basic, glance_size), S_SUCCESS)
; cl_assert_equal_i(app_glance_db_get_len((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE), glance_size); uint8_t *glance_out = kernel_malloc(glance_size); cl_assert_equal_i(app_glance_db_read((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE, glance_out, glance_s...
ntent_indicator_configure_direction(content_indicator, direction, &(ContentIndicatorConfig) { .layer = indicator_layer, .colors.foreground = gcolor_legible_over(card_bg_color), .colors.background = card_bg_color, }); } static void prv_refresh_content_indicators(HealthCardView *health_card_view) { prv_c...
(layer, from_frame, to_frame)
/* * 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...
("", string_list_get_at(list, 0))
; cl_assert_equal_s("", string_list_get_at(list, 1)); cl_assert_equal_s("", string_list_get_at(list, 2)); cl_assert_equal_s("", string_list_get_at(list, 3)); // non-null-terminated string is treated as one string - this is the standard case // please note that the string will only be terminated if there's an...
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 ANY KIND,...
(&dest_rect)
; const int16_t dest_y_end = grect_get_max_y(&dest_rect); const uint8_t num_dest_blocks_per_row = (dest_end_x / 32) + ((dest_end_x % 32) ? 1 : 0) - dest_begin_x; const GColor *palette = src_bitmap->palette; const uint8_t *src = src_bitmap->addr; const uint8_t src_bpp = gbitmap_get_bits_per_pixel(gbitmap_...
/* * 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...
{ // Mutable types Iterator utf8_iter; Utf8IterState utf8_iter_state; // Immutable types bool success = false; const Utf8Bounds utf8_bounds = utf8_get_bounds(&success, s_valid_test_string); cl_assert(success); const int NUM_VALID_CODEPOINTS = sizeof(s_valid_test_codepoints) / sizeof(uint32_t); // I...
static void *s_context; static int s_each_count = 0; static bool prv_each_codepoint(int index, Codepoint codepoint, void *context) { static int s_index = 0; static Codepoint s_codes[] = { 0xf0, 'a' }; cl_assert_equal_i(s_codes[index], codepoint); cl_assert_equal_i(s_index++, index); cl_assert_equal_p(cont...
, 20, 40, 10)); ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10))); setup_test(&context, false, 2, GColorBlack, GColorBlack, false); graphics_draw_circle(&context, GPoint(50, 50), 10); ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, 2)); setup_test(&context, false...
GPoint(5, 5)
, GPoint(45, 10)); #if PBL_COLOR ASSERT_CALLED(graphics_line_draw_stroked_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN)); #else ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_EVEN)); #endif setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false); 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...
(DISP_GPIO, DISP_PIN_SCS, Bit_SET)
; // SCS -> HIGH // Send dummy clocks for (unsigned int i = 0; i < 8; ++i) { display_write_byte(0x00); } if (!GPIO_ReadInputDataBit(DISP_GPIO, DISP_PIN_CDONE)) { PBL_LOG(LOG_LEVEL_WARNING, "CDONE not high after programming!"); return false; } return true; } void display_power_enable(void) { ...
gsFile *file) { settings_file_close(file); mutex_unlock(s_mutex); } //! Assumes the file is opened and locked static status_t prv_save_serialized_prefs(SettingsFile *file, const void *key, size_t key_len, const void *val, size_t val_len) { // Invert flags before writing ...
serialized_prefs->num_actions, attributes_per_action, string_alloc_size); iOSNotifPrefs *notif_prefs = kernel_zalloc_check(sizeof(iOSNotifPrefs) + alloc_size); uint...
void ios_notif_pref_db_free_prefs(iOSNotifPrefs *prefs) { kernel_free(prefs); } status_t ios_notif_pref_db_store_prefs(const uint8_t *app_id, int length, AttributeList *attr_list, TimelineItemActionGroup *action_group) { SettingsFile file; status_t rv = prv_file_open_and_...
/* * 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...
{ MfgData data = prv_fetch_struct(); strncpy(data.model, model, sizeof(data.model)); data.model[MFG_INFO_MODEL_STRING_LENGTH - 1] = '\0'; prv_update_struct(&data); }
GPoint mfg_info_get_disp_offsets(void) { // Not implemented. Can just assume no offset return (GPoint) {}; } void mfg_info_set_disp_offsets(GPoint p) { // Not implemented. } void mfg_info_update_constant_data(void) { if (mfg_info_is_boot_fpga_bitstream_written()) { PBL_LOG(LOG_LEVEL_INFO, "Boot FPGA bit...
/* * 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...
{ // Just return a predictable result to validate the unit tests return (light_level / ALG_RAW_LIGHT_SENSOR_DIVIDE_BY) % AMBIENT_LIGHT_LEVEL_ENUM_COUNT; }
BatteryChargeState battery_get_charge_state(void) { BatteryChargeState state = { .charge_percent = 50, .is_charging = s_alg_next_plugged_in, .is_plugged = s_alg_next_plugged_in, }; return state; } void kalg_enable_activity_tracking(KAlgState *kalg_state, bool enable) {} bool activity_tracking_on(v...
PULSE2_BULKIO_PROTOCOL); resp->opcode = BULKIO_RESP_INTERNAL_ERROR; resp->status_code = status_code; size_t response_len = sizeof(*resp); size_t command_len = MIN(length, PULSE_MAX_SEND_SIZE - response_len); response_len += command_len; memcpy(resp->bad_command, cmd, command_len); pulse_reliable_se...
(PULSE2_BULKIO_PROTOCOL)
; resp->opcode = BULKIO_RESP_DOMAIN_CLOSE; resp->fd = cmd->close.fd; pulse_reliable_send(resp, sizeof(*resp)); prv_free_fd(cmd->close.fd); } static void prv_handle_read(Command *cmd, size_t length) { if (cmd->read.length == 0) { prv_respond_internal_error(cmd, length, E_INVALID_ARGUMENT); return; ...
================================================================================================= // Public functions // ------------------------------------------------------------------------------------------------- // Setup a very high priority interrupt to fire periodically. This ISR will call task_watchdog_feed(...
{ // we don't want the interrupt to fire while we are editing the feed count TIM_Cmd(TIM2, DISABLE); s_ticks_since_successful_feed += timer_ticks_elapsed; TIM_Cmd(TIM2, ENABLE); }
TIM2->CNT = timer_ticks % TIME_PERIOD; prv_task_watchdog_feed(); } #define WATCHDOG_WARN_TICK_CNT (5 * TIMER_INTERRUPT_HZ) /* 5s */ #define WATCHDOG_COREDUMP_TICK_CNT ((65 * TIMER_INTERRUPT_HZ) / 10) /* 6.5 s */ //! Test to see if all the bits are set. If so, feed the hardware watchdog. //! Note: ...
.bounds.size.w) { data->rect_velocity_x = data->rect_velocity_x * -1; } data->rect.origin.y += (data->rect_velocity_y * PIXEL_SPEED_PER_FRAME * 2); if (data->rect.origin.y < 0 || data->rect.origin.y + data->rect.size.h > data->window.layer.bounds.size.h) { data->rect_velocit...
(ctx, data->circle_origin, data->circle_radius)
12th 2015, 00:00:01 (T-11:59:59) rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) + 1); clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS); cl_assert_equal_s("IN 12 H", time_buf); // June 12th 2015, 00:29:29 (T-11:30:31) rtc_set_time(event_time - (12 * SECONDS_PER_HOU...
("10 MIN AGO", time_buf)
/* * 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...
mfg_display_calibration_app_get_info()
); } #endif static void prv_select_accel(int index, void *context) { launcher_task_add_callback(prv_launch_app_cb, (void*) mfg_accel_app_get_info()); } static void prv_select_button(int index, void *context) { launcher_task_add_callback(prv_launch_app_cb, (void*) mfg_button_app_get_info()); } static void prv_sel...
tmap, TEST_PBI_FILE)); } void test_action_menu_window__wide_display_mode_with_chevron(void) { ActionMenuLevel *root_level = action_menu_level_create(3); ActionMenuLevel *voice_level = action_menu_level_create(1); action_menu_level_add_action(voice_level, "This won't be seen", ...
gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)
); } void test_action_menu_window__wide_display_mode_with_separator(void) { ActionMenuLevel *root_level = action_menu_level_create(3); action_menu_level_add_action(root_level, "Change Time", prv_noop_action_callback, 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...
{ memset(s_cache_buffer, 0, sizeof(s_cache_buffer)); memset(s_cache_keys, 0, sizeof(s_cache_keys)); keyed_circular_cache_init(&s_test_cache, s_cache_keys, s_cache_buffer, sizeof(TestCacheItem), TEST_BUFFER_SIZE); }
CommSessionCloseReason_UnderlyingDisconnection); } void test_session__send_next_not_called_when_session_closed_in_mean_time(void) { Transport *transport = (Transport *) TransportID1; CommSession *session = comm_session_open(transport, &s_transport_imp, TransportDestinatio...
(session, CommSessionCloseReason_UnderlyingDisconnection)
; } void test_session__capabilities(void) { Transport *transport = (Transport *) TransportID1; CommSession *session = comm_session_open(transport, &s_transport_imp, TransportDestinationSystem); for (int i = 0; i < (sizeof(int) * 8); ++i) { CommSessionCapability cap...
IES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "calendar.h" #include "event.h" #include "peek.h" #include "drivers/rtc.h" #include "kernel/event_loop.h" #include "kernel/events.h" #include ...
{ state->filter_header = &filter_headers[i]; state->filter_header->common.id = UUID_INVALID; if (state->impl->will_update) { state->impl->will_update(&state->context); } }
ON_CONFIG[PMIC_MON_CONFIG_VSYS_INDEX]; prv_set_mon_config(mon_config); ADCVoltageMonitorReading reading = battery_read_voltage_monitor(); uint32_t millivolts = battery_convert_reading_to_millivolts(reading, mon_config->ratio, 1); prv_set_mon_config_register(0); prv_mon_config_unlock(); return (uint16_t)m...
system_task_add_callback_from_isr(prv_handle_pmic_interrupt, NULL, should_context_switch)
; } /* Private Function Implementations */ static bool prv_is_alive(void) { uint8_t val; prv_read_register(0x00, &val); if (val == 0x01) { PBL_LOG(LOG_LEVEL_DEBUG, "Found the max14690"); return true; } else { PBL_LOG(LOG_LEVEL_DEBUG, "Error: read max14690 whomai byte 0x%x, expecting 0...
l_i(prv_count_handler_entries(&s_started_handler_calls, a), 0); 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, inner_seq), 0); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0); cl_as...
prv_last_update_distance(b)
, ANIMATION_NORMALIZED_MIN); #endif } // -------------------------------------------------------------------------------------- // Test the get_duration call on a sequence animation void test_animation__sequence_get_duration(void) { #ifdef TEST_INCLUDE_COMPLEX const int duration_a = 300; const int delay_a = 100;...
o the firmware. // // No attempt is made to set CONTROL to zero as it should already be set to // the reset value when this code executes. __asm volatile ( "cpsie if\n" // Clear PRIMASK and FAULTMASK "mov lr, 0xFFFFFFFF\n" "mov sp, %[initial_sp]\n" "bx %[reset_handler]\n" : : ...
{ if (!prv_prf_button_combination_is_pressed()) { // stop waiting if not held down any longer return false; } delay_ms(1); }
return true; } void *reset_vector, *initial_sp; prv_get_fw_reset_vector(&reset_vector, &initial_sp); if ((uintptr_t)reset_vector == 0xffffffff || (uintptr_t)initial_sp == 0xffffffff) { dbgserial_putstr("Firmware is erased"); return true; } return false; } static void sad_watch(uint32_t...
if (((irb_ble_stack_msg_t *)hdr)->msg_type == HCI_EVT_MSG) { hci_rom_passthrough_handle_evt(&((irb_ble_stack_msg_t *)hdr)->msg.hci.evt); #if TEST_HCI_ROM_PASSTHROUGH test_hci_passthrough(); #endif break; }
// FALLTHROUGH default: // Unhandled ble_handle_event_default(hdr); PBL_LOG(LOG_LEVEL_DEBUG, "Unhandled BLE event: 0x%"PRIx16, hdr->evt_code); break; } handled: OS_FREE(hdr); no_event: // notify again if there are more events to process in qu...
/* * 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...
{ uint32_t num_elements = analytics_metric_num_elements(metric); uint32_t element_size = analytics_metric_element_size(metric); return num_elements * element_size; }
bool analytics_metric_is_array(AnalyticsMetric metric) { const AnalyticsMetricDataType *type = prv_get_metric_data_type(metric); return (type->num_elements > 1); } bool analytics_metric_is_unsigned(AnalyticsMetric metric) { const AnalyticsMetricDataType *type = prv_get_metric_data_type(metric); return (type-...
moved to the next page, which is ZERO since we had to wrap around. cl_assert_equal_b(shared_prf_storage_get_valid_page_number(), 0); } // Sets the getting started field, then corrupts the ble_pairing_data crc // This tests that when setting a value, all fields in the struct must be valid. void test_shared_prf_storag...
shared_prf_storage_set_getting_started_complete(false)
; cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0); shared_prf_storage_set_getting_started_complete(true); cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1); shared_prf_storage_set_getting_started_complete(true); cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1); ...
ce_subscribed(true); // Revoke: ble_hrm_revoke_sharing_permission_for_connection(&s_conn_a); cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a)); cl_assert_equal_b(false, ble_hrm_is_sharing()); prv_assert_event_service_subscribed(false); prv_assert_last_disconnected(s_device_a); } void ...
(call_count_before + 1, s_bt_driver_hrm_service_handle_measurement_call_count)
; cl_assert_equal_i(bpm, s_last_ble_hrm_measurement.bpm); cl_assert_equal_b(expected_is_on_wrist, s_last_ble_hrm_measurement.is_on_wrist); } else { cl_assert_equal_i(call_count_before, s_bt_driver_hrm_service_handle_measurement_call_count); } } void test_ble_hrm__handle_hrm_event(void) { bt_driver_cb...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
pbl_log_set_level(level)
/* * 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 (!list_contains(g_profiler.nodes, (ListNode *)node)) { // Instead of calling syscall_failed(), simply return. If PROFILE_INIT has not been // executed yet, there won't be any nodes in the list. return; }
} node->start = DWT->CYCCNT; } DEFINE_SYSCALL(void, sys_profiler_node_stop, ProfilerNode *node) { // Capture the cycle count as soon as possible, before we validate the node argument uint32_t dwt_cyc_cnt = DWT->CYCCNT; if (PRIVILEGE_WAS_ELEVATED) { if (!list_contains(g_profiler.nodes, (ListNode *)nod...
e "apps/system_apps/health/health_data_private.h" #include "test_health_app_includes.h" // Setup and Teardown //////////////////////////////////// static GContext s_ctx; static FrameBuffer s_fb; GContext *graphics_context_get_current_context(void) { return &s_ctx; } void test_health_sleep_detail_card__initialize...
gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)
); } void test_health_sleep_detail_card__render_sleep_data_2(void) { HealthData health_data = { .sleep_data[0] = (7 * SECONDS_PER_HOUR) + (14 * SECONDS_PER_MINUTE), .sleep_data[1] = (4 * SECONDS_PER_HOUR) + (59 * SECONDS_PER_MINUTE), .sleep_data[2] = (8 * SECONDS_PER_HOUR) + (17 * SECONDS_PER_MINUTE), ...
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 permissions and * limitations und...
if (prv_should_set_first_event(update, header)) { update->first_header = *header; }
if (timeline_item_should_show(&header->common, TimelineIterDirectionFuture)) { update->future_has_event = true; } if ((now > start) && (time_util_get_midnight_of(now) == time_util_get_midnight_of(start))) { update->today_timed_event_passed = true; } if (now >= end) { return false; } if (heade...
/* * 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...
{ int32_t value = 0; LOCK_AND_GET_STORE(store); settings_file_get(store, &key, sizeof(key), &value, sizeof(value)); return value; }
DEFINE_SYSCALL(int, persist_read_data, const uint32_t key, void *buffer, const size_t buffer_size) { if (PRIVILEGE_WAS_ELEVATED) { syscall_assert_userspace_buffer(buffer, buffer_size); } LOCK_AND_GET_STORE(store); const int len = settings_file_get_len(store, &key, sizeof(key)); if (len =...
/* * 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...
rocky_runtime_context_init()
; jerry_init(JERRY_INIT_EMPTY); s_log_internal__expected = NULL; } void test_rocky_api_util__cleanup(void) { jerry_cleanup(); rocky_runtime_context_deinit(); fake_pbl_malloc_check_net_allocs(); s_log_internal__expected = NULL; } ////////////////////////////////////////////////////////////////////////////...
IVITY_SESSION_UPDATE_MIN; i++) { activity_test_run_minute_callback(); } } // ------------------------------------------------------------------------------- // Feed in N seconds of idle movement static void prv_feed_idle_movement_sec(uint32_t seconds) { AccelRawData idle[SAMPLES_PER_SECOND]; for (int i = 0...
activity_prefs_activity_insights_set_enabled(true)
; // Reset all stored data activity_test_reset(true /*reset_settings*/, true /*tracking_on*/, NULL, NULL); int32_t before; activity_get_metric(ActivityMetricStepCount, 1, &before); // Walk for about 30 minutes const int k_num_minutes = 30; // The sample we feed in feeds about 90 steps/min const int ...