prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
uint8_t s_pmic_gpio_output_state = 0;
typedef enum PmicGpio {
PmicGpio1 = (1 << 0),
PmicGpio2 = (1 << 1),
PmicGpio3 = (1 << 2),
PmicGpio4 = (1 << 3),
PmicGpio5 = (1 << 4),
} PmicGpio;
typedef enum {
PmicRegisters_SD1_VOLTAGE = 0x01,
PmicRegisters_LDO1_VOLTAGE = 0x02,
PmicRegisters_LDO2_VOLTAGE = 0x03,... | {
val &= ~(1 << bit);
} | |
.attributes = action1_attributes
}
},
{
.id = 1, .type = TimelineItemActionTypeResponse,
.attr_list = {
.num_attributes = ARRAY_LENGTH(action2_attributes),
.attributes = action2_attributes
}
},
{
.id = 2,
.type = TimelineItemActionTypeResponse,
.attr_list = {
... | uuid_generate(&invalid_uuid) | ;
cl_assert_equal_b(notification_storage_get(&invalid_uuid, &r), false);
}
void test_notification_storage__multiple(void) {
Uuid i1 ;
uuid_generate(&i1);
TimelineItem e1 = {
.header = {
.id = i1,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 0,
.layout = Layou... |
/*
* 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_get_timezone_id() | ;
}
void clock_set_timezone_by_region_id(uint16_t region_id) {
return;
}
// Tests
///////////////////////////////////////////////////////////
void test_time__initialize(void) {
}
void test_time__cleanup(void) {
}
void test_time__serial_distance32(void) {
uint32_t day, hour, minute, second;
{
time_util_s... |
,
{ -152, -160, -992},
{ -144, -152, -992},
{ -152, -128, -992},
{ -144, -136, -992},
{ -152, -160, -1000},
{ -144, -152, -992},
{ -144, -144, -984},
{ -152, -144, -992},
{ -144, -136, -1000},
{ -144, -136, -1008},
{ -144, -160, -984},
{ -144, -136, -992},
{ -152, -14... | { -152, -112, -968},
{ -152, -88, -1032},
{ -176, -88, -984},
{ -136, -96, -992},
{ -128, -128, -1000},
{ -128, -96, -1024},
{ -136, -120, -984},
{ -152, -96, -1008},
{ -168, -128, -992},
{ -160, -152, -976},
{ -136, -144, -1000},
{ -144, -128, -984},
{ -128, -128, -9... |
{ -144, -152, -984},
{ -144, -136, -984},
{ -160, -152, -992},
// 29 seconds
{ -160, -152, -1000},
{ -152, -184, -992},
{ -144, -168, -1000},
{ -152, -152, -984},
{ -160, -160, -976},
{ -152, -152, -1000},
{ -152, -160, -992},
{ -152, -184, -992},
{ -152, -184, -1000... |
Don't ask me, I didn't decide this.
if (wday == normal_compare || (YEAR_IS_LEAP(year) && wday == leap_compare)) {
return 53;
} else {
return 52;
}
}
static int prv_iso8601_adjust(const struct tm *t, int year) {
const int week = prv_iso8601_base_week(t);
if (week == 0) {
return -1;
} else if (w... | #define FMT_RECURSE_I18N(FMT) do { \
i18nstr = FMT; \
goto _fmt_recurse; \
} while (0)
// Terrible local state for goto hell
const char *cpystr = NULL;
const char *i18nstr;
int cpyint_val;
size_t cpyint_len;
unsigned int cpyint_flag;
// Process conversion specifiers
switch (*fmt) {
... |
}
length = localized_strftime(dest_str, left, cpystr, t, locale);
if (i18nstr) {
i18n_free(i18nstr, dest_str);
}
if (length == 0) {
goto _out_of_size;
}
dest_str += length;
left -= length;
break;
case 'C': // SU
F... |
ase_suspend = 1 << 6,
},
.dummy_cycles = {
.fast_read = 10,
.fast_read_ddr = 8,
},
.block_lock = {
.has_lock_data = true,
.lock_data = 0x1,
.locked_check = 0x1,
},
.reset_latency_ms = 51,
.suspend_to_read_latency_us = 0,
.standby_to_low_power_latency_us = 3,
.low_power_to_standby_l... | qspi_flash_set_lower_power_mode(QSPI_FLASH, true) | ;
return S_SUCCESS;
}
status_t flash_impl_exit_low_power_mode(void) {
qspi_flash_set_lower_power_mode(QSPI_FLASH, false);
return S_SUCCESS;
}
status_t flash_impl_set_burst_mode(bool burst_mode) {
// NYI
return S_SUCCESS;
}
status_t flash_impl_blank_check_sector(FlashAddress addr) {
return qspi_flash_blank... |
/*
* 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... | debug_print_str("Bus fault") | ;
prv_handle_fault();
}
void MemManag_HandlerC(uint32_t *fault_args) {
debug_print_str("MemManag fault");
prv_handle_fault();
}
void NMI_HandlerC(uint32_t *fault_args) {
debug_print_str("NMI Handler");
prv_handle_fault();
}
|
/*
* 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 (timeout-- == 0) {
dbgserial_putstr("FPGA CDONE timeout expired!");
return false;
}
delay_us(100);
} |
return true;
}
static bool prv_reset_into_nvcm(void) {
// Reset the FPGA and wait for it to program itself via NVCM.
// NVCM configuration is initiated by pulling CRESET high while SCS is high.
GPIO_WriteBit(DISP_GPIO, DISP_PIN_SCS, Bit_SET);
// CRESET needs to be low for at least 200 ns
GPIO_WriteBit(DIS... |
} else if (strcmp(token, "TEST_EXPECTED_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.exp_steps_min);
} else if (strcmp(token, "TEST_EXPECTED_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.exp_steps_max);
} else if (strcmp(token, "TEST_WE... | {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.value);
} | |
ItemTypePin;
pin->header.from_watch = true;
pin->header.ancs_uid = uid;
// patch the dismiss action to be a remove action
TimelineItemAction *remove_action = timeline_item_find_dismiss_action(pin);
// TODO: PBL-23915
// We leak this i18n'd string because not leaking it is really hard.
// We make sure we... | attribute_get_uint32(&action->attr_list, AttributeIdAncsId,
item->header.ancs_uid) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | memset(dst_color, src_color.argb, (size_t)width) | ;
#endif // CAPABILITY_HAS_MASKING
}
// Plots row at given starting position and width, dithers grayscale colors
static void prv_assign_row_with_pattern_1bit(GBitmap *framebuffer, int16_t y, int16_t x,
int32_t width, GColor color) {
const uint32_t pattern = graphics_priva... |
ds
{ 208, -384, -848},
{ 184, -376, -848},
{ 184, -352, -848},
{ 192, -360, -848},
{ 128, -320, -960},
{ 208, -384, -1016},
{ 184, -480, -944},
{ 184, -296, -928},
{ 168, -320, -848},
{ 184, -384, -880},
{ 184, -440, -848},
{ 192, -368, -848},
{ 216, -352, -864},
... | { 328, 320, -840},
{ 336, 296, -824},
{ 336, 280, -840},
{ 360, 288, -824},
{ 344, 256, -824},
{ 336, 256, -816},
{ 344, 296, -824},
{ 336, 272, -832},
{ 352, 264, -832},
{ 344, 272, -832},
{ 336, 280, -824},
{ 344, 264, -824},
{ 360, 312, -824},
// 108 seconds
... |
{ 336, 352, -856},
{ 328, 288, -864},
{ 344, 232, -984},
{ 328, 144, -960},
{ 264, -464, -616},
{ 320, -320, -872},
{ 304, -376, -816},
{ 304, -448, -768},
{ 304, -432, -784},
{ 288, -400, -816},
{ 272, -432, -808},
{ 240, -440, -808},
{ 240, -480, -784},
{ 240, ... |
/*
* 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_output_set(&BOARD_CONFIG_BACKLIGHT.ctl, false) | ;
periph_config_release_lock();
s_initialized = true;
}
if (BOARD_CONFIG_BACKLIGHT.options & ActuatorOptions_Pwm) {
periph_config_acquire_lock();
pwm_init(&BOARD_CONFIG_BACKLIGHT.pwm,
TIMER_PERIOD_RESOLUTION,
TIMER_PERIOD_RESOLUTION * PWM_OUTPUT_FREQUENCY_HZ);
periph_c... |
l_is_selected);
} else {
prv_menu_cell_basic_draw_custom_one_column_round(ctx, &cell_layer_bounds, config,
GTextAlignmentCenter, GAlignCenter,
cell_is_selected);
}
}
static ALWAYS_INLINE void prv_draw_cell... | (FONT_KEY_GOTHIC_14_BOLD) | ;
GRect box = cell_layer->bounds;
// Pixel nudging...
box.origin.x += 2;
box.origin.y -= 1;
graphics_draw_text(ctx, title, font, box, GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
}
|
applib_release_log_state(state);
}
}
static void prv_log_internal(bool async, uint8_t log_level, const char* src_filename,
int src_line_number, const char* fmt, va_list args) {
LogState *state = prv_get_log_state();
if (!state) {
return;
}
va_list bin_args;
va_copy(bin_args, ... | strcat(expanded_fmt_buffer, " `%s`") | ;
} else {
strcat(expanded_fmt_buffer, " %x"); // add a space
}
}
prv_sprintf_to_msg(msg, max_message_length, expanded_fmt_buffer, fmt_args);
}
}
sys_pbl_log((LogBinaryMessage*) state->buffer, async);
prv_release_log_state(state);
}
#endif /* PBL_LOGS_HASHED */
void p... |
264, -912},
{ -280, 440, -920},
{ -280, 432, -920},
{ -304, 384, -912},
{ -312, 392, -912},
{ -288, 432, -856},
{ -248, 456, -832},
{ -224, 464, -872},
{ -192, 528, -864},
{ -240, 416, -856},
// 160 seconds
{ -280, 344, -880},
{ -312, 320, -872},
{ -320, 408, -920},
... | { -288, 344, -912},
// 165 seconds
{ -296, 320, -920},
{ -304, 344, -928},
{ -304, 352, -920},
{ -304, 328, -920},
{ -296, 336, -920},
{ -288, 344, -920},
{ -296, 344, -920},
{ -296, 344, -928},
{ -296, 352, -920},
{ -288, 352, -904},
{ -288, 352, -920},
{ -296, 3... |
{ -296, 352, -912},
{ -288, 352, -912},
{ -288, 336, -912},
{ -288, 344, -920},
{ -296, 320, -904},
{ -304, 360, -920},
{ -296, 392, -944},
{ -288, 336, -920},
{ -288, 328, -912},
{ -280, 352, -920},
{ -280, 328, -928},
{ -272, 312, -920},
// 168 seconds
{ -296, ... |
id dls_list_remove_all(void) {
mutex_lock_recursive(s_list_mutex);
DataLoggingSession *cur = s_logging_sessions;
DataLoggingSession *next;
while (cur != NULL) {
next = cur->next;
if (cur->data) {
mutex_destroy(cur->data->mutex);
kernel_free(cur->data);
}
kernel_free(cur);
cur = n... | if (!callback(logging_session, data)) {
mutex_unlock_recursive(s_list_mutex);
return false;
} |
logging_session = next_logging_session;
}
mutex_unlock_recursive(s_list_mutex);
return true;
}
void dls_list_init(void) {
s_list_mutex = mutex_create_recursive();
s_logging_sessions = NULL;
}
bool dls_list_is_session_valid(DataLoggingSession *logging_session) {
mutex_lock_recursive(s_list_mutex);
... |
pbl_malloc.h"
#include "applib/pbl_std/pbl_std.h"
#include "process_state/app_state/app_state.h"
#include "resource/resource_ids.auto.h"
#include "services/common/clock.h"
#include "services/normal/activity/health_util.h"
#include "util/size.h"
#include "util/string.h"
#include "util/time/time.h"
#include "util/trig.h"... | prv_inset_point(&frame, end_outer_point, fill_thickness) | ;
#if PBL_BW
// Make sure we draw something if we have any steps
if ((start_outer_point.y == end_outer_point.y) && (end_outer_point.x > start_outer_point.x) &&
(end_outer_point.x - start_outer_point.x < 3)) {
end_outer_point.x = start_outer_point.x + 3;
end_inner_point.x = start_inner_point.x + 3;
... |
obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Lice... | menu_layer_set_selected_next(menu_layer, up, MenuRowAlignCenter, animated) | ;
}
static void prv_menu_click_config_provider(MenuLayer *menu_layer) {
// The config that gets passed in, has already the UP and DOWN buttons configured
// we're overriding the default behavior here:
window_single_repeating_click_subscribe(BUTTON_ID_UP, 100 /*ms*/,
(ClickHandler)menu_up_click_handler);
... |
/*
* 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... | ("Performance") | |
/* 2:20am in minutes */);
}
// ---------------------------------------------------------------------------------------
// Test that sleep sessions get registered in the correct day
void test_activity__sleep_history(void) {
// Start activity tracking. This method assumes it can be called from any task, so we mu... | (captured_data, k_raw_samples) | ;
cl_assert_equal_m(raw_data, captured_data, k_raw_samples * sizeof(AccelRawData));
}
// ---------------------------------------------------------------------------------------
// Feed in some raw samples with some runs
{
prv_reset_captured_dls_data();
activity_raw_sample_collection(true, false, &... |
_px == 3 * HORIZ_ADVANCE_PX);
cl_assert(iter_next(&word_iter));
cl_assert(line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 7 * HORIZ_ADVANCE_PX);
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box... | iter_next(&word_iter) | );
cl_assert(!line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX);
// reset line
line = (Line) { 0 };
line.max_width_px = text_box_params.box.size.w;
line.height_px = text_box_params.box.size.h;
c... |
function
// Reuse rect as the title text frame
rect = (GRect) {
.origin = GPoint(cell_layer_bounds_origin_x, title_text_frame_origin_y),
.size = GSize(cell_layer_bounds_size.w, title_text_frame_height)
};
// Accumulate the cap offsets we need to position the title properly
int cap_offsets_to_apply = ... | (0, horizontal_inset + config->horizontal_inset) | |
level %d, app run level %d",
process_metadata_get_name(app_md), s_minimum_run_level,
process_metadata_get_run_level(app_md));
app_install_release_md(app_md);
return false;
}
s_next_app = (NextApp) {
.md = app_md,
.common = config->common,
};
s_next_app.common.transition = prv_... | {
const PebbleProcessMd *default_process = system_app_state_machine_get_default_app();
const AppInstallId current_app_id = s_app_task_context.install_id;
const AppInstallId new_app_id = app_install_get_id_for_uuid(&default_process->uuid);
s_next_app = (NextApp) {
.md = default_process,
};
s_next_app.com... |
const PebbleProcessMd* app_manager_get_current_app_md(void) {
return s_app_task_context.app_md;
}
AppInstallId app_manager_get_current_app_id(void) {
return s_app_task_context.install_id;
}
ProcessContext* app_manager_get_task_context(void) {
return &s_app_task_context;
}
bool app_manager_is_watchface_runnin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_manager_put_launch_app_event(config) | ;
}
static void prv_quick_launch_handler(ClickRecognizerRef recognizer, void *data) {
ButtonId button = click_recognizer_get_button_id(recognizer);
if (!quick_launch_is_enabled(button)) {
return;
}
AppInstallId app_id = quick_launch_get_app(button);
if (app_id == INSTALL_ID_INVALID) {
app_id = app_in... |
LUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_seq = 0;
// Create 2 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
// Create a... | cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, a),... |
ings
cl_assert_equal_i(4, string_list_count(list));
cl_assert_equal_s("", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s("", string_list_get_at(list, 3));
// non-null-terminated string is treated as one... | cl_assert_equal_s("a", string_list_get_at(list, 3)) | ;
}
|
mer->expire_time) {
PBL_ASSERTN(list_contains(manager->running_timers, &timer->list_node));
list_remove(&timer->list_node, &manager->running_timers /* &head */, NULL /* &tail */);
} else {
PBL_ASSERTN(list_contains(manager->idle_timers, &timer->list_node));
list_remove(&timer->list_node, &manager->idl... | list_contains(manager->idle_timers, &timer->list_node) | );
list_remove(&timer->list_node, &manager->idle_timers /* &head */, NULL /* &tail */);
mutex_unlock(manager->mutex);
kernel_free(timer);
}
}
void task_timer_manager_init(TaskTimerManager *manager, SemaphoreHandle_t semaphore) {
*manager = (TaskTimerManager) {
.mutex = mutex_create(),
// Initi... |
*config) {
GTextNode *node = &layout_create_headings_paragraphs_node(layout, config)->container.node;
if (node) {
prv_set_text_node_extent(node, (LayoutNodeExtentConfig *)config);
}
return node;
}
#define METRICS_PER_PAGE 2
typedef struct {
const char *name;
const char *value;
AppResourceInfo *icon_... | graphics_text_node_container_add_child(&vertical_node->container, metric_node) | ;
#if PBL_ROUND
if (index == METRICS_PER_PAGE - 1 && !layout->has_page_break) {
// after filling a page with metric nodes, add a page break
layout->has_page_break = true;
GTextNode *page_break =
&timeline_layout_create_page_break_node((const TimelineLayout *)layout)->node;
graphics_text_node_c... |
n 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 "clar.h"
#include "drivers/hrm.h"
#include "os/tick.h"
#include "services/common/hrm/hrm_manager.h"
#inc... | ARRAY_LENGTH(s_cb_events_1) | ) {
return;
}
s_cb_events_1[s_num_cb_events_1++] = *event;
}
static PebbleHRMEvent s_cb_events_2[16];
static int s_num_cb_events_2 = 0;
static void prv_fake_hrm_2_cb(PebbleHRMEvent *event, void *context) {
if (s_num_cb_events_2 >= ARRAY_LENGTH(s_cb_events_2)) {
return;
}
s_cb_events_2[s_num_cb_events... |
}
}
bool ancs_can_handle_characteristic(BLECharacteristic characteristic) {
if (!s_ancs_client) {
return false;
}
for (int c = 0; c < NumANCSCharacteristic; ++c) {
if (s_ancs_client->characteristics[c] == characteristic) {
return true;
}
}
return false;
}
// -------------------------------... | (length, data) | ;
}
}
void ancs_handle_read_or_notification(BLECharacteristic characteristic, const uint8_t *value,
size_t value_length, BLEGATTError error) {
if (error != BLEGATTErrorSuccess) {
PBL_LOG(LOG_LEVEL_ERROR, "Read or notification error: %d", error);
prv_reset_due_to_bt_err... |
revious message:
if (rtr->bytes_to_ignore) {
const uint32_t num_ignored_bytes = MIN(*data_size_p, rtr->bytes_to_ignore);
rtr->bytes_to_ignore -= num_ignored_bytes;
*data_size_p -= num_ignored_bytes;
if (*data_size_p == 0) {
return true; // we're done
}
*data_p += num_ignored_bytes;
}
... | prv_cleanup_router(rtr) | ;
}
}
}
void comm_session_receive_router_cleanup(CommSession *session) {
ReceiveRouter *rtr = &session->recv_router;
if (rtr->receiver_imp) {
rtr->receiver_imp->cleanup(rtr->receiver);
}
// Wipe it, to avoid confusing ourselves when looking at core dumps:
prv_cleanup_router(rtr);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | app_timer_register((uint32_t)time_until_slice_expires_ms, prv_slice_expiration_timer_cb,
service) | ;
service->next_slice_expiration_time = new_slice_expire_time;
}
static bool prv_glance_cache_slice_expiration_foreach_cb(ListNode *node, void *context) {
LauncherAppGlanceService *service = context;
PBL_ASSERTN(service);
const LauncherAppGlanceCacheEntry *entry = (LauncherAppGlanceCacheEntry *)node;
Launch... |
s under the License.
*/
#include "applib/graphics/graphics_circle.h"
#include "util/trig.h"
#include "clar.h"
#include "pebble_asserts.h"
#include <stdio.h>
// stubs
#include "stubs_process_manager.h"
#include "stubs_passert.h"
#include "stubs_logging.h"
#include "stubs_app_state.h"
#include "stubs_heap.h"
GBitma... | grect_centered_from_polar(container_rect1, mode, 0, GSize(3, 5)) | ;
cl_assert_equal_grect(resulting_rect1, GRect(3, -2, 3, 5));
// Container rect is offset from GPointZero
const GRect container_rect2 = GRect(2, 2, 4, 4);
const GRect resulting_rect2 = grect_centered_from_polar(container_rect2, mode, 0, GSize(2, 4));
cl_assert_equal_grect(resulting_rect2, GRect(3, 0, 2, 4));... |
if (install_id == INSTALL_ID_INVALID) {
return;
} |
mutex_lock_recursive(s_recent_apps.mutex);
{
const time_t cur_time = time_get_uptime_seconds();
RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id);
if (app) {
app->last_activity = cur_time;
app->can_expire = can_expire;
} else {
RecentApp app = {
.id =... | |
ffer[1 + MAX_DATA_LENGTH];
flash_read_bytes(&buffer[1], request->address, request->length);
bool is_all_same = true;
uint8_t same_byte = buffer[1];
for (uint32_t i = 1; i < request->length; i++) {
if (buffer[i + 1] != same_byte) {
is_all_same = false;
break;
}
}
// As an optimization, if... | {
PBL_LOG(LOG_LEVEL_ERROR, "Got unexpected opcode (0x%x)", header->opcode);
} |
prv_reset_buffer(buf);
}
// Receiving (ISR-based)
////////////////////////////////////////////////////////////////////
static bool prv_handle_data(uint8_t data) {
bool should_context_switch = false;
bool hdlc_err;
bool should_store;
bool is_complete = hdlc_streaming_decode(&s_curr_buf->hdlc_ctx, &data, &... |
0_system),
BLEGATTErrorSuccess);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
ppogatt_handle_read_or_notification(s_characteristics[1][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_app, sizeo... | (s_characteristics[0][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_system,
sizeof(s_meta_v0_system),
BLEGATTErrorSuccess) | ;
// Client created:
cl_assert_equal_i(ppogatt_client_count(), 1);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
Transport *client = ppogatt_client_for_uuid(&s_meta_v0_system.app_uuid);
// Rediscovery:
ppogatt_invalidate_all_references();
prv_notify_services_discovered... |
SM128BitKey keys_out[2];
for (SMRootKeyType key_type = 0; key_type < SMRootKeyTypeNum; ++key_type) {
cl_assert_equal_b(shared_prf_storage_get_root_key(key_type, &keys_out[key_type]), true);
// It's a byte array inside, so memcmp should be OK to use:
cl_assert_equal_i(memcmp(&keys[key_type], &keys_out[key... | (requires_address_pinning, true) | ;
cl_assert_equal_i(flags, 0xff);
cl_assert_equal_b(sm_is_pairing_info_equal_identity(&PAIRING_INFO, &pairing_info_out), true);
cl_assert_equal_s(device_name_out, DEVICE_NAME);
// Check getting started
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), GETTING_STARTED_COMPLETE);
// Check... |
/*
* 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... | {
prompt_send_response_fmt(buffer, sizeof(buffer),
"%s {%u args}", cmd->cmd_str, cmd->num_params);
} | else {
prompt_send_response(cmd->cmd_str);
}
}
}
typedef struct CommandArgs {
unsigned int num_args;
const char* args[NUM_SUPPORTED_PARAM_COUNT];
} CommandArgs;
static CommandArgs prv_parse_arguments(char* buffer, char* buffer_end) {
CommandArgs args;
for (int i = 0; i < NUM_SUPPORTED_PARAM_COUN... |
/*
* 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 true;
} |
void fake_resource_syscalls_cleanup(void) {
for (int i = resource_start_index; i <= resource_index; i++) {
FILE *resource_file = resource_files[i];
if (resource_file) {
fclose(resource_file);
resource_files[i] = NULL;
}
}
resource_index = resource_start_index;
}
|
se 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 for the specific langua... | ("pebble_time_steel_gold") | |
{ 0, 0x59, 980, 153},
{ 0, 0x68, 0, 150},
{ 0, 0x68, 36, 153},
{ 0, 0x68, 228, 153},
{ 0, 0x68, 0, 153},
{ 0, 0x68, 37, 150},
{ 0, 0x68, 979, 140},
// 315: Local time: 11:50:00 PM
{ 0, 0x63, 0, 140},
{ 0, 0x62, 468, 151},
{ 0, 0x60, 0, 151},
{ 0, 0x60, 0, 151},
{ 0, 0x60,... | { 0, 0x61, 0, 150},
{ 0, 0x61, 0, 150},
{ 0, 0x61, 0, 150},
{ 0, 0x61, 25, 147},
// 435: Local time: 01:50:00 AM
{ 0, 0x62, 0, 150},
{ 0, 0x62, 0, 150},
{ 0, 0x62, 0, 150},
{ 0, 0x62, 0, 150},
{ 0, 0x62, 0, 140},
{ 0, 0x62, 0, 151},
{ 0, 0x62, 0, 150},
{ 0, 0x62, 0, 1... |
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 146},
// 495: Local time: 02:50:00 AM
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 150},
{ 0, 0x1e, 0, 149},
{ 0, 0x1e, 0, 147},
{ 0, 0x1e, 37, 140},
{ 0, 0x1e, 0, ... |
rt);
cl_assert(line_add_words(&line, &word_iter, NULL));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 0);
cl_assert(line.origin.x == 0);
cl_assert(line.suffix_codepoint == 0);
cl_assert(*line.start == '\n');
// \n
cl_assert(*word_iter_state.current.start == '\n');
cl... | {
// Exit after 2 lines
cl_assert(count == 2);
break;
} |
if (!iter_next(&line_iter)) {
// Should not get here
cl_assert(false);
break;
}
}
}
|
(&data->battery_icon, data->battery_icon_id) | ;
}
}
///////////////////
// Events
static void prv_event_handler(PebbleEvent *e, void *context) {
LauncherMenuData *data = (LauncherMenuData *) context;
prv_reload_status_bar_icons(data);
}
static void prv_subscribe_to_event(EventServiceInfo *result,
PebbleEventType type,
... | |
.rx_dma = &DIALOG_SPI_RX_DMA_REQUEST,
.tx_dma = &DIALOG_SPI_TX_DMA_REQUEST
};
SPISlavePort * const DIALOG_SPI = &DIALOG_SPI_SLAVE_PORT;
//
// iCE40LP configuration
//
static ICE40LPDeviceState s_ice40lp_state;
static ICE40LPDevice ICE40LP_DEVICE = {
.state = &s_ice40lp_state,
.spi_port = &ICE40LP_SPI_SLAVE_P... | voltage_monitor_device_init(VOLTAGE_MONITOR_BATTERY) | |
ware
* 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.
*/
//! This file generates a menu that lets the user select a q... | ("Quick Launch") | |
* SECONDS_PER_MINUTE);
workout_service_frontend_closed();
cl_assert_equal_b(s_hrm_subscribed, false);
cl_assert_equal_i(s_hrm_expiration, 0);
}
// ---------------------------------------------------------------------------------------
void test_workout_service__heart_rate_zone_time(void) {
const int ZONE_0_HR... | (workout_service_get_current_workout_hr_zone_time(hr_zone_time_s)) | ;
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone0], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone1], 20);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 20);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 20);
cl_assert(!workout_service_get_current_workout_hr_zone_time(NULL));
cl_assert(workout_service... |
bool success = true;
AnimationPrivate *parent = animation_private_animation_find(parent_h);
parent->type = type;
// Keep track of which children we added so we can restore them in case of error
bool used_children[array_len];
memset(used_children, 0, sizeof(bool) * array_len);
// Set the parent on each o... | {
if (from->is_property_animation) {
PropertyAnimationPrivate *prop = property_animation_private_clone(
(PropertyAnimationPrivate *)from);
if (prop) {
clone = &prop->animation;
clone->is_property_animation = true;
}
... | |
writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "drivers/gpio.h"
#include "drivers/pe... | (VREF_ADC, DISABLE) | ;
if (!same_adc) {
ADC_Cmd(device->adc, DISABLE);
}
ADC_TempSensorVrefintCmd(DISABLE);
periph_config_disable(VREF_ADC, VREF_ADC_CLOCK);
if (!same_adc) {
periph_config_disable(device->adc, device->clock_ctrl);
}
mutex_unlock(s_adc_mutex);
}
|
break;
}
continue;
}
hw_spi_fifo_write8(s_spi->bus_id, core_dump_connect_response[tx_index++]);
if (tx_index == sizeof(core_dump_connect_response)) {
return true;
}
}
}
// Pulse the INT line to wake the host
host_transport_set... | prv_low_power_mode() | ;
break;
default:
break;
}
}
}
NORETURN core_dump(bool user_requested) {
// Feed the watchdog before we continue
hw_watchdog_set_pos_val(0xFF);
// Disable interrupts, should we not have been called from fault context
portDISABLE_INTERRUPTS();
// Reconfig debug serial
debug_ua... |
d, green, blue, 255)
#define GColorARGB8FromHEX(v) \
GColorARGB8FromRGB(((v) >> 16) & 0xff, ((v) >> 8) & 0xff, ((v) & 0xff))
// if performance ever becomes an issue with this, we can sort the names and to a binary search
T_STATIC const RockyAPIGraphicsColorDefinition s_color_definitions[] = {
// taken from https:/... | GColorARGB8FromHEX(0xadd8e6) | },
{"lightcoral", GColorARGB8FromHEX(0xf08080)},
{"lightcyan", GColorARGB8FromHEX(0xe0ffff)},
{"lightgoldenrodyellow", GColorARGB8FromHEX(0xfafad2)},
// {"lightgray", GColorARGBFromHEX(0xd3d3d3)}, inconsistent with Pebble color
{"lightgreen", GColorARGB8FromHEX(0x90ee90)},
// {"lightgrey", GColorARGBFromHEX(0... |
ght 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 in writing, s... | (&data->direction_layer, "Direction: Up/Down") | ;
} else {
text_layer_set_text(&data->direction_layer, "Direction: Left/Right");
}
if (data->word_wrap) {
frame.size.w = 72;
frame.size.h = 60;
} else {
frame.size.w = 72;
frame.size.h = 32;
}
init_text_layer(data, frame);
if (data->word_wrap) {
text_layer_set_text(&data->word_w... |
.type = SubsectorEraseCommand
};
}
void flash_erase_sector_blocking(uint32_t sector_addr) {
s_command_list[s_command_list_index++] = (EraseCommand) {
.addr = sector_addr,
.type = SectorEraseCommand
};
}
void flash_erase_subsector(uint32_t subsector_addr, FlashOperationCompleteCb cb,
... | prv_test_erase_optimal_range(
0, 4 * 1024, 64 * 1024, 64 * 1024,
(EraseCommand[]) {
{ 0, SectorEraseCommand },
{ },
}) | ;
}
void test_flash_erase__sector_and_subsector(void) {
// Offer a more than a full sector range, needs a sector and a subsector
prv_test_erase_optimal_range(
60 * 1024, 60 * 1024, 2 * 64 * 1024, 2 * 64 * 1024,
(EraseCommand[]) {
{ 60 * 1024, SubsectorEraseCommand },
{ 64 * 1024, Se... |
x.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
void app_install_clear_app_db(void) {
}
void put_bytes_cancel(void) {
}
typedef void (*InstallCallbackDoneCallb... | strncmp((char *)&app3.name, (char *)&temp.name, APP_NAME_SIZE_BYTES) | );
}
void test_app_db__retrieve_app_db_entries_by_install_id(void) {
AppDBEntry temp;
// check app_db_get_install_id_for_uuid for app 1
memset(&temp, 0, sizeof(AppDBEntry));
AppInstallId app_one_id = app_db_get_install_id_for_uuid(&app1.uuid);
cl_assert(app_one_id > 0);
cl_assert_equal_i(S_SUCCESS, app_db... |
te, low-rate job will be scheduled.
static void prv_schedule_ad_job(void) {
BLEAdData *ad = ble_ad_create();
// Advertisement part:
// Centrals will be filtering on Service UUID first. Assuming that the
// central is only doing a scan request if the Service UUID matches with their
// interests, to save radio... | ble_ad_destroy(ad) | ;
}
// -----------------------------------------------------------------------------
bool gap_le_slave_is_discoverable(void) {
bool is_discoverable = false;
bt_lock();
{
is_discoverable = (s_discovery_advert_job != NULL);
}
bt_unlock();
return is_discoverable;
}
// ------------------------------------... |
own
void test_graphics_gpath_${BIT_DEPTH_NAME}__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
s_house_path = gpath_create(&s_house_path_info);
s_bolt_path = gpath_create(&s_bolt_path_info);
s_duplicates_path = gpath_create(&s_duplicates_path_info);... | test_graphics_context_init(&ctx, fb) | ;
s_current_path = s_house_path;
gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH, SCREEN_HEIGHT / 2));
ctx.draw_state.drawing_box = GRect(-SCREEN_WIDTH / 2, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
ctx.draw_state.clip_box = GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitm... |
/*
* 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... | {
bool msg_matches_expected = (memcmp(msg, expected_msg, tot_len) == 0);
cl_assert(msg_matches_expected);
} | |
_card_index, slide_up);
if (next_card_index < 0) {
// Exit
app_window_stack_pop_all(true);
} else if (next_card_index >= CardCount) {
// Top of the list (no-op)
// TODO: maybe we want an animation?
return;
} else {
// animate the cards' positions
prv_schedule_slide_animation(health_ca... | window_deinit(&health_card_view->window) | |
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Se... | kernel_free(s_test_buffer) | ;
}
}
void command_mic_start(char *timeout_str, char *sample_size_str, char *sample_rate_str,
char *volume_str) {
static const int MAX_TIMEOUT = 60;
if (!accessory_manager_set_state(AccessoryInputStateMic)) {
PBL_LOG(LOG_LEVEL_ERROR, "The accessory is already in use!");
return;
... |
/*
* 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 (processor && processor->post) {
processor->post(processor, ctx, bitmap_to_draw, &rect);
} | |
{
if (prv_clocksource_is_lse_started()) {
return true;
}
delay_us(1000);
}
dbgserial_putstr("LSE oscillator did not start");
return false;
}
//! This routine relies on bootbits already having enabled
//! access to the PWR clock and backup domain. Re-enabling
//! it here breaks wakeup for some... | (time_register & (RTC_TR_ST | RTC_TR_SU)) | ;
return (((hours * 60) + minutes) * 60) + seconds;
}
static uint32_t prv_elapsed_ticks(uint32_t before, uint32_t after) {
int32_t result = after - before;
if (result < 0) {
result = (TICKS_IN_INTERVAL - before) + after;
}
return result;
}
void rtc_slow_down(void) {
if (prv_slow_mode()) {
// If w... |
tory*)list_get_tail((ListNode*)s_vibe_history);
if (vibe->time_end == END_NOT_SET) {
vibe->time_end = ((uint64_t)s) * 1000 + ms;
}
mutex_unlock(s_vibe_history_mutex);
}
typedef struct {
ListNode list_node;
uint32_t duration_ms;
int32_t strength;
} VibePatternStep;
static const uint32_t MAX_VIBE_DURAT... | (duration_ms, MAX_VIBE_DURATION_MS) | ;
step->strength = strength;
if (s_vibe_queue_head == NULL) {
s_vibe_queue_head = step;
} else {
list_append((ListNode*)s_vibe_queue_head, (ListNode*)step);
}
mutex_unlock(s_vibe_pattern_mutex);
return true;
}
DEFINE_SYSCALL(bool, sys_vibe_pattern_enqueue_step_raw, uint32_t duration_ms, int32_t ... |
erry_release_value(arg);
mismatch_args[i] = 0;
}
}
static jerry_value_t prv_dummy(const jerry_value_t function_obj_p,
const jerry_value_t this_val,
const jerry_value_t args_p[],
const jerry_length_t args_count) {
retur... | ROCKY_ARG_STR(output, sizeof(output)) | |
/*
* 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... | (left_margin_px, show_action_bar ? 11 : left_margin_px) | |
);
return;
}
// If app_message_outbox_handle_app_outbox_message_sent() has been called with an error,
// don't wait for an (N)ACK (it won't ever come), but finish right away:
outbox->result = result;
prv_transition_to_accepting(outbox);
}
//! Use sys_current_process_schedule_callback to maximize the stac... | PBL_LOG(LOG_LEVEL_ERROR,
"Must call app_message_outbox_send() before calling app_message_outbox_begin() again!") | ;
return APP_MSG_INVALID_STATE;
} else if (phase == OUT_CLOSED) {
PBL_LOG(LOG_LEVEL_ERROR,
"Must call app_message_open() before calling app_message_outbox_begin()!");
return APP_MSG_INVALID_STATE;
}
// Reset the send state (dictionary, counters, etc.)
// We do this here, as this functio... |
"License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
... | (&event_blob) | ;
}
// ------------------------------------------------------------------------------------------
// Log a pin open/create/update event.
static void prv_simple_pin_event(time_t timestamp, const Uuid *parent_id,
AnalyticsEvent event_enum, const char *verb) {
// Format the event speci... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (buffer, (void*)(FMC_BANK_1_BASE_ADDRESS + start_addr), buffer_size) | ;
}
static void flash_s29vs_software_reset(void) {
flash_s29vs_issue_command(0, S29VSCommand_SoftwareReset);
}
void flash_init(void) {
gpio_use(GPIOB);
gpio_use(GPIOD);
gpio_use(GPIOE);
// Configure the reset pin (D2)
GPIO_InitTypeDef gpio_init = {
.GPIO_Pin = GPIO_Pin_2,
.GPIO_Mode = GPIO_Mode_... |
for (size_t i = 0; i < num_points; i++) {
for (size_t j = i + 1; j < num_points; j++) {
int cmp = comparator(&points[i], &points[j], context);
if (reverse ? cmp < 0 : cmp > 0) {
prv_swap_gpoint(&points[i], &points[j]);
}
}
}
}
bool gpointprecise_equal(const GPointPrecise * const ... | (s_r2.origin.y, s_r1.origin.y) | ;
const uint8_t max_x = MAX(s_r2.origin.x + s_r2.size.w,
s_r1.origin.x + s_r1.size.w);
const uint8_t max_y = MAX(s_r2.origin.y + s_r2.size.h,
s_r1.origin.y + s_r1.size.h);
GRect result = GRect(min_x, min_y, max_x - min_x, max_y - min_y);
return result;
}
... |
nt, 0);
cl_assert_equal_p(s_stroke_points, NULL);
cl_assert(prv_compare_points(¢er, s_fill_points, s_path_num_points));
prv_reset();
// restore stroke color and set radius to zero - only a stroke should be drawn
gdraw_command_set_stroke_color(command, GColorPurple);
gdraw_command_set_radius(command, 0)... | gdraw_command_list_get_command(command_list, 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... | (ctx, text, font, *box, overflow_mode, alignment, layout) | ;
} else {
graphics_text_layout_get_max_used_size(ctx, text, font, *box, overflow_mode, alignment,
layout);
}
}
static GSize prv_draw_emoji(GContext *ctx, const GRect *bounds, GFont font, bool render) {
TextLayoutExtended layout = {
.line_spacing_delta = 2, // G... |
ebuffer_is_empty("outside_y_origin_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_x_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_x_y_origin_layer", ctx.parent_framebuffer, GColorWh... | graphics_draw_pixel(ctx, GPoint(p.x + 2, p.y)) | ;
graphics_draw_pixel(ctx, GPoint(p.x + 3, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 4, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 5, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 6, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 7, p.y));
graphics_draw_pixel(ctx, GPoint(p.x + 0, p.y + 1));
graphics_dr... |
/*
* 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(strspn(testbuf, "Hel"), 4) | ;
cl_assert_equal_i(strspn(testbuf, "Heo"), 2);
cl_assert_equal_i(strspn(testbuf, "B"), 0);
cl_assert_equal_i(strspn(testbuf, "Helo!B"), 7);
}
void test_strspn__c_basic(void) {
char testbuf[8] = "Hello!B";
cl_assert_equal_i(strcspn(testbuf, "o!B"), 4);
cl_assert_equal_i(strcspn(testbuf, "o"), 4);
cl_asse... |
3 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
Animation *c = prv_create_test_animation();
animation_set_duration(c, duration_c);
// Create a spawn out of b and c
Animat... | cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, c), 1)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_unload(items_to_unload[i]->window) | ;
applib_free(items_to_unload[i]);
}
}
static void prv_transition_to(Window *window_from, Window *window_to,
const WindowTransitionImplementation *transition) {
PBL_ASSERTN(window_to && transition);
WindowStack *window_stack = window_to->parent_window_stack;
WindowTransitionin... |
bool revert,
bool animated) {
// copies the contents at text into title_text_buffer for display
strncpy(status_bar_layer->config.title_text_buffer, text, TITLE_TEXT_BUFFER_SIZE);
if (revert) { // revert title text back to clock time after STATUS_BAR_LAYER_TITLE_... | (status_bar_layer->config.title_text_buffer,
sizeof(status_bar_layer->config.title_text_buffer)) | |
ue;
s_did_send_byte = true;
PBL_ASSERTN(!s_input_enabled);
while (!(uart_is_tx_ready(ACCESSORY_UART))) continue;
// this section needs to be atomic since the UART IRQ also modifies these variables
portENTER_CRITICAL();
if (s_send_history.has_data) {
// The send buffer is full. This means that the receiv... | prv_disable_dma() | |
,
sizeof(s_session_pin_state.start_utc));
activity_private_settings_close(file);
}
INSIGHTS_LOG_DEBUG("Last sleep reward state: %ld",
s_sleep_reward_state.common.last_triggered_utc);
INSIGHTS_LOG_DEBUG("Last activity reward state: %ld",
s_activi... | activity_prefs_sleep_insights_are_enabled() | ) {
prv_push_reward(now_utc, &SLEEP_REWARD_NOTIF_CONFIG);
}
if (activity_prefs_activity_insights_are_enabled()) {
prv_push_reward(now_utc, &ACTIVITY_REWARD_NOTIF_CONFIG);
}
}
static void prv_test_push_day_insights(void *unused) {
time_t now_utc = rtc_get_time();
for (int i = 0; i < ActivationDelayIn... |
set_complete_remote_initiated();
// Receive malformed ResetComplete:
uint8_t malformed_payload[sizeof(PostMessageResetCompletePayload) - 1] = {};
RCV_APP_MESSAGE(TupletBytes(PostMessageKeyResetComplete,
malformed_payload, sizeof(malformed_payload)));
// Expect Error:
const Post... | prv_init_and_goto_session_open() | ;
EXECUTE_SCRIPT("var isCalled = false;"
"_rocky.on('postmessagedisconnected', function() { isCalled = true; });");
ASSERT_JS_GLOBAL_EQUALS_B("isCalled", false);
RCV_RESET_COMPLETE();
cl_assert_equal_i(rocky_api_app_message_get_state(),
PostMessageStateAwaitingResetCompl... |
uffer, sizeof(buffer),
"%s {%u args}", cmd->cmd_str, cmd->num_params);
} else {
prompt_send_response(cmd->cmd_str);
}
}
}
typedef struct CommandArgs {
unsigned int num_args;
const char* args[NUM_SUPPORTED_PARAM_COUNT];
} CommandArgs;
static CommandArgs prv_parse_argu... | if (UNLIKELY(prompt_command_is_executing())) {
return;
} |
if (LIKELY(c >= 0x20 && c < 127)) {
// Printable character.
if (!prompt_context_append_char(&s_dbgserial_prompt_context, c)) {
dbgserial_putchar(0x07); // bell
return;
}
// Echo
dbgserial_putchar_lazy(c);
return;
}
// Handle unprintable control characters.
if (UNLIKELY(... |
s val
uint8_t val[sizeof(s_ios_pref_db_insert_dict)];
memcpy(val, s_ios_pref_db_insert_dict, sizeof(s_ios_pref_db_insert_dict));
ios_notif_pref_db_insert(key, sizeof(key), val, sizeof(val));
uint32_t flags = ios_notif_pref_db_get_flags(key, sizeof(key));
cl_assert_equal_i(flags, 0);
}
void test_ios_notif_p... | for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
ios_notif_pref_db_store_prefs((uint8_t *)keys[i], key_len, NULL, NULL);
} |
bool is_dirty = false;
cl_assert_equal_i(ios_notif_pref_db_is_dirty(&is_dirty), S_SUCCESS);
cl_assert(is_dirty);
BlobDBDirtyItem *dirty_list = ios_notif_pref_db_get_dirty_list();
cl_assert(dirty_list);
cl_assert(list_count((ListNode *)dirty_list) == ARRAY_LENGTH(keys));
// Mark some items as synced
... |
};
if (s_read_head) {
list_append((ListNode *)s_read_head, &read->node);
} else {
s_read_head = read;
}
return BTErrnoOK;
}
void gatt_client_consume_read_response(uintptr_t object_ref,
uint8_t value_out[],
uint16_t value_leng... | {
s_write_return_value = e;
} |
void fake_gatt_client_op_clear_write_list(void) {
Write *write = s_write_head;
while (write) {
Write *next = (Write *) write->node.next;
free(write->value);
free(write);
write = next;
}
s_write_head = NULL;
}
void fake_gatt_client_op_assert_no_write(void) {
cl_assert_equal_p(s_write_head, N... |
void __attribute__((noreturn)) prv_jump_to_fw(void) {
void *initial_stack_pointer, *reset_handler;
prv_get_fw_reset_vector(&reset_handler, &initial_stack_pointer);
dbgserial_print("Booting firmware @ ");
dbgserial_print_hex((uintptr_t)reset_handler);
dbgserial_newline();
dbgserial_newline();
prv_hw_rese... | (BOOT_BIT_FW_START_FAIL_STRIKE_ONE) | ;
}
return false;
}
static bool prv_check_force_boot_recovery(void) {
if (boot_bit_test(BOOT_BIT_FORCE_PRF)) {
boot_bit_clear(BOOT_BIT_FORCE_PRF);
return true;
}
if (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)) {
dbgserial_putstr("Hold down UP + BACK for 5 secs. to forc... |
ctual callback to trigger.
cl_assert_equal_i(s_out_sent_call_count, 1);
// Check that the state is reset properly after everything
cl_assert_equal_b(app_message_is_accepting_outbound(), true);
}
void test_app_message__cancel_timer(void) {
prv_set_remote_receive_handler(prv_ack_sent_callback);
prv_send_test_... | (s_process_manager_callback_data) | ;
// Check that the ack/nack timer is removed:
cl_assert_equal_p(app_message_outbox_get_ack_nack_timer(), NULL);
cl_assert_equal_i(1, s_out_failed_call_count);
cl_assert_equal_i(s_failure_result, APP_MSG_NOT_CONNECTED);
cl_assert_equal_b(s_nack_sent_is_called, false);
// Check the state is reset properly... |
nst uint16_t backlight_low_power_intensity = (BACKLIGHT_BRIGHTNESS_MAX * (uint32_t)25) / 100;
return low_power_is_active() ? backlight_low_power_intensity : backlight_get_intensity();
}
static void prv_change_brightness(int32_t new_brightness) {
const uint16_t HALF_BRIGHTNESS = (prv_backlight_get_intensity() - BAC... | mutex_lock(s_mutex) | ;
s_num_buttons_down--;
if (s_num_buttons_down < 0) {
PBL_LOG(LOG_LEVEL_ERROR, "More buttons were released than have been pressed.");
s_num_buttons_down = 0;
}
if (s_num_buttons_down == 0 &&
s_light_state == LIGHT_STATE_ON &&
!s_user_controlled_state) {
// no more buttons pressed: wait... |
on return
if (timer->defer_delete) {
mutex_unlock(manager->mutex);
return;
}
// Automatically stop it if it it's not stopped already
if (timer->expire_time) {
timer->expire_time = 0;
PBL_ASSERTN(list_contains(manager->running_timers, &timer->list_node));
list_remove(&timer->list_node, &mana... | } else {
// The next timer hasn't expired yet. Update
ticks_to_wait = next_expiry_time - current_time;
}
} else {
// No timers running
ticks_to_wait = portMAX_DELAY;
}
mutex_unlock(manager->mutex);
if (ticks_to_wait) {
return ticks_to_wait;
}
// R... |
}
void* task_timer_manager_get_current_cb(const TaskTimerManager *manager) {
return manager->current_cb;
}
|
e second sentence
s_test_transcription_example[26] = 0; // invalidate word length of first word in second sentence
result = transcription_validate(validate_test, test_size);
cl_assert_equal_p(result, false);
s_test_transcription_example[26] = 5; // invalidate word length of first word in second sentence
r... | transcription_iterate_sentences((TranscriptionSentence *) sentence_test, 1,
(TranscriptionSentenceIterateCb)prv_cb_return_true, NULL) | ;
cl_assert_equal_p(result, &sentence_test[21]);
s_count = 0;
result = transcription_iterate_sentences((TranscriptionSentence *) sentence_test, 2,
(TranscriptionSentenceIterateCb)prv_cb_return_false, (void *) 0);
cl_assert_equal_p(result, sentence_test);
s_count = 0;
result = transcription_iterate_s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
prv_timer_cleanup(timer_data);
} |
}
static jerry_value_t prv_create_timer(const jerry_value_t *argv,
const jerry_length_t argc,
bool is_repeating) {
if (argc < 1) {
return rocky_error_arguments_missing();
}
jerry_value_t callback = argv[0];
if (!jerry_value_is_fu... |
rotocolEndpoint kernel_nack_endpoint = {
.endpoint_id = APP_MESSAGE_ENDPOINT_ID,
.handler = app_message_app_protocol_system_nack_callback,
.access_mask = PebbleProtocolAccessAny,
.receiver_imp = &g_default_kernel_receiver_implementation,
.receiver_opt = NULL,
};
Receiver *kernel_receiver = g_def... | {
kernel_receiver_finally_cb(receiver->kernel_receiver);
kernel_free(receiver);
} | |
ode) {
if (!node) {
return false;
}
return !node->prev;
}
bool list_is_tail(const ListNode *node) {
if (!node) {
return false;
}
return !node->next;
}
uint32_t list_count_to_tail_from(ListNode* node) {
if (node == NULL) {
return 0;
}
uint32_t count = 1;
while ((node = node->next) != NU... | {
if (!each_cb) {
return;
}
ListNode *iter = head;
while (iter) {
// Save off a pointer so the client to this function can destroy the node (useful for deinits)
ListNode *next = iter->next;
if (!each_cb(iter, context)) {
return;
}
iter = next;
}
} |
void list_debug_dump(ListNode *head) {
ListNode *iter = head;
char buffer[30];
while (iter) {
snprintf(buffer, sizeof(buffer), "node %p (%p, %p)", iter, iter->prev, iter->next);
UTIL_LOG(buffer);
iter = iter->next;
}
}
|
4, 1056, -224},
{ 1176, 912, -144},
{ 1336, 824, -264},
{ 1472, 824, -280},
{ 1592, 608, -160},
{ 1768, 552, -128},
// 51 seconds
{ 1736, 520, -88},
{ 1352, 384, -80},
{ 1112, 296, -88},
{ 960, 200, -32},
{ 808, 144, 24},
{ 736, 120, -32},
{ 664, 32, -112},
{ 808,... | { 1648, 600, 72},
{ 1536, 520, -96},
{ 1168, 432, -128},
{ 968, 336, -32},
{ 896, 232, -64},
{ 832, 168, -40},
{ 744, 144, -56},
{ 688, 136, -32},
{ 824, 128, -40},
{ 832, 104, 16},
{ 1040, 160, -16},
{ 1048, 224, -8},
{ 1296, 288, -160},
{ 1560, 328, -176},
{... |
{ 1704, 288, -88},
{ 1472, 320, -296},
{ 1184, 488, -448},
{ 952, 504, -304},
{ 888, 528, -336},
{ 864, 592, -328},
{ 856, 648, -392},
{ 928, 672, -328},
{ 984, 744, -288},
{ 984, 784, -192},
{ 1168, 768, -184},
{ 1048, 696, -224},
{ 1344, 688, -240},
{ 1728, 648... |
uint8_t *)&hdr,
sizeof(SerializedTimelineItemHeader));
timeline_item_deserialize_header(item_out, &hdr);
return rv;
}
/////////////////////////
// Reminder DB specific API
/////////////////////////
status_t reminder_db_delete_with_parent(const TimelineItemId *parent_id) {
return (timeline_item_storage_delet... | uuid_to_string((Uuid *)key, uuid_buffer) | ;
PBL_LOG(LOG_LEVEL_INFO, "Reminder added: %s", uuid_buffer);
if (rv == S_SUCCESS) {
if (has_reminded) {
reminders_handle_reminder_updated(&hdr->common.id);
} else {
rv = reminders_update_timer();
}
}
return rv;
}
status_t reminder_db_insert_item(TimelineItem *item) {
if (item->heade... |
l_ints[1], ExtiTrigger_Rising,
bmi160_IRQ2_handler);
bmi160_enable_spi_mode();
if (bmi160_query_whoami()) {
prv_run_command(BMI160_CMD_SOFTRESET);
bmi160_enable_spi_mode();
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to query BMI160");
}
prv_set_accel_scale(BMI160_SCALE_4G);
}
bool bmi160... | bmi160_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) {
return true;
}
return false;
}
void bmi16... |
/*
* 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... | find_device_by_conn_idx(conn_idx) | ;
const bool is_bonded = dev ? dev->bonded : false;
storage_release();
return is_bonded;
}
static void prv_device_foreach_search_gateway(const device_t *dev, void *ud) {
bool *has_bonded_gateway = ud;
if (dev->is_gateway) {
*has_bonded_gateway = true;
}
}
static bool prv_has_bonded_gateway(void) {
b... |
/*
* 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(notification_uid, s_expected_uid) | ;
cl_assert_equal_i(action_id, ActionIDNegative);
s_performed_dismiss = true;
}
void test_nexmo__initialize(void) {
s_expected_attributes = NULL;
s_expected_actions = NULL;
s_performed_store = false;
s_expected_uid = INVALID_UID;
s_performed_dismiss = false;
}
void test_nexmo__cleanup(void) {
}
void te... |
m(&link_key_in, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_in, name_out);
cl_assert_equal_i(platform_bits_in, platform_bits_out);
// Now try to read out a pairing that doesn't exist
addr_in.octets[0] = 0xff;
id_out = bt_persistent_storage_get_bt_classic_pairing_by_addr(&addr_in, &link_key_o... | (&addr_in, &link_key_in,
name_in, &platform_bits_in) | ;
cl_assert(id != BT_BONDING_ID_INVALID);
// Delete a pairing that doesn't exist
BTDeviceAddress dummy_addr = {{0xff, 0x11, 0x22, 0x14, 0x15, 0x16}};
bt_persistent_storage_delete_bt_classic_pairing_by_addr(&dummy_addr);
// Make sure the pairing is actually still there
ret = bt_persistent_storage_get_bt_cl... |
f the wrapped read
cl_assert(shared_circular_buffer_read(&buffer, &client, 1, &out_buffer, &out_length));
cl_assert_equal_i(out_length, 1);
cl_assert(memcmp(out_buffer, (uint8_t*) "a", 1) == 0);
cl_assert(shared_circular_buffer_consume(&buffer, &client, 1));
// Consume one without reading it
cl_assert(shar... | (&buffer, &client1, 2, &out_buffer, &out_length) | );
cl_assert_equal_i(out_length, 2);
cl_assert(memcmp(out_buffer, "gh", 2) == 0);
cl_assert(shared_circular_buffer_consume(&buffer, &client1, 2));
cl_assert_equal_i(shared_circular_buffer_get_read_space_remaining(&buffer, &client1), 3);
cl_assert_equal_i(shared_circular_buffer_get_read_space_remaining(&buffe... |
eatherDBKey *key, WeatherDBEntry *entry,
void *context) {
WeatherDBIteratorContext *iterator_context = context;
SerializedWeatherAppPrefs *prefs = iterator_context->serialized_prefs;
char key_string_buffer[UUID_STRING_BUFFER_LENGTH] = {0};
size_t location_index;
if (!prv_... | task_free(forecast->current_weather_phrase) | ;
task_free(forecast);
}
}
static void prv_blobdb_event_handler(PebbleEvent *event, void *context) {
const PebbleBlobDBEvent *blobdb_event = &event->blob_db;
const BlobDBId blobdb_id = blobdb_event->db_id;
if ((blobdb_id != BlobDBIdWeather) && (blobdb_id != BlobDBIdWatchAppPrefs)) {
// Only care about... |
cl_must_pass(settings_file_compact(&file));
}
settings_file_get(&file, (uint8_t *)&j, sizeof(uint32_t),
(uint8_t *)&value, sizeof(uint32_t));
value += 1;
set_and_verify(&file, (uint8_t *)&j, sizeof(uint32_t), (uint8_t *)&value, sizeof(uint32_t));
}
}
// ens... | ((char *)key, sizeof(key), "k%03d", i) | |
indow_stack_pop(true);
window_stack_push(data->hr_window, true /* Animated */);
}
// -------------------------------------------------------------------------------
static void steps_down_long_click_handler(ClickRecognizerRef recognizer, void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)contex... | (ctx, bounds, GOvalScaleModeFitCircle, 15, 0, TRIG_MAX_ANGLE) | ;
graphics_context_set_stroke_color(ctx, GColorJaegerGreen);
graphics_context_set_fill_color(ctx, GColorJaegerGreen);
graphics_fill_radial(ctx, bounds, GOvalScaleModeFitCircle, 15, 0, TRIG_MAX_ANGLE * percent / 100);
}
// -------------------------------------------------------------------------------
static vo... |
unless we're stable and discharging but the % went up.
if (!charging && likely_stable &&
new_charge_percent > s_last_battery_state.percent) {
// It's okay to return early since any connection/plugged changes will reset the filter,
// so we won't catch those.
return;
}
#endif
s_last_battery_sta... | {
return s_periodic_timer_id;
} |
uint16_t battery_state_get_voltage(void) {
return s_last_battery_state.voltage;
}
#include "console/prompt.h"
void command_print_battery_status(void) {
char buffer[32];
PreciseBatteryChargeState state = prv_get_precise_charge_state(&s_last_battery_state);
prompt_send_response_fmt(buffer, 32, "%"PRIu16" mV",... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.