prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
C is
// not 0xFFFFFFFF instead of comparing all bytes.
*(uint32_t *)field = new_crc;
flash_write_bytes(field, prv_current_page_flash_addr() + offset, field_size);
cleanup:
prv_dealloc_struct(data);
}
static void prv_erase_field(size_t offset, size_t field_size) {
SharedPRFData *data = prv_alloc_and_fetch_s... | SPRF_FETCH_FIELD(data, root_keys) | ;
if (!rv) {
goto unlock;
}
SM128BitKey nil_key = {};
if (0 == memcmp(&nil_key, &data.keys[key_type], sizeof(nil_key))) {
rv = false;
goto unlock;
}
if (key_out) {
memcpy(key_out, &data.keys[key_type], sizeof(*key_out));
}
rv = true;
}
unlock:
prv_unlock();... |
key(file, (uint8_t *)&app_id, sizeof(AppInstallId));
data->max_id = MAX(data->max_id, app_id);
data->num_apps++;
return true; // continue iterating
}
struct UuidFilterData {
Uuid uuid;
AppInstallId found_id;
};
//! SettingsFileEachCallback function is used to iterate over all entries and search ... | (&s_app_db.settings_file, prv_enumerate_entries, &cb_data) | ;
prv_close_file_and_unlock_mutex();
kernel_free(db_entry);
return;
}
/////////////////////////
// Blob DB API
/////////////////////////
void app_db_init(void) {
memset(&s_app_db, 0, sizeof(s_app_db));
s_app_db.mutex = mutex_create();
// set to zero to reset unit test static variable.
s_next_unique_fl... |
fig.h"
#include "drivers/pwm.h"
#include "drivers/timer.h"
#include "kernel/util/stop.h"
#include "system/logging.h"
#include "system/passert.h"
// Parameters to a timer based PWM.
//
// ---------------- ---------- ---------- ---------- ----------
// | | | | | ... | {
prv_backlight_pwm_enable(false);
} | |
eTask_Worker) ? "Worker" : "App";
APP_LOG(APP_LOG_LEVEL_ERROR, "%s fault! %s PC: %s LR: %s", process_string, buffer, pc_str, lr_str);
PBL_LOG(LOG_LEVEL_ERROR, "%s fault! %s", process_string, buffer);
PBL_LOG(LOG_LEVEL_ERROR, " --> PC: %s LR: %s", pc_str, lr_str);
analytics_event_app_crash(&crash_info->app_uu... | make_crash_info_pc(stashed_lr) | ;
setup_log_app_crash_info(crash_info);
system_task_add_callback(prv_log_app_lr_and_pc_system_task, &s_current_app_crash_info);
prv_kill_user_process(stashed_lr);
for (;;) {} // Not Reached
}
static void hardware_fault_landing_zone(void) {
prv_log_app_lr_and_pc_system_task(&s_current_app_crash_info);
prv... |
memcmp(copy_out, "01234567", 8) | , 0);
circular_buffer_consume(&buffer, 2);
cl_assert_equal_i(circular_buffer_copy(&buffer, copy_out, copy_out_size), 6);
cl_assert_equal_i(memcmp(copy_out, "234567", 6), 0);
contiguous_num_bytes_left = circular_buffer_write_prepare(&buffer, &data_out);
cl_assert_equal_i(contiguous_num_bytes_left, 2);
memc... | |
(samples_collected < 5) {
return; // wait a few samples for ramp up error to stabilize
}
int16_t new_corr[3];
MagCalStatus cal_status = ecomp_corr_add_raw_mag_sample((int16_t *)&mag_data,
(s_saved_corr_present) ? s_saved_corr : NULL, new_corr);
if (cal_status != MagCalStatusNoSolution) ... | (buffer, sizeof(buffer), "Mx=%d, My=%d, Mz=%d",
s_last_mag_sample.x, s_last_mag_sample.y, s_last_mag_sample.z) | |
{ -952, 96, 104},
{ -1000, 144, 64},
{ -1112, -176, 144},
{ -1040, -320, -16},
{ -1248, 40, -80},
{ -1384, 264, -296},
{ -1536, 592, -504},
{ -1504, 80, 64},
{ -1440, -24, 240},
{ -1272, 472, 96},
{ -896, 504, 96},
{ -816, 416, -16},
{ -904, 384, 56},
{ -880, 200,... | { -1568, 336, 176},
{ -1584, 288, 200},
{ -1408, 192, 208},
{ -1296, 128, 192},
{ -1256, 128, 152},
{ -1160, 128, 136},
{ -1096, 152, 104},
{ -1120, 40, 72},
{ -920, -312, 48},
{ -920, -176, -80},
{ -1232, -16, -88},
{ -1392, 264, -184},
// 39 seconds
{ -1288, 288... |
{ -928, -32, 232},
{ -1216, -8, 64},
{ -912, 328, -400},
{ -1144, 512, -328},
{ -1240, 616, -424},
{ -1736, 456, -400},
{ -1696, 184, 24},
{ -1328, 592, -48},
{ -1144, 504, 32},
{ -1272, 928, 352},
{ -1040, 232, 64},
{ -944, 232, 72},
{ -848, 232, 80},
{ -808, 24... |
(BMA255Register_INT_EN_1, en_value) | ;
prv_update_accel_interrupts(enable_int, AccelOperatingMode_Data);
}
void accel_set_num_samples(uint32_t num_samples) {
// Disable interrupts so they won't fire while we change sampling rate
prv_configure_fifo_interrupts(false, false);
// Workaround some bma255 issues:
// Need to use Standby Mode to read/... | |
10, 15)
#define CENTER_OF_OFFSET_RECT_NXNY GPoint(0, 5)
void test_graphics_stroke_circle_${BIT_DEPTH_NAME}__offset_layer_aa(void) {
#if SCREEN_COLOR_DEPTH_BITS == 8
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Big circles
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, S... | (&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, STROKE_SMALL) | ;
graphics_circle_quadrant_draw_stroked_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornerBottomRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_r8_quad_bottom_right.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, S... |
ed_encoded_msg);
s_saved_encoded_msg = NULL;
}
}
// Flush it out now, this should send any remaining data out
success = protobuf_log_session_flush(session_ref);
cl_assert(success);
if (num_samples_encoded < num_samples) {
if (s_saved_encoded_msg == NULL) {
LOG("No message available yet..... | ARRAY_LENGTH(events) | ,
.events = events,
}
};
prv_common_payload_initialize(&input);
// Create a session
ProtobufLogConfig log_config = {
.type = ProtobufLogType_Events,
};
ProtobufLogTransportCB transport_cb = prv_protobuf_log_transport;
ProtobufLogRef session_ref = protobuf_log_create(&log_config, transport... |
{
return jerry_create_string((const jerry_char_t *)app_get_system_locale());
} |
static jerry_value_t prv_get_fw_version(void) {
WatchInfoVersion fw_version = watch_info_get_firmware_version();
JS_VAR version_major = jerry_create_number(fw_version.major);
JS_VAR version_minor = jerry_create_number(fw_version.minor);
JS_VAR version_patch = jerry_create_number(fw_version.patch);
// Parse... | |
QUADSPI_CCR_IMODE | \
QUADSPI_CCR_ADMODE | \
QUADSPI_CCR_ADSIZE | \
QUADSPI_CCR_ABMODE | \
QUADSPI_CCR_ABSIZE | \
QUADSPI_CCR_DCYC | \
... | if (last_address_aligned < start_address_aligned) {
dma_size = 0;
leading_bytes = length;
trailing_bytes = 0;
} | |
tch);
// reset our state machine
s_hci_cmd_info = (HciCmdInfo) { };
}
}
bool bt_driver_test_selftest(void) {
DialogChipID chip_id;
if (!hc_endpoint_chip_id_query_chip_info(&chip_id)) {
return false;
}
// Sanity check the timestamp that should always be programmed:
return (chip_id.info.timestam... | (tx_channel) | ;
}
void bt_driver_stop_unmodulated_tx(void) {
if (!prv_in_test_mode()) {
return;
}
hc_endpoint_test_unmodulated_tx_test_stop();
}
|
_is_valid(session), true);
fake_session_send_queue_set_length(1234);
cl_assert_equal_i(fake_system_task_count_callbacks(), 0);
comm_session_send_next(session);
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(fake_s... | for (int i = 0; i < (sizeof(int) * 8); ++i) {
CommSessionCapability capability = (1 << i);
cl_assert_equal_b(false, comm_session_has_capability(session, capability));
} | |
/*
* 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... | {
const bool first = (s_state.handler == NULL);
s_state = (TickTimerServiceState) {
.handler = handler,
.tick_units = tick_units,
.first_tick = true,
};
if (first && handler != NULL) {
prv_schedule_next_update();
}
} | |
t num_samps = s_le_conn_params.num_samps;
if (num_samps != 0) {
params[0] = s_le_conn_params.slave_latency_events / num_samps;
params[1] = s_le_conn_params.supervision_to_ms / num_samps;
}
s_le_conn_params = (LeConnectionParams){};
}
static void prv_update_conn_params(uint16_t slave_latency_events,
... | analytics_add(ANALYTICS_DEVICE_METRIC_BLE_RSSI_SUM,
ABS(rssi), AnalyticsClient_System) | |
/*
* 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 (decimal_divisor > 1) {
result /= (decimal_divisor / base);
const bool round_up = ((ABS(result) % base) >= (base / 2));
result /= base;
if (round_up) {
if (result > 0) {
++result;
} else {
--result;
}
}
} | |
date(command_list, size));
free(command_list);
}
void test_gdraw_command__validate_image(void) {
size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6);
GDrawCommandImage *image = malloc(size);
GDrawCommandList *command_list = prv_create_command_list_3();
memcpy(&... | prv_reset() | ;
gdraw_command_frame_draw(ctx, NULL, frame, GPoint(-1, 1));
cl_assert_equal_i(s_path_num_points, 2);
points[0] = GPoint(0, 2);
points[1] = GPoint(1, -1);
cl_assert(prv_compare_points(points, s_stroke_points, s_path_num_points));
cl_assert(prv_compare_points(points, s_fill_points, s_path_num_points));
fr... |
/*
* 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, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appear,
.unload = prv_window_unload,
}) | ;
window_set_click_config_provider_with_context(window, prv_click_config_provider, data);
const bool animated = true;
app_window_stack_push(window, animated);
}
static void prv_deinit(void) {
MorphSquareDemoData *data = app_state_get_user_data();
app_free(data);
}
///////////////////////////
// App boiler... |
/*
* 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... | (c->next_erased_item_idx <= c->total_items) | ;
if (c->next_erased_item_idx == c->total_items) {
c->next_erased_item_idx = 0;
}
}
void circular_cache_fill(CircularCache *c, uint8_t *item) {
// If you need item_destructor and fill, add an index pointing to the oldest item for destruction
UTIL_ASSERT(c->item_destructor == NULL);
for (int i = 0; i < c-... |
/*
* 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 (++i > QSPI_WAIT_TIME) {
break;
} | |
l_assert_equal_i(r->state, RecognizerState_Failed);
cl_assert_equal_b(cancelled, false);
cl_assert_equal_i(rec_event, -1);
r->state = RecognizerState_Cancelled;
recognizer_cancel(r);
cl_assert_equal_i(r->state, RecognizerState_Cancelled);
cl_assert_equal_b(cancelled, false);
cl_assert_equal_i(rec_event, ... | cl_assert_equal_i(last_touch_event.type, TouchEvent_Touchdown) | ;
cl_assert_equal_b(updated, true);
cl_assert_equal_i(rec_event, RecognizerEvent_Completed);
}
static bool prv_filter(const Recognizer *recognizer, const TouchEvent *touch_event) {
bool *allow = recognizer_get_user_data(recognizer);
return *allow;
}
void test_recognizer__handle_touch_events_filter_cb(void) {
... |
320},
{ 168, 840, 288},
{ 176, 824, 272},
{ 176, 848, 312},
{ 160, 848, 344},
{ 144, 848, 304},
{ 160, 888, 280},
{ 176, 848, 296},
{ 184, 832, 304},
// 296 seconds
{ 176, 856, 304},
{ 160, 864, 280},
{ 152, 848, 264},
{ 176, 864, 256},
{ 176, 848, 320},
{ 16... | { 144, 880, 88},
{ 128, 912, 152},
{ 104, 904, 152},
{ 104, 904, 136},
{ 96, 888, 120},
{ 104, 912, 112},
{ 128, 912, 120},
{ 120, 912, 128},
{ 120, 896, 120},
{ 120, 912, 104},
{ 120, 920, 112},
{ 128, 896, 120},
{ 128, 904, 160},
{ 112, 912, 144},
{ 120, 952... |
// 304 seconds
{ 224, 848, 304},
{ 232, 832, 264},
{ 240, 824, 224},
{ 208, 840, 248},
{ 216, 872, 264},
{ 216, 864, 280},
{ 224, 880, 264},
{ 216, 856, 248},
{ 208, 856, 208},
{ 216, 896, 184},
{ 200, 952, 160},
{ 160, 1008, 88},
{ 136, 1160, 32},
{ 112, 936... |
/*
* 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... | {
// Middle of flash has 64k lock units
block_addr = flash_impl_get_sector_base_address(block_addr);
block_size = SECTOR_SIZE_BYTES;
} | else {
// Start and end of flash have 1 sector of 4k lock units
block_addr = flash_impl_get_subsector_base_address(block_addr);
block_size = SUBSECTOR_SIZE_BYTES;
}
const status_t sc = qspi_flash_lock_sector(QSPI_FLASH, block_addr);
if (FAILED(sc)) {
return sc;
}
block_addr ... |
Odd rows of different lengths
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);... | GPoint(0, 1) | , MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), MAX_NUM_COLS + 4);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 7), 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 9), 2);
graphics_draw_horizontal_line_dott... |
r = err * 100.0 / exp_distance_m;
printf("\nTest %d: height:%d, steps:%d, seconds:%.1f, exp_distance:%d, exp_distance_2min:%d, "
"act_distance_2min:%"PRIu32", pct_err: %.2f%% \n", i, params->height_in, params->steps,
params->seconds, params->exp_distance_m, exp_distance_m, value, pct_err);
... | cl_assert(last_update_utc >= rtc_get_time() - 1) | ;
cl_assert(last_update_utc <= rtc_get_time());
// Should still be sampling every 1 second
cl_assert_equal_i(s_hrm_manager_update_interval, 1);
// Tick one more second, should trigger slow sampling
prv_advance_time_hr(1, 100 /*bpm*/, HRMQuality_Good, false /*force_continuous*/);
// Should be back to no sa... |
);
battery_monitor_init();
periodic_timer_trigger(1);
cl_assert(!battery_monitor_critical_lockout());
fake_battery_set_millivolts(critical_mv);
periodic_timer_trigger(25);
cl_assert(battery_monitor_critical_lockout());
cl_assert_equal_i(standby_timer_get_timeout(), 30000);
standby_timer_trigger(1);
... | periodic_timer_trigger(1) | ;
cl_assert_equal_i(battery_get_charge_state().charge_percent, 100);
}
void test_battery_monitor__battery_get_charge_state(void) {
// range through all discrete percentages and verify that battery_get_charge_state()
// returns sane values
BatteryChargeState result;
uint8_t last_charge_percent = 0;
uint8_t ... |
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, &da... |
st_add_cstring(&list, AttributeIdBody,
"Cloudy with rain and snow. High 1C. Winds light and variable. "
"Chance of precip 100%. 3-7cm of snow expected.");
attribute_list_add_uint32(&list, AttributeIdLastUpdated, now);
if (!has_timestamp) {
attribute_list... | (&list, AttributeIdHeadings, &headings) | ;
attribute_list_add_string_list(&list, AttributeIdParagraphs, ¶graphs);
attribute_list_add_cstring(&list, AttributeIdBody,
"Topics for the week can be found here: "
"http://docs.google.com/u/1/#inbox/14b9fa5f872ebbc6\n\n"
"W... |
, &light);
} else if (state->test_entry.version == 3) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d, %d", &steps, &orientation, &vmc,
&light, &plugged_in);
} else {
cl_assert(false);
}
fflush(stdout);
PBL_ASSERTN(state->test_entry.num_samples < SLEEP... | {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} | |
/*
* 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... | ("pebble_time_white") | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ERROR, "Unhandled %s", 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... | {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, DISABLE);
} |
static void prv_flash_start(void) {
gpio_use(FLASH_CONFIG.spi_gpio);
// Enable the GPIOA clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
uint8_t altfunc = GPIO_AF_SPI1;
// Connect pins to their SPI functionality
GPIO_PinAFConfig(FLASH_CONFIG.spi_gpio, FLASH_CONFIG.sclk_pin, altfunc);
GPIO... |
/*
* 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_glance_db_init() | |
MS = 10;
delay_ms(MIN_STOP_TIME_MS);
bus_pin_cfg_input(BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_scl);
bus_pin_cfg_input(BOARD_CONFIG.i2c_bus_configs[bus_idx].i2c_sda);
BOARD_CONFIG.i2c_bus_configs[bus_idx].rail_ctl_fn(true);
}
//! Initialize the I2C peripheral
//! Lock the bus and peripheral config access b... | {
PBL_ASSERTN(s_initialized);
PBL_ASSERT(device_id < BOARD_CONFIG.i2c_device_count, "I2C device ID out of bounds %d (max: %d)",
device_id, BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
bus_lock(bus);
if (bus->user_count ... |
void i2c_release(I2cDevice device_id) {
PBL_ASSERTN(s_initialized);
PBL_ASSERTN(device_id < BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
bus_lock(bus);
if (bus->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted rel... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_ASSERTN(array && num);
size_t i = 0;
while (i < *num) {
if (array[i] == NULL) {
for (size_t j = i + 1; j < *num; j++) {
array[j-1] = array[j];
}
(*num)--;
} else {
i++;
}
}
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (sizeof(AlarmNode)) | ;
list_init((ListNode*) new_node);
new_node->id = id;
new_node->info = *info;
memcpy(&new_node->scheduled_days, info->scheduled_days, sizeof(new_node->scheduled_days));
new_node->info.scheduled_days = &new_node->scheduled_days;
data->alarm_list_head = (AlarmNode *)list_sorted_add((ListNode *)data->alarm_lis... |
ndler_entries(&s_stopped_handler_calls, b2), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b3), 1);
// Make sure the all the spawn a stopped handlers got called before any of the spawn b
// started handlers
uint32_t last_fire_a = 0;
last_fire_a = MAX(last_fire_a,
... | cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Just before A completes
prv_advance_to_ms_with_timers(start_ms + delay_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (__data_start, __data_load_start, __data_end - __data_start) | ;
// Clear the bss section, assumes .bss goes directly after .data
memset(__bss_start, 0, __bss_end - __bss_start);
#if MICRO_FAMILY_STM32F7
// Clear the DTCM bss section
memset(__dtcm_bss_start, 0, __dtcm_bss_end - __dtcm_bss_start);
#endif
SystemInit();
icache_enable();
dcache_enable();
main();
... |
draw_arc(GContext *ctx, GRect rect, GOvalScaleMode scale_mode,
int32_t angle_start, int32_t angle_end) {
GPointPrecise center;
Fixed_S16_3 radius;
grect_polar_calc_values(&rect, scale_mode, ¢er, &radius);
graphics_draw_arc_precise_internal(ctx, center, radius, angle_start, angle_end);... | PBL_ASSERTN(ctx) | ;
if (ctx->lock) {
return;
}
if (radius == 0) {
// Filling a circle of radius zero should just draw a single pixel.
// Backup the stroke color and set that to the current fill color since the stroke color
// is what is used for draw pixel. Restore the stroke color afterwards.
GColor backup_st... |
(&l, true) | ;
menu_layer_reload_data(&l);
const int focused_height = MENU_CELL_ROUND_FOCUSED_TALL_CELL_HEIGHT;
// focus last row
menu_layer_set_selected_index(&l, MenuIndex(0, s_num_rows - 1), MenuRowAlignNone, false);
cl_assert_equal_i(focused_height, l.selection.h);
s_num_rows--;
cl_assert_equal_i(2, s_num_rows);... | |
/*
* 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... | atoi(length_str) | ;
if (length == 0) {
prompt_send_response("Invalid length");
return;
}
// Temporarily turn on logging so the hexdump comes out.
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
uint8_t buffer[128];
while (length) {
uint32_t chunk_size = MIN(length, 128);
flash_read_bytes(buffer, ad... |
ents should survive air plane mode toggles:
if (hci_reason != GAPLEConnectHCIReasonExtensionAirPlaneMode) {
client->is_used = false;
}
}
if (client->connected != connected) {
if (client->is_pairing_required &&
event == GAPLEConnectionEventConnectedNotEncrypted) {
// ... | prv_put_legacy_connection_event(&event->peer_address, true /* connected */) | ;
}
if (gap_le_connection_is_connected(&event->peer_address)) {
// We have seen this crop up for cases where the phone has disconnected due to a timeout
// but the watch has not yet. In practice, I think the only way it could happen is if a
// user is sitting in the Bluetooth settin... |
PebbleTask pebble_task, TaskParameters_t *task_params,
TaskHandle_t *handle) {
}
void * process_loader_load(const PebbleProcessMd *app_md, PebbleTask task,
MemorySegment *segment) {
if (app_md == (PebbleProcessMd *)&s_borked_app) {
return NULL;
} else {
retu... | {
test_app_manager__start_first();
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = &s_third_party_app.common,
});
// We've sent the deinit event to the first app, but it's going to continue running.
cl_assert_equal_i(s_last_to_app_event.type, PEBBLE_PROCESS_DEINIT_EVENT);
cl_assert(app_manager_g... |
void test_app_manager__start_third_party_and_crash_back_to_root(void) {
test_app_manager__start_third_party();
// Simulate a crash
app_manager_get_task_context()->safe_to_kill = true;
app_manager_close_current_app(false /* gracefully */);
cl_assert(app_manager_get_current_app_md() == (PebbleProcessMd*) &s... |
// Bus did not recover after reset
stop_mode_enable(bus->stop_mode_inhibitor);
mutex_unlock(bus->state->bus_mutex);
PBL_LOG(LOG_LEVEL_ERROR, "I2C bus did not recover after reset (%s)", bus->name);
prv_analytics_track_i2c_error();
return false;
}
}
// Take binary semaphore so... | PBL_ASSERTN(slave) | |
t_cache,
text_box_params->font, HYPHEN_CODEPOINT);
int truncated_word_length_px = (line->width_px - suffix_width_px);
PBL_ASSERTN(word->width_px >= truncated_word_length_px);
word->width_px -= truncated_word_length_px;
word->start = utf8_get_next(last_visited);
return false;
}
if (!is_... | (text_box->font) |
};
Iterator line_iter;
line_iter_init(&line_iter, &ctx->text_draw_state.line_iter_state, ctx);
prv_walk_lines_down(&line_iter, layout, callbacks);
}
static void prv_graphics_text_layout_update(GContext* ctx, const char* text, GFont const font,
const GRect box, con... |
/*
* 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_push_language_changed_dialog, (void *)lang_name) | ;
}
|
sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(12, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 6), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 7), 10);
graphics_draw_vertical_line_dotted(&ctx, GPoint(24, 7), 10);
cl_che... | graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 7), 10) | ;
graphics_draw_vertical_line_dotted(&ctx, GPoint(24, 7), 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_no_clip")));
// Even cols of different lengths
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_ODD, OFFSET_RECT_ODD, false, 1);
graphics_draw_vertical_... |
{
return 0;
}
return entry->impl->read(entry, offset, data, num_bytes);
}
static void prv_get_manifest(ResourceStoreEntry *entry, ResourceManifest *manifest) {
if (prv_read(entry, 0, manifest, sizeof(ResourceManifest)) != sizeof(ResourceManifest)) {
*manifest = (ResourceManifest){0};
}
}
static bool p... | {
PBL_LOG(LOG_LEVEL_DEBUG, "Out of bound resource %"PRId32" vs %"PRId32,
entry->id, manifest->num_resources);
return false;
} |
ResTableEntry table_entry = {0};
if (!prv_read_res_table_entry(&table_entry, entry, entry->id - 1)) {
return false;
}
if (entry->id != table_entry.resource_id) {
PBL_LOG(LOG_LEVEL_ERROR, "Resource table entry for %" PRIx32 " is corrupt!"
"(%"PRIx32" != %"PRIx32")", resource_id, entry->id, table... |
/*
* 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_DEBUG, "ble_gattc_discover_cancel: %u", e);
} |
}
void hc_endpoint_discovery_send_service_found(
const HcProtocolDiscoveryServiceFoundPayload *payload, uint32_t payload_size) {
// Note: kind of wasteful double copy here, a service node could get sort of
// big (several hundred bytes)
hc_protocol_enqueue_with_payload(HcEndpointID_Discovery, HcMessageID_Di... |
* SECONDS_PER_MINUTE), now,
HealthIterationDirectionPast, prv_activity_cb, NULL);
cl_assert_equal_i(7, s_prv_activity_cb__call_count);
cl_assert_equal_i(s_prv_activity_cb__args[0].time_start,
s_sys_activity_get_sessions_values.out.sessions[1].start_utc);
cl... | health_service_get_minute_history(NULL, ARRAY_LENGTH(data), &time_start, &time_end) | ;
cl_assert_equal_i(0, written);
// empty boundary
written = health_service_get_minute_history(data, 0, &time_start, &time_end);
cl_assert_equal_i(0, written);
// empty start
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), NULL, &time_end);
cl_assert_equal_i(0, written);
// empt... |
yer_get_hidden((Layer *)&data->mic_window.progress_bar)) {
return;
}
progress_layer_set_progress((ProgressLayer *)&data->mic_window.progress_bar, 0);
animation_unschedule((Animation *)data->mic_window.progress_anim);
data->mic_window.progress_anim = prv_create_int16_prop_anim(0, MAX_PROGRESS_FUDGE_AMOUNT,
... | (data, StateRecording) | ;
break;
case StateRecording:
// do nothing
break;
case StateStopRecording:
prv_set_mic_window_state(data, StateWaitForResponse);
break;
case StateStopWaitForResponse:
prv_set_mic_window_state(data, StateTransitionToText);
break;
case StateTransitionToText: ... |
/*
* 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... | ascii_hex_to_int(msb) | + ascii_hex_to_int(lsb);
}
uintptr_t str_to_address(const char *address_str) {
char *endptr;
uintptr_t address = strtoul(address_str, &endptr, 0);
if (*endptr != '\0') { // A non-address character encountered
return -1;
}
return address;
}
bool convert_bt_addr_hex_str_to_bd_addr(const char *hex_str, ui... |
if (i2c_hal_is_busy(bus)) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for bus %s to become non-busy", bus->name);
return false;
}
}
return true;
}
//! Set up and start a transfer to a bus, wait for it to finish and clean up after the transfer
//! has completed
static bool prv_do_transfer(I2CBu... | (bus->state) | |
) {
bt_driver_start_unmodulated_tx(atoi(tx_channel));
}
void command_btle_unmod_tx_stop(void) {
bt_driver_stop_unmodulated_tx();
}
void command_btle_test_le_tx_start(
char *tx_channel, char *tx_packet_length, char *packet_payload_type) {
bt_driver_le_transmitter_test(
atoi(tx_channel), atoi(tx_packet_... | (ctx, GPoint(DISP_COLS/4, 0), GPoint(DISP_COLS, DISP_ROWS)) | ;
// ~39 degrees
graphics_draw_line(ctx, GPoint(0, DISP_ROWS/5), GPoint(DISP_COLS, DISP_ROWS));
profiler_stop();
uint32_t total_time = profiler_get_total_duration(false);
uint32_t us = profiler_get_total_duration(true);
char buf[80];
prompt_send_response_fmt(buf, sizeof(buf),
"... |
"
#include "text_resources.h"
#include "utf8.h"
#include "applib/fonts/codepoint.h"
#include "applib/fonts/fonts.h"
#include "kernel/ui/kernel_ui.h"
#include "process_state/app_state/app_state.h"
#include "applib/applib_malloc.auto.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include ... | prv_char_iter_next_start_of_word(&char_iter) | ;
if (!success) {
// We couldn't find the next start of the word, just initialize to nothing
word->start = start;
word->end = start;
return false;
}
// Init the word & state
word->start = utf8_iter_state->current;
WordState state = WordStateStart;
state = word_state_update(state, utf8_iter... |
0x55, 0x65, 0x72, 0x22, 0xb4,
0x40, 0x01, // Size value
// value (made up for now)
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4, 0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4,
0x8c, 0x31, 0x4f, ... | (s_insert_cmd_zero_key_size, sizeof(s_insert_cmd_zero_key_size)) | ;
// Check Response
cl_assert(0 < *(uint16_t*)resp_ptr);
resp_ptr += sizeof(uint16_t);
cl_assert(BLOB_DB_INVALID_DATA == *resp_ptr);
resp_ptr += sizeof(uint8_t);
cl_assert((resp_ptr - s_data) == s_sending_data_length);
}
/**************************************************
* Checking for value size of z... |
_window);
client->out.tx_window_size = MIN(client->out.tx_window_size, payload->ppogatt_max_rx_window);
client->out.rx_window_size = MIN(client->out.rx_window_size, payload->ppogatt_max_tx_window);
}
}
PBL_LOG(LOG_LEVEL_DEBUG, "Hurray! PPoGATT Session is opened (Vers: %d TXW: %d RXW: %d)!",
... | {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid type %u", packet->type);
return;
} |
if (UNLIKELY(packet->type) == PPoGATTPacketTypeResetRequest) {
PBL_LOG(LOG_LEVEL_INFO, "Got reset request!");
prv_handle_reset_request(client);
return;
}
if (LIKELY(client->state == StateConnectedOpen)) {
if (LIKELY(packet->type == PPoGATTPacketTypeData)) {
prv_handle_data(client, packet, v... |
+
sizeof(GDrawCommand) * num_commands +
sizeof(c0_points) + sizeof(c1_points) + sizeof(c2_points)+ sizeof(c3_points) +
sizeof(c4_points));
*image = (GDrawCommandImage){
.version = 1,
.size = GSize(48, 48),
.command_list = (GDrawCommandList) {
.num_commands = ... | memcpy(c2->points, c2_points, sizeof(c2_points)) | ;
GDrawCommand *c3 = gdraw_command_list_get_command(list, 3);
*c3 = *c0;
memcpy(c3->points, c3_points, sizeof(c3_points));
GDrawCommand *c4 = gdraw_command_list_get_command(list, 4);
*c4 = (GDrawCommand){
.type = GDrawCommandTypePath,
.stroke_color = GColorBlack,
.stroke_width = 3,
.... |
/*
* 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... | {
_clar_path[len++] = '/';
} |
strncpy(_clar_path + len, path_tail, sizeof(_clar_path) - len);
#if defined(__MINGW32__)
if (_mktemp(_clar_path) == NULL)
return -1;
if (mkdir(_clar_path, 0700) != 0)
return -1;
#elif defined(_WIN32)
if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
return -1;
if (mkdir(_clar_path, 0700) != 0)
retur... |
{ -80, -232, -976},
{ -88, -224, -984},
{ -80, -224, -984},
{ -88, -224, -992},
{ -80, -224, -984},
{ -80, -224, -984},
{ -80, -232, -984},
{ -80, -224, -976},
{ -80, -224, -984},
{ -80, -224, -984},
{ -88, -232, -984},
{ -80, -224, -984},
{ -80, -224, -984},
{ -8... |
{ 0, 96, -976},
{ 0, 104, -984},
{ 8, 88, -976},
{ 0, 96, -984},
{ 8, 80, -976},
{ 8, 88, -976},
// 259 seconds
{ 0, 80, -984},
{ -8, 80, -968},
{ 16, 96, -976},
{ -8, 80, -976},
{ 8, 64, -984},
{ -8, 72, -984},
{ 0, 88, -968},
{ 8, 88, -976},
{ 0, 64, -9... | |
*notif_prefs,
time_t timestamp,
ANCSProperty properties) {
const ANCSAttribute *app_id = notif_attributes[FetchedNotifAttributeIndexAppID];
const ANCSAttribute *display_name = app_attributes[FetchedAppAttributeIndexDisplayName]... | prv_should_hide_reply_because_group_sms(action, app_id, subtitle) | ) {
continue;
}
attributes_per_action[action_idx++] = action->attr_list.num_attributes;
}
}
int num_attr = ((title && title->length > 0 && !has_multimedia) ? 1 : 0) +
((display_name && display_name->length > 0) ? 1 : 0) +
((subtitle->length > 0) ? 1 : 0) +... |
on_create_layer_frame(&menu_layer->inverter.layer,
&from, &target);
animation_set_duration(a1, 100);
animation_set_curve(a1, AnimationCurveEaseOut);
animation_set_auto_destroy(a1, true);
// Step 2. Skip the top of the highlight down to the t... | (&menu_layer->scroll_layer, GPoint(0, y), animated) | ;
}
}
typedef struct MenuSelectIndexIterator {
MenuIterator it;
MenuCellSpan selection;
bool did_change_selection:1;
} MenuSelectIndexIterator;
static void prv_menu_layer_iterator_selection_index_callback(MenuIterator *iterator) {
MenuSelectIndexIterator *it = (MenuSelectIndexIterator*)iterator;
if (!menu... |
LOG(LOG_LEVEL_WARNING,
"Failed to deserialize an AttributeList from a serialized slice");
return false;
}
// Check if the AttributeList has the attributes required for the slice
const bool is_attr_list_valid = prv_is_slice_attribute_list_valid(serialized_slice->type,
... | mutex_lock(s_app_glance_db.mutex) | ;
const status_t rv = settings_file_open(&s_app_glance_db.settings_file, SETTINGS_FILE_NAME,
SETTINGS_FILE_SIZE);
if (rv != S_SUCCESS) {
mutex_unlock(s_app_glance_db.mutex);
}
return rv;
}
static void prv_close_file_and_unlock_mutex(void) {
settings_file_close(&s_... |
const uint16_t TEXT_OFFSET = 6;
x = left_margin_px;
y = (icon ? icon_offset + icon_size.h : -TEXT_OFFSET) + header_content_height;
w = frame.size.w - right_margin_px - left_margin_px - action_bar_offset
- right_aligned_box_reduction;
h = INT16_MAX; // height is clamped to content size
GFont font = fon... | (
indicator, ContentIndicatorDirectionUp,
&(ContentIndicatorConfig) {
.layer = &expandable_dialog->dialog.status_layer.layer,
.times_out = true,
.colors.foreground = dialog->text_color,
.colors.background = dialog->window.background_color,
}) | |
threshold,
&state->cache->alert_threshold_heart_rate);
return (void *)HealthMetricHeartRateBPM;
default:
return NULL;
}
#endif
}
// ----------------------------------------------------------------------------------------------
bool health_service_cancel_metric_alert(Healt... | if (!sys_activity_get_metric(ActivityMetricSleepState, 1, &sleep_state)) {
return HealthActivityNone;
} |
HealthActivityMask result = HealthActivityNone;
if (sleep_state == ActivitySleepStateLightSleep) {
result |= HealthActivitySleep;
}
// yes, when sleeping restful, there's also always an activity of HealthActivitySleep
// when calling health_service_activities_iterate()
if (sleep_state == ActivitySleep... |
*prefs_out, prefs_len);
if (rv != S_SUCCESS) {
kernel_free(*prefs_out);
return 0;
}
return (prefs_len - sizeof(SerializedNotifPrefs));
}
static void prv_free_serialzed_prefs(SerializedNotifPrefs *prefs) {
kernel_free(prefs);
}
iOSNotifPrefs* ios_notif_pref_db_get_prefs(const uint8_t *app_id, int key_... | {
SettingsFile file;
status_t rv = prv_file_open_and_lock(&file);
if (rv != S_SUCCESS) {
return rv;
}
size_t payload_size = attributes_actions_get_serialized_payload_size(attr_list, action_group);
size_t serialized_prefs_size = sizeof(SerializedNotifPrefs) + payload_size;
SerializedNotifPrefs *new_pr... |
void ios_notif_pref_db_init(void) {
s_mutex = mutex_create();
PBL_ASSERTN(s_mutex != NULL);
}
status_t ios_notif_pref_db_insert(const uint8_t *key, int key_len,
const uint8_t *val, int val_len) {
if (key_len == 0 || val_len == 0 || val_len < (int) sizeof(SerializedNotifPrefs))... |
erry_char_t *)data_buffer, str_size);
OutgoingObject * const obj = task_zalloc(sizeof(*obj));
if (!obj) {
task_free(data_buffer);
return prv_create_oom_error();
}
*obj = (OutgoingObject) {
.data_buffer = data_buffer,
};
const bool is_first = prv_object_queue_add(obj);
if (is_first) {
if ... | prv_handle_callback_registration(event_name, handler) | ;
}
const RockyGlobalAPI APP_MESSAGE_APIS = {
.init = prv_init_apis,
.deinit = prv_deinit_apis,
.add_handler = prv_add_handler,
};
////////////////////////////////////////////////////////////////////////////////
// Unit Test Helpers
//////////////////////////////////////////////////////////////////////////////... |
4, 408, -168},
{ 1232, 336, -88},
{ 1232, 288, -96},
{ 1096, 280, -88},
{ 840, 224, -48},
{ 720, 168, -96},
{ 656, 120, -72},
{ 648, 128, -32},
{ 744, 128, -80},
{ 752, 88, -48},
{ 968, 96, -72},
{ 1056, 104, -64},
{ 1048, 120, -104},
{ 1256, 144, -160},
{ 1128, 2... | { 1184, 496, -208},
{ 1152, 488, -224},
{ 1072, 400, -200},
// 48 seconds
{ 1256, 408, -192},
{ 1192, 424, -184},
{ 1136, 424, -168},
{ 1120, 368, -128},
{ 1168, 312, -80},
{ 1088, 240, -24},
{ 848, 184, 8},
{ 712, 176, -56},
{ 712, 168, -56},
{ 776, 152, -16},
... |
{ 736, 224, -24},
{ 744, 224, 32},
{ 864, 496, 72},
{ 864, 616, -32},
{ 896, 824, -72},
{ 1072, 904, -224},
{ 1096, 1000, -232},
{ 1320, 944, -392},
{ 1216, 792, -512},
{ 1008, 472, -496},
{ 912, 176, -560},
// 51 seconds
{ 816, 8, -624},
{ 584, -72, -600},
{... |
s.h"
#include "util/crc32.h"
#include "util/misc.h"
#include "util/misc.h"
#include "util/net.h"
#include <stdbool.h>
#define MAX_MESSAGE (256)
#define FRAME_DELIMITER '\x55'
#define PULSE_TRANSPORT_PUSH (0x5021)
#define PULSE_PROTOCOL_LOGGING (0x0003)
static const int SERIAL_BAUD_RATE = 1000000;
typedef struct PAC... | prv_putchar(FRAME_DELIMITER) | ;
s_message_length = 0;
}
void dbgserial_putstr(const char* str) {
dbgserial_print(str);
dbgserial_newline();
}
void dbgserial_print_hex(uint32_t value) {
char buf[12];
itoa_hex(value, buf, sizeof(buf));
dbgserial_print(buf);
}
|
graphics_context_set_fill_color(&ctx, GColorBlue);
graphics_fill_rect(&ctx, &GRect(0, 0, 20, 10));
graphics_draw_rotated_bitmap(&ctx, test_image_color,
GPoint(30, 30), DEG_TO_TRIGANGLE(45), GPointZero);
cl_check(gbitmap_pbi_eq(
&ctx.dest_bitmap,
"draw_rotate... | (&ctx, test_image_color,
GPoint(30, 1), DEG_TO_TRIGANGLE(2), GPoint(72, 84)) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_offset_topedge_2.Xbit.pbi"));
// left edge center rotation point, Angle 2
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, GCompOpAssign);
graphics_draw_rotated_bitmap(&ctx, test_image_color,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_region_size(i) | )) {
// if active, increment known flash version and increase size to check next region
flash_version = i + 1;
known_size += prv_region_size(i);
} else {
// if not active, break and return known flash version
break;
}
}
// go back to the state we were in before the function
... |
itmap_sequence),
GBitmapFormat8Bit);
cl_assert(bitmap);
// first frame always shows at the beginning (0 ms)
status = gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 0);
cl_assert_equal_b(status, true);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(1)));
... | cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3))) | ;
// Frame 3 has delay 1000 ms, frame 4 and 5 have zero delay, so at time 2000 ms == frame 5
gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 2 * 1000);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
// Since loop only equals 1, make sure that huge elapsed time leaves us at final frame
... |
e ActivitySleepStateLightSleep:
// Start a light sleep session if we were awake before. If we were in restful sleep,
// we should already have one
if (prior_state == ActivitySleepStateAwake) {
cl_assert(s_test_alg_state.minute_data.num_sessions_created < TEST_ACTIVITY_MAX_SESSIONS);
... | time_util_get_minute_of_day(session->start_utc) | ;
ACTIVITY_LOG_DEBUG("Found session %d: start_min: %d, len_min: %"PRIu16" ", session->type,
start_minute, session->length_min);
if (!activity_sessions_prv_is_sleep_activity(session->type)) {
continue;
}
if (s_test_alg_state.minute_data.sessions[i].start_utc
+ (s_te... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25672_1
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ -80, -720, -648},
{ -... |
{ 96, -360, -896},
{ 72, -376, -744},
{ 112, -248, -888},
{ 64, -296, -760},
{ 56, -64, -752},
{ 120, 272, -808},
{ 296, 456, -712},
{ 384, 600, -664},
{ 448, 616, -632},
{ 424, 688, -584},
{ 456, 800, -592},
{ 432, 800, -488},
{ 448, 944, -512},
{ 416, 712, -368... |
gle) {
if (!path) {
return;
}
path->rotation = angle % TRIG_MAX_ANGLE;
}
void gpath_move_to(GPath *path, GPoint point) {
if (!path) {
return;
}
path->offset = point;
}
void gpath_move(GPath *path, GPoint delta) {
if (!path) {
return;
}
path->offset.x += delta.x;
path->offset.y += delta... | prv_is_in_range(min_x, max_x, clip_min_x, clip_max_x) | ) {
goto cleanup;
}
// x-intersections of path segments whose direction is up
intersections_up = applib_zalloc(path->num_points * sizeof(Intersection));
// x-intersections of path segments whose direction is down
intersections_down = applib_zalloc(path->num_points * sizeof(Intersection));
// If either... |
i18n_free_all(workout_dialog) | ;
app_workout_dialog_push(workout_dialog);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Public Functions
void workout_push_summary_window(void) {
WorkoutAppData *data = app_state_get_user_data();
data->summary_window = workout_summary_window_create(... | |
ns and
* limitations under the License.
*/
#include "compositor.h"
#include "compositor_dma.h"
#include "compositor_display.h"
#include "applib/graphics/bitblt.h"
#include "applib/graphics/framebuffer.h"
#include "applib/graphics/gcontext.h"
#include "applib/graphics/gtypes.h"
#include "applib/ui/animation.h"
#incl... | compositor_get_app_framebuffer_as_bitmap() | ;
src_bitmap.bounds = GRect(x_range_begin.integer - offset->x, y - offset->y,
x_range_end.integer - x_range_begin.integer, 1);
GBitmap dest_bitmap = compositor_get_framebuffer_as_bitmap();
bitblt_bitmap_into_bitmap(&dest_bitmap, &src_bitmap, GPoint(x_range_begin.integer, y),
... |
/*
* 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... | uuid_equal(&md->uuid, uuid) | |
fines
//! which app first runs at start up and what app should be launched to replace the current
//! app if the current app wants to close.
//!
//! The logic for which app should replace closing apps is a little tricky. Apps can be launched
//! in various ways, either due to direct user interaction (selecting an app i... | {
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = panic_app_get_app_info(),
});
} |
// Else, just wait for the app_manager to initialize to show the panic app using
// system_app_state_machine_system_start().
}
|
&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, d), 1);
// Run to the completion of D
prv_advance_to_ms_with_timers(start_ms + 1300 + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, d), 1);
cl_assert_equ... | animation_set_auto_destroy(b, auto_destroy) | ;
animation_schedule(b);
Animation *c = prv_create_test_animation();
animation_set_duration(c, duration_a);
animation_set_delay(c, delay_a);
animation_set_handlers(c, handlers, context);
animation_set_auto_destroy(c, auto_destroy);
animation_schedule(c);
prv_advance_to_ms_with_timers(start_ms + durati... |
e specific language governing permissions and
* limitations under the License.
*/
#include "services/common/clock.h"
#include "console/prompt.h"
#include "drivers/rtc.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session.h"
#include "services/common/i18n/i18n.h"... | (&time_tm) | |
OINLINE activity_insights_process_sleep_data(time_t now_utc) {
// Check sleep insights
if (activity_prefs_sleep_insights_are_enabled()) {
prv_do_sleep_reward(now_utc);
}
prv_do_sleep_summary(now_utc);
}
// ------------------------------------------------------------------------------------------------
// ... | {
attribute_list_add_cstring(&response_action_attr_list, AttributeIdTitle,
i18n_get(config->response.title, ¬if_attr_list));
} |
const int max_num_actions = 4; // dismiss, open app, open pin, response
int num_actions = 0;
int action_id = 0;
TimelineItemAction actions[max_num_actions];
actions[num_actions++] = (TimelineItemAction) {
.id = action_id++,
.type = TimelineItemActionTypeDismiss,
.attr_list = dismiss_action_attr_... |
elease = offsetof(ClickConfig, long_click.release_handler),
ClickHandlerOffsetRawUp = offsetof(ClickConfig, raw.up_handler),
ClickHandlerOffsetRawDown = offsetof(ClickConfig, raw.down_handler),
} ClickHandlerOffset;
static ClickHandler prv_get_handler(ClickRecognizer *recognizer, ClickHandlerOffset offset) {
ret... | if (false == prv_is_long_click_enabled(recognizer)) {
return 0;
} |
if (recognizer->config.long_click.delay_ms == 0) {
return LONG_CLICK_DEFAULT_DELAY_MS;
}
return recognizer->config.long_click.delay_ms;
}
inline static bool prv_can_more_clicks_follow(ClickRecognizer *recognizer) {
if (recognizer->number_of_clicks_counted >= prv_multi_click_get_max(recognizer)) {
retu... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_ASSERTN(!s_read_mbuf) | ;
s_read_mbuf = mbuf_get(s_read_data, MAX_FRAME_LENGTH, MBufPoolSmartstrap);
SmartstrapResult result = smartstrap_send(SmartstrapProfileLinkControl, &send_mbuf, s_read_mbuf,
TIMEOUT_MS);
if (result != SmartstrapResultOk) {
mbuf_free(s_read_mbuf);
s_read_mbuf = N... |
/*
* 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_check_free_list() | ;
mutex_unlock(s_free_list_lock);
}
// Basic setters and getters
////////////////////////////////////////////////////////////////////////////////
void mbuf_set_data(MBuf *m, void *data, uint32_t length) {
PBL_ASSERTN(m);
//! We should never be trying to set the data on an mbuf in the free list
PBL_ASSERTN(!m... |
ging] = { .enter = prv_shutdown }
#else
[BatteryShutdownCharging] = { .enter = prv_enter_shutdown_charging }
#endif
};
static BatteryUIStateID s_state = BatteryGood;
static BatteryUIWarningLevel s_warning_points_index = -1;
#if PLATFORM_SPALDING
/* first warning for S4 is at 12 hours remaining, second at 6 hours re... | {
if (ui_states[s_state].next_state[i] == next_state) {
return true;
}
} |
return false;
}
static BatteryUIStateID prv_get_state(PreciseBatteryChargeState *state) {
// TODO: Refactor?
if (state->is_plugged) {
// Don't use the PreciseBatteryChargeState definition of is_charging, as it maps to the
// result of @see battery_charge_controller_thinks_we_are_charging instead of the... |
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
if (prv_is_inbox_being_written(inbox)) {
++inbox->num_failed;
PBL_LOG(LOG_LEVEL_ERROR, "Dropping data, already written by <%p>", inbox->writer);
// Don't send event here, when th... |
unlock:
prv_unlock();
return success;
}
bool app_inbox_service_write(AppInboxServiceTag tag, const uint8_t *data, size_t length) {
bool success = false;
prv_lock();
{
AppInboxNode *inbox = prv_find_inbox_by_tag_and_log_if_not_found(tag);
if (!inbox) {
goto unlock;
}
prv_mark_failed_if_... | |
aml->selected_index);
if (item && aml->cb) {
aml->cb(item, aml->context);
}
}
static bool prv_aml_is_short(ActionMenuLayer *aml) {
return (aml->num_short_items != 0 || aml->num_items == 0);
}
static int16_t prv_get_cell_padding(ActionMenuLayer *aml) {
const int16_t default_sep_height = 10;
#if PBL_ROUND
... | (ctx, separator_start_point, separator_width) | ;
separator_start_point.x -= i & 1;
}
}
}
static int16_t prv_get_header_height_cb(struct MenuLayer *menu_layer, uint16_t second_index,
void *callback_context) {
ActionMenuLayer *aml = callback_context;
if (!prv_should_center(aml) || prv_aml_is_short(aml) || aml->... |
/*
* 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... | uart_set_baud_rate(BT_TX_BOOTROM_UART, DIALOG_BOOTROM_UART_BAUDRATE) | |
rocky_path_steps_num + num_steps_increment);
if (required_array_len <= s_rocky_path_steps_array_len) {
goto success;
}
const size_t new_array_len = prv_get_realloc_array_len(required_array_len);
void *new_steps_array = task_realloc(s_rocky_path_steps,
sizeof(RockyAPIPa... | {
return rocky_error_oom("too many points to fill");
} | |
/test_framebuffer.h"
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
static FrameBuffer *fb = NULL;
// Setup
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize)... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_offset_layer.${BIT_DEPTH_NAME}.pbi")) | |
_set_overrides_back_button(window, true);
window_set_click_config_provider(window, NULL);
}
static void confirm_click_handler(ClickRecognizerRef recognizer, Window *window) {
ConfirmUIData *data = window_get_user_data(window);
// Need to lock-out inputs after starting the factory reset.
prv_lockout_back_butto... | i18n_get(BT_FORGET_PAIRING_STR, data) | ,
fonts_get_system_font(FONT_KEY_GOTHIC_18), text_color,
GColorClear, alignment, overflow_mode);
layer_add_child(&window->layer, &forget_text_layer->layer);
#if PBL_ROUND
text_layer_enable_screen_text_flow_and_paging(forget_text_layer, text_flow_in... |
_glance_subtitle_dynamic_text_node_update(
UNUSED GContext *ctx, UNUSED GTextNode *node, UNUSED const GRect *box,
UNUSED const GTextNodeDrawConfig *config, UNUSED bool render, char *buffer, size_t buffer_size,
void *user_data) {
LauncherAppGlanceStructured *structured_glance = user_data;
LauncherAppGlan... | {
// Use the strings to fill the subtitle buffer
snprintf(music_glance->subtitle, music_glance_subtitle_size, "%s - %s", artist_buffer,
title_buffer);
// Choose the icon we should display; note that we'll use the default icon we set above if we
// don't have an icon for the curre... | |
{
GContext ctx;
Layer layer;
test_graphics_context_init(&ctx, fb);
layer_init(&layer, &GRect(10, 10, 60, 60));
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_inside_offset_layer... | GPoint(0, 18) | , 22);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 20), 143);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), 145);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_even_rows_no_clip")));
// Odd rows of different lengths
setup_test_aa_sw... |
8_t *)&hdr.last_written, sizeof(hdr.last_written),
prv_page_to_flash_offset(prev_written_page) +
offsetof(PageHeader, last_written));
if (hdr.last_written == LAST_WRITTEN_TAG) {
hdr.last_written = LAST_WRITTEN_UNMARK;
prv_flash_write((uint8_t *)&hdr.last_written, sizeof(hdr.last_written),
... | {
uint16_t curr_region = (region + start_region) % num_erase_regions;
if (s_gc_block.block_valid && (gc_erase_region == curr_region)) {
// don't use pre-allocated garbage collection regions
continue;
}
uint32_t sectors_active = prv_get_sector_page_status(curr_region, &next_page... |
}
if (next_page != INVALID_PAGE) { // a free page was found
if (use_page) {
prv_update_last_written_page(next_page);
}
*free_page = s_last_page_written = next_page;
return (S_SUCCESS);
}
return (E_OUT_OF_STORAGE);
}
//! Note: expects that the caller does _not_ hold the pfs mutex
//! N... |
break;
}
// It's possible new data has been batched up while we were sending data.
// Check the circular buffer and notify the controller if that's the case
if (prv_host_transport_tx_get_length() > 0) {
prv_indicate_has_data_if_idle();
}
hc_protocol_process_receive_buffer();
... | xSemaphoreGive(s_spi_transport.semph) | ;
while (s_spi_transport.task_is_running) {
// Trigger context switches & give low priority tasks a chance to run until
// the host_transport thread wakes and exits
psleep(2);
}
vSemaphoreDelete(s_spi_transport.semph);
s_spi_transport.semph = NULL;
s_spi_transport.task = NULL;
hc_protocol_cb_d... |
icense 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 "applib/graphics/graphics.h"
#include "applib/graphics/graphics_private.h"
#includ... | {
for (int16_t x = 0; x < rect->size.w; x++) {
draw_func(ctx, rect->origin.x + x, rect->origin.y, grect_get_max_y(rect) - 1, color);
}
} |
static void prv_draw_vline_test_pattern(GContext *ctx, HLinePatternDrawFunction draw_func) {
const GRect *bitmap_bounds = &ctx->dest_bitmap.bounds;
// Fill the screen with red
graphics_context_set_fill_color(ctx, GColorRed);
graphics_fill_rect(ctx, bitmap_bounds);
const GSize *bitmap_bounds_size = &bitmap_... |
pplicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "debug/p... | (PowerSystemMcuCoreSleep) | ;
__DSB(); // Drain any pending memory 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 ... |
/*
* 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... | (!iter_next(&char_iter)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.