prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
this check is
only performed from the tick hook function (which runs in an interrupt context).
It is a good debugging aid - but won't catch interrupt stack problems until the
tick interrupt next executes. */
// #define mainCHECK_INTERRUPT_STACK 1
#if mainCHECK_INTERRUPT_STACK == 1
const unsigned char ucExpectedInterrup... | (status == OS_TASK_CREATE_SUCCESS) | ;
/* Start the tasks and timer running. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following
line will never be reached. If the following line does execute, then
there was insufficient FreeRTOS heap memory available for the idle and/or
timer tasks ... |
{1184889600,"29","07"},
{1184976000,"29","07"},{1185062400,"29","07"},{1185148800,"30","07"},{1185235200,"30","07"},{1185321600,"30","07"},{1185408000,"30","07"},{1185494400,"30","07"},
{1185580800,"30","07"},{1185667200,"30","07"},{1185753600,"31","07"},{1185840000,"31","07"},{1185926400,"31","07"},{1186012800,"31... | printf("%d: %ld(%d,%d,%d,%d), ", i, s_iso8601_data[i].stamp, wrk.tm_yday,wrk.tm_year,wrk.tm_mon,wrk.tm_mday) | ;
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%V", &wrk);
cl_assert_equal_s(tmbuf, s_iso8601_data[i].str_V);
printf("%s, ", tmbuf);
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%g", &wrk);
cl_assert_equal_s(tmbuf, s_iso8601_data[i].str_g);
printf("%s\n", tmbuf);
}
}
#endif
#i... |
(america_los_angeles_region != -1) | ;
// Verify that they're the same underlying region
cl_assert_equal_i(us_pacific_region, america_los_angeles_region);
const int america_new_york_region = FIND_REGION("America/New_York");
cl_assert(america_new_york_region != -1);
cl_assert(america_new_york_region != america_los_angeles_region);
}
void test_... | |
to be registered as "awake" for over 2 hours
prv_feed_steps_min((2.5 * MINUTES_PER_HOUR) + ACTIVITY_SESSION_UPDATE_MIN);
// Fast forward time
rtc_set_time(time_util_get_midnight_of(rtc_get_time()) + 4 * SECONDS_PER_DAY);
}
activity_prefs_sleep_insights_set_enabled(prev_insights_enabled);
prv_test_en... | (&time_tm) | );
// Set the step history
activity_test_set_steps_history();
prv_feed_steps_min(4);
// Trigger insights
activity_insights_recalculate_stats();
prv_feed_steps_min(1);
prv_test_end(context, passed);
}
// -------------------------------------------------------------------------------
static void prv_tes... |
2_t s_next_value_to_write;
static void prv_cb_before_write(void) {
prv_receive_put(s_last_response_cookie, (uint8_t *)&s_next_value_to_write, VALID_OBJECT_SIZE);
}
void test_put_bytes__receive_batched_messages(void) {
uint8_t max_batched_ops = prv_put_bytes_get_max_batched_pb_ops();
int num_ops = 500;
if (max... | assert_ack_count(0) | ;
assert_nack_count(1);
}
void test_put_bytes__abort_message_cookie_mismatch(void) {
prv_receive_init_and_put_fw_object();
prv_process_and_reset_test_counters();
prv_receive_abort(~s_last_response_cookie);
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__abort_message_ok(void) {
prv_r... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | system_flash_erase(system_flash_base, erase_length, prv_display_erase_progress, 0) | ;
}
// Fills in the last 50% of the progress bar
static void prv_display_write_progress(
uint32_t progress, uint32_t total, void *ctx) {
display_firmware_update_progress(progress/2 + total/2, total);
}
static bool prv_write_new_firmware(bool new_world, uint32_t flash_new_fw_start,
... |
re_frame_buffer_format(ctx, CANVAS_GBITMAP_FORMAT);
}
// Overrides same function in graphics.c; we need to do this so we can release the framebuffer we're
// using even though its format doesn't match GBITMAP_NATIVE_FORMAT (see comment for mocked
// graphics_capture_frame_buffer() above)
bool graphics_release_frame_bu... | snprintf(snooze_buf, sizeof(snooze_buf), snooze_text, 10) | ;
dialog_set_text(dialog, snooze_buf);
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_CONFIRMATION_LARGE);
dialog_set_background_color(dialog, GColorJaegerGreen);
dialog_set_timeout(dialog, DIALOG_TIMEOUT_DEFAULT);
prv_push_and_render_simple_dialog(dialog);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE... |
/*
* 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... | {
kino_area = data->charging_kino_area;
res_id = RESOURCE_ID_RECOVERY_LOW_POWER_CHARGING;
} | else if (!current_state.is_charging && data->saved_state.is_charging) {
kino_area = data->discharging_kino_area;
res_id = RESOURCE_ID_RECOVERY_LOW_POWER_DISCHARGING;
} else {
goto reschedule;
}
layer_set_frame((Layer *) &data->kino_layer, &kino_area);
kino_layer_set_reel_with_resource(&data->kino_... |
TF("%"PRIu64": frame at: %d, %d, %d %d\n", time_ms - start_ms,
layer.frame.origin.x, layer.frame.origin.y,
layer.frame.size.w, layer.frame.size.h);
cl_assert(max_loops > 0);
max_loops--;
}
// Make sure the frame reached the "to" state
cl_assert_equal_point(layer.frame.origin, to_... | property_animation_create_layer_frame(&layer, &from_r, &to_r) | ;
Animation *h = property_animation_get_animation(prop_h);
void *context = &layer;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
prv_clear_handler_histories();
// Before we run, the context should be non NULL
cl_assert(animation_get_context(h) == context);
animati... |
/*
* 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... | ceil_log_two(n) | |
is_valid(connection)) {
PBL_LOG(LOG_LEVEL_DEBUG, "Changing connection flag: %c=%u",
prv_debug_char_for_flag(flag), enabled);
if (enabled) {
connection->flags |= (1 << flag);
} else {
connection->flags &= ~(1 << flag);
}
}
}
prv_unlock();
}
void connection_s... | {
bool rv = true;
prv_lock();
{
GattOperation *tmp_tail = (GattOperation *)list_get_tail((ListNode *)connection->gatt_op_list);
if (!tmp_tail) {
PBL_LOG(LOG_LEVEL_WARNING, "Gatt: Attempted to pop recent op when list empty");
PBL_ASSERTN(0);
}
connection->gatt_op_list = (GattOperation ... | |
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gatts_read_cfm: %u", e);
} |
}
static void prv_send_notification(uint16_t conn_idx, uint16_t value_handle) {
uint8_t data[READ_RESPONSE_BUFFER_SIZE] = {};
size_t length = 0;
if (!prv_get_value(conn_idx, value_handle, data, &length)) {
PBL_LOG(LOG_LEVEL_ERROR, "Unexpected handle! %u", value_handle);
return;
}
ble_error_t e = b... | |
onnection, event->conn_idx);
hc_endpoint_gap_service_mtu_changed(connection, event->mtu);
}
static void prv_configure_local_device_properties(const BTDriverConfig *config) {
ble_error_t e;
e = ble_gap_appearance_set(BLE_GAP_APPEARANCE_GENERIC_WATCH, ATT_PERM_READ);
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LE... | xTaskNotifyWait(0, (uint32_t) -1, ¬if, portMAX_DELAY) | ;
configASSERT(ret == pdTRUE);
sys_watchdog_resume(s_ble_perip_wdog_id);
hc_protocol_process_receive_buffer();
extern bool should_log_about_mic_error(uint32_t *max_subsequent_failures);
uint32_t num_subsequent_failures = 0;
if (should_log_about_mic_error(&num_subsequent_failures)) {
hc_... |
_index_selected(menu_layer, cell_index) ?
MENU_CELL_ROUND_FOCUSED_SHORT_CELL_HEIGHT :
MENU_CELL_ROUND_UNFOCUSED_TALL_CELL_HEIGHT));
}
static uint16_t prv_information_get_num_rows_callback(MenuLayer *menu_layer,
... | PBL_IF_RECT_ELSE(0, STATUS_BAR_LAYER_HEIGHT) | |
1000},
{ -96, -272, -944},
{ -128, -280, -968},
{ -104, -272, -984},
{ -120, -280, -992},
{ -112, -320, -944},
{ -128, -296, -976},
{ -120, -304, -976},
{ -120, -288, -992},
{ -96, -304, -968},
{ -88, -296, -952},
{ -96, -312, -960},
// 138 seconds
{ -120, -248, -984}... | { -96, -208, -984},
{ -88, -200, -992},
{ -96, -216, -992},
{ -88, -200, -984},
// 143 seconds
{ -88, -208, -984},
{ -96, -208, -976},
{ -88, -216, -992},
{ -96, -208, -992},
{ -88, -208, -976},
{ -88, -216, -976},
{ -96, -216, -1000},
{ -96, -208, -984},
{ -88, -... |
{ -96, -200, -1000},
{ -96, -224, -984},
{ -96, -208, -992},
{ -88, -216, -984},
{ -96, -216, -992},
{ -96, -224, -992},
{ -88, -200, -984},
{ -96, -208, -984},
{ -96, -216, -984},
{ -88, -208, -984},
{ -96, -224, -984},
{ -104, -216, -976},
{ -88, -216, -984},
{... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | jerry_value_is_string(string) | ) {
uint32_t sz = jerry_get_utf8_string_size(string);
out_str = task_zalloc_check(sz + 1);
jerry_string_to_utf8_char_buffer(string, (jerry_char_t *)out_str, sz);
}
return out_str;
}
void rocky_log_exception(const char *message, jerry_value_t exception) {
// using APP_LOG in this function so that 3rd-... |
/*
* 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... | PebbleEventToBTDeviceInternal(conn_event) | ;
ble_app_state->connection_handler(device.opaque,
prv_bt_errno_for_event(conn_event));
}
BTErrno ble_central_set_connection_handler(BLEConnectionHandler handler) {
BLEAppState *ble_app_state = app_state_get_ble_app_state();
const bool is_subscribed = (ble_app_state->connectio... |
ash__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_system_flash__erase_some_sectors_from_beginning(void) {
cl_assert(system_flash_erase(FLASH_BASE, 128 KiB, ... | {
erased_sector |= (1 << sector/8);
} |
return return_status;
}
extern FLASH_Status FLASH_ProgramByte(uint32_t address, uint8_t data) {
cl_assert_(!flash_locked, "Attempted to write to a locked flash");
cl_assert_(address >= flash_data_start &&
address < flash_data_start + flash_data_length,
"Address out of range");
cl_ass... |
/*
* 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... | for (int i=len; i < sizeof(s_result); ++i) {
cl_assert_equal_i(0x20, s_result[i]);
} |
// NULL-terminate the result so that it can be compared as a string.
s_result[len] = '\0';
cl_assert_equal_s(expected, (char *)s_result);
}
void test_ihex__eof_record(void) {
ihex_encode(s_result, IHEX_TYPE_EOF, 0, NULL, 0);
prv_assert_ihex(":00000001FF");
}
void test_ihex__data_record(void) {
uint8_t da... |
RROR, "Resetting because max timeouts reached...");
prv_start_reset(client);
return;
}
PBL_LOG(LOG_LEVEL_WARNING, "Rolling back from (%u, %u) to %"PRIu32,
client->out.next_data_sn, client->out.next_expected_ack_sn, sn);
// Go back and send again:
// No need to worry about the timeouts of the... | if (client->state == StateConnectedOpen) {
comm_session_close(client->session, (CommSessionCloseReason)reason);
} |
list_remove(&client->node, (ListNode **) &s_ppogatt_head, NULL);
new_timer_delete(client->rx_ack_timer);
kernel_free(client);
if (s_ppogatt_head == NULL) {
regular_timer_remove_callback(&s_ack_timer);
}
}
// ----------------------------------------------------------------------------------------------... |
ence->current_frame >= bitmap_sequence->total_frames) {
if ((++bitmap_sequence->play_index < bitmap_sequence->play_count) ||
(bitmap_sequence->play_count == PLAY_COUNT_INFINITE)) {
prv_gbitmap_sequence_restart(bitmap_sequence, false);
} else {
return false; // animation complete
}
}
... | (bitmap, corrected_dst_y) | ;
int16_t delta_x = fctl.x_offset + bitmap->bounds.origin.x;
for (int32_t x = MAX(0, row_info.min_x - delta_x);
x < MIN((int32_t)fctl.width, row_info.max_x - delta_x + 1);
x++) {
const uint32_t corrected_dst_x = x + delta_x;
const uint8_t palette_index = raw_image_get_v... |
uuid_equal(&state.pin.header.id, &all_day_item.header.id));
cl_assert(uuid_equal(&state.node->id, &all_day_item.header.id));
cl_assert(!state.node->all_day);
cl_assert_equal_i(state.node->timestamp, midnight_march_3_utc + SECONDS_PER_DAY);
cl_assert_equal_i(state.node->duration, 0);
cl_assert_equal_i(state.cu... | (&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_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(timeline_iter_remove_node_with_id(&head, &mult... |
us = prv_read_status_register(sector_base_addr)) &
S29VSStatusBit_DeviceReady) == 0) {
delay_us(10);
}
return (status);
}
//! Issue the second part of a two-cycle command. This is not merged with the
//! prv_issue_command as not all commands have an argument.
//!
//! @param sector_address The address... | {
PBL_ASSERTN(start_sector <= end_sector);
flash_impl_use();
prv_issue_command(0, S29VSCommand_SectorLock);
prv_issue_command_argument(0, S29VSCommand_SectorLock);
start_sector = flash_impl_get_sector_base_address(start_sector);
end_sector = flash_impl_get_sector_base_address(end_sector);
((__IO uint1... |
void flash_s29vs_hw_init(void) {
// Configure the reset pin (D2)
GPIO_InitTypeDef gpio_init = {
.GPIO_Pin = GPIO_Pin_2,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_Speed = GPIO_Speed_100MHz,
.GPIO_OType = GPIO_OType_PP,
.GPIO_PuPd = GPIO_PuPd_NOPULL
};
GPIO_Init(GPIOD, &gpio_init);
GPIO_WriteBit(GPIOD, GPI... |
transfer);
// Check the incoming CRC
uint32_t crc = crc32(CRC32_INIT, &remote_status_in, sizeof(remote_status_in));
if (crc != CRC32_RESIDUE) {
PBL_LOG(LOG_LEVEL_ERROR, "CRC32 failed on Status Exchange: 0x%"PRIu32 " vs 0x%"PRIu32,
crc, (uint32_t)CRC32_RESIDUE);
PBL_LOG(LOG_LEVEL_D... | sys_watchdog_notify(s_ble_host_transport_wdog_id) | ;
sys_watchdog_suspend(s_ble_host_transport_wdog_id);
// Handle missed SPI CS edge:
prv_sample_spi_cs_and_unblock_loop_if_needed();
// Block the transaction loop until there's either data to transmit, or until the master
// asserts the SCS line:
xTaskNotifyWait(0, ~0, NULL, portMAX_DELAY);
... |
context_deinit();
}
fake_pbl_malloc_check_net_allocs();
}
static const RockyGlobalAPI *s_graphics_api[] = {
&GRAPHIC_APIS,
NULL,
};
#define PP(x, y) \
GPointPrecise((int16_t)(((x)) * FIXED_S16_3_FACTOR), \
(int16_t)(((y)) * FIXED_S16_3_FACTOR))
void test_rocky_api_graphics_path2d__invalid_... | (3, lc->path.num_points) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ptr, 0, bytes) | ;
}
return ptr;
}
void *kernel_malloc_check(size_t bytes) {
void *ptr = prv_heap_malloc(bytes);
PBL_ASSERTN(ptr);
return ptr;
}
void *kernel_zalloc_check(size_t bytes) {
void *ptr = prv_heap_malloc(bytes);
PBL_ASSERTN(ptr);
memset(ptr, 0, bytes);
return ptr;
}
void kernel_free(void *ptr) {
regist... |
, 10 * SECONDS_PER_MINUTE + 10);
cl_assert(workout_service_stop_workout());
cl_assert(!workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
}
// ---------------------------------------------------------------------------... | (110, HRMQuality_Good) | |
/*
* 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... | evented_timer_get_data((EventedTimerID)timer) | ;
}
|
sizeof(*cd->menu_items) * ++cd->menu_count);
PBL_ASSERTN(cd->menu_items);
cd->menu_items[cd->menu_count - 1] = *item;
}
static void prv_append_regulatory_compliance_mark(SystemCertificationData *cd,
GBitmap *mark) {
// Determine whether adding this mark overflow... | window_get_user_data(window) | ;
prv_init_status_bar(&data->status_layer, &data->window, i18n_get("Certification", data));
SystemCertificationData *cd = &data->certification_data;
*cd = (SystemCertificationData) {};
// Load up the assets
gbitmap_init_with_resource(&cd->fcc_mark, RESOURCE_ID_SYSTEM_FCC_MARK);
gbitmap_init_with_resource... |
ncs.decode = prv_decode_packed_measurement_data,
.arg = decoder_info,
}
};
if (!pb_decode(stream, pebble_pipeline_Measurement_fields, &msg)) {
return false;
}
if (*decoder_info->num_samples < decoder_info->max_num_samples) {
decoder_info->offset_sec[(*decoder_info->num_samples)++] = msg.offse... | PBL_ASSERTN(str_len <= PLOG_MAX_SENDER_VERSION_PATCH_LEN) | ;
return pb_read(stream, (uint8_t *)ret_sender_version_patch, str_len);
}
// ---------------------------------------------------------------------------------------------
// Decode an encoded message. Used for debugging and unit tests.
bool protobuf_log_private_mset_decode(ProtobufLogType *type,
... |
> new_idx || new_idx >= NUM_NOTIFS) {
return NULL;
}
return data->layout_layers[new_idx];
}
static void prv_layout_removed_handler(SwapLayer *swap_layer, LayoutLayer *layout,
void *context) {
// layer_destroy(layer);
}
static void prv_layout_will_appear_handler(SwapL... | {
attribute_list_add_uint8(&attr_list, AttributeIdSecondaryColor, notif.sec_color);
} |
if (notif.prim_color != GColorClearARGB8) {
attribute_list_add_uint8(&attr_list, AttributeIdPrimaryColor, notif.prim_color);
}
if (notif.icon_id != 0) {
attribute_list_add_uint32(&attr_list, AttributeIdIconTiny, notif.icon_id);
}
if (notif.title) {
attribute_list_add_cstring(&a... |
S_PER_MINUTE);
// Open the app, confirm that we are now subscribed with no end in sight
workout_service_frontend_opened();
cl_assert_equal_b(s_hrm_subscribed, true);
cl_assert_equal_i(s_hrm_expiration, 0);
prv_inc_time(1 * SECONDS_PER_MINUTE);
cl_assert(workout_service_start_workout(ActivitySessionType_Ru... | cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 10) | ;
// Unpause workout
cl_assert(workout_service_pause_workout(false));
prv_inc_time(10);
prv_put_bpm_event(ZONE_3_HR, HRMQuality_Good);
cl_assert(workout_service_get_current_workout_hr_zone_time(hr_zone_time_s));
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_... |
buffer), "%c: %"PRIi8, 'X' + i,
data->axis_offsets[X_AdjustState + i]);
graphics_draw_text(ctx, data->text_buffer, font,
GRect(bounds->origin.x, bounds->origin.y + 35 + LINE_HEIGHT * i,
pixel_max, pixel_max),
GTextOverflowModeWo... | prv_display_serial_number(layer, ctx) | ;
if (data->is_saving) {
prv_display_saving_message(layer, ctx);
}
}
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *data) {
AppData *app_data = app_state_get_user_data();
app_data->app_state = (app_data->app_state + 1) % (NumAdjustStates);
layer_mark_dirty(&app_data->window.l... |
tting the tint color to blue should result in a gradient from blue to yellow
tint_color = GColorBlue;
gcolor_tint_luminance_lookup_table_init(tint_color, lookup_table_out);
cl_assert(gcolor_equal(lookup_table_out[0], GColorBlue));
cl_assert(gcolor_equal(lookup_table_out[1], GColorLiberty));
cl_assert(gcolor_e... | gcolor_component_multiply(2, 2) | |
gnizerRef recognizer, void *data) {
ButtonId button = click_recognizer_get_button_id(recognizer);
if (!quick_launch_is_enabled(button)) {
return;
}
AppInstallId app_id = quick_launch_get_app(button);
if (app_id == INSTALL_ID_INVALID) {
app_id = app_install_get_id_for_uuid(&quick_launch_setup_get_app_i... | {
case PEBBLE_BUTTON_DOWN_EVENT:
click_recognizer_handle_button_down(&s_click_manager.recognizers[e->button.button_id]);
break;
case PEBBLE_BUTTON_UP_EVENT:
click_recognizer_handle_button_up(&s_click_manager.recognizers[e->button.button_id]);
break;
default:
PBL_CROAK("Invalid ... |
}
static void prv_watchface_launch_low_power(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "Switching default watchface to low_power_mode watchface");
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = APP_ID_LOW_POWER_FACE,
});
}
void watchface_launch_default(const CompositorTransition *animation) {
ap... |
If not in HRM-mode, the host can just read the SYNC-byte (register 57).
// Reading the SYNC-byte causes the AS7000 to release the handshake-signal
// and allows deep-sleep mode (if the AS7000 is configured for this).
// This step must be the last read for this handshake-pulse.
static void prv_handle_... | if (app_ids == AS7000AppId_Idle) {
PBL_LOG(LOG_LEVEL_DEBUG, " - None (idle)");
} else {
if (app_ids & AS7000AppId_Loader) {
PBL_LOG(LOG_LEVEL_DEBUG, " - Loader");
}
if (app_ids & AS7000AppId_HRM) {
PBL_LOG(LOG_LEVEL_DEBUG, " - HRM");
}
if (app_ids & AS7000AppId_PRV) {
PBL_LOG... |
}
static bool prv_get_and_log_device_info(HRMDevice *dev, AS7000InfoRecord *info,
bool log_version) {
// get the device info
if (!prv_read_register_block(dev, ADDR_INFO_START, info, sizeof(AS7000InfoRecord))) {
return false;
}
if (log_version) {
// print out th... |
gb);
#endif
color.a = 2;
graphics_context_set_stroke_color(&context, color);
#if PBL_COLOR
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlue.argb);
#else
cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlack.argb);
#endif
color.a = 1;
graphics_context_set_stroke_color(&conte... | (&context, GPoint(5, 5), GPoint(45, 10)) | );
#else
ASSERT_CALLED(graphics_line_draw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#endif
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, tru... |
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_outside_y);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "... | (0, gothic_18_handle, 0, &s_font_info) | );
test_graphics_context_init(&ctx, fb);
// Test when clipping/drawing and text bounds are all at (0, 0)
setup_test_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
G... |
censed 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 in writing, software
* distributed under... | (node, new_node) | ;
if (!ascending) {
order = -order;
}
if (order < 0) {
list_insert_before(node, new_node);
if (node == head) {
return new_node;
} else {
return head;
}
}
ListNode *next = node->next;
if (next == NULL) {
list_insert_after(node, new_node);
... |
/*
* 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... | (addr_mac_str_out, BT_DEVICE_ADDRESS_FMT_BUFFER_SIZE,
BT_DEVICE_ADDRESS_FMT, BT_DEVICE_ADDRESS_XPLODE(s_local_address)) | |
/*
* 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... | file_system_format() | ;
file_system_reset();
ancs_app_storage_init();
}
void test_ancs_app_storage__cleanup(void) {
ancs_app_storage_deinit();
}
void test_ancs_app_storage__one_app(void) {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_da... |
cl_assert(success);
}
// Flush it out now, this should end up in our transport method being called
TestPLParsedMsg *msg = prv_flush_get_record(&input, false /* use_data_logging */, session_ref);
prv_assert_msg_equal(&input, msg);
// ------------------
// Send another set of measurements
uint32_t o... | (msg->msrmt.values, &values[num_samples_encoded * num_values_per_sample],
msg->msrmt.num_values * sizeof(uint32_t)) | ;
}
}
// Delete the session now
protobuf_log_session_delete(session_ref);
}
// ---------------------------------------------------------------------------------------------
// Test using the data logging transport
void test_protobuf_log__measurements_with_data_logging(void) {
ProtobufLogMeasurementType ty... |
rdfaults after leaving a
// wfi instruction if we have mcu debugging enabled. For now, just turn off mcu debugging
// entirely unless we explicitly want it. See PBL-10174
disable_mcu_debugging();
#else
// Turn on MCU debugging at boot. This consumes some power so we'll turn it off after a short
// time has pa... | backlight_init() | ;
ambient_light_init();
#if CAPABILITY_HAS_TEMPERATURE
temperature_init();
#endif
rtc_init_timers();
rtc_alarm_init();
power_tracking_init();
}
static void clear_reset_loop_detection_bits(void) {
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit... |
ompleted_callback(bool success) {
prompt_command_finish();
}
void command_log_dump_current(void) {
flash_dump_log_file(0, prv_serial_dump_chunk_callback, prv_serial_dump_completed_callback);
prompt_command_continues_after_returning();
}
void command_log_dump_last(void) {
flash_dump_log_file(1, prv_serial_dump... | {
prompt_send_response("ERROR");
} |
}
#ifndef RELEASE
#include "system/profiler.h"
void command_audit_delay_us(void) {
profiler_init();
// don't let context switches skew our results
__disable_irq();
char buf[80];
// test short delays because we should really be using psleep() for longer stalls!
for (uint32_t i = 1; i <= 1000; i += 2) {
... |
/*
* 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... | (RTC_TIMEZONE_DST_END, raw[4]) | ;
}
void rtc_get_timezone(TimezoneInfo *tzinfo) {
uint32_t *raw = (uint32_t*)tzinfo;
raw[0] = RTC_ReadBackupRegister(RTC_TIMEZONE_ABBR_START);
raw[1] = RTC_ReadBackupRegister(RTC_TIMEZONE_ABBR_END_TZID_DSTID);
raw[2] = RTC_ReadBackupRegister(RTC_TIMEZONE_GMTOFFSET);
raw[3] = RTC_ReadBackupRegister(RTC_TIME... |
s_radius_outer = (Fixed_S16_3){};
}
void test_graphics_circle__gpoint_from_polar_returns_zero_for_null(void) {
const uint16_t radius = 5;
const GPoint result = gpoint_from_polar_internal(NULL, radius, 0);
cl_assert_equal_gpoint(result, GPointZero);
}
void test_graphics_circle__gpoint_from_polar_returns_correc... | (&p1, GSize(2, 2)) | );
p1.x.raw_value += FIXED_S16_3_HALF.raw_value;
cl_assert_equal_grect(GRect(0, -1, 2, 2), grect_centered_internal(&p1, GSize(2, 2)));
// Repeat for an offset center point
GPointPrecise p2 = GPointPreciseFromGPoint(GPoint(5, 5));
// GRectZero + standardize
cl_assert_equal_grect(GRect(5, 5, 0, 0), grect_ce... |
ndler_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, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Just before A completes
prv_advance_to_ms_with_timer... | (&s_teardown_handler_calls, b) | , 0);
cl_assert_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MIN);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MIN);
#endif
}
// --------------------------------------------------------------------------------------
// Test a sequence within a sequence where the imbedded one... |
_orig = mag_data.y;
mag_data.y = mag_data.x;
mag_data.x = my_orig;
mag_data.z = -mag_data.z;
samples_collected++;
// don't perform any calibration if the charger is plugged in
if (!s_charger_plugged && (s_current_cal_status != CompassStatusCalibrated)) {
// if we haven't tried to calibrate yet, run at... | (s_accel_session) | ;
mag_release();
}
//! Serial command for reading a single value from the compass.
void command_compass_peek(void) {
int32_t prev_heading = s_last_heading;
launcher_task_add_callback(prv_ecompass_start_callback, NULL);
// wait for last heading to be updated
int retries = 50; // 5 seconds should be ample ti... |
me_hr(1 /*sec*/, 120 /*hr*/, HRMQuality_Excellent, true /*force_continuous*/);
cl_assert_equal_i(s_num_hr_events, 4);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 120);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.quality, HRMQuality_Excellent);
// Should not fire off an ev... | (ActivityMetricSleepExitAtSeconds, Wednesday, 60) | ;
activity_get_metric(ActivityMetricSleepExitAtSeconds, 2, metric_values);
cl_assert_equal_i(metric_values[1], 60);
activity_stop_tracking();
fake_system_task_callbacks_invoke_pending();
activity_metrics_prv_set_metric(ActivityMetricStepCount, Thursday, 5555);
activity_get_metric(ActivityMetricStepCount, ... |
v_will_change,
.change = prv_change,
.did_change = prv_did_change,
};
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.will_change, prv_w... | (handlers, s_data.context) | |
{ 0, 0x86, 0, 192, 0},
{ 0, 0x85, 1553, 183, 0},
{ 0, 0x61, 2324, 180, 0},
{ 0, 0x71, 0, 192, 0},
{ 0, 0x71, 674, 193, 0},
{ 0, 0x5f, 139, 191, 0},
{ 0, 0x8e, 299, 192, 0},
{ 0, 0x5c, 2772, 197, 0},
{ 0, 0x79, 2319, 191, 0},
{ 0, 0x4c, 1579, 167, 0},
{ 0, 0x67, 1042, 186, 0},... |
{ 0, 0x51, 0, 194, 1},
{ 0, 0x61, 32, 196, 0},
{ 0, 0x62, 0, 196, 1},
{ 0, 0x61, 1908, 189, 1},
// 180: Local time: 09:35:00 PM
{ 0, 0x60, 0, 192, 1},
{ 0, 0x60, 0, 192, 1},
{ 0, 0x60, 0, 192, 1},
{ 0, 0x60, 46, 181, 1},
{ 0, 0x60, 0, 192, 1},
{ 0, 0x60, 20, 181, 1},
{ 0... | |
f there are no recognizer lists
prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL);
RecognizerList app_list = {};
s_app_list = &app_list;
Window window = {};
layer_init(&window.layer, &GRectZero);
manager.window = &window;
Layer layer_a, layer_b, layer_c;
layer_init(&layer_a, &G... | cl_assert(prv_dispatch_touch_event(r, &ctx)) | ;
cl_assert(!handled);
cl_assert(!ctx.triggered);
r->state = RecognizerState_Started;
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equal_p(ctx.triggered, r);
ctx.triggered = NULL;
handled = false;
r->state = RecognizerState_Updated;
cl_assert(prv_dispatch_touch_event... |
/*
* 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... | accessory_enable_input() | ;
accessory_set_baudrate(AccessoryBaud115200);
accessory_set_power(false);
break;
case AccessoryInputStateSmartstrap:
case AccessoryInputStateMic:
// fallthrough
default:
break;
}
mutex_unlock(s_state_mutex);
PBL_LOG(LOG_LEVEL_DEBUG, "Setting accessory state to %u", state);
return tru... |
prv_is_in_window(time_t node_timestamp, uint16_t node_duration, time_t timestamp) {
time_t future_window = time_util_get_midnight_of(timestamp + TIMELINE_FUTURE_WINDOW);
time_t past_window = time_util_get_midnight_of(timestamp - TIMELINE_PAST_WINDOW);
time_t end_time = node_timestamp + (node_duration * SECONDS_P... | time_util_get_midnight_of(header->timestamp + header->duration *
SECONDS_PER_MINUTE - 1) | |
oduce a pin
prv_add_sleep_session(0, 7);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 1);
Uuid orig_id = s_last_timeline_id;
// Next session, < 1h after should move the pin
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_sleep_session(0.5, 1.5);
... | (fake_kernel_services_notifications_ancs_notifications_count(), 3) | ;
}
// ---------------------------------------------------------------------------------------
void test_activity_insights__activation_delay_insights_fifteen_interval_trigger(void) {
time_t now = mktime(&s_init_time_tm);
prv_set_activation_time(now);
activity_insights_process_minute_data(now);
cl_assert_equal... |
text_layer_deinit(&data->title_text_layer) | ;
text_layer_deinit(&data->status_text_layer);
window_deinit(&data->window);
app_free(data);
}
static void prv_main(void) {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
}
const PebbleProcessMd* mfg_hrm_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_f... | |
ave code
// in one of a few small ranges, a pointer can be packed into much fewer
// than 28 bits while still being able to address a function anywhere in
// memory that exists.
//
// For reference, those ranges are:
// 0x0000 0000 - 0x0001 FFFF - Internal Flash, remapped at 0x0
// 0x0800 0000 - 0x0801 FFFF - Inter... | (delta_ms, 0) | + rate_control_delay_ms;
if (animation_legacy2_scheduler->timer_handle != NULL) {
app_timer_reschedule(animation_legacy2_scheduler->timer_handle, interval_ms);
// Ignore the return value of reschedule. If it fails it probably means the callback is already
// fired and we're waiting for the handler to be... |
assert(g_gbitmap_spalding_data_row_infos != bmp->data_row_infos); // union with .palette
bmp = gbitmap_create_blank(s10, GBitmapFormat8BitCircular);
cl_assert(NULL == bmp);
bmp = gbitmap_create_blank(s180, GBitmapFormat8BitCircular);
cl_assert(NULL != bmp);
cl_assert(g_gbitmap_spalding_data_row_infos == bmp... | cl_assert_equal_i( 70, prv_gbitmap_size_for_data(GSize(13, 10), GBitmapFormat4BitPalette)) | ;
cl_assert_equal_i( 0, prv_gbitmap_size_for_data(GSize(13, 10), GBitmapFormat8BitCircular));
const size_t expected = PBL_IF_RECT_ELSE(0, DISPLAY_FRAMEBUFFER_BYTES);
cl_assert_equal_i(expected,
prv_gbitmap_size_for_data(GSize(180, 180), GBitmapFormat8BitCircular));
cl_assert_equal_i(expected,
prv_... |
/*
* 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_ASSERT(length <= pulse_link_max_send_size() - sizeof(PushPacket),
"Packet to big to send") | ;
// We're blindly assuming that buf is the same pointer returned by
// pulse_push_send_begin. If it isn't, we'll either crash here
// when trying to dereference it or we'll hit the assert in
// pulse_link_send.
PushPacket *packet = (void *)((char *)buf - offsetof(PushPacket,
... |
/*
* 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... | ((cur - limit_b), (limit_c - limit_b)) | ));
} else if (cur <= limit_d) {
// zone c - d
return GPoint(frame.origin.x +
DIV_X(frame.size.w * (1000 - MULT_X((cur - limit_c), (limit_d - limit_c)))),
frame.origin.y + frame.size.h);
} else if (cur <= limit_e) {
// zone d - e
return GPoint(frame.origin.x,
... |
ntext()->to_process_event_queue;
break;
case PebbleTask_App:
queue = app_manager_get_task_context()->to_process_event_queue;
break;
case PebbleTask_KernelBackground:
queue = NULL;
break;
default:
WTF;
}
return queue;
}
void pebble_task_create(PebbleTask pebble_task, ... | mpu_set_task_configurable_regions(region_config, region_ptrs) | ;
vTaskAllocateMPURegions(xTaskGetIdleTaskHandle(), region_config);
}
|
b/rockyjs/api/rocky_api.h"
#include "applib/rockyjs/api/rocky_api_global.h"
#include "applib/rockyjs/api/rocky_api_graphics.h"
#include "applib/rockyjs/api/rocky_api_graphics_text.h"
#include "applib/rockyjs/pbl_jerry_port.h"
#include "util/trig.h"
// Standard
#include "string.h"
// Fakes
#include "fake_app_timer.h"
... | (s_graphics_draw_text.last_call.draw_text.text,
text, sizeof(s_graphics_draw_text.last_call.draw_text.text)) | ;
}
static MockCallRecordings s_graphics_text_attributes_destroy;
void graphics_text_attributes_destroy(GTextAttributes *text_attributes) {
record_mock_call(s_graphics_text_attributes_destroy){};
}
static MockCallRecordings s_graphics_text_layout_get_max_used_size;
static GSize s_graphics_text_layout_get_max_used_s... |
;
location_name = pstring_create_pstring16_from_string(location);
short_phrase = pstring_create_pstring16_from_string(phrase);
data_size = strlen(location) +
strlen(phrase) +
sizeof(uint16_t) * 2; // One for each string
const size_t entry_size = sizeof(WeatherDBEntry) + data_size;... | pstring_get_pstring16_from_list(&pstring16_list, 0) | |
imer_id);
}
void enter_standby(RebootReasonCode reason) {
s_entered_standby = true;
}
void event_put(PebbleEvent* event) {
s_last_event_put = *event;
if (event->type == PEBBLE_BATTERY_STATE_CHANGE_EVENT) {
battery_monitor_handle_state_change_event(event->battery_state.new_state);
} else if (event->type =... | fake_battery_set_charging(true) | |
c_get_time();
struct tm local_tm;
localtime_r(&now, &local_tm);
DayInWeek day_in_week = local_tm.tm_wday;
// ----------------------------------------
// Let's fill in some known data for the daily totals and accumulate the totals and counts
// for each day of the week.
int day_totals[DAYS_PER_WEEK] = {};... | (minute_end_idx < MINUTES_PER_DAY) | ;
const int k_minutes_per_step_avg = MINUTES_PER_DAY / ACTIVITY_NUM_METRIC_AVERAGES;
uint32_t chunk_start_idx = minute_start_idx / k_minutes_per_step_avg;
uint32_t chunk_end_idx = minute_end_idx / k_minutes_per_step_avg;
uint32_t sum = 0;
for (int i = chunk_start_idx; i < chunk_end_idx; i++) {
sum += avg... |
error);
static void prv_consume_read_response(const PebbleBLEGATTClientEvent *e,
GenericReadHandler handler) {
uint8_t *value = NULL;
uint16_t value_length = e->value_length;
const uintptr_t object_ref = e->object_ref;
BLEGATTError gatt_error = e->gatt_error;
// Read R... | if (event_subtype >= PebbleBLEGATTClientEventTypeNum) {
WTF;
} |
// MT: This is a bit smaller in code size than a switch():
static const PrvHandler handler[] = {
[PebbleBLEGATTClientEventTypeServiceChange] = prv_handle_service_change,
[PebbleBLEGATTClientEventTypeCharacteristicRead] = prv_handle_characteristic_read,
[PebbleBLEGATTClientEventTypeNotification] = prv_h... |
GTextAttributes *text_attributes) {
record_mock_call(s_graphics_draw_text){
.draw_text.box = box,
.draw_text.color = ctx->draw_state.text_color,
};
strncpy(s_graphics_draw_text.last_call.draw_text.text,
text, sizeof(s_graphics_draw_text.last_call.draw_text.text));
}
static MockCallRecordi... | (s_graphics_api) | ;
cl_assert_equal_b(false, rocky_global_has_event_handlers("draw"));
EXECUTE_SCRIPT("_rocky.on('draw', function() {});");
cl_assert_equal_b(true, rocky_global_has_event_handlers("draw"));
}
void test_rocky_api_graphics__draw_event_has_ctx(void) {
rocky_global_init(s_graphics_api);
EXECUTE_SCRIPT(
"var ... |
{ 816, 192, -192},
{ 808, 216, -120},
{ 968, 288, -112},
{ 1112, 344, -72},
{ 1184, 384, -56},
{ 1192, 376, 32},
{ 1576, 424, 104},
{ 1448, 552, 56},
{ 1136, 576, 48},
{ 1192, 792, -160},
{ 864, 592, -232},
{ 992, 424, -120},
{ 1032, 560, -112},
{ 1216, 576, -72},
... | { 1288, 208, -280},
{ 1256, 184, -120},
{ 1072, 208, -136},
{ 912, 280, -184},
{ 960, 304, -192},
{ 1032, 288, -96},
{ 1104, 320, -64},
// 92 seconds
{ 1088, 368, -56},
{ 1176, 408, -80},
{ 1616, 544, -120},
{ 1232, 704, -72},
{ 1144, 616, -80},
{ 1048, 552, -128}... |
{ 1040, 616, 184},
{ 1424, 840, 8},
{ 864, 704, -96},
{ 904, 560, -48},
{ 976, 616, 24},
{ 1280, 640, 48},
{ 1400, 456, 104},
{ 1376, 264, 152},
{ 1424, 152, 136},
{ 1448, 200, 80},
{ 1368, 232, 56},
{ 1136, 232, 96},
{ 1144, 224, 136},
{ 1168, 256, 56},
{ 92... |
/*
* 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... | {
WTF;
} | |
#include "applib/rockyjs/api/rocky_api_global.h"
#include "applib/rockyjs/api/rocky_api_graphics.h"
#include "applib/rockyjs/api/rocky_api_graphics_color.h"
#include "applib/rockyjs/pbl_jerry_port.h"
#include "util/trig.h"
// Standard
#include "string.h"
// Fakes
#include "fake_app_timer.h"
#include "fake_logging.h"... | fake_malloc_set_largest_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_graphics_line_draw_preci... |
gap_le_advert_schedule(NULL, &advert_term,
sizeof(advert_term)/sizeof(GAPLEAdvertisingJobTerm),
unscheduled_callback, s_unscheduled_cb_data, 0) | ;
cl_assert_equal_p(job, NULL);
free(ad);
free(ad_scannable);
}
void test_gap_le_advert__unschedule_non_existent(void) {
// Unscheduling non-existent job should be fine, should not crash:
gap_le_advert_unschedule((GAPLEAdvertisingJobRef)(uintptr_t) 0x1234);
// Unschedule callback should not have been cal... | |
(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0, 3, 1}, 4, &s_recognizers_handled);
prv_compare_recognizers_processed(NULL, 0, &s_recognizers_reset);
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersTriggered);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Failed);
... | (recognizers[3]->state, RecognizerState_Failed) | ;
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Failed);
// Touchdown occurs, Window recognizer completes, active layer becomes non-null
e.type = TouchEvent_Touchdown;
s_next_state = RecognizerState_Completed;
s_idx_to_change = 0;
s_active_layer = &layer_a;
recognizer_manager_handle_touch_even... |
// History with low median
static const int32_t step_history[ACTIVITY_HISTORY_DAYS] = {
AVERAGE_STEPS, // This is 'today'
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS,
AVERAGE_STEPS
... | strlen(ACTIVITY_INSIGHTS_SETTINGS_ACTIVITY_REWARD) | |
/*
* 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_flash_operation() | ;
app_event_loop();
}
const PebbleProcessMd* flash_demo_get_app_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
.name = "Flash Demo"
};
return (const PebbleProcessMd*) &s_app_info;
}
|
/*
* 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... | (gack, 123) | ;
cl_will_return(gack, 456);
cl_will_return(gack, 789);
printf("gack() = %d\n", gack()); // 123
printf("gack() = %d\n", gack()); // 456
printf("gack() = %d\n", gack()); // 789
cl_will_return_count(gack, 765, 3);
printf("gack() = %d\n", gack()); // 765
printf("gack() = %d\n", gack()); // 765
printf("ga... |
prv_unlock();
}
//
// Getters
//
// Note: Using a lock on the getters doesn't really accomplish anything since
// the fields we read are either set on creation or atomic operations. We do
// run the risk that the connection handle is no longer valid and could add
// some extra checks in the future to protect against... | connection_is_valid(connection) | ) {
PBL_LOG(LOG_LEVEL_DEBUG, "Changing connection flag: %c=%u",
prv_debug_char_for_flag(flag), enabled);
if (enabled) {
connection->flags |= (1 << flag);
} else {
connection->flags &= ~(1 << flag);
}
}
}
prv_unlock();
}
void connection_set_subscribed_to_con... |
sert(sum.raw_value == sum_c.raw_value);
// sum = 1 + 3.5 = 4.5 - test commutative property of addition
num1 = FIXED_S16_3_ONE;
num2 = (Fixed_S16_3){ .raw_value = (int16_t)((float)3.5 * (1 << FIXED_S16_3_PRECISION)) };
sum = Fixed_S16_3_add(num1, num2);
sum_c = (Fixed_S16_3){ .raw_value = (int16_t)((float)4.5... | (sum.raw_value == sum_c.raw_value) | ;
// sum = 3.5 + 1 = 4.5
num1 = (Fixed_S32_16){ .raw_value = (int32_t)((float)3.5 * (1 << FIXED_S32_16_PRECISION)) };
num2 = FIXED_S32_16_ONE;
sum = Fixed_S32_16_add(num1, num2);
sum_c = (Fixed_S32_16){ .raw_value = (int32_t)((float)4.5 * (1 << FIXED_S32_16_PRECISION)) };
cl_assert(sum.raw_value == sum_c.r... |
bit
// - no flow control
dev->periph->CR1 = cr1_extra_flags;
dev->periph->CR2 = 0;
dev->periph->CR3 = (dev->half_duplex ? USART_CR3_HDSEL : 0);
// QEMU doesn't want you to read the DR while the UART is not enabled, but it
// should be fine to clear errors this way
#if !TARGET_QEMU
// Clear any stale err... | {
uint16_t errors = dev->periph->SR;
UARTRXErrorFlags flags = {
.parity_error = (errors & USART_FLAG_PE) != 0,
.overrun_error = (errors & USART_FLAG_ORE) != 0,
.framing_error = (errors & USART_FLAG_FE) != 0,
.noise_detected = (errors & USART_FLAG_NE) != 0,
};
return flags;
} |
bool uart_is_rx_ready(UARTDevice *dev) {
return dev->periph->SR & USART_SR_RXNE;
}
bool uart_has_rx_overrun(UARTDevice *dev) {
return dev->periph->SR & USART_SR_ORE;
}
bool uart_has_rx_framing_error(UARTDevice *dev) {
return dev->periph->SR & USART_SR_FE;
}
bool uart_is_tx_ready(UARTDevice *dev) {
return d... |
{
static const VoiceUiState state_map[] = {
StateStart,
StateWaitForReady, // StateStartWaitForReady
StateWaitForReady,
StateRecording, // StateStopWaitForReady
StateRecording,
StateWaitForResponse, // StateStopRecording
StateWaitForResponse,
StateTransitionToText, // S... | (layer_get_window(layer)) | ;
// get frame to place dot in middle of layer
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_circle(ctx, grect_center_point(&layer->bounds), data->mic_window.mic_dot_radius);
}
static void prv_set_dot_width(void *subject, int16_t radius) {
VoiceUiData *data = subject;
data->mic_window.mic_... |
GTextAlignmentRight);
const MusicAppSizeConfig *config = prv_config();
const GRect artist_rect = prv_artist_rect();
const GRect title_rect = prv_title_rect();
const GRect time_rect = prv_time_rect();
const GRect cassette_rect = prv_cassette_rect();
const GRect track_rect = prv_track_rect();
... | (RESOURCE_ID_VIBE_SCORE_HAPTIC_FEEDBACK) | ;
#endif
prv_update_now_playing(data);
prv_update_layout(data);
prv_update_track_progress(data);
prv_update_ui_state(data, false);
}
static void prv_push_window(MusicAppData *data) {
Window *window = &data->window;
window_init(window, WINDOW_NAME("Music"));
window_set_user_data(window, data);
window_s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_populate_name(s_local_device_name, s_local_default_device_name_format) | ;
prv_populate_name(s_local_le_device_name, s_local_default_le_device_name_format);
}
static bool prv_has_device_name(void) {
return (s_local_device_name[0] != '\0');
}
static void prv_configure_device_name(void) {
bt_driver_id_set_local_device_name(s_local_device_name);
}
void bt_local_id_configure_driver(voi... |
vance time to past expiration time
rtc_set_time(rtc_get_time() + expire_s + 1);
// Send more data, the subscription should go away now
prv_fake_send_new_data();
fake_system_task_callbacks_invoke_pending();
cl_assert(prv_get_subscriber_state_from_ref(session_ref) == NULL);
}
void test_hrm_manager__subscribe... | TO_SESSION_REF(i+1) | ;
const uint16_t expire_s = SECONDS_PER_MINUTE;
sys_hrm_manager_app_subscribe(app_id, 1, expire_s, HRMFeature_BPM|HRMFeature_LEDCurrent);
}
prv_fake_send_new_data();
// Two events for each app subscriber
cl_assert_equal_i(s_event_count, num_refs * 2);
for (int i = 0; i < num_refs; ++i) {
sys_hr... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_db_delete((uint8_t *)&entry.uuid, sizeof(Uuid)) | ;
prompt_send_response("OK");
}
bool prv_print_app_info(AppInstallEntry *entry, void *data) {
if (app_install_id_from_system(entry->install_id)) {
return true;
}
char buffer[120];
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&entry->uuid, uuid_buffer);
prompt_send_response_fmt(buffe... |
cl_assert_equal_i(steps, 2000);
cl_assert_equal_i(duration_s, 600);
cl_assert_equal_i(distance_m, 1600);
// Get the active calories, should be same as session
workout_service_get_active_kcalories(&active_kcalories);
cl_assert_equal_i(200, active_kcalories);
// Add some time and steps
prv_inc_time(600);... | cl_assert_equal_i(bpm, 80) | ;
cl_assert(workout_service_pause_workout(true));
cl_assert(workout_service_pause_workout(true));
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 20);
cl_assert_equal_i(duratio... |
tic void prv_will_change(GRect final_area, void *context) {
s_data.last_will_change_final_area = final_area;
cl_assert_equal_p(context, s_data.context);
s_data.num_will_change_calls++;
}
static void prv_change(AnimationProgress progress, void *context) {
s_data.last_change_progress = progress;
cl_assert_equa... | 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_will_change(from_area.size.h, to_area.size.h);
cl_assert_passert(fake_event_service_handle_last());
}
void test_unobstructed_area_service__change(void) {
UnobstructedAreaHan... |
/*
* 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->detected_workout_dialog) | ;
}
static void prv_detected_workout_down_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutAppData *data = context;
workout_push_summary_window();
workout_dialog_pop(&data->detected_workout_dialog);
}
static void prv_detected_workout_click_config_provider(void *context) {
window_single_c... |
urn next;
}
static void prv_select_indicator_layer_update_proc(Layer *layer, GContext *ctx) {
action_button_draw(ctx, layer, SELECT_INDICATOR_COLOR);
}
static void prv_refresh_select_indicator(HealthCardView *health_card_view) {
Layer *card_layer = health_card_view->card_layers[health_card_view->current_card_inde... | (&health_card_view->select_indicator_layer, true) | ;
prv_hide_content_indicators(health_card_view);
}
static void prv_bg_animation_stopped_handler(Animation *animation, bool finished, void *context) {
HealthCardView *health_card_view = context;
for (int i = 0; i < CardCount; i++) {
if (i != health_card_view->current_card_index) {
layer_set_hidden(hea... |
ex_lock_recursive(state->mutex);
{
SettingsFile *file = activity_private_settings_open();
if (!file) {
goto unlock;
}
ActivitySettingsValueHistory history;
ActivityMetricInfo m_info;
for (ActivityMetric metric = ActivityMetricFirst; metric < ActivityMetricNumMetrics;
metric++) ... | ACTIVITY_LOG_DEBUG("resting kcalories: %"PRIu16"",
state->step_data.resting_kcalories) | ;
}
mutex_unlock_recursive(state->mutex);
}
// ------------------------------------------------------------------------------------------
// Pushes an HR Median/Filtered/LastStable event.
static void prv_push_median_hr_event(uint8_t median_hr) {
if (median_hr > 0) {
PebbleEvent event = {
.type = PEBBL... |
itmap, "test_bitblt__1bit_to_8bit_or-expect.8bit.pbi"));
memset(dest_data, GColorBlue.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpAnd, GColorWhite);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_and-expect.8bit.pbi"));
memset(dest_data, G... | cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_8bit_comptint_black_cross_white_corners-expect.8bit.pbi"));
memset(dest_data, GColorBlack.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, (GPoint){0}, GCompOpTint, GColorBlack);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test... |
// Setup:
// - Source is 25x25.
// - Source has alternating white / black lines.
// - Dest is Blue, 100x100.
// - Dest offset is set to 8x10 clipped in the bottom right corner.
// Result:
// - There should be an 8x10 alternating black & white lines in the bottom right corner.
void test_bitblt__1bit_to_8bit_... |
/*
* 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_info_set_model(model) | |
_FIFO_MAX_FRAMES * BMA255_FIFO_FRAME_SIZE_BYTES)
// Driver state
static BMA255PowerMode s_accel_power_mode = BMA255PowerMode_Normal;
static bool s_fifo_is_enabled = false;
static bool s_shake_detection_enabled = false;
static bool s_accel_outstanding_motion_work = false;
static bool s_accel_outstanding_data_work = fa... | {
reading |= 0xF000;
} |
return reading;
}
static void prv_convert_accel_raw_data_to_mgs(const uint8_t *buf, AccelDriverSample *data) {
int16_t readings[3];
for (int i = 0; i < 3; ++i) {
readings[i] = prv_conv_raw_to_12bit(&buf[i*2]);
}
const AccelConfig *cfg = &BOARD_CONFIG_ACCEL.accel_config;
*data = (AccelDriverSample) {
... |
ttr_list.attributes[2].id, AttributeIdBody);
cl_assert_equal_s(item->attr_list.attributes[2].cstring, "This is a test notification. "
"Look at it and behold the awesome.");
cl_assert_equal_i(item->action_group.num_actions, 2);
cl_assert_equal_i(item-... | string_list_get_at(list, 1) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_assert_key_is_equal_to_retrieved_key(&keys[SMRootKeyTypeIdentity], SMRootKeyTypeIdentity) | ;
}
void test_ble_root_keys__regenerate_if_key_not_present(void) {
// Pretend one of the root keys isn't there:
cl_will_return_count(bt_persistent_storage_get_root_key, true, 1);
cl_will_return_count(bt_persistent_storage_get_root_key, false, 1);
cl_will_return_count(rng_rand, true, RNG_ROUNDS * SMRootKeyType... |
_patch);
LOG("payload_send_time: %"PRIu32"", s_parsed_msg.payload_send_time);
const int num_events = s_parsed_msg.events.num_events;
LOG("Events: Number: %d", num_events);
for (int i = 0; i < num_events; i++) {
pebble_pipeline_Event *event = &s_parsed_msg.events.events[i];
LOG(" Event -- T... | strncpy(input->payload_sender_type, PLOG_PAYLOAD_SENDER_TYPE, PLOG_MAX_SENDER_ID_LEN) | ;
strncpy(input->payload_sender_id, TEST_PL_SERIAL_NUM, PLOG_MAX_SENDER_ID_LEN);
prv_fill_version(input);
// Reset data logging storage
prv_reset_captured_dls_data();
}
static ProtobufLogRef prv_log_create_measurement(TestPLParsedMsg *input, bool use_data_logging) {
// Create a session
ProtobufLogTranspo... |
License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impl... | (direction) | ;
// in the video for S4 with 180px I measured 80px
// this expression tries express this in a future-proof manner in case we will have round
// displays with a different resolution
const int16_t offset_value = DISP_COLS * 80 / 180;
const GPoint offset = GPoint(factor.x * offset_value, factor.y * o... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_manager_set_minimum_run_level(ProcessAppRunLevelNormal) | ;
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = mfg_menu_app_get_info(),
});
}
void mfg_enter_mfg_mode(void) {
if (!s_mfg_mode) {
s_mfg_mode = true;
#if CAPABILITY_HAS_ACCESSORY_CONNECTOR
accessory_manager_set_state(AccessoryInputStateMfg);
#endif
prf_idle_watchdog_stop();
low_powe... |
uint32_t write_size = 32 * 1024;
const uint32_t subsector_size = 4 * 1024;
for (uint32_t i = region.begin; i < region.end; i += block_size) {
struct Region write_region;
write_region.begin = i;
write_region.end = i + write_size;
if (!check_region_write(write_region, false, true)) {
success ... | (&stress_data.window, &(WindowHandlers) {
.load = stress_window_load,
.unload = stress_window_unload
}) | |
(scroll_layer) | .y);
cl_assert_equal_i(page_height * pages, -scroll_layer_get_content_offset(scroll_layer).y);
// once the last full page of content has been displayed
// another scroll down shouldn't advance the offset
scroll_layer_scroll(scroll_layer, ScrollDirectionDown, false);
cl_assert_equal_i(page_height * pages, -sc... | |
even boundaries - no offset
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_EVEN, ORIGIN_RECT_NO_CLIP, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("d... | (&ctx, GPoint(col, 0), MAX_NUM_ROWS) | ;
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_even_clip")));
// Clipping on odd boundaries - no offset
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_ODD, OFFSET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_d... |
u 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 WARRANT... | (app_entry) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.