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... | {
GPIO_InitTypeDef gpio_init_struct;
gpio_init_struct.GPIO_Pin = pin_config.gpio_pin;
gpio_init_struct.GPIO_Mode = GPIO_Mode_AF;
gpio_init_struct.GPIO_Speed = GPIO_Speed_50MHz;
gpio_init_struct.GPIO_OType = GPIO_OType_OD;
gpio_init_struct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(pin_config.gpio, &gpio_init... |
//! Configure bus pin as input
//! Lock bus and peripheral config access before use
static void bus_pin_cfg_input(AfConfig pin_config) {
// Configure pin as high impedance input
GPIO_InitTypeDef gpio_init_struct;
gpio_init_struct.GPIO_Pin = pin_config.gpio_pin;
gpio_init_struct.GPIO_Mode = GPIO_Mode_IN;
gpi... |
->name_font;
lines++;
} else if (prv_has_long_name(s_phone_ui_data->name_font)) {
caller_id_font = s_phone_ui_data->long_name_font;
lines++;
} else {
caller_id_font = s_phone_ui_data->name_font;
}
text_layer_set_font(&s_phone_ui_data->caller_id_text_layer, caller_id_font);
if (lines == 1) {
... | (0, -BOUNCEBACK_DISTANCE) | ,
&GPointZero));
animation_set_curve(bounceback, AnimationCurveEaseOut);
animation_set_duration(bounceback, BOUNCEBACK_ANIMATION_FRAMES * ANIMATION_FRAME_MS);
Animation *animation = animation_sequence_create(upward, bounceback, NULL);
s_phone_ui_data->call_status_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... | (JERRY_ERROR_TYPE, (jerry_char_t *)msg) | |
.size_w = line->max_width_px};
const GRangeVertical vertical_range = {
.origin_y = line_in_perimeter_space.y + TEXT_LINE_CAP_LINE(line),
.size_h = TEXT_LINE_BASE_LINE(line) - TEXT_LINE_CAP_LINE(line)
};
GRangeHorizontal perimeter_horizon... | (line_iter) | );
}
}
////////////////////////////////////////////////////////////
// Text layout
//! @return is_success
bool line_add_word(GContext* ctx, Line* line, Word* word, const TextBoxParams* const text_box_params) {
// Horizontal overflow
if (line->width_px > line->max_width_px) {
return false;
}
// Don't se... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERT(runlevel < RunLevel_COUNT, "Unknown runlevel %d", runlevel) | ;
PBL_LOG(LOG_LEVEL_INFO, "Setting runlevel to %d", runlevel);
services_common_set_runlevel(runlevel);
#ifndef RECOVERY_FW
services_normal_set_runlevel(runlevel);
#endif
}
static const char *s_runlevel_debug_names[] = {
#define RUNLEVEL(number, name) [number] = #name,
#include "runlevel.def"
#undef RUNLEVEL
};
... |
t_reverse(h, true);
cl_assert(animation_get_reverse(h) == true);
animation_set_reverse(h, false);
// Position
int32_t elapsed_ms = 0;
AnimationProgress progress = 0;
animation_schedule(h);
cl_must_pass(animation_get_elapsed(h, &elapsed_ms));
cl_assert_equal_i(elapsed_ms, -delay);
cl_assert_passert(an... | (seq, true, true) | ;
cl_assert_equal_i(duration, duration_a + delay_a + duration_b + delay_b);
// The position of seq should be the amount we already played of a, including the 'a' delay
// since a is embedded within seq
int32_t position;
animation_get_elapsed(seq, &position);
cl_assert_equal_i(position, duration_a + delay_... |
----------
bool worker_manager_launch_new_worker_with_args(const PebbleProcessMd *app_md, const void *args) {
PBL_ASSERT_TASK(PebbleTask_KernelMain);
// Don't launch workers in recovery mode to reduce the chance of crashes
#ifdef RECOVERY_FW
return false;
#endif
// If workers are disabled, don't launch
if (... | }
// The rest of worker_ram is available for worker state to use as it sees fit.
if (!worker_state_configure(&worker_ram)) {
PBL_LOG(LOG_LEVEL_ERROR, "Worker state configuration failed");
return false;
}
// The remaining space in worker_segment is assigned to the worker's
// heap. Worker state need... |
// If no default yet, set as the default so that it can be relaunched upon system reset
if (worker_manager_get_default_install_id() == INSTALL_ID_INVALID) {
worker_manager_set_default_install_id(s_worker_task_context.install_id);
}
return true;
}
// -------------------------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | list_insert_after(&a, &b) | |
y_prefs_heart_rate_is_enabled(void) {
return s_activity_prefs_heart_rate_is_enabled;
}
static bool s_bt_driver_hrm_service_is_enabled;
static int s_bt_driver_hrm_service_enable_call_count;
void bt_driver_hrm_service_enable(bool enable) {
s_bt_driver_hrm_service_enable_call_count++;
s_bt_driver_hrm_service_is_ena... | fake_event_service_get_info(PEBBLE_HRM_EVENT) | ;
if (is_subscribed) {
cl_assert(info->handler);
} else {
cl_assert_equal_p(NULL, info->handler);
}
}
void test_ble_hrm__cleanup(void) {
ble_hrm_deinit();
prv_assert_event_service_subscribed(false);
// hrm manager sub vs unsub calls should be the same, there should be no subscription any more
//... |
on;
ResourceId current_icon_id;
bool hid_action_bar;
GBitmap up_bitmap;
GBitmap select_bitmap;
GBitmap down_bitmap;
ClickHandler up_action;
ClickHandler select_action;
ClickHandler down_action;
const PhoneStyle *style;
GFont name_font;
GFont long_name_font;
GFont status_font;
char caller_i... | (&timeline_res, s_phone_ui_data->style->icon_size, &icon_res_info) | ;
const ResourceId resource = icon_res_info.res_id;
KinoReel *image = kino_reel_create_with_resource(resource);
#if !PLATFORM_TINTIN
GRect layer_frame = s_phone_ui_data->icon_layer.layer.frame;
GSize size = kino_reel_get_size(image);
GRect icon_from = {
.origin.x = layer_frame.origin.x + (layer_frame.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... | fake_spi_flash_init(0, 0x1000000) | ;
pfs_init(false);
pfs_format(false);
cron_service_init();
alarm_init();
alarm_service_enable_alarms(true);
}
void test_alarm__cleanup(void) {
cron_service_deinit();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Basic Store / Get Tests
void te... |
tain 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 implied.
* See the License... | i18n_get("Not connected", data) | ;
// Subscribe to the BT remote app connect event
data->connect_event_info = (EventServiceInfo) {
.type = PEBBLE_COMM_SESSION_EVENT,
.handler = prv_remote_comm_session_event_handler
};
event_service_client_subscribe(&data->connect_event_info);
break;
case AppFetchResult... |
/*
* 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... | {
connection->gatt_mtu = event->mtu;
bt_driver_pebble_pairing_service_handle_gatt_mtu_change(connection);
} |
BLE_LOG_DEBUG("GATT MTU Updated: remote: %u", event->mtu);
}
unlock:
bt_unlock();
}
void bt_driver_cb_gatt_handle_notification(const GattServerNotifIndicEvent *event) {
GAPLEConnection *connection = NULL;
bt_lock();
{
connection = gap_le_connection_by_addr(&event->dev_address);
}
bt_unlock();
... |
estarted again once we get re-enabled.
if (s_activity_state.started) {
prv_stop_tracking_cb(NULL);
// We want to turn tracking on again once we get re-enabled, so change the state of
// should_be_started to true (prv_stop_tracking_cb() sets it to false).
s_activity_state.should_be_... | time_util_get_minute_of_day(utc_now) | ;
s_activity_state.resting_calories = activity_private_compute_resting_calories(minute_of_day);
key = ActivitySettingsKeyLastSleepActivityUTC;
settings_file_get(file, &key, sizeof(key),
&s_activity_state.logged_sleep_activity_exit_at_utc,
sizeof(s_activity_state.logged_sle... |
r_calls, a), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handle... | (seq, handlers, seq) | ;
// Play it
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
prv_advance_to_ms_with_timers(start_ms + total_duration + 5 * MIN_FRAME_INTERVAL_MS);
// Make sure neither inner_seq, a, nor b played
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_cal... |
layer.layer, hide_layer);
}
static void prv_unload_no_music_window(Window *window) {
MusicNoMusicWindow *music_window = (MusicNoMusicWindow *)window;
gbitmap_deinit(&music_window->bitmap);
bitmap_layer_deinit(&music_window->bitmap_layer);
text_layer_deinit(&music_window->text_layer);
i18n_free_all(music_wind... | prv_update_layout(data) | ;
}
static void prv_copy_time_period(char *buffer, size_t n, uint32_t period_s) {
uint32_t hours = period_s / SECONDS_PER_HOUR;
uint32_t minutes = (period_s % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE;
uint32_t seconds = period_s % SECONDS_PER_MINUTE;
if (hours > 0) {
snprintf(buffer, n, "%"PRIu32":%02"PRIu32... |
zeof(buffer));
jerry_string_to_utf8_char_buffer(str_js, (jerry_char_t *) buffer, sizeof(buffer));
return strcmp(buffer, str) == 0;
}
jerry_value_t jerry_get_object_getter_result(jerry_value_t object, const char *getter_name) {
JS_VAR getter = jerry_get_object_field(object, getter_name);
const bool is_function ... | (&prop_desc) | ;
prop_desc.is_get_defined = getter != NULL;
prop_desc.getter = jerry_create_external_function(getter);
prop_desc.is_set_defined = setter != NULL;
prop_desc.setter = jerry_create_external_function(setter);
JS_VAR prop_name_js = jerry_create_string((const jerry_char_t *) prop_name);
JS_UNUSED_VAL = jerry_def... |
tionFlag_IsSubscribedToConnectionStatusNotifications] = 'S',
[ConnectionFlag_IsSubscribedToGattMtuNotifications] = 'M',
[ConnectionFlag_IsSubscribedToConnParamNotifications] = 'C',
[ConnectionFlag_ShouldPinAddress] = 'P',
[ConnectionFlag_ShouldAutoAcceptRePairing] = 'A',
[ConnectionFlag_IsReversedPP... | {
bool rv = true;
prv_lock();
{
GattOperation *tmp = connection->gatt_op_list;
if (!tmp) {
rv = false;
goto unlock;
}
*context_ref = tmp->object_ref;
*resp_dest = tmp->resp_dest;
PBL_ASSERTN(tmp->op_type == expected_op_type);
connection->gatt_op_list = (GattOperation *)l... |
bool connection_pop_gatt_op(Connection *connection) {
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);... |
tification below the one we want to focus,
// set it as the current notification, then swap up. This allows us
// to accomplish the animation effect, while still pleasing the SwapLayer
// when it wants to retrieve the layouts it wants to.
notifications_presented_list_set_current(second_id);
... | (prv_alert_type_for_notification_type(type)) | ) {
#if CAPABILITY_HAS_VIBE_SCORES
VibeScore *score = vibe_client_get_score(VibeClient_Notifications);
if (score) {
vibe_score_do_vibe(score);
vibe_score_destroy(score);
}
#else
vibes_short_pulse();
#endif
// Timestamp set after call to vibrate since if something fails,
// its better... |
AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include "applib/app.h"
#include "applib/app_message/app_message.h"
#include "applib/ui/app_window_s... | (HRM, &hrm_info) | ;
dict_write_uint8(app_data->out_iter, AppMessageKey_HRMProtocolVersionMajor,
hrm_info.protocol_version_major);
dict_write_uint8(app_data->out_iter, AppMessageKey_HRMProtocolVersionMinor,
hrm_info.protocol_version_minor);
dict_write_uint8(app_data->out_iter, AppMess... |
LED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, 2));
}
void test_graphics_context_${BIT_DEPTH_NAME}__draw_stroke_width_even(void) {
// Stroke width even > 2, non-antialiased
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoi... | ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN)) | ;
#else
ASSERT_CALLED(prv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN));
#endif
setup_test(&context, true, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circle_draw_stroked_aa(&context, GPoint(50, 50), 10, SW_... |
tLayer *temp_range_layer;
char cur_temp_text[32];
char temp_range_text[128];
int min_temp;
int max_temp;
} TemperatureDemoAppData;
static TemperatureDemoAppData *s_data;
// -------------------------------------------------------------------------------
static void select_click_handler(ClickRecognizerRef reco... | (ctx, GPoint(x_pos, PLOT_BOTTOM - line_height)) | ;
}
}
// -------------------------------------------------------------------------------
static void prv_window_load(Window *window) {
TemperatureDemoAppData *data = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
// GRect bounds = window_layer->bounds;
layer_set_update_pr... |
p_into_bitmap_tiled(&dest_bitmap, src_bitmap, dest_rect, src_origin_offset,
GCompOpAssign, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap,
"test_bitblt__1bit_to_8bit_src_origin_offset_wrap2-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Set... | {
GBitmap *src_bitmap = get_gbitmap_from_pbi("test_bitblt__1bit_to_1bit_comptint.1bit.pbi");
const GRect bounds = gbitmap_get_bounds(src_bitmap);
cl_assert_equal_i(src_bitmap->info.format, GBitmapFormat1Bit);
uint8_t dest_data[bounds.size.w * bounds.size.h];
GBitmap dest_bitmap = {
.addr = dest_data,
... |
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to_1bit_comptint_black_on_black-expect.1bit.pbi"));
memset(dest_data, 0b00000000, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, (GPoint){0}, GCompOpTint, GColorWhite);
cl_check(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__1bit_to... |
g_to_connection(&s_conn_a));
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_b));
cl_assert_equal_b(false, ble_hrm_is_sharing());
prv_assert_event_service_subscribed(false);
}
void test_ble_hrm__revoke_after_disconnection(void) {
ble_hrm_revoke_sharing_permission_for_connection(NULL);
s_co... | (HRMEvent_BPM, 80, HRMQuality_Excellent,
true /* expect bt driver cb */, true /* expected_is_on_wrist */) | |
(num.integer == -1) | ;
cl_assert(num.fraction == 5);
test_num = (int32_t)((float)-0.250 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 6);
test_num = (int32_t)((float)-0.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_valu... | |
x__send_not_user_space_buffer(void) {
// TODO: really implement privilege escalation in unit tests. See PBL-9688
return;
cl_assert_passert(app_outbox_send(NULL, s_test_data_length,
test_app_outbox_sent_handler, s_expected_cb_ctx));
assert_syscall_failed();
}
// Disallowed, b... | assert_sent_cb_last_status(AppOutboxStatusConsumerDoesNotExist) | ;
cl_assert_equal_b(true, app_outbox_service_is_message_cancelled(s_last_message));
// the consumer must call ..._consume_message(), to free the resources:
app_outbox_service_consume_message(s_last_message, AppOutboxStatusSuccess);
// sent_handler shouldn't get called again, it's already been called:
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... | PBL_ASSERTN(s_num_subscribers > 0) | ;
--s_num_subscribers;
if (s_num_subscribers == 0) {
PBL_LOG(LOG_LEVEL_DEBUG, "stopping tick timer");
regular_timer_remove_callback(&s_tick_timer_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... | {
#if CAPABILITY_HAS_BUILTIN_HRM
if (!s_hrm_present) {
return;
}
const uint32_t last_toggled_ts = s_activity_state.hr.toggled_sampling_at_ts;
bool should_toggle = false;
if (s_activity_state.hr.currently_sampling) {
// If we are currently sampling, turn off when:
// - We reach the end of our max... |
if (!s_activity_state.hr.currently_sampling && watch_is_flat) {
PBL_LOG(LOG_LEVEL_INFO, "Not subscribing to HRM: watch is flat(ish)");
}
// Pick the subscription rate (essentially ON and OFF)
const uint32_t desired_interval_sec = (should_be_sampling)
? A... |
ash_file(start_page); // on failure, unallocate
return (rv);
}
pg_hdr.next_page_crc = crc8_next_page(next_page);
pg_hdr.next_page = next_page;
write_pg_header(&pg_hdr, curr_page);
curr_page = next_page;
// continuation page header settings
memset(&pg_hdr, 0xff, sizeof(... | (f->name, name) | == 0) {
PBL_ASSERTN(PFS_FD(fd).fd_status != FD_STATUS_FREE);
*fdp = fd;
return ((PFS_FD(fd).fd_status == FD_STATUS_IN_USE) ? FDBusy : FDAlreadyLoaded);
}
}
}
// a simple least-recently-accessed cache scheme
int unref = -1;
uint16_t curr_time_closed = 0;
for (int fd = FD_IN... |
/*
* 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... | (worker_state_ram, NULL,
sizeof(WorkerState)) | ;
return s_worker_state_ptr != NULL;
}
void worker_state_init(void) {
s_worker_state_ptr->rand_seed.mat1 = 0; // Uninitialized
accel_service_state_init(worker_state_get_accel_state());
plugin_service_state_init(worker_state_get_plugin_service());
battery_state_service_state_init(worker_state_get_battery_s... |
_service_change(area.size.h, to_area.size.h, progress);
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_will_change_calls, 1);
cl_assert_equal_i(s_data.num_change_calls, 1);
cl_assert_equal_i(s_data.last_change_progress, progress);
}
void test_unobstructed_area_service__change_no_will(void) {
... | (unobstructed_bounds, GRect(210, 220, 190, 180)) | ;
}
void test_unobstructed_area_service__layer_clip_nx_ny(void) {
app_state_get_unobstructed_area_state()->area = GRect(0, 0, 400, 400);
Layer root_layer = {
.bounds = GRect(-110, -120, 300, 300),
};
GRect unobstructed_bounds;
layer_get_unobstructed_bounds(&root_layer, &unobstructed_bounds);
cl_assert... |
36},
{ 168, 744, -736},
{ 168, 744, -736},
{ 176, 744, -728},
{ 168, 752, -728},
{ 168, 744, -736},
{ 168, 736, -736},
{ 160, 744, -728},
{ 168, 744, -728},
{ 160, 752, -736},
{ 160, 744, -736},
{ 160, 744, -736},
{ 160, 744, -736},
{ 160, 744, -728},
{ 152, 736, ... | { 168, 728, -752},
{ 176, 712, -752},
{ 168, 712, -760},
{ 176, 720, -752},
{ 176, 720, -760},
{ 176, 720, -760},
{ 176, 712, -752},
{ 176, 712, -752},
{ 176, 712, -752},
// 199 seconds
{ 176, 720, -752},
{ 176, 712, -752},
{ 176, 712, -760},
{ 176, 720, -760},
... | |
it's
// not useful as a generic one-shot. We'll let it run free and calculate deltas.
static void prv_timer_enable(void) {
timer0_config cfg = {
.clk_src = HW_TIMER0_CLK_SRC_SLOW,
.on_clock_div = false,
.on_reload = TIMER0_RELOAD_VALUE,
};
hw_timer0_init(&cfg);
hw_timer0_enable();
}
// The initial... | (CRC32_INIT, buffer, len) | ;
s_spi_dma_complete = false;
hw_spi_write_buf(s_spi->bus_id, buffer, len, prv_spi_dma_tx_cb, NULL);
// Now signal the host that we're ready to TX.
host_transport_set_mcu_int(true);
prv_wait_for_dma(true);
host_transport_set_mcu_int(false);
prv_timer_delay_1ms();
// Now send the CRC
s_spi_dma_comp... |
r;
SPITransportMsgFooter *tx_footer;
bool watchdog_timer_active;
} SPITransport;
static uint8_t DMA_READ_BSS s_spi_tx_storage_buffer[HOST_TRANSPORT_HOST_TX_BUFFER_SIZE];
static SPITransportMsgFooter DMA_READ_BSS s_spi_tx_footer;
static SPITransportMsgStatus DMA_READ_BSS s_spi_status_local;
static SPITransport DMA... | prv_lock() | ;
circular_buffer_consume(&s_spi_transport.tx, s_spi_transport.bytes_sendable_count);
prv_unlock();
prv_give_semamphore_from_isr(should_context_switch);
}
static void prv_handle_sending_complete_isr(bool *should_context_switch) {
// Wait for the controller to signal that it's ready
prv_watchdog_start();
s... |
out_min + (out_max - out_min) * (progress - in_min) / (in_max - in_min);
}
static void prv_draw_banner_round(NotificationLayout *notification_layout, GContext *ctx,
const GRect *const notification_layout_frame,
LayoutColors colors) {
// We use DISP... | (ctx, GColorBlack) | ;
(text_visible ? graphics_text_node_draw :
graphics_text_node_get_size)(layout->view_node, ctx, &box, &config,
&layout->view_size);
#if PBL_ROUND
if (render) {
// restore original clip box
ctx->draw_state.clip_box.size.h = orig_clip_height;
... |
_clar.errors = error;
if (_clar.last_error != NULL)
_clar.last_error->next = error;
_clar.last_error = error;
error->test = _clar.active_test;
error->test_number = _clar.test_count;
error->suite = _clar.active_suite;
error->file = file;
error->line_number = line;
error->error_msg = error_msg... | printf(" ") | ;
i++;
}
// And print the final ASCII bit.
printf(" %s\n", buff);
}
void clar__assert_equal_m(
uint8_t *m1,
uint8_t *m2,
int n,
const char *file,
int line,
const char *err,
int should_abort)
{
if (m1 == m2 || n == 0) {
return;
}
if (m1 == NULL || m2 == NULL) {
char buf[4096];
... |
/*
* 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... | MIN(day, max_days) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ("Weather - warning dialog") | ;
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_destroy_on_pop(dialog, false);
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_WARNING_TINY);
dialog_set_text(dialog, localized_string);
const DialogCallbacks callbacks = {
.unload = prv_warning_dialog_unload,
};
dialog_set_ca... |
/*
* 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... | (session,
GET_BYTES_ENDPOINT_ID,
(const uint8_t *) &rsp,
sizeof(rsp),
COMM_SESSION_DEFAULT_TIMEOUT) | ;
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "GET_BYTES: aborted");
s_get_bytes_in_progress = false;
return false;
}
if (result != GET_BYTES_ALREADY_IN_PROGRESS) {
s_get_bytes_in_progress = false;
}
prv_put_status_event(DebugInfoStateFinished);
return true;
}
static void prv_gather_and_rec... |
ta = false;
s_bus_contention_detected = false;
prv_unlock();
}
void accessory_enable_input(void) {
// NOTE: This function may be called from an ISR
if (s_input_enabled) {
return;
}
prv_lock();
if (s_sent_data) {
// wait for the TC flag to be set
uart_wait_for_tx_complete(ACCESSORY_UART);
... | (s_did_send_byte) | ;
} else {
// we're done sending
portBASE_TYPE was_higher_task_woken = pdFALSE;
xSemaphoreGiveFromISR(s_send_semaphore, &was_higher_task_woken);
should_context_switch = (was_higher_task_woken != pdFALSE);
uart_set_tx_interrupt_enabled(dev, false);
s_stream_cb = NULL;
s_stre... |
/*
* 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_InitTypeDef init = {
.GPIO_Pin = af_config->gpio_pin,
.GPIO_Mode = GPIO_Mode_AF,
.GPIO_Speed = speed,
.GPIO_OType = otype,
.GPIO_PuPd = pupd
};
gpio_use(af_config->gpio);
GPIO_PinAFConfig(af_config->gpio, af_config->gpio_pin_source,
af_config->gpio_af);
GPIO_Init... |
void gpio_af_configure_low_power(const AfConfig *af_config) {
GPIO_InitTypeDef init = {
.GPIO_Pin = af_config->gpio_pin,
.GPIO_Mode = GPIO_Mode_AN,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_PuPd = GPIO_PuPd_NOPULL
};
gpio_use(af_config->gpio);
GPIO_Init(af_config->gpio, &init);
gpio_release(af_... |
se 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.
*/
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "drive... | cl_assert(qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)) | ;
prv_send_footer();
cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol));
// -----------------------------------------------------------------------------
// Check after just part of the data
prv_send_hdr(QemuProtocol_SPP, 2*sizeof(msg_data));
cl_assert(!qemu_serial_priva... |
ion (if active). If session was active, locks it and returns true.
// If session is not active, does no locking and returns false.
//
// Note regarding the list_mutex and the session->data-mutex:
// * session->status can only be read/modified while holding the list mutex
// * session->data->open_count can only be r... | mutex_lock_recursive(s_list_mutex) | ;
DataLoggingSession *iter = s_logging_sessions;
while (iter != NULL) {
if (iter->comm.session_id > session_id) {
break;
}
if (iter->comm.session_id == session_id) {
mutex_unlock_recursive(s_list_mutex);
return (iter);
}
iter = iter->next;
}
mutex_unlock_recursive(s_list_m... |
_to_8bit_set-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Setup:
// - Source is an image of a white cross
// - Dest is blue, same size as source
// Result:
// - Destination should be written with a White cross
// Description:
// - This test verifies that when the bitmap is 1-bit, we treat white as ... | get_gbitmap_from_pbi("test_bitblt__1bit_to_8bit_clipping.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));
GPoint dest_offset = { ... |
160_set_gyro_power_mode(BMI160_Gyro_Mode_Normal);
// Write the gyr_self_test_start bit
prv_write_reg(BMI160_REG_SELF_TEST, 0x10);
psleep(50);
const uint8_t status = bmi160_read_reg(BMI160_REG_SELF_TEST);
// power down the gyro
bmi160_set_gyro_power_mode(BMI160_Gyro_Mode_Suspend);
if (status | 0x2) {
... | (interval_us) | |
turn 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;
}
ret... | (ERROR_BAD_SPI_FLASH) | ;
}
boot_bit_dump();
// If the recovery firmware crashed at start-up, the watch is now a
// $150 brick. That's life!
if (check_for_recovery_start_failure()) {
boot_bit_clear(BOOT_BIT_RECOVERY_START_IN_PROGRESS);
sad_watch(ERROR_CANT_LOAD_FW);
}
bool force_boot_recovery_mode = check_force_boot_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... | {
cl_assert_equal_i(S_SUCCESS, app_cache_add_entry(app1.id, app1.size));
cl_assert_equal_i(app1.id, app_cache_get_next_eviction());
} |
/*************************************
* Add 3, remove 2, evict one *
*************************************/
void test_app_cache__add_remove_evict(void) {
// add all three
cl_assert_equal_i(S_SUCCESS, app_cache_add_entry(app1.id, app1.size));
cl_assert_equal_i(S_SUCCESS, app_cache_add_entry(app2.id, app2.siz... |
LE / 8;
angle_end = angle_start + (TRIG_MAX_ANGLE / 4);
}
}
void test_graphics_draw_circle_${BIT_DEPTH_NAME}__calc_draw_config_caps(void) {
// ## Section with special cases
// Test for no angles
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(0), TO_TRIG(0)), ((EllipsisDrawConfig){
.start_qua... | (prv_calc_draw_config_ellipsis(TO_TRIG(90), TO_TRIG(270)), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(90),GCornerBottomRight},
.full_quadrants = GCornersBottom,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft}
})) | |
208},
{ -80, 872, -272},
{ -152, 920, -136},
{ -320, 1088, -328},
{ -592, 1560, -16},
{ -440, 704, -144},
{ -384, 808, -512},
{ -104, 608, -520},
{ -64, 648, -584},
{ 184, 312, -640},
{ 416, 272, -880},
{ 448, 168, -920},
{ 464, 72, -1008},
{ 384, 176, -1112},
{ 3... | { -104, 144, -1000},
{ -96, 136, -1000},
{ -104, 136, -1008},
{ -96, 152, -1008},
{ -96, 152, -1000},
// elapsed: 2 minutes
{ -96, 152, -1000},
{ -104, 160, -1008},
{ -104, 136, -1000},
{ -80, 152, -1024},
{ -88, 168, -1024},
{ -80, 152, -992},
{ -104, 200, -1024},
... |
{ 96, 320, -1008},
{ 120, 296, -1000},
{ 128, 280, -984},
{ 128, 272, -976},
{ 144, 280, -968},
{ 168, 272, -968},
{ 168, 280, -944},
{ 136, 296, -928},
{ 144, 288, -952},
{ 144, 280, -936},
{ 144, 280, -944},
{ 128, 264, -936},
{ 128, 296, -968},
{ 144, 328, -96... |
bt_driver_stop_le_scan();
kernel_free(s_reports_buffer);
s_reports_buffer = NULL;
s_is_scanning = false;
if (s_dropped_reports) {
PBL_LOG(LOG_LEVEL_INFO, "LE Scan -- Dropped reports: %" PRIu32, s_dropped_reports);
}
}
}
bt_unlock();
return success;
}
// ----------------... | if (s_is_scanning) {
gap_le_stop_scan();
s_is_scanning = false;
} |
bt_unlock();
}
// For UNIT Tests
uint32_t gap_le_scan_get_dropped_reports_count(void) {
return s_dropped_reports;
}
|
;
layer_init(&layer_b, &GRectZero);
layer_init(&layer_c, &GRectZero);
layer_add_child(root, &layer_a);
layer_add_child(root, &layer_b);
layer_add_child(&layer_a, &layer_c);
recognizer_add_to_list(recognizers[0], window_get_recognizer_list(&window));
recognizer_add_to_list(recognizers[1], &layer_a.recogni... | recognizer_add_to_list(recognizers[2], &layer_b.recognizer_list) | ;
recognizer_add_to_list(recognizers[3], &layer_c.recognizer_list);
recognizer_add_to_list(recognizers[4], s_app_list);
s_active_layer = &layer_c;
TouchEvent e = { .type = TouchEvent_PositionUpdate };
// No active recognizers because manager is waiting for a touchdown event
recognizer_manager_handle_touch... |
/*
* 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... | ((uint8_t) crc) | ;
prv_put_byte_hdlc((uint8_t) (crc >> 8));
prv_put_byte_hdlc((uint8_t) (crc >> 16));
prv_put_byte_hdlc((uint8_t) (crc >> 24));
prv_put_hdlc_frame_delimiter();
}
if (s_timeout == 0) {
mic_stop(MIC);
PROFILER_STOP;
PROFILER_PRINT_STATS;
kernel_free(s_test_buffer);
accessory_ena... |
le 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 in writing, software
* di... | {
new_timer_stop(s_alarm_popup_data->vibe_timer);
new_timer_delete(s_alarm_popup_data->vibe_timer);
s_alarm_popup_data->vibe_timer = TIMER_INVALID_ID;
#if CAPABILITY_HAS_VIBE_SCORES
if (s_alarm_popup_data->vibe_score) {
vibe_score_destroy(s_alarm_popup_data->vibe_score);
s_alarm_popup_data->... |
vibes_cancel();
}
// ----------------------------------------------------------------------------------------------
//! Vibe Timer
#define TINTIN_VIBE_REPEAT_INTERVAL_MS (1000)
#define TINTIN_MAX_VIBES (10 * 60) // 10 minutes at 1 vibe a second
#define TINTIN_LPM_VIBES_PER_MINUTE (10)
#define VIBE_DURATION (10 * SE... |
service, glance->current_slice.expiration_time);
return glance;
}
static bool prv_should_use_glance_cache_for_app_with_uuid(const Uuid *uuid) {
// Use the glance cache only if the app does not have the system UUID (all zeros)
return !uuid_is_system(uuid);
}
/////////////////////
// Glance events
static void p... | {
if (!service) {
return;
}
*service = (LauncherAppGlanceService) {};
prv_reset_slice_expiration_timer(service);
service->glance_event_info = (EventServiceInfo) {
.type = PEBBLE_APP_GLANCE_EVENT,
.handler = prv_handle_glance_event,
.context = service,
};
event_service_client_subscribe(&... |
void launcher_app_glance_service_set_handlers(LauncherAppGlanceService *service,
const LauncherAppGlanceServiceHandlers *handlers,
void *context) {
if (!service) {
return;
} else if (!handlers) {
service->handlers ... |
NULL == bmp);
bmp = gbitmap_create_blank(s180, GBitmapFormat8BitCircular);
cl_assert(NULL == bmp);
#endif
#ifdef PLATFORM_SNOWY
bmp = gbitmap_create_blank(s10, GBitmapFormat1Bit);
cl_assert(NULL != bmp);
cl_assert(NULL == bmp->data_row_infos);
bmp = gbitmap_create_blank(s10, GBitmapFormat8Bit);
cl_asser... | gbitmap_create_blank_with_palette(s180, GBitmapFormat8BitCircular, p, true) | );
#endif
#ifdef PLATFORM_SPALDING
cl_assert(NULL == gbitmap_create_blank_with_palette(s10, GBitmapFormat1Bit, p, true));
cl_assert(NULL == gbitmap_create_blank_with_palette(s10, GBitmapFormat8Bit, p, true));
bmp = gbitmap_create_blank_with_palette(s10, GBitmapFormat1BitPalette, p, true);
cl_assert(NULL != bmp... |
jerry_create_number(idx) | , jerry_create_number(1)};
JS_VAR remove_result = jerry_call_function(splice, event_listeners,
args, ARRAY_LENGTH(args));
if (jerry_value_has_error_flag(remove_result)) {
rocky_log_exception("removing event listener", remove_result);
}
for (size_t i =... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
uint16_t length = strlen(string);
if (length == 0) {
// Empty string
pstring_out->str_length = length;
pstring_out->str_value[0] = '\0';
} else {
pstring_out->str_length = length;
strncpy(pstring_out->str_value, string, length);
}
} |
bool pstring_equal(const PascalString16 *ps1, const PascalString16 *ps2) {
return ps1 && ps2 && (ps1->str_length == ps2->str_length) &&
(memcmp(ps1->str_value, ps2->str_value, ps1->str_length) == 0);
}
bool pstring_equal_cstring(const PascalString16 *pstr, const char *cstr) {
return pstr && cstr && (pst... |
/*
* 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... | (MemoryManagement_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY) | |
cl_assert(uuid_equal(&item1.header.id, &temp.header.id));
temp.attr_list.attributes = NULL;
cl_assert(memcmp(&item1, &temp, sizeof(TimelineItem)) == 0);
cl_assert(S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(U... | reminder_db_get_len((uint8_t*)&item4.header.id, sizeof(Uuid)) | |
nfo is_alive_timer;
ReassemblyContext reassembly_ctx;
ANCSAttribute *attributes[NUM_FETCHED_NOTIF_ATTRIBUTES];
NotificationQueueNode *queue;
bool alive_check_pending;
ANCSVersion version;
} ANCSClient;
static ANCSClient *s_ancs_client;
// Keeps track of used NS flags for analytics purposes:
static uint8_t s... | {
NotificationQueueNode *node = kernel_malloc_check(sizeof(NotificationQueueNode));
*node = (NotificationQueueNode) {
.op = NotificationQueueOpPerformAction,
.uid = uid,
.action_id = action_id
};
prv_notif_queue_push_common(node);
} |
static void prv_notif_queue_push_attr_request(uint32_t uid, ANCSProperty properties) {
NotificationQueueNode *node = kernel_malloc_check(sizeof(NotificationQueueNode));
*node = (NotificationQueueNode) {
.op = NotificationQueueOpGetAttributes,
.uid = uid,
.properties = properties,
};
prv_notif_que... |
_t*) &stored_data, MIN((unsigned)info->val_len, sizeof(stored_data)));
if (stored_data.type == BtPersistBondingTypeBLE) {
internal_itr_data->cb(key, &stored_data, internal_itr_data->cb_data);
}
return true;
}
void bt_persistent_storage_for_each_ble_pairing(BtPersistBondingDBEachBLE cb, void *context) {
F... | if (key == BT_BONDING_ID_INVALID) {
// We are out of keys....
return BT_BONDING_ID_INVALID;
} |
} else {
// Load the existing data so the optional fields don't get overwritten
bt_persistent_storage_get_bt_classic_pairing_by_addr(address,
&new_data.bt_classic_data.link_key,
new_data.bt_class... |
nt);
GTextNodeHorizontal *horiz_container = graphics_text_node_create_horizontal(MAX_TEXT_NODES);
GTextNodeContainer *container = &horiz_container->container;
horiz_container->horizontal_alignment = GTextAlignmentCenter;
if (data->now_bpm == 0) {
health_util_create_text_node_with_text(
EM_DASH, fo... | (health_data) | ,
.bpm_font = fonts_get_system_font(FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM),
.timestamp_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
.units_font = fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS),
};
data->pulsing_heart_timer = app_timer_register(0, prv_pulsing_heart_timer_cb, base_layer);
... |
/*
* 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... | (&sub_bitmap, context_bitmap, ctx->draw_state.drawing_box) | ;
// The sub-bitmap might have different bounds than this layer:
// when the requested bounds lie outside of the original bitmap it will be clipped.
// The following work-around will make sure the sub-bitmap gets painted at
// exactly the same spot as it came from:
GRect rect = sub_bitmap.bounds;
rect.orig... |
ate PBI generated by bitmapgen.py from the PNG copied to TEST_IMAGES_PATH
// covers 1,2,4,8 bit palettized
// covers 1,2,4,8 bit palettized with transparency
// covers 1, 2 bit greyscale
// covers 1, 2 bit greyscale with transparency
// covers 4 bit greyscale with transparency (black, white, dark_grey, light_grey, tran... | (gbitmap_get_format(bitmap), GBitmapFormat1BitPalette) | ;
}
// Tests 1-bit b&w greyscale PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__greyscale_1_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(1bitpalette));
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(1bitpalette)));
cl_assert_equal_i(gbitmap_get... |
xt) {
goto error;
}
*new_timer_context = (ButtonPressNewTimerContext) {
.button_id = button_id,
.button_is_held_down = false,
.num_presses_remaining = num_presses,
.hold_down_time_ms = hold_down_timeout_ms,
.delay_between_presses_ms = delay_between_presses_timeout_ms,
};
// In order to ... | prompt_command_continues_after_returning() | ;
}
static void spam_callback(void *data) {
uint32_t iteration = (uintptr_t) data;
uint8_t buffer[128];
time_t base = sys_get_time();
for (int i = 0; i < 16; ++i) {
LogBinaryMessage* msg = (LogBinaryMessage*) buffer;
msg->timestamp = htonl(base + iteration * 16 + i);
msg->log_level = LOG_LEVEL_ERRO... |
!ble_data->is_remote_encryption_info_valid &&
!ble_data->is_remote_identity_info_valid &&
!ble_data->is_remote_signing_info_valid) {
goto done;
}
if (pairing_info_out) {
*pairing_info_out = (const SMPairingInfo) {};
pairing_info_out->local_encryption_info.ediv = ble_data->local_ediv;
... | (&empty_data, sizeof(empty_data),
offsetof(SharedPRFData, ble_data)) | ;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! BT Classic Pairing Data
bool shared_prf_storage_get_bt_classic_pairing_data(BTDeviceAddress *addr_out,
char *device_name_out,
... |
he packing end.
*/
static const uint8_t LEVEL_MAP[8] = { LOG_LEVEL_ALWAYS, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING,
LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_VERBOSE,
LOG_LEVEL_DEBUG_VERBOSE, LOG_LEVEL_DEBUG_VERBOSE };
static const struct OV... | if (length == 0) {
return;
} |
s_log_buffer.transmitting = true;
circular_buffer_read(&s_log_buffer.circular_buffer, length, &data, &length);
hw_uart_send(CONFIG_LOG_UART, data, length, prv_uart_tx_callback, NULL);
}
static void prv_log_to_buffer(uint8_t *buffer, uint16_t length) {
prv_lock();
if (!circular_buffer_write(&s_log_buffer.ci... |
max_rows) + b->row);
if (a_abs > b_abs) {
return 1;
} else if (a_abs < b_abs) {
return -1;
} else {
return 0;
}
}
static void prv_selection_complete(Animation *animation, bool finished, void *context) {
MenuLayer *menu_layer = (MenuLayer *) context;
menu_layer->animation.animation = NULL;
}
s... | (&menu_layer->inverter.layer) | ;
}
}
static MenuRowAlign prv_corrected_scroll_align(MenuLayer *menu_layer, MenuRowAlign align) {
if (menu_layer->center_focused) {
return MenuRowAlignCenter;
}
return align;
}
static void prv_menu_layer_update_selection_scroll_position(MenuLayer *menu_layer,
... |
sumed(AppMessageSenderErrorDisconnected, 1);
app_free(outbox_data);
}
void test_app_message_sender__no_sessions_connected(void) {
s_system_session_ptr = NULL;
s_app_session_ptr = NULL;
AppMessageAppOutboxData *outbox_data =
prv_create_and_send_outbox_message(NULL /* auto-select */, ALLOWED_ENDPOINT_ID,
... | (1, comm_session_send_queue_copy(s_app_session_ptr, 0 /* offset */,
1 /* length */, &byte_out)) | ;
cl_assert_equal_i(TEST_EXPECTED_PP_MSG[i], byte_out);
comm_session_send_queue_consume(s_app_session_ptr, 1 /* length */);
}
assert_consumed(AppMessageSenderErrorSuccess, 1);
cl_assert_equal_i(s_app_install_timestamp_update_count, 1);
app_free(outbox_data);
}
void test_app_message_sender__byte_by_by... |
_count);
cl_assert_equal_i(1, s_graphics_context_set_fill_color.call_count);
cl_assert_equal_i(0, s_graphics_context_set_stroke_color.call_count);
cl_assert_equal_i(0, s_graphics_context_set_stroke_width.call_count);
}
// run update proc multiple times to verify we don't have a memory leak
for (int i... | ("e1", e1) | ;
cl_assert(*s_log_internal__expected == NULL);
// string
s_log_internal__expected = (const char *[]){
"Exception while e2", "TypeError", NULL,
};
rocky_log_exception("e2", e2);
cl_assert(*s_log_internal__expected == NULL);
// number
s_log_internal__expected = (const char *[]){
"Exception whil... |
/*
* 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_calculate_incremental_start() | ;
// First calculate the CRC of the whole words, since the hardware works 4
// bytes at a time.
uint32_t* data_words = (uint32_t*) data;
const unsigned int num_words = data_length / 4;
prv_calculate_incremental_words(data_words, num_words);
const unsigned int num_remaining_bytes = data_length % 4;
const... |
need to fetch the new next layer, since we will do that
// in the swap down complete
swap_layer->previous = swap_layer->current;
swap_layer->current = swap_layer->next;
swap_layer->next = NULL;
return true;
}
static void prv_scroll(SwapLayer *swap_layer, int16_t dy, AnimationCurve curve) {
if (dy == 0) {
... | if (!is_repeating || swap_layer->swap_delay_remaining <= 0) {
prv_attempt_swap(swap_layer, direction, false /* to_top */);
swap_layer->swap_delay_remaining = MESSAGE_SWAP_DELAY;
} else {
swap_layer->swap_delay_remaining--;
} |
}
T_STATIC void prv_attempt_scroll(SwapLayer *swap_layer, ScrollDirection direction,
bool is_repeating) {
prv_finish_animation(swap_layer);
#if PBL_ROUND
is_repeating = false;
#endif
int16_t offset = prv_get_current_notification_offset(swap_layer);
int16_t max_dy = prv_get_m... |
e *file,
SettingsRecordInfo *info, void *context) {
// check entry is valid
if (info->val_len == 0 || info->key_len != sizeof(BTBondingID)) {
return true; // continue iterating
}
BTBondingID *first_ancs_supported_bonding_found = (BTBondingID *) context;
BtPersi... | prv_file_each(prv_ble_pairing_internal_for_each_itr, &internal_itr_data) | ;
}
void analytics_external_collect_ble_pairing_info(void) {
unsigned int ble_pairings_count = prv_get_num_pairings_by_type(BtPersistBondingTypeBLE);
analytics_set(ANALYTICS_DEVICE_METRIC_BLE_PAIRING_RECORDS_COUNT,
ble_pairings_count, AnalyticsClient_System);
analytics_set(ANALYTICS_DEVICE_BT_P... |
sys_resource_get_and_cache(app_num, resource_id) | ) {
return false;
}
PBL_LOG_D(LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG, "FMD read: bytes:%d", (int)sizeof(FontMetaDataV3));
FontMetaDataV3 header;
SYS_PROFILER_NODE_START(text_render_flash);
uint32_t bytes_read = sys_resource_load_range(app_num, resource_id, 0,
(u... | |
cl_assert_equal_i(settings_file_set(&file, key, key_len, val, val_len), E_OUT_OF_STORAGE) | ;
int val_len_out = settings_file_get_len(&file, key, key_len);
cl_must_pass(val_len_out);
uint8_t *val_out = malloc(val_len_out);
cl_assert_equal_i(settings_file_get(&file, key, key_len, val_out, val_len_out), E_DOES_NOT_EXIST);
free(val_out);
}
void test_settings_file__used_space_tracking(void) {
printf(... | |
aepelin_algorithm__activity_tests(void) {
bool success = prv_sample_discovery_init(&s_activity_sample_discovery_state.common,
SampleFileType_MinuteSamples,
"activity/activity_samples");
cl_assert(success);
// Init algorithm sta... | printf("\n\n") | ;
printf("\n%-24s", "name");
// Print header line
for (int i = 0; i < ARRAY_LENGTH(metrics); i++) {
printf(" exp_%-8s act_%-7s", metrics[i], metrics[i]);
}
printf(" %-10s %-10s", "weight_err", "status");
printf("\n------------------------");
for (int i = 0; i < ARRAY_LENGTH(metrics); i++) {
prin... |
qspi_flash_erase_resume(QSPIFlash *dev, uint32_t addr) {
qspi_use(dev->qspi);
prv_write_cmd_no_addr(dev, dev->state->part->instructions.erase_resume);
// wait for the erase_suspend bit to be cleared
qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_flag_status,
dev->state->part->flag... | if (active) {
instruction = dev->state->part->instructions.enter_low_power;
delay = dev->state->part->standby_to_low_power_latency_us;
} else {
instruction = dev->state->part->instructions.exit_low_power;
delay = dev->state->part->low_power_to_standby_latency_us;
} | |
/*
* 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_put_area_event(UnobstructedAreaEventType_Change, current_y, final_y, progress) | |
120},
{ 792, 120, 120},
{ 784, 112, 88},
{ 816, 24, 136},
{ 848, 64, 112},
{ 1032, -24, 64},
{ 1056, 8, -32},
{ 1080, -104, 24},
{ 1504, -160, 192},
{ 1088, 208, -24},
{ 1064, 264, -120},
{ 1240, 240, -16},
{ 856, 304, 96},
{ 680, 264, 48},
{ 840, 296, 96},
{... | { 760, 440, 72},
{ 728, 328, 16},
{ 864, 712, 64},
{ 1008, 232, -152},
{ 1224, 504, -40},
{ 1280, 352, 88},
{ 1576, 448, 72},
{ 1216, 496, -136},
{ 920, 344, -24},
{ 1048, 152, 112},
{ 1080, 176, 176},
{ 872, 168, 176},
{ 736, 168, 144},
{ 736, 112, 120},
{ 75... |
{ 1136, -72, 32},
{ 1704, -88, 80},
{ 1344, 192, -56},
{ 960, 376, -208},
// 36 seconds
{ 984, 216, -80},
{ 824, 112, 32},
{ 720, 136, 24},
{ 784, 200, -40},
{ 832, 240, -8},
{ 808, 344, -120},
{ 912, 280, -136},
{ 1016, 280, -224},
{ 1216, 176, -160},
{ 1280... |
*has_more_out) {
bool has_more = false;
GATTBufferedNotificationHeader next_header = {};
prv_lock();
{
if (!prv_check_buffer(client)) {
has_more = false; // the client went away
goto unlock;
}
GATTBufferedNotificationHeader header = {};
const bool has_notification = prv_get_next_no... | if (s_circular_buffer_retain_count[client] == 0) {
// First subscription for this client to require the circular buffer, go ahead and create it:
PBL_ASSERTN(s_circular_buffer[client] == NULL);
const size_t size = sizeof(CircularBuffer) + GATT_CLIENT_SUBSCRIPTIONS_BUFFER_SIZE;
// TODO: Use app_ma... |
++s_circular_buffer_retain_count[client];
}
unlock:
prv_unlock();
return rv;
}
// -------------------------------------------------------------------------------------------------
static bool prv_find_subscription_cb(ListNode *node, void *data) {
const GATTClientSubscriptionNode *subscription = (const GA... |
// Should fire off an event. OffWrist, tell clients
prv_advance_time_hr(1 /*sec*/, 0 /*hr*/, HRMQuality_OffWrist, true /*force_continuous*/);
cl_assert_equal_i(s_num_hr_events, 3);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 0);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.... | activity_metrics_prv_set_metric(ActivityMetricSleepRestfulSeconds, Wednesday, 60) | ;
activity_get_metric(ActivityMetricSleepRestfulSeconds, 2, metric_values);
cl_assert_equal_i(metric_values[1], 60);
activity_metrics_prv_set_metric(ActivityMetricSleepEnterAtSeconds, Thursday, 60);
activity_get_metric(ActivityMetricSleepEnterAtSeconds, 1, metric_values);
cl_assert_equal_i(metric_values[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... | (&recognizer->multi_click_timer) | ;
}
static bool prv_dispatch_event(ClickRecognizer *recognizer, ClickHandlerOffset handler_offset,
bool needs_reset) {
if (recognizer) {
ClickHandler handler = prv_get_handler(recognizer, handler_offset);
if (handler) {
void *context;
if ((handler_offset == ClickHan... |
/*
* 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_BKP_BOOTBIT_DR) | |
p_inbox_service_write / app_inbox_service_end
static const uint8_t s_test_data[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09,
0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19
};
static void prv_create_test_inbox_and_begin_write(void) {
prv_create_test_inbox... | cl_assert_equal_b(true, app_inbox_service_end(AppInboxServiceTagUnitTest)) | ;
// No space:
cl_assert_equal_b(false, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE + 1, s_writer));
// Shouldn't call ..._end() here because ..._begin() failed.
// Message 3:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServi... |
/*
* 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... | set_text(window, "Erasing Normal+Sys firmware...") | |
void test_graphics_context_${BIT_DEPTH_NAME}__draw_antialiased_stroke_width_odd(void) {
// Stroke width odd > 1, antialiased
setup_test(&context, true, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
#if PBL_COLOR
ASSERT_CALLED(graphics_line_draw_stroked_aa(... | (graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10))) | ;
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, true);
ASSERT_NO_CHAN... |
&item_animation->bottom_offset_y);
animation_set_duration((Animation *)r_animation,
(DELAY_PER_LINE / 4) * (item_height / line_height));
animation_set_curve((Animation *)r_animation, AnimationCurveEaseInOut);
animation_set_handlers((Animation *)r_animation, (AnimationHandlers){0}, aml);
... | menu_cell_basic_draw_custom(ctx, mutable_cell_layer, font, item->label, font, indicator, font,
NULL, NULL, false, overflow_mode) | ;
// Restore the cell layer's bounds
mutable_cell_layer->bounds = saved_bounds;
}
static void prv_cell_item_content_draw_round(GContext *ctx, const Layer *cell_layer,
const ActionMenuLayer *aml, const ActionMenuItem *item,
b... |
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET);
// CRESET needs to be low for at least 200 ns
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_RESET);
delay_ms(1);
GPIO_WriteBit(DISP_GPIO, DISP_PIN_CRESET, Bit_SET);
return prv_wait_programmed();
}
static bool prv_reset_fpga(void) {
#ifdef BLANK_FPGA
return... | ASSERT_BUSY_IS(Bit_SET) | ;
dbgserial_print("Does the draw-scene command complete? ");
dbgserial_putstr(prv_wait_busy()? "Yes" : "No");
#endif
// Work around an issue which some boards exhibit where the FPGA ring
// oscillator can start up with higher harmonics, massively overclocking the
// design and causing malfunction. When this... |
d 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.
*/
#include "timeline_layout_animations.h"
#include "applib/graphics/graphics.h"... | {
TimelineLayout *timeline_layout = context;
// reset the first half of the animation
kino_reel_set_elapsed(kino_layer_get_reel(&timeline_layout->icon_layer), 0);
// Clip for the static icon
layer_set_clips(&layer->layer, true);
if (finished) {
// begin the second half of the animation
prv_pin_to_... |
void timeline_layout_transition_pin_to_card(TimelineLayout *pin_timeline_layout,
TimelineLayout *card_timeline_layout) {
KinoReel *from_reel = kino_reel_create_with_resource_system(
pin_timeline_layout->icon_res_info.res_app_num,
pin_timeline_layout->icon_res_... |
t 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 WARRANTIES OR C... | RCC_AHB1PeriphResetCmd(ahb1_periphs, ENABLE) | ;
RCC_AHB1PeriphResetCmd(ahb1_periphs, DISABLE);
RCC_AHB2PeriphResetCmd(ahb2_periphs, ENABLE);
RCC_AHB2PeriphResetCmd(ahb2_periphs, DISABLE);
RCC_AHB3PeriphResetCmd(ahb3_periphs, ENABLE);
RCC_AHB3PeriphResetCmd(ahb3_periphs, DISABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, ENABLE);
RCC_APB1PeriphResetCmd(ap... |
CommSession) {
.transport = transport,
.transport_imp = implementation,
.destination = destination,
};
s_session_head = (CommSession *) list_prepend((ListNode *) s_session_head, &session->node);
prv_log_session_event(session, true /* is_open */);
// Request capabilities for both the Pebble app an... | if (session->is_send_next_call_pending) {
return;
} |
TransportSchedule schedule_func = session->transport_imp->schedule;
if (!schedule_func) {
schedule_func = bt_driver_comm_schedule_send_next_job;
}
if (schedule_func(session)) {
session->is_send_next_call_pending = true;
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to schedule comm_session_send_nex... |
_zone));
// Compute our own version of active_kcalories
const int32_t distance_delta_m = (new_distance_m - distance_m);
const int32_t calculated_active_kcalories
= ROUND(activity_private_compute_active_calories(distance_delta_m * MM_PER_METER, 600 * MS_PER_SECOND),
ACTIVITY_CALORIES_PER_KCAL)... | (steps, 20) | ;
cl_assert_equal_i(duration_s, 20);
cl_assert_equal_i(bpm, 117);
cl_assert(workout_service_pause_workout(false));
cl_assert(workout_service_pause_workout(false));
prv_inc_time(10);
prv_inc_steps_and_put_event(10);
prv_put_bpm_event(113, HRMQuality_Good);
cl_assert(workout_service_get_current_workout... |
ht = 10;
#if PBL_ROUND
// when showing columns, set cells further apart
return prv_aml_is_short(aml) ? default_sep_height : 1;
#elif SCREEN_COLOR_DEPTH_BITS == 1
return default_sep_height;
#else
const int16_t line_height = fonts_get_font_height(aml->layout_cache.font);
const int16_t sep_height = MAX(menu_cell... | prv_should_center(aml) | || prv_aml_is_short(aml) || aml->num_items == 0) {
return 0;
}
const int16_t line_height = fonts_get_font_height(aml->layout_cache.font);
const int16_t padding = prv_get_cell_padding(aml);
const int16_t max_visible_height = line_height * MAX_NUM_VISIBLE_LINES;
const GRect *bounds = &aml->layer.bounds;
... |
_logging.h"
#include "stubs_passert.h"
#include "stubs_rand_ptr.h"
// setup and teardown
void test_generic_attribute__initialize(void) {
}
void test_generic_attribute__cleanup(void) {
}
// tests
void test_generic_attribute__find_attribute(void) {
uint8_t data1[] = {
0x02, // attribute list - num attri... | (attr2->length, 0x2F) | ;
offset = sizeof(GenericAttributeList) + sizeof(GenericAttribute) +
attr1->length + sizeof(GenericAttribute);
cl_assert_equal_p(attr2->data, &data2[offset]);
GenericAttribute *attr3 = generic_attribute_find_attribute(attr_list1, VEAttributeIdAppUuid,
... |
tore total_steps_avg = 0;
for (int i = 0; i < ACTIVITY_NUM_METRIC_AVERAGES && i < num_chunks; ++i) {
if (averages->average[i] != ACTIVITY_METRIC_AVERAGES_UNKNOWN) {
total_steps_avg += averages->average[i];
}
}
kernel_free(averages);
return total_steps_avg;
}
// ---------------------------------... | attribute_list_destroy_list(&response_action_attr_list) | |
cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_size), 8) | ;
cl_assert_equal_i(memcmp(copy_out, "234567AB", 8), 0);
contiguous_num_bytes_left = circular_buffer_write_prepare(&buffer, &data_out);
cl_assert_equal_i(contiguous_num_bytes_left, 0);
cl_assert_equal_p(data_out, NULL);
}
void test_circular_buffer__read_or_copy_returns_false_when_length_is_too_long(void) {
... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (e.app_cache_event.cache_event_type, PebbleAppCacheEvent_Removed) | |
rror_data_getter, NULL);
rocky_global_call_event_handlers(event);
}
////////////////////////////////////////////////////////////////////////////////
// API: postMessage()
////////////////////////////////////////////////////////////////////////////////
static void prv_start_session_closed_object_queue_timer(void);
... | sys_app_pp_get_comm_session() | ) {
// There is a _small_ race here if a connection occurs async on
// the BT thread after subscribing but before we check the current state.
// This could result in us transitioning to a connected state, and then
// getting an event to transition again.
// We're guarding against this by ignoring th... |
a->uuid, &entry.uuid)) {
uuid_data->found_id = app_id;
return false; // stop iterating
}
return true; // continue iterating
}
//! Retrieves the AppInstallId for a given UUID using the SettingsFile that is already open.
//! @note Requires holding the lock already
static AppInstallId prv_find_install_id_for_... | PBL_LOG(LOG_LEVEL_INFO, "Found %"PRIu32" apps. Next ID: %"PRIu32" ", data.num_apps,
s_next_unique_flash_app_id) | ;
prv_close_file_and_unlock_mutex();
}
status_t app_db_insert(const uint8_t *key, int key_len, const uint8_t *val, int val_len) {
if (key_len != UUID_SIZE ||
val_len != sizeof(AppDBEntry)) {
return E_INVALID_ARGUMENT;
}
status_t rv = prv_lock_mutex_and_open_file();
if (rv != S_SUCCESS) {
retu... |
ounds = &window_layer->bounds;
static SimpleMenuItem menu_items[] = {
{
.title = "Tracking",
.callback = prv_debug_cmd_tracking,
}, {
.title = "Activity Insights",
.callback = prv_debug_cmd_activity_insights,
}, {
.title = "Sleep Insights",
.callback = prv_debug_cmd_sl... | app_state_get_user_data() | ;
window_destroy(data->debug_window);
app_free(data);
}
// -------------------------------------------------------------------------------
static void init(void) {
ActivityDemoAppData *data = app_malloc_check(sizeof(ActivityDemoAppData));
s_data = data;
memset(data, 0, sizeof(ActivityDemoAppData));
app_st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.