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... | ("off_screen_left_aa_clipping") | ));
};
void test_framebuffer_clipping__off_screen_right_aa_clipping(void) {
cl_assert_equal_i(GBITMAP_NATIVE_FORMAT, GBitmapFormat8BitCircular);
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, true, 1);
cl_assert_equal_i(ctx.dest_bitmap.... |
imation = NULL;
s_count_display_update = 0;
s_count_compositor_init_func_a = 0;
s_count_compositor_init_func_b = 0;
s_app_window_render_count = 0;
s_modal_manager_render_count = 0;
s_display_update_in_progress = false;
s_render_pending = false;
compositor_init();
}
void test_compositor__cleanup(vo... | compositor_transition(NULL) | ;
cl_assert_equal_i(s_count_display_update, 0);
cl_assert_equal_i(s_count_animation_create, 0);
// Now the app has rendered something and we should actually update the display.
compositor_app_render_ready();
cl_assert_equal_i(s_count_display_update, 1);
}
void test_compositor__app_not_ready_modal_push_pop(v... |
/*
* 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(a.x, b.x) | |
er_bytes_allocated -= (sizeof(PebbleProtocolHeader)
+ sb->payload_buffer_length);
kernel_free(sb);
xSemaphoreGive(s_default_kernel_sender_write_semaphore);
}
// -------------------------------------------------------------------------------------------------
// Interfa... | if (remaining_ms == 0) {
is_timeout = true;
} else {
if (is_current_task_send_next_task) {
// If there is no space and this is called from the task that performs the sending,
// the "send_next" callback is waiting in the task queue after this callback.
// Therefore, data will nev... |
if (is_timeout) {
analytics_inc(ANALYTICS_DEVICE_METRIC_BT_COMM_SESSION_SEND_DATA_FAIL_COUNT,
AnalyticsClient_System);
PBL_LOG(LOG_LEVEL_WARNING,
"Failed to get send buffer (bytes=%"PRIu32", endpoint_id=%"PRIu16", to=%"PRIu32")",
(uint32_t)required_payl... |
roy(workout_glance->icon);
app_timer_cancel(workout_glance->timer);
}
app_free(workout_glance);
}
static bool prv_set_glance_icon(LauncherAppGlanceWorkout *workout_glance,
uint32_t new_icon_resource_id) {
if (workout_glance->icon_resource_id == new_icon_resource_id) {
// N... | strncpy(workout_glance->title, node->name, title_size) | ;
workout_glance->title[title_size - 1] = '\0';
const bool should_consider_slices = false;
LauncherAppGlanceStructured *structured_glance =
launcher_app_glance_structured_create(&node->uuid, &s_workout_structured_glance_impl,
should_consider_slices, workout_glanc... |
se RXMenuIdx_HRM:
title = "HRM";
subtitle = data->is_hrm_enabled ? "Enabled" : "Disabled";
break;
#endif
#if CAPABILITY_HAS_MICROPHONE
case RXMenuIdx_Microphone:
title = "Microphone";
subtitle = data->is_mic_enabled ? "Enabled" : "Disabled";
break;
#endif
case... | if (data->current_test_step != BTLETestStep_None) {
// Currently outstanding test not complete, finish it.
switch (data->current_test_step) {
case BTLETestStep_BTStart:
case BTLETestStep_BTEnd:
prv_run_test_step(BTLETestStep_BTEnd, data);
break;
case BTLETestStep_BTLETransmitS... |
data->current_test_step = BTLETestStep_None;
data->current_test = BTLETestType_None;
}
static void prv_enter_txrx_menu(AppData *data, BTLETestType test) {
switch (test) {
case BTLETestType_TX:
case BTLETestType_RX:
break; // OK
default:
WTF;
}
data->current_test = test;
window_se... |
void prv_disable_all_interrupts(I2CBus *bus) {
bus->hal->i2c->CR1 &= ~(I2C_CR1_TXIE |
I2C_CR1_RXIE |
I2C_CR1_TCIE |
I2C_CR1_NACKIE |
I2C_CR1_ERRIE);
}
void i2c_hal_abort_transfer(I2CBus *bus) {
// Disable all i... | {
case I2CTransferState_WriteRegAddress:
if ((i2c->ISR & I2C_ISR_TXIS) != 0) {
i2c->TXDR = transfer->register_address;
}
if ((transfer->direction == I2CTransferDirection_Read) && (i2c->ISR & I2C_ISR_TC)) {
// done writing the register address for a read request - start a read reque... |
return i2c_handle_transfer_event(bus, I2CTransferEvent_NackReceived);
}
if ((i2c->ISR & I2C_ISR_TCR) != 0) {
prv_resume_transfer(bus, false /* !generate_start */);
}
if ((i2c->ISR & I2C_ISR_TC) != 0) {
return prv_end_transfer_irq(bus, I2CTransferEvent_TransferComplete);
... |
ssert_equal_i(fake_system_task_count_callbacks(), 1);
cl_assert_equal_i(s_send_next_count, 0);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(fake_system_task_count_callbacks(), 0);
cl_assert_equal_i(s_send_next_count, 1);
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task... | (transport, &s_transport_imp,
TransportDestinationSystem) | |
= click_recognizer_get_button_id(recognizer);
if (button_id == BUTTON_ID_BACK) {
VOICE_LOG("Exit UI");
prv_cancel_dictation(data);
DictationSessionStatus status = DictationSessionStatusFailureTranscriptionRejected;
if ((data->error_count > 0) && !data->last_session_successful) {
status = Dictati... | PBL_ASSERT(current_state != next_state, "Trying to transition to the same state %d",
next_state) | ;
PBL_ASSERTN(next_state != StateStart); // Cannot transition to start state
VOICE_LOG("Transition: Current state: %d; new state: %d", current_state, next_state);
// Transition will be handled by the animation stopped handler if defer_transition is set to true
*defer_transition = false;
// These transitio... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
s_resource_size = 0;
s_fake_bitmap_data = (FakeBitmapData) { 0 };
} |
static uint32_t prv_calculate_size(FakeBitmapData *bitmap) {
const uint32_t required_size_bytes =
offsetof(BitmapData, data) + // header size
(bitmap->row_size_bytes * bitmap->height) + // pixel data
gbitmap_get_palette_size(bitmap->info.format); // palette data
return required_size_bytes;
}
vo... |
y less than the size of the region
const uint32_t TEST_ADDR = FLASH_REGION_FIRMWARE_SCRATCH_BEGIN;
const uint32_t TEST_LENGTH = SECTOR_SIZE_BYTES;
PBL_ASSERTN((TEST_ADDR & SECTOR_ADDR_MASK) == TEST_ADDR);
PBL_ASSERTN((TEST_ADDR + TEST_LENGTH) <= FLASH_REGION_FIRMWARE_SCRATCH_END);
// erase a sector
flash_e... | prompt_send_response_fmt(buffer, sizeof(buffer), "SECTOR - 0x%-6"PRIX32" :: %s",
addr, erased ? "true" : "false") | ;
if (show_subsectors && !erased) {
for (uint32_t i = 0; i < (SECTOR_SIZE_BYTES / SUBSECTOR_SIZE_BYTES); i++) {
const uint32_t sub_addr = (addr + (i * SUBSECTOR_SIZE_BYTES));
bool sub_erased = prv_is_really_erased(sub_addr, true);
prompt_send_response_fmt(buffer, sizeof(buffer), " SUB... |
case ActivitySessionTypeCount:
WTF;
break;
}
if (!callback(session_activity, session->start_utc,
session->start_utc + (session->length_min * SECONDS_PER_MINUTE),
context)) {
// clients can interrupt the iteration at any time
... |
// ----------------------------------------------------------------------------------------------
bool health_service_private_get_yesterdays_sleep_activity(HealthValue *enter_sec,
HealthValue *exit_sec) {
return
sys_activity_get_metric(ActivityMetricSlee... | |
/*
* 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_get_array_index_of_type(weather_type) | ]};
};
TimelineResourceId weather_type_get_timeline_resource_id(WeatherType weather_type) {
return s_weather_type_timeline_resource_ids[prv_get_array_index_of_type(weather_type)];
};
|
for (int i = 0; i < num_iters; i++) {
int files_written = run_full_flash_region_test();
if ((i % 2) == 0) {
pfs_init(true); // simulate a reboot
}
// delete all files
for (int i = (files_written - 1); i >= 0; i--) {
char name[128];
snprintf(name, sizeof(name), "file%d", i);
c... |
}
void test_pfs__active_in_region(void) {
cl_assert(pfs_active_in_region(0, pfs_get_size()));
}
void test_pfs__get_size(void) {
cl_assert(pfs_get_size() == (ftl_get_size() - SECTOR_SIZE_BYTES));
}
void test_pfs__migration(void) {
// reset the flash
fake_spi_flash_cleanup();
fake_spi_flash_init(0, 0x100000... | |
else if (!s_profiles) {
smartstrap_link_control_disconnect();
}
return false;
}
s_strikes = 0;
if (header->type == LinkControlTypeStatus) {
// status message
const LinkControlStatus status = header->data[0];
if (status == LinkControlStatusOk) {
PBL_LOG(LOG_LEVEL_DEBUG, "Got link c... | if (accessory_bus_contention_detected()) {
PBL_LOG(LOG_LEVEL_WARNING, "Bus contention while sending status message");
// Count bus contention as a strike as it could be that the accessory is disconnected
// or misbehaving.
prv_fatal_error_strike();
} |
s_last_status_check_time = current_time;
}
return true;
}
return false;
}
static void prv_read_aborted(void) {
mbuf_free(s_read_mbuf);
s_read_mbuf = NULL;
}
const SmartstrapProfileInfo *smartstrap_link_control_get_info(void) {
static const SmartstrapProfileInfo s_link_control_info = {
.pr... |
sent_data = (DataNode *) list_prepend(&fake_transport->sent_data->node,
&data_node->node);
}
circular_buffer_consume(&session->send_buffer, sizeof(pp_header) + pp_header.length);
}
kernel_free(buffer);
}
static void prv_fake_transport_reset(Transp... | (data_node) | ;
data_node = next_data_node;
}
kernel_free(fake_transport);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Transport helper functions
bool fake_comm_session_send_buffer_write_raw_by_transport(Transport *transport,
... |
ransform_is_equal(&t, &t_c));
cl_assert(gtransform_is_only_scale(&t));
cl_assert(gtransform_is_only_scale(&t_c));
t_c = GTransformScaleFromNumber(2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
// Test Translation Matrix
t = GTransformTranslation(GTransformNumberFromNumber(2), GTransformNumberFromNumber(... | gtransform_scale(&t1, &t1, GTransformNumberFromNumber(10), GTransformNumberFromNumber(200)) | ;
cl_assert(gtransform_is_equal(&t1, &t_c));
}
void test_graphics_gtransform_${BIT_DEPTH_NAME}__translation(void) {
GTransform t_new;
GTransform t1;
GTransform t2;
GTransform t_c; // matrix to compare against
// Test translation
t1 = GTransformFromNumbers(1, 2, 3, 4, 5, 6);
t2 = GTransformFromNumbers(... |
_accel_power_mode(BMI160_Accel_Mode_Low);
BMI160_DBG("%s", "Enable low power mode");
}
// TODO: If we aren't doing anything else, suspend the chip?
}
static void prv_enable_operating_mode(AccelOperatingMode mode, BMI160SampleRate sample_rate) {
s_operating_states[mode].enabled = true;
s_operating_states[m... | {
prv_write_reg(BMI160_REG_INT_MOTION_1,
BOARD_CONFIG_ACCEL.accel_config.shake_thresholds[AccelThresholdLow]);
} | else {
prv_write_reg(BMI160_REG_INT_MOTION_1,
BOARD_CONFIG_ACCEL.accel_config.shake_thresholds[AccelThresholdHigh]);
}
}
static void prv_enable_shake_detection(void) {
// don't automatically power-up the gryo when an anymotion interrupt fires!
prv_write_reg(BMI160_REG_PMU_TRIGGER, 0x0);
// Enabl... |
/*
* 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... | (timer != NULL) | ;
// Try to cancel it twice. This used to crash, but should not crash anymore.
// In particular, we're looking to see that at least if we don't do more app_heap
// allocations, we will be able to detect that we're effectively trying to
// double-release this timer.
app_timer_cancel(timer);
app_timer_cancel... |
_first_subscriber(void) {
BLECharacteristic characteristic = prv_get_indicatable_characteristic();
BTErrno e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientKernel);
cl_assert_equal_i(e, BTErrnoOK);
cl_assert_equal_i(... | (s_last_cccd_value, BLESubscriptionIndications) | ;
// Simulate getting confirmation from remote:
prv_confirm_cccd_write(BLEGATTErrorSuccess);
fake_event_clear_last();
// Subscribe app:
e = gatt_client_subscriptions_subscribe(characteristic, BLESubscriptionIndications,
GAPLEClientApp);
s_last_cccd_value = ~0;
... |
if (event->bluetooth.comm_session_event.is_open &&
event->bluetooth.comm_session_event.is_system) {
progress_window_pop(&data->window);
}
}
static void prv_set_progress_failure(AppFetchUIData *data) {
uint32_t icon;
const char *message;
switch (data->result) {
case AppFetchResultNoBluetooth:
... | PBL_LOG(LOG_LEVEL_DEBUG, "App Fetch: Got the start event") | |
"stubs_pebble_tasks.h"
#include "stubs_resources.h"
#include "stubs_ui_window.h"
#include "stubs_unobstructed_area.h"
void framebuffer_clear(FrameBuffer* f) {}
void graphics_context_move_draw_box(GContext* ctx, GPoint offset) {}
typedef uint16_t ResourceId;
const uint8_t *resource_get_builtin_bytes(ResAppNum app_num, ... | (resource_id) | ;
cl_assert(kino_reel);
cl_assert(kino_reel_get_type(kino_reel) == KinoReelTypePDCS);
kino_reel_set_elapsed(kino_reel, 0);
GDrawCommandList *list1 = kino_reel_get_gdraw_command_list(kino_reel);
GDrawCommandList *list1_direct = gdraw_command_frame_get_command_list(
gdraw_command_sequence_get_frame_by_el... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, " --> PC: %s LR: %s", pc_str, lr_str) | |
+ SECONDS_PER_DAY);
// no more
cl_assert(!iter_next(&iterator));
// 4 deletes
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.head... | (!iter_next(&iterator)) | ;
// 1 delete
cl_assert(timeline_iter_remove_node_with_id(&head, &all_day_item.header.id));
cl_assert(!timeline_iter_remove_node_with_id(&head, &all_day_item.header.id));
}
void test_timeline__0_duration(void) {
const time_t midnight_march_3_utc = 1425340800;
TimelineItem all_day_item = {
.header = {
... |
12, 864, 96},
{ -248, 560, 112},
{ 72, 784, -288},
{ 32, 464, -8},
{ -32, 592, -16},
{ -104, 840, -16},
{ -248, 520, -192},
{ -112, 808, -176},
{ -288, 1120, -232},
{ -288, 1264, -280},
// 78 seconds
{ -424, 1360, -56},
{ -320, 1096, -88},
{ -432, 920, -88},
{ -35... | { -72, 1096, 560},
{ -280, 1216, 336},
{ -272, 1216, 376},
{ -408, 1056, 440},
{ -424, 992, 384},
{ -208, 688, 256},
{ -64, 688, 160},
{ 8, 576, 168},
{ 48, 608, 176},
{ 48, 728, 248},
{ -32, 856, 328},
{ -8, 1008, 392},
{ -8, 1096, 488},
{ -152, 968, 656},
{ ... |
// 86 seconds
{ -40, 800, 248},
{ 0, 560, 216},
{ 104, 536, 104},
{ 152, 512, 176},
{ 128, 632, 216},
{ 120, 904, 464},
{ 48, 1096, -136},
{ 56, 1104, 40},
{ -72, 1160, 136},
{ 56, 1392, 488},
{ -296, 792, 440},
{ -80, 1184, 136},
{ -40, 1128, 48},
{ -64, 111... |
{ 56, 232, -1000},
{ -8, 256, -1000},
{ 40, 240, -1032},
{ 136, 160, -1008},
{ 128, 184, -1048},
{ 144, 152, -984},
{ 288, 136, -1024},
{ 88, 88, -1016},
{ -104, 472, -912},
{ -56, 320, -984},
{ -8, 200, -1032},
{ -48, 240, -1032},
{ 40, 208, -1024},
{ -32, 208, ... | { 144, 592, -880},
{ 152, 600, -864},
{ 136, 592, -848},
{ 168, 600, -896},
{ 160, 536, -864},
{ 152, 544, -880},
{ 160, 544, -880},
{ 152, 544, -880},
{ 168, 568, -888},
{ 152, 576, -856},
{ 160, 592, -880},
// 183 seconds
{ 152, 584, -864},
{ 160, 592, -856},
... |
{ 152, 752, -696},
{ 152, 760, -712},
{ 152, 752, -712},
{ 152, 776, -720},
{ 144, 792, -704},
{ 144, 784, -712},
{ 168, 768, -704},
{ 184, 728, -712},
{ 184, 760, -720},
{ 184, 736, -704},
{ 184, 768, -712},
{ 184, 760, -712},
{ 176, 760, -704},
{ 192, 768, -720... |
today is a weekday
result = health_service_sum_averaged(HealthMetricStepCount,
time_util_get_midnight_of(now),
time_util_get_midnight_of(now) + SECONDS_PER_DAY,
HealthServiceTimeScopeDailyWeekdayOrWeek... | cl_assert_equal_i(value, exp_value) | |
unch.h"
#include "comm/bt_lock.h"
#include "services/common/bluetooth/bluetooth_persistent_storage.h"
#include "services/common/comm_session/protocol.h"
#include "services/common/comm_session/session_remote_version.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "kernel/events.h"
#include "ke... | session->transport_imp->reset(session->transport) | ;
}
unlock:
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
// Interfaces towards Transport (reading from the send buffer to actually transmit the data):
// ------------------------------------------------------------------------------------------... |
enuLayer);
if (layer) {
menu_layer_init(layer, &frame);
}
return layer;
}
void menu_layer_pad_bottom_enable(MenuLayer *menu_layer, bool enable) {
menu_layer->pad_bottom = enable;
}
void menu_layer_deinit(MenuLayer *menu_layer) {
prv_cancel_selection_animation(menu_layer);
layer_deinit(&menu_layer->inv... | (menu_layer, callback_context, &callbacks) | ;
}
void menu_layer_set_click_config_onto_window(MenuLayer *menu_layer, struct Window *window) {
// Delegate this directly to the scroll layer:
scroll_layer_set_click_config_onto_window(&menu_layer->scroll_layer, window);
}
//! @returns 0 if A and B are equal, 1 if A has a higher section & row combination than B ... |
64, 288, -432},
{ 864, 288, -432},
{ 864, 288, -432},
{ 864, 296, -432},
{ 864, 288, -432},
{ 864, 288, -432},
{ 864, 288, -440},
// 85 seconds
{ 864, 280, -432},
{ 864, 296, -424},
{ 872, 288, -432},
{ 864, 288, -432},
{ 864, 288, -432},
{ 872, 288, -432},
{ 872,... | { 864, 296, -424},
{ 864, 296, -424},
{ 864, 296, -416},
{ 864, 304, -424},
{ 864, 296, -424},
{ 864, 296, -424},
{ 872, 296, -432},
{ 864, 304, -424},
{ 864, 296, -432},
{ 864, 296, -432},
{ 864, 304, -424},
{ 864, 304, -432},
{ 864, 304, -416},
{ 864, 296, -424}... | |
mory writes before entering sleep.
do_wfi(); // Wait for Interrupt (enter sleep mode). Work around F2/F4 errata.
__ISB(); // Let the pipeline catch up (force the WFI to activate before moving on).
power_tracking_stop(PowerSystemMcuCoreSleep);
uint32_t systick_stop = SysTick->VAL;
uint32... | xTaskGetTickCountFromISR() | ;
if (act_ticks > target_rtos_ticks + 100 || act_ticks < target_rtos_ticks - 100) {
// If we are too far out of range of the target ticks, just reset our offsets. This could
// be caused either by the RTC time being changed or by staying in the debugger too long
s_rtc_ticks_to_rtos_ticks = (int64_t)act_t... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | assert_output_equal("\0A\0\0B\0", 6) | ;
}
void test_cobs_decode__max_length_block(void) {
decode_start(254);
assert_decode_char_succeeds(0xff);
for (int c = 0x01; c <= 0xfe; ++c) {
assert_decode_char_succeeds(c);
}
assert_decode_completed(254);
const unsigned char *iter = out;
for (int c = 0x01; c <= 0xfe; ++c) {
cl_assert_equal_i(*i... |
mmand_transforms__to_square_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
int32_t dt = ANIMATION_NORMALIZED_MAX / 16;
int32_t t = 0;
while (t <= ANIMATION_NORMALIZED_MAX) {
graphics_context_set_fill_color(&ctx, GColorFromHEX(0x55aaf... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "test_gdraw_command_transforms__segmented_scale.8bit.pbi")) | ;
}
// re-enable this "test" to debug per-frame transitions
void _test_gdraw_command_transforms__scale_segmented_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
int32_t dt = ANIMATION_NORMALIZED_MAX / 16;
int32_t t = 0;
InterpolateInt64Fu... |
/*
* 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... | gdraw_command_image_validate(draw_command_image, data_size) | ) {
gdraw_command_image_destroy(draw_command_image);
return NULL;
}
return draw_command_image;
}
bool gdraw_command_image_copy(void *buffer, size_t buffer_length, GDrawCommandImage *src) {
size_t src_size = gdraw_command_image_get_data_size(src);
if (buffer_length < src_size) {
return false;
}
... |
&state.pin.header.id, &s_all_day_items[1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(state.node->all_day);
// check that the item we see is timestamped at local midnight rather than utc midnight
// 1421136000 is midnight Jan 13, PST
cl_assert_equal_i(state.pin.... | (uuid_equal(&state.pin.header.id, &s_all_day_items[0].header.id)) | ;
cl_assert(state.node->all_day);
cl_assert(!iter_next(&iterator));
cl_assert(iter_prev(&iterator));
cl_assert(!iter_prev(&iterator));
}
void test_timeline__all_day_middle_past(void) {
prv_insert_all_day_items();
// 1421183640 is 13:14 on Jan 13, 2015
// after first timed event of the day but not all o... |
();
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_READ);
flash_send_24b_address(start_addr);
// There is delay associated with setting up the stm32 dma, using FreeRTOS
// sempahores, handling ISRs, etc. Thus for short reads, the cost of using
// DMA is far more expensive than the read being pe... | power_tracking_stop(PowerSystemFlashErase) | ;
flash_unlock();
}
// It is dangerous to leave this built in by default.
#if 0
void flash_erase_bulk(void) {
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
flash_prf_set_protection(false);
power_tracking_start(PowerSystemFlashErase);
enable_f... |
/*
* 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... | (display_buf, DISPLAY_BUF_LEN, " Name: %s",
device_name) | |
/*
* 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... | gpoint_from_polar_internal(¢er, radius, -(TRIG_MAX_ANGLE * 5 / 4)) | |
specific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/gtypes.h"
#include "clar.h"
#include "pebble_asserts.h"
#include <stdio.h>
// stubs
#include "stubs_process_manager.h"
#include "stubs_passert.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
////////... | (1, PBL_IF_RECT_ELSE(1,2)) | ;
#elif defined(PLATFORM_SNOWY)
cl_assert_equal_i(1, PBL_IF_RECT_ELSE(1,2));
#elif defined(PLATFORM_SPALDING)
cl_assert_equal_i(2, PBL_IF_RECT_ELSE(1,2));
#else
#error "unknown platform"
#endif
}
void test_gtypes__pbl_if_round_else(void) {
#if defined(PLATFORM_TINTIN)
cl_assert_equal_i(2, PBL_IF_ROUND_ELSE(1,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... | {
s_stroke_points = prv_copy_points((GPoint*)points, num_points, s_offset);
s_path_open = open;
s_path_stroke_precise_count++;
} |
void graphics_draw_circle(GContext* ctx, GPoint p, uint16_t radius) {
s_stroke_points = prv_copy_points(&p, 1, s_offset);
s_radius = radius;
s_circle_stroke_count++;
}
void graphics_fill_circle(GContext* ctx, GPoint p, uint16_t radius) {
s_fill_points = prv_copy_points(&p, 1, s_offset);
s_radius = radius;
... |
t_call_pending;
TransportDestination destination;
uint8_t *temp_write_buffer;
uint16_t endpoint_id;
uint16_t bytes_written;
uint16_t max_out_payload_length;
CircularBuffer send_buffer;
uint8_t storage[1024];
} CommSession;
static CommSession *s_session_head;
static int s_session_close_call_count;
static... | (list_contains((const ListNode *) s_session_head, &session->node)) | ;
return circular_buffer_get_read_space_remaining(&session->send_buffer);
}
size_t comm_session_send_queue_copy(CommSession *session, uint32_t start_off, size_t length,
uint8_t *data_out) {
cl_assert(data_out);
cl_assert(list_contains((const ListNode *) s_session_head, &sessio... |
t_event(1, 0);
prv_test_touch_event(touch_event, 1, TouchEvent_Liftoff, &GPointZero, 0, 0, &GPoint(1, 13),
3686401, 0, true);
}
void test_touch__handle_update_liftoff_null_pos(void) {
touch_handle_update(0, TouchState_FingerDown, &GPoint(1, 13), 5, 3686400);
TouchEvent *touch_event = touch... | (touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(13, 13), 40, 6, true) | ;
touch_handle_update(0, TouchState_FingerUp, &GPoint(18, 5), 0, 3686440);
// Test the same event (event at index 1): it should update to reflect the difference between this
// and the first event and that it is a liftoff event
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event... |
r since we're about to overwrite it
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparent);
cl_assert(mask);
const GSize mask_size = ctx->dest_bitmap.bounds.size;
for (int16_t x = 0; x < mask_size.w; x++) {
const uint8_t mask_pixel_value = (uint8_t)(x / num_pixel... | (num_dest_colors * hline_applying_test_column_width,
num_src_colors) | |
arLayerLegacy2 *action_bar, void *context) {
action_bar->context = context;
}
static void action_bar_legacy2_raw_up_down_handler(ClickRecognizerRef recognizer,
ActionBarLayerLegacy2 *action_bar,
bool is_highlighted)... | if (action_bar == NULL || action_bar->window == NULL) {
return;
} |
layer_remove_from_parent(&action_bar->layer);
window_set_click_config_provider_with_context(action_bar->window, NULL, NULL);
action_bar->window = NULL;
}
void action_bar_layer_legacy2_set_background_color_2bit(ActionBarLayerLegacy2 *action_bar,
GColor2 background_color) {
GColor native_background_color = ... |
72, -32},
{ 1336, 144, 184},
{ 1760, 224, 152},
{ 1264, 344, 72},
{ 1040, 176, 88},
{ 1144, 136, 152},
{ 968, 120, 216},
{ 872, 112, 176},
{ 760, 152, 64},
{ 776, 64, 64},
{ 824, 56, 48},
{ 768, -8, 72},
{ 776, -80, 56},
{ 968, -104, 48},
{ 1032, 72, -48},
{ 1... | { 1584, -120, 152},
{ 1736, -24, 224},
// 70 seconds
{ 1208, 552, -144},
{ 992, 640, -192},
{ 880, 352, 152},
{ 696, 112, 208},
{ 752, 152, 200},
{ 864, 208, 256},
{ 784, 392, 104},
{ 696, 376, 40},
{ 816, 400, -16},
{ 1032, 320, 24},
{ 1240, 384, 40},
{ 1552,... |
{ 1008, 232, 56},
{ 1168, 184, 160},
{ 1120, 104, 104},
{ 864, 0, 200},
{ 760, 16, 152},
{ 744, 24, 120},
{ 728, 32, 112},
// 73 seconds
{ 696, 8, 104},
{ 856, -56, 128},
{ 1032, 40, -16},
{ 1064, 8, -104},
{ 1872, 200, 144},
{ 1312, 464, -216},
{ 1168, 296, ... |
case KAlgActivityTypeCount:
WTF;
break;
}
int start_idx = (session->start_utc - test_start_utc) / SECONDS_PER_MINUTE;
printf("\nfound %s len: %d, start: %d, ", desc, (int) session->len_minutes,
start_idx);
// Only compare the first activity found
if ... | ARRAY_LENGTH(exp_minutes) | |
ancel_all(GAPLEClient client) {
}
BTErrno gap_le_connect_cancel_by_bonding(BTBondingID bonding_id, GAPLEClient client) {
return BTErrnoOK;
}
BTErrno gap_le_connect_connect_by_bonding(BTBondingID bonding_id, bool auto_reconnect,
bool is_pairing_required, GAPLEClient client) ... | {
++s_services_discovered_count;
} |
void test_client_invalidate_all_references(void) {
}
void test_client_handle_service_removed(BLECharacteristic *characteristics,
uint8_t num_characteristics) {
}
static bool s_can_handle_characteristic;
bool test_client_can_handle_characteristic(BLECharacteristic characteri... |
SP_COLS * 0.14; // 20 on snowy
const int32_t s_upwards_movement_size = DISP_ROWS * 0.18; // 30 on snowy
static void prv_transition_animation_update(GContext *ctx, Animation *animation,
uint32_t progress) {
const bool direction_negative = ((s_data.direction == CompositorTra... | (animation, AnimationCurveLinear) | ;
s_data.animation_offset_px = 0;
}
static void prv_transition_animation_update_stub(GContext *ctx,
Animation *animation,
uint32_t progress) {
}
const CompositorTransition *compositor_shutter_transition_get(
Compo... |
/*
* 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... | {
WorkoutAppData *data = app_state_get_user_data();
s_activity_type = type;
workout_summary_update_activity_type(data->summary_window, type);
} |
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Detected Workout
static void prv_detected_workout_up_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutAppData *data = context;
if (workout_service_takeover_activity_session(&data->ongoing... |
mic's data output pin goes Hi-Z
// for half of each clock cycle, so power could be wasted on the
// input if the signal voltage moves around too much while the mic
// data output is Hi-Z.
//
// During self-test we want to enable a pull resistor so that we can
// accurately detect the absence of the mic.
... | dma_request_stop(this->dma) | ;
DFSDM_ChannelCmd(this->channel, DISABLE);
DFSDM_Cmd(DISABLE);
prv_disable_clocks(this);
}
void mic_init(MicDevice *this) {
PBL_ASSERTN(!this->state->initialized);
this->state->main_pending = false;
this->state->bg_pending = false;
this->state->running = false;
this->state->subscriber = (struct MicS... |
/*
* 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... | i18n_get_with_buffer("Music", buffer, 3) | |
#include "util/math.h"
#include "util/stats.h"
#include "util/time/time.h"
T_STATIC void prv_merge_adjacent_sessions(ActivitySession *current,
ActivitySession *previous) {
if (previous == NULL || current == NULL) {
return;
}
if (current->type != previous->type ||
... | activity_get_metric_typical(ActivityMetricSleepExitAtSeconds, local_tm.tm_wday,
&health_data->typical_sleep_end) | |
(dest_data, GColorWhite.argb, 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_8bit_comptint_white_cross_white_corners-expect.8bit.pbi"));
memset(dest_data, GColorWhite.argb, sizeof(dest_data));
bitblt_bitmap_into_bitmap(&dest_bitmap, s... | |
de, GTextNode *child) {
if (!container_node || !child) {
return false;
}
const size_t num_nodes = container_node->num_nodes;
if (num_nodes >= container_node->max_nodes) {
return false;
}
GTextNode *prev_child = (num_nodes > 0) ? container_node->nodes[num_nodes - 1] : NULL;
container_node->nodes[co... | if (ctx->render) {
prv_align_axis(ctx);
} | |
t32(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
uint32_t value;
uint32_t start_value, end_value, mid_value;
const int duration = 1000;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
// NOTE: We are not exposing the GTransfo... | cl_assert(gcolor_equal(value, start_value)) | |
true /* auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientKernel);
cl_assert_equal_i(e, BTErrnoOK);
// Simulate getting a Connection Complete event for the device from Bluetopia:
prv_fake... | cl_assert_equal_i(gap_le_connect_connection_intents_count(), 1) | ;
cl_assert_equal_b(gap_le_connect_has_connection_intent(&device, GAPLEClientKernel), true);
cl_assert_equal_b(gap_le_connect_has_connection_intent(&device, GAPLEClientApp), false);
cl_assert_equal_b(gap_le_connect_has_pending_create_connection(), true);
}
// -----------------------------------------------------... |
_pinned_address(&pinned_address);
}
// if we get here there is no pinned address in PRF, let's load the address fw has been
// using. This shouldn't ever really happen unless we reboot while saving new information to
// shared PRF
if (bt_persistent_storage_get_ble_pinned_address(&pinned_address)) {
share... | bt_persistent_storage_store_ble_pairing(&prf_pairing_info, true /* is_gateway */, device_name,
requires_address_pinning, flags) | ;
}
static void prv_load_data_from_prf(void) {
prv_load_local_data_from_prf();
prv_load_pinned_address_from_prf();
if (bt_driver_supports_bt_classic()) {
prv_load_bt_classic_data_from_prf();
}
prv_load_ble_pairing_from_prf();
}
////////////////////////////////////////////////////////////////////////////... |
ate.
// See PBL-35548
return;
}
vibe_score_do_vibe(s_phone_ui_data->vibe_score);
#else
vibes_long_pulse();
#endif
}
if (alerts_should_enable_backlight_for_type(AlertPhoneCall)) {
light_enable_interaction();
}
}
static void prv_start_ringing(void) {
alerts_incoming_alert_analytics();... | (s_phone_ui_data->call_duration_timer) | ;
s_phone_ui_data->call_duration_timer = EVENTED_TIMER_INVALID_ID;
}
static void prv_set_status_text(CallStatus status) {
if (status == ACCEPTED) {
i18n_get_with_buffer("Call Accepted", s_phone_ui_data->call_status_text_buf,
CALL_STATUS_BUFFER_LENGTH);
} else if (status == DISCONNECT... |
imestamp_midnight == today_midnight) {
switch (style) {
case FullStyleLower12h:
case FullStyleCapital12h:
time_fmt = i18n_noop("%l:%M %p");
break;
case FullStyleLower24h:
case FullStyleCapital24h:
time_fmt = i18n_noop("%R");
break;
}
} else if (timestamp... | i18n_noop("In %lu minute") | ;
} else {
str_fmt = i18n_noop("In %lu minutes");
}
snprintf(buffer, buf_size, i18n_get(str_fmt, buffer), num_minutes);
} else if (difference >= -(SECONDS_PER_HOUR * max_relative_hrs)) {
const int num_hrs =
prv_round(-difference, SECONDS_PER_HOUR, RoundTypeHalfDown) / SECONDS_PER_HOUR;
... |
trapProfileGenericService,
SmartstrapResultOk, 0x1111, 0x2222, 10);
cl_assert(!s_pending_did_read.active);
// destroy the attribute
app_smartstrap_attribute_destroy(attr);
}
void test_app_smartstrap__write(void) {
// create the attribute
SmartstrapAttribute *attr = app_smar... | prv_prepare_for_did_read(attr, 100);
smartstrap_attribute_send_event(SmartstrapDataReceivedEvent, SmartstrapProfileGenericService,
SmartstrapResultOk, 0x1111, 0x2222, 100);
cl_assert(!s_pending_did_read.active);
// destroy the attribute
app_smartstrap_attribute_destroy(attr)... | |
bool is_hrm_enabled;
#endif
#if CAPABILITY_HAS_MICROPHONE
bool is_mic_enabled;
int16_t *mic_buffer;
#endif
BTLETestStep current_test_step;
bool last_test_step_result;
uint16_t rx_test_received_packets;
SemaphoreHandle_t btle_test_semaphore;
HRMSessionRef hrm_session;
} AppData;
// Forward declarat... | if (data->is_hrm_enabled) {
AppInstallId app_id = 1;
uint16_t expire_s = SECONDS_PER_HOUR;
data->hrm_session = sys_hrm_manager_app_subscribe(app_id, 1, expire_s, HRMFeature_LEDCurrent);
} | |
timeline layer from the left
Layer *layer = &data->timeline_layer.layer;
GPoint from_origin = { -layer->bounds.size.w, 0 };
Animation *layer_in = (Animation *)property_animation_create_bounds_origin(layer, &from_origin,
&GPointZero);
a... | (&s_app_data->intro_timer_id) | ;
prv_cleanup_timer(&s_app_data->inactive_timer_id);
event_service_client_unsubscribe(&s_app_data->focus_event_info);
event_service_client_unsubscribe(&s_app_data->blobdb_event_info);
timeline_layer_deinit(&s_app_data->timeline_layer);
timeline_model_deinit();
app_free(s_app_data);
}
static void prv_main... |
/*
* 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... | {
UTIL_ASSERT(iter->next);
return iter->next(iter->state);
} |
bool iter_prev(Iterator* iter) {
UTIL_ASSERT(iter->prev);
return iter->prev(iter->state);
}
|
/*
* 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... | {
case BINLOGMSG_VERSION_STRING_V1:
prv_log_string_v1((BinLogMessage_String_v1 *)header);
break;
case BINLOGMSG_VERSION_PARAM_V1:
#if PBL_LOGS_HASHED
prv_log_param_v1((BinLogMessage_Param_v1 *)header);
#else
PBL_LOG(LOG_LEVEL_ERROR, "HcLog: received ha... |
}
break;
default:
PBL_LOG(LOG_LEVEL_INFO, "HcLog: unhandled message id: %d\n", msg->command_id);
break;
}
}
void hc_endpoint_logging_set_level(uint8_t level) {
hc_protocol_enqueue_with_payload(HcEndpointID_Logging, HcMessageID_Logging_SetLevel,
&level... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (!prop_anim) {
return;
} |
Animation *animation = property_animation_get_animation(prop_anim);
// If we failed, pause on the screen for a little.
animation_set_delay(animation, delay);
animation_set_duration(animation, duration);
animation_set_curve(animation, AnimationCurveEaseOut);
animation_set_handlers(animation, (AnimationHand... |
/*
* 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... | activity_private_compute_distance_mm(steps, time_ms) | |
include "resource/resource.h"
#include "resource/resource_ids.auto.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include <inttypes.h>
#include <stdint.h>
// The dialog BLE chip has a baked in bootloader capable of talking serial
// protocols. The bootloader allows a contiguous mem... | if (uart_is_rx_ready(BT_RX_BOOTROM_UART)) {
*char_received = uart_read_byte(BT_RX_BOOTROM_UART);
return true;
} |
} while (rtc_get_ticks() <= end_ticks);
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for char");
return false;
}
static bool prv_bootrom_wait_for_char(char *char_received) {
const uint32_t wait_time_ticks = (DIALOG_BOOTROM_DEFAULT_CHAR_TIMEOUT_MS * RTC_TICKS_HZ) / 1000;
return prv_bootrom_wait_for_char_with... |
28, -80},
// 15 seconds
{ -1128, 360, -160},
{ -1248, 400, -88},
{ -1424, 400, -24},
{ -1432, 336, -16},
{ -1216, 240, 16},
{ -1056, 24, 88},
{ -1000, -24, 96},
{ -936, 96, 16},
{ -960, 192, 24},
{ -1088, -72, 168},
{ -1112, -320, 184},
{ -1064, -136, 56},
{ -1376... | { -1304, 1216, -224},
{ -1400, -200, -336},
{ -1096, 184, -312},
{ -1240, 488, -120},
{ -1496, 408, 40},
{ -1400, 144, -48},
{ -1080, 120, -88},
{ -1056, 80, 48},
{ -1120, 40, 160},
{ -1096, 8, 112},
{ -992, 24, 120},
{ -1096, 96, 160},
{ -1176, 32, 144},
{ -1032,... |
// 23 seconds
{ -1192, -56, 128},
{ -1208, 8, 32},
{ -1216, 264, -296},
{ -1080, 256, -264},
{ -1208, 80, -216},
{ -1208, -416, 88},
{ -1296, -256, 40},
{ -1328, 120, 96},
{ -1272, 432, 152},
{ -1256, 520, 96},
{ -1232, 288, 96},
{ -1088, 256, 8},
{ -1200, 424, -... |
g, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <stdlib.h>
#include "dr... | (&bufcmp[0], i, sizeof(bufcmp)) | |
* +1 for Type byte */,
0x07, // Service UUIDs, 128-bit, Complete
};
memcpy(&expected_ad_data[2], uuid_bytes, sizeof(Uuid));
// One should fit though:
cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 1), true);
cl_assert_equal_i(memcmp(expected_ad_data, ad->data,
sizeof(exp... | {
BLEAdData *ad;
ad = ble_ad_create();
uint8_t expected_ad_data[] = {
1 /* +1 for Type byte */ + 13 /* Company ID + data */,
0xff, // Manufacturer Specific data
0x34, 0x12,
'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd',
};
// Should fit fine, expect true:
cl_assert_equal_b(ble_ad_s... |
void test_ble_ad_parse__set_flags(void) {
BLEAdData *ad;
ad = ble_ad_create();
const uint8_t flags = 0x03;
const uint8_t expected_ad_data[] = {
1 /* +1 for Type byte */ + 1 /* uint8_t with value */,
0x01, // Flags type
flags,
};
// Should fit fine, expect true:
cl_assert_equal_b(ble_ad_se... |
G_MAX_ANGLE;
// This is going to be divided by fixed-point precision number so division here is unnecessary
int32_t radius_xy = ((int32_t)radius_x * radius_y);
int32_t radius_xx = ((int32_t)radius_x * radius_x) >> FIXED_S16_3_PRECISION;
int32_t radius_yy = ((int32_t)radius_y * radius_y) >> FIXED_S16_3_PRECISIO... | prv_plot4(fb, clip_box, center, GPoint(offset.y, offset.x), brightness, stroke_color, quadrant) | ;
}
#if PBL_COLOR
T_STATIC void graphics_circle_quadrant_draw_1px_aa(GContext* ctx, GPoint p, uint16_t radius,
GCornerMask quadrant) {
/* This will draw antialiased circle with width of 1px, can be drawn in quadrants
* Based on wu-xiang line drawing, will draw ci... |
), format_time);
cl_assert_equal_s("Jun 10", time_buf);
// June 7th 2015, 12:00:00 (-07:00:00)
format_time = event_time - SECONDS_PER_DAY - (24 * SECONDS_PER_HOUR);
clock_get_month_named_abbrev_date(time_buf, sizeof(time_buf), format_time);
cl_assert_equal_s("Jun 7", time_buf);
// June 16th 2015, 13:00:00... | clock_get_relative_daypart_string(timestamp, 53 /* hours_in_the_future */) | ;
cl_assert_equal_s(day_after_tomorrow, daypart_string);
// (11pm 2 days from now) time between 2 days from now 9am and midnight is the day after tomorrow
daypart_string = clock_get_relative_daypart_string(timestamp, 67 /* hours_in_the_future */);
cl_assert_equal_s(day_after_tomorrow, daypart_string);
// (m... |
language governing permissions and
* limitations under the License.
*/
#include "peek_layer.h"
#include "util/trig.h"
#include "applib/ui/kino/kino_reel/scale_segmented.h"
#include "applib/ui/kino/kino_reel/transform.h"
#include "applib/ui/kino/kino_reel/unfold.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/... | {
peek_layer_init(peek_layer, &frame);
} |
return peek_layer;
}
void peek_layer_destroy(PeekLayer *peek_layer) {
if (peek_layer) {
peek_layer_deinit(peek_layer);
}
task_free(peek_layer);
}
void peek_layer_init(PeekLayer *peek_layer, const GRect *frame) {
*peek_layer = (PeekLayer) {
.icon_offset_y = PEEK_LAYER_ICON_OFFSET_Y,
.subtitle_... |
ap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette)));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat4BitPalette);
}
// Tests 8-bit palettized 64-color PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_8_bit(void) {
GBitmap *bitmap = setup_png_test(TEST_P... | cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE_FMT(4bitpalette))) | ;
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat4BitPalette);
}
// Tests 8-bit transparent color PNG with 4-bit number of colors (<= 16 colors)
// loading into gbitmap
// Checks for bug fixed for PBL-15809, where GBitmap depth was based off
// number of colors and not index value bits-per-pixel (bpp).
/... |
/*
* 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... | {
return false;
} |
return ((AnimationPrivate*)animation)->immutable;
}
bool WEAK animation_set_reverse(Animation *animation, bool reverse) {
if (!animation) {
return false;
}
((AnimationPrivate*)animation)->reverse = reverse;
return true;
}
bool WEAK animation_get_reverse(Animation *animation) {
if (!animation) {
r... |
_invalidate_addr;
typedef enum {
UserSpaceBuffer_Unchecked,
UserSpaceBuffer_Valid,
UserSpaceBuffer_Invalid,
UserSpaceBuffer_NotRun,
} UserSpaceBufferValidity;
static UserSpaceBufferValidity s_addr_result;
uint32_t dcache_line_size(void) {
return cl_mock_type(size_t);
}
uint32_t icache_line_size(void) {
r... | cl_assert_equal_i(s_flush_addr, 0x00) | ;
cl_assert_equal_i(s_flush_size, 0x10);
cl_assert_equal_i(s_invalidate_addr, 0x00);
cl_assert_equal_i(s_invalidate_size, 0x10);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Unchecked);
}
void test_cpu_cache__without_icache(void) {
cl_will_return(icache_is_enabled, false);
cl_will_return(dcache_is_ena... |
S OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "window_private.h"
#include "applib/app_logging.h"
#include "applib/graphics/graphics.h"
#include "applib/ui/app_window_click_glue.h"
#include "applib/ui/app_... | {
frame.origin.x = 0;
} |
status_bar_layer_render(ctx, &frame, &config);
ctx->draw_state.clip_box = saved_clip_box;
}
}
void window_render(Window *window, GContext *ctx) {
PBL_ASSERTN(window);
if (window->on_screen == false) {
window->is_render_scheduled = false;
return;
}
// workaround for 3rd-party apps
// if... |
-
HealthValue health_service_peek_current_value(HealthMetric metric) {
time_t now_utc = sys_get_time();
return health_service_aggregate_averaged(metric, now_utc, now_utc, HealthAggregationAvg,
HealthServiceTimeScopeOnce);
}
static HealthValue prv_hr_aggregate_averaged(He... | {
if (prv_get_intraday_averages(state, metric, &averages, local_tm->tm_wday)) {
result += prv_sum_intraday_averages(&averages, time_start, time_end);
num_sums++;
}
} | else if ((scope == HealthServiceTimeScopeDaily)
|| (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend)) {
for (DayInWeek day = Sunday; day <= Saturday; day++) {
if (scope == HealthServiceTimeScopeDailyWeekdayOrWeekend) {
if (is_weekend != prv_is_weekend(day)) {
continue;
... |
/*
* 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, current_value) | ;
}
void boot_bit_clear(BootBitValue bit) {
uint32_t current_value = RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR);
current_value &= ~bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
bool boot_bit_test(BootBitValue bit) {
uint32_t current_value = RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR);
re... |
e;
static PPoGATTPacket * s_client_reset_complete;
static uint16_t s_client_reset_complete_size;
static int s_ppogatt_version;
static int s_tx_window_size;
static int s_rx_window_size;
static void prv_create_expected_reset_request(void) {
s_client_reset_request_size = sizeof(PPoGATTPacket) + sizeof(PPoGATTResetReq... | fake_gatt_client_op_assert_write(characteristic,
(const uint8_t *) &expected_response, s_client_reset_complete_size,
GAPLEClientKernel, false /* is_response_required */) | ;
if (s_ppogatt_version > 0) {
s_tx_window_size = MIN(s_tx_window_size, expected_response.payload.ppogatt_max_tx_window);
s_rx_window_size = MIN(s_rx_window_size, expected_response.payload.ppogatt_max_rx_window);
} else {
s_tx_window_size = s_rx_window_size = PPOGATT_V0_WINDOW_SIZE;
}
}
static void... |
new pin, false if it updated
static bool prv_push_pin(TimelineItem *item, Uuid *existing_uuid) {
bool rv = false;
if (item) {
item->header.from_watch = true;
item->header.parent_id = (Uuid)UUID_HEALTH_DATA_SOURCE;
if (!uuid_is_invalid(existing_uuid)) {
item->header.id = *existing_uuid;
} els... | ("History validation failed - total/consecutive days didn't match: "
"%"PRIu8" %"PRIu8, stats->total_days, stats->consecutive_days) | ;
return false;
}
// We want to look at the x days before today (which is always index 0), so add 1
uint32_t history_len = insight_settings->reward.target_qualifying_days + 1;
if (history_len > ACTIVITY_HISTORY_DAYS) {
PBL_LOG(LOG_LEVEL_ERROR, "Insight qualifying history length is too long: %"PRIu32,
... |
DMA Requests
static DMARequestState s_dbg_uart_dma_request_state;
static DMARequest DBG_UART_RX_DMA_REQUEST = {
.state = &s_dbg_uart_dma_request_state,
.stream = &DMA1_STREAM1_DEVICE,
.channel = 4,
.irq_priority = IRQ_PRIORITY_INVALID, // no interrupts
.priority = DMARequestPriority_High,
.type = DMAReque... | (I2C1_EV, i2c_hal_event_irq_handler, &I2C_MAIN_BUS) | ;
IRQ_MAP(I2C1_ER, i2c_hal_error_irq_handler, &I2C_MAIN_BUS);
IRQ_MAP(I2C2_EV, i2c_hal_event_irq_handler, &I2C_2V5_BUS);
IRQ_MAP(I2C2_ER, i2c_hal_error_irq_handler, &I2C_2V5_BUS);
// VOLTAGE MONITOR DEVICES
static const VoltageMonitorDevice VOLTAGE_MONITOR_ALS_DEVICE = {
.adc = ADC2,
.adc_channel = ADC_Channel_12... |
ite->cleanup);
break;
}
case 'q':
_clar.report_errors_only = 1;
break;
case 'Q':
_clar.exit_on_error = 1;
break;
case 'i': {
int offset = (argument[2] == '=') ? 3 : 2;
if (strcasecmp("all", argument + offset) == 0)
clar_category_enable_all(_clar_suit... | {
char buf[256];
snprint_eq(buf, 256, "%d not within [%d, %d]", n, min, max);
clar__assert(0, file, line, err, buf, should_abort);
} | |
{
s_dnd_active = false;
s_low_power_active = false;
alerts_set_mask(AlertMaskAllOn);
}
void test_alerts__cleanup(void) {
}
// Tests
/////////////////////////////////
void test_alerts__enabled(void) {
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
// Should allow all no... | alerts_should_notify_for_type(AlertPhoneCall) | |
uffer_get_write_space_remaining(&session->send_buffer)) {
return NULL;
}
if (session->temp_write_buffer) {
// Already writing, fake doesn't support multiple tasks trying to write at the same time
return NULL;
}
session->temp_write_buffer = (uint8_t *) kernel_malloc(session->max_out_payload_length);
... | ((const ListNode *) s_fake_transport_head,
(const ListNode *) fake_transport) | , true);
CommSession *session = fake_transport->session;
PebbleProtocolHeader pp_header;
uint8_t *buffer = kernel_malloc(1024);
while (circular_buffer_copy(&session->send_buffer,
(uint8_t *) &pp_header, sizeof(pp_header)) == sizeof(pp_header)) {
circular_buffer_copy_offset(&ses... |
/*
* 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... | strlen(expected) | ;
// Cehck that bytes aren't touched past the end of the record.
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_ihe... |
28, 624, -232},
{ 808, 512, -168},
{ 1096, 576, -8},
{ 1560, 488, 80},
{ 1448, 144, 88},
{ 1152, 24, 16},
{ 1104, 104, 0},
{ 1160, 216, 0},
{ 1192, 264, -8},
{ 1104, 280, -88},
{ 1072, 192, -120},
{ 1264, 128, -224},
{ 1120, 0, -264},
{ 1312, -176, 144},
// 35 sec... | { 1224, 72, 56},
{ 1112, 48, 80},
{ 1104, 120, 56},
{ 1080, 176, -16},
{ 952, 208, -8},
{ 1104, 168, 24},
{ 1096, 152, -112},
{ 952, 144, -160},
{ 1192, 56, -24},
{ 1280, 152, -88},
{ 1200, 192, -248},
{ 1472, 176, -248},
{ 1344, 208, -280},
{ 1000, 224, -184},
... | |
/*
* 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... | {
break;
} | else if (less > greater) {
max = max_lt_guess;
} else {
min = min_gt_guess;
}
}
if (less >= ((num_values + 1) / 2)) {
return max_lt_guess;
} else if ((less + equal) >= ((num_values + 1) / 2)) {
return guess;
} else {
return min_gt_guess;
}
}
// ------------------------------... |
void gpath_draw_filled(GContext* ctx, GPath *path) {}
void graphics_draw_circle(GContext* ctx, GPoint p, uint16_t radius) {}
void graphics_fill_circle(GContext* ctx, GPoint p, uint16_t radius) {}
void graphics_context_move_draw_box(GContext* ctx, GPoint offset) {}
void graphics_line_draw_precise_stroked(GContext* ctx,... | (!gdraw_command_sequence_validate(sequence, size)) | ;
sequence->num_frames = 2;
sequence->version = 0xFF;
cl_assert(!gdraw_command_sequence_validate(sequence, size));
free(sequence);
}
void test_gdraw_command_sequence__get_frame_by_elapsed(void) {
GDrawCommandSequence *sequence;
prv_create_test_sequence(&sequence);
GDrawCommandFrame *frame = gdraw_comm... |
cteristics;
//! Stuffs that deals with inbound data
struct {
uint8_t next_expected_data_sn;
} in;
//! Stuffs that deals with outbound data
struct {
union {
PPoGATTPacket reset_packet_to_send;
//! Set to 0 if there is no reset packet to send
uint8_t reset_packet_byte;
};
uni... | (connection, consumer, state, max_period_secs,
granted_handler) | ;
}
static const Uuid *prv_get_uuid(Transport *transport) {
PPoGATTClient *client = (PPoGATTClient *) transport;
return &client->app_uuid;
}
static CommSessionTransportType prv_get_type(struct Transport *transport) {
return CommSessionTransportType_PPoGATT;
}
static const TransportImplementation s_ppogatt_tran... |
offset, int x, int width,
GColor8 src_color) {
if (!dst_color) {
return;
}
// If there's no mask, just set the color normally and return
if (!mask) {
memset(dst_color, src_color.argb, (size_t)width);
return;
}
const uint8_t pixels_per_byte = (uint8_t)GDRAWM... | (mask_row_data, (uint32_t)adjusted_x, fake_y, row_stride_bytes,
GDRAWMASK_BITS_PER_PIXEL, value) | ;
}
#endif // CAPABILITY_HAS_MASKING
|
true);
}
// Callbacks for the main settings filter list menu.
////////////////////////////////////////////////////
#define SHUTDOWN_MIN_BOOT_VERSION 1354647953
static bool prv_shutdown_enabled(void) {
return boot_version_read() >= SHUTDOWN_MIN_BOOT_VERSION;
}
static void prv_shutdown_confirm_cb(ClickRecognizerRef... | {
static const SettingsModuleMetadata s_module_info = {
.name = i18n_noop("System"),
.init = prv_init,
};
return &s_module_info;
} | |
nsightCopyVariants s_running_intros = {
.num_variants = 5,
.variants = {
i18n_noop("Feelin' hot? Cause you're on 🔥"),
i18n_noop("Hey lightning bolt, way to go!"),
i18n_noop("You're a machine!"),
i18n_noop("Hey speedster, we can barely keep up!"),
i18n_n... | i18n_get("Distance", headings) | , headings_buf_size);
string_list_add_string(values, values_buf_size, distance_str, values_buf_size);
}
static void prv_add_step_metric_info(StringList *headings, int headings_buf_size,
StringList *values, int values_buf_size,
ActivitySession ... |
/*
* 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... | {
return 4;
} | |
ither express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "layout_node.h"
#include "timeline_layout.h"
#include "kernel/pbl_malloc.h"
#include "services/common/i18n/i18n.h"
#include "system/passert.h"
#include "util/size.h"
#include... | (text_node, layout, &config->text) | ;
}
if (config->use_i18n) {
i18n_free(config->str, layout);
}
return text_node;
}
typedef struct {
const LayoutLayer *layout;
LayoutNodeTextDynamicConfig config;
char buffer[];
} TextDynamicContext;
static void prv_text_dynamic_node_callback(GContext *ctx, GTextNode *node, const GRect *box,
... |
config);
return prv_push_pin(item, existing_uuid);
}
// ------------------------------------------------------------------------------------------------
// Pushes a new reward notification and saves the trigger time to flash
static void prv_push_reward(time_t now_utc, const RewardNotifConfig *notif_config) {
prv_... | for (uint32_t i = 1; i < history_len; ++i) {
if (history[i] < target) {
INSIGHTS_LOG_DEBUG("History validation failed - not above target on day %"PRIu32
": %"PRIi32, i, history[i]);
return false;
}
} |
return true;
}
// ------------------------------------------------------------------------------------------------
static TimelineItem *prv_create_day_1_insight(time_t notif_time) {
if (activity_prefs_get_health_app_opened_version() != 0) {
// The user already knows about the Health app
return NULL;
}
... |
int32_t sleep_total_seconds) {
SLEEP_SUMMARY_PIN_CONFIG.detail_text[0] = '\0';
prv_strcat_formatted_time(sleep_enter_seconds, SLEEP_SUMMARY_PIN_CONFIG.detail_text,
SUBTITLE_BUFFER_LENGTH, &SLEEP_SUMMARY_PIN_CONFIG);
safe_strcat(SLEEP_SUMMARY_PIN_CONFIG.detail_text, "-", SUB... | (time_range, max_attr_length, time_range_fmt, start_time, end_time) | ;
attribute_list_add_cstring(&pin_attr_list,
PBL_IF_RECT_ELSE(AttributeIdLocationName, AttributeIdTitle),
time_range);
// Don't display the time in the title
attribute_list_add_uint8(&pin_attr_list, AttributeIdDisplayTime, WeatherTimeType_None);
attribu... |
/*
* 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... | {
factory_reset_set_reason_and_reset();
} | |
s(readings[cfg->axes_offsets[AXIS_Y]]),
.z = (cfg->axes_inverts[AXIS_Z] ? -1 : 1) *
prv_raw_to_mgs(readings[cfg->axes_offsets[AXIS_Z]]),
};
}
static void prv_read_curr_accel_data(AccelDriverSample *data) {
uint8_t raw_buf[BMA255_FIFO_FRAME_SIZE_BYTES];
bma255_burst_read(BMA255Register_ACCD_X_LSB,... | BMA255_DBG("No Axis?: 0x%"PRIx8" 0x%"PRIx8, int0_status, int2_status) | ;
}
int32_t direction = ((int2_status & BMA255_INT_STATUS_2_SLOPE_SIGN) == 0) ? 1 : -1;
direction *= (invert ? -1 : 1);
accel_cb_shake_detected(axis, direction);
}
}
// Services tap/motion interrupts
static void prv_bma255_IRQ1_handler(bool *should_context_switch) {
BMA255_DBG("Slope Int");
if (... |
x_elapsed_ticks)) {
break;
}
}
mutex_lock_recursive(s_pfs_mutex);
s_last_page_written = last_written_page; // reset our tracker
mutex_unlock_recursive(s_pfs_mutex);
}
// In the future, the next_page field may be updated dynamically (i.e to resize
// a file). Use a CRC to catch corruption issues in t... | write_file_header(&file_hdr, start_page) | ;
prv_flash_write((uint8_t *)f->name, strlen(f->name),
prv_page_to_flash_offset(start_page) + FILE_NAME_OFFSET);
if (!f->is_tmp) {
update_curr_state(f->start_page, TMP_STATE_OFFSET, TMP_STATE_DONE);
}
// finally, mark the creation as complete
update_curr_state(start_page, CREATE_STATE_OFFSET, CRE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.