prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
gs_bluetooth.h"
#include "system/logging.h"
#define MESSAGE_BUF_SIZE 96
typedef struct ConfirmUIData {
Window window;
ActionBarLayer action_bar;
TextLayer msg_text_layer;
TextLayer forget_text_layer;
PeekLayer resetting_layer;
char msg_text_layer_buffer[MESSAGE_BUF_SIZE];
GBitmap *action_bar_icon_check;... | text_layer_get_content_size(ctx, msg_text_layer) | |
entry->id, table_entry.resource_id);
return false;
}
const uint32_t resource_crc = prv_get_crc(entry, table_entry.length, table_entry.offset);
if (resource_crc != table_entry.crc) {
PBL_LOG(LOG_LEVEL_DEBUG, "Bad resource CRC for %" PRIx32 ", %" PRIx32
" vs %" PRIx32, resource_id, resource_crc... | PBL_LOG(LOG_LEVEL_WARNING, "expected version <%#010"PRIx32", %"PRIu32">,",
expected_version->crc, expected_version->timestamp) | |
/*
* 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 (BTDeviceInternal) {
.address.octets = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
},
};
} |
static void (*s_launcher_task_callback)(void *data);
static void *s_launcher_task_callback_data;
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
// Simple fake, can only handle one call
cl_assert_equal_p(s_launcher_task_callback, NULL);
s_launcher_task_callback = callback;
s_laun... |
_md));
TaskParameters_t task_params = {
.pvTaskCode = prv_app_task_main,
.pcName = task_name,
.usStackDepth = stack_size / sizeof(portSTACK_TYPE),
.pvParameters = entry_point,
.uxPriority = APP_TASK_PRIORITY | portPRIVILEGE_BIT,
.puxStackBuffer = stack,
};
PBL_LOG(LOG_LEVEL_DEBUG, "Start... | (dialog, RESOURCE_ID_GENERIC_WARNING_LARGE) | ;
dialog_set_timeout(dialog, DIALOG_TIMEOUT_INFINITE /* no timeout */);
// Any sort of application crash or window crash is a critical message as it
// impacts the UX experience, so we want to push it to the forefront of the
// window stack.
WindowStack *window_stack = modal_manager_get_window_stack(ModalPri... |
eMutex *s_free_list_lock;
//! This array should be initialized with the maximum number of MBufs which may be allocated for
//! each pool.
static int s_mbuf_pool_space[] = {
[MBufPoolSmartstrap] = 2,
#if UNITTEST
[MBufPoolUnitTest] = 100,
#endif
};
_Static_assert(ARRAY_LENGTH(s_mbuf_pool_space) == NumMBufPools,
... | {
dbgserial_putstr_fmt(buffer, sizeof(buffer), "MBuf <%p>: length=%"PRIu32", data=%p, "
"flags=0x%"PRIx32, m, m->length, m->data, m->flags);
m = m->next;
} | |
GColor8 tint_color) {
const int16_t dest_begin_y = dest_rect.origin.y;
const int16_t dest_end_y = dest_begin_y + dest_rect.size.h;
int16_t src_y = src_bitmap->bounds.origin.y + src_origin_offset.y;
for (int16_t dest_y = dest_begin_y; dest_y < dest_end_y; ++dest_y, ++src_y) {
// Wrap-ar... | if (!set) {
dest[dest_x] = tint_color.argb;
} |
}
break;
default:
case GCompOpAssign:
for (int i = src_start_idx; i < src_end_idx; ++i, ++dest_x) {
const uint32_t bit = (1 << i);
const bool set = src & bit;
dest[dest_x] = (set) ? GColorWhite.argb : GColorBlack.argb;
}
... |
MPLES (0x0e)
#define ADDR_NUM_PPG_SAMPLES (0x0f)
#define ADDR_ACCEL_SAMPLE_IDX (0x14)
#define ADDR_ACCEL_X_MSB (0x15)
#define ADDR_ACCEL_Y_MSB (0x17)
#define ADDR_ACCEL_Z_MSB (0x19)
#define ADDR_PPG_IDX (0x1b)
#define ADDR_PPG_MSB (0x1c)
#define ADDR_PPG_LSB (0x1d)
#define ADDR_TIA_MSB (0x1e)
#define ADDR_TIA_LSB (0x... | i2c_write_register_block(dev->i2c_slave, register_address, length, buffer) | ;
i2c_release(dev->i2c_slave);
return rv;
}
static bool prv_read_register(HRMDevice *dev, uint8_t register_address, uint8_t *value) {
i2c_use(dev->i2c_slave);
bool rv = i2c_read_register(dev->i2c_slave, register_address, value);
i2c_release(dev->i2c_slave);
return rv;
}
static bool prv_read_register_block... |
rcm_mark, RESOURCE_ID_SYSTEM_AUS_RCM_MARK);
gbitmap_init_with_resource(
&cd->nom_nyce_mark, RESOURCE_ID_SYSTEM_NOM_NYCE_MARK);
// Construct the certification menu
const RegulatoryFlags *flags = prv_get_regulatory_flags();
if (flags->has_usa_fcc) {
prv_append_certification_menu(cd, &(SystemCertificati... | (&data->status_layer) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_x_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(... |
/*
* 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... | bitmap_layer_init(&layer, &BITMAP_LAYER_FRAME) | ;
bitmap_layer_set_bitmap(&layer, &bitmap);
// set bounds with non-zero origin
layer_set_bounds((Layer *)&layer, &BITMAP_LAYER_BOUNDS);
// !legacy2
cl_will_return(process_manager_compiled_with_legacy2_sdk, false);
layer_render_tree((Layer *)&layer, &ctx);
GRect expected_rect = BITMAP_BOUNDS;
cl_assert... |
// Now process the second nibble
rle_unit_pair >>= 4;
num_rle_units--;
}
}
// Flush out any remaining pixels
while (buf_num_bits > 0) {
PBL_ASSERTN(dst < &((uint8_t *)g->data)[CACHE_GLYPH_SIZE]);
*dst++ = (buf & 0xFF);
buf >>= 8;
buf_num_bits -= 8;
}
// Fix-up the heigh... | (LOG_DOMAIN_TEXT, LOG_LEVEL_DEBUG, "looking up cp: %"PRIx32", key:%"PRIx32,
codepoint, cache_key) | ;
// If the glyph_buffer doesn't match this glyph, or we have bitmap caching, check the
// keyed_circular_cache for this glyph.
if (!cached) {
cached = keyed_circular_cache_get(&font_cache->line_cache, cache_key);
#if !CAPABILITY_HAS_GLYPH_BITMAP_CACHING
// If we don't have bitmap caching, the keyed_circ... |
plete(void) {
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(),
... | cl_assert_equal_d(jerry_get_number_value(number), 1.0) | |
6, 480, 216},
{ 72, 776, 264},
{ -40, 1096, 336},
{ -248, 1144, 424},
{ -216, 976, 248},
{ -296, 1312, 304},
{ -288, 1072, 368},
// 43 seconds
{ -200, 1216, 112},
{ -144, 984, 96},
{ -120, 776, 96},
{ 24, 664, -120},
{ 80, 576, -88},
{ 80, 728, -8},
{ 24, 928, -72... | { 120, 1472, 360},
{ -112, 1504, 304},
{ 112, 1352, 336},
{ -16, 1048, 384},
{ 32, 672, 240},
{ 128, 496, 128},
{ 192, 504, 80},
{ 288, 592, 168},
{ 272, 800, 168},
{ 288, 920, 240},
{ 216, 1136, 224},
{ 88, 1200, 232},
{ 40, 1128, 176},
{ 0, 1240, 168},
// 49... |
{ 184, 576, -24},
{ 248, 656, 72},
{ 288, 1032, -56},
{ 224, 984, -32},
{ 256, 1376, 72},
{ 64, 1400, 320},
{ 336, 1320, 328},
{ 64, 1080, 488},
{ 192, 1112, 528},
{ 80, 768, 264},
{ 8, 920, 376},
{ 112, 792, 80},
{ 248, 496, 32},
{ 288, 456, 120},
{ 304, 696... |
/*
* 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 (dialog->callback_context) {
dialog->callbacks.load(dialog->callback_context);
} else {
dialog->callbacks.load(dialog);
} |
}
}
// Unloads the core dialog. Should be called from each dialog window's unload callback.
void dialog_unload(Dialog *dialog) {
app_timer_cancel(dialog->timer);
if (dialog->show_status_layer) {
status_bar_layer_deinit(&dialog->status_layer);
}
dialog_set_icon(dialog, INVALID_RESOURCE);
text_layer_d... |
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System) | ;
}
static void prv_handle_call_end(bool disconnected) {
if (!disconnected) {
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System);
}
if (s_call_in_progress) {
prv_call_end_common();
phone_ui_handle_call_end(false /*call accepted*/, disconnected);
} else if (!disconn... | |
/*
* 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... | NEW_RECOGNIZER(r) | = test_recognizer_create(&s_test_impl_data, &event_type);
// Test that manager state change handler is called when not called from a touch event handler
recognizer_transition_state(r, RecognizerState_Failed);
cl_assert_equal_i(r->state, RecognizerState_Failed);
cl_assert(s_manager_state_change);
cl_assert_eq... |
EG_CNTL = 0x24,
PmicRegisters_GPIO_CNTL1 = 0x25,
PmicRegisters_GPIO_CNTL2 = 0x26,
PmicRegisters_SD_CNTL1 = 0x30,
PmicRegisters_BATT_VOLTAGE_MON = 0x32,
PmicRegisters_STARTUP_CNTL = 0x33,
PmicRegisters_REFERENCE_CNTL = 0x35,
PmicRegisters_RESET_CNTL = 0x36,
PmicRegisters_OVERTEMP_CNTL = 0x37,
PmicReg... | {
return false;
} |
val |= (1 << bit);
return prv_write_register(register_address, val);
}
static bool prv_register_clear_bit(uint8_t register_address, uint8_t bit) {
uint8_t val;
if (!prv_read_register(register_address, &val)) {
return false;
}
val &= ~(1 << bit);
return prv_write_register(register_address, val);
}
... |
font_cache->cache_data, sizeof(LineCacheData), LINE_CACHE_SIZE);
graphics_context_set_default_drawing_state(context, init_mode);
}
void graphics_context_set_default_drawing_state(GContext *ctx,
GContextInitializationMode init_mode) {
PBL_ASSERTN(ctx);
... | {
PBL_ASSERTN(ctx);
return ctx->lock;
} |
GBitmap* graphics_capture_frame_buffer_format(GContext *ctx, GBitmapFormat format) {
PBL_ASSERTN(ctx);
if (ctx->lock) {
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame buffer has already been captured; it cannot be captured again until "
"graphics_release_frame_buffer has been called.");
ret... |
y = ActivitySessionTypeCount;
switch (kalg_activity) {
case KAlgActivityType_Walk:
activity = ActivitySessionType_Walk;
break;
case KAlgActivityType_Run:
activity = ActivitySessionType_Run;
break;
case KAlgActivityType_RestfulSleep:
activity = ActivitySessionType_RestfulSleep... | (LOG_LEVEL_INFO, __FILE_NAME__, __LINE__, "SLP: %s", base64_buf) | ;
return true;
}
// ----------------------------------------------------------------------------------------------
// Log minute data to PBL_LOG
// @param earliest_wake_time ignore any sleep cycles that end before this time.
bool activity_algorithm_dump_minute_data_to_log(void) {
if (!prv_lock()) {
return fal... |
/*
* 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... | (attribute, (char *)buffer, attribute_id) | ;
return (uint8_t *)prv_copy_pstring_and_add_ellipsis(&ancs_attr->pstr, (char *)buffer,
(ancs_attr->length == max_length));
}
static uint8_t *prv_add_action_msg_to_attribute(
uint8_t *buffer, const ANCSAttribute *sender, int sender_max_length,
const ANCSA... |
kSet);
cl_assert(rv == 0);
rv = pfs_seek(fd, len + 1, FSeekCur);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, len + 1, FSeekSet);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, -1, FSeekSet);
cl_assert(rv == E_RANGE);
}
void test_pfs__read(void) {
const int rd_len = 10;
int rv = pfs_read(-1, NULL, rd_l... | ("the fd is: %d\n", fd) | ;
cl_assert(fd >= 0);
cl_assert(pfs_write(fd, bigbuf, large_file_size) == large_file_size);
cl_assert(pfs_close(fd) == S_SUCCESS);
}
free(bigbuf);
// now read back the large files
curr = 0;
for (int i = 0; i < 2; i++) {
snprintf(file_large, sizeof(file_large), "large%d", i);
int fd = pfs_... |
mal/filesystem/pfs.h"
#include "services/normal/process_management/app_storage.h"
#include "services/normal/settings/settings_file.h"
#include "shell/normal/quick_launch.h"
#include <util/size.h>
#include "system/logging.h"
#include "util/attributes.h"
#include <stdio.h>
// Fakes
////////////////////////////////////
#... | cl_assert_equal_i(S_SUCCESS, app_cache_app_launched(app1.id)) | ;
cl_assert_equal_i(S_SUCCESS, app_cache_app_launched(app3.id));
// ensure the one that has the lowest priority is evicted
cl_assert_equal_i(app2.id, app_cache_get_next_eviction());
}
/*************************************
* Add 3, remove 3, evict INVALID_ID *
*************************************/
void test... |
enter_focused;
scroll_layer_set_clips_content_offset(&menu_layer->scroll_layer, !center_focused);
}
void menu_layer_init(MenuLayer *menu_layer, const GRect *frame) {
*menu_layer = (MenuLayer) {
.pad_bottom = true,
};
ScrollLayer *scroll_layer = &menu_layer->scroll_layer;
scroll_layer_init(scroll_layer, ... | if (menu_layer->pad_bottom) {
total_height += MENU_LAYER_BOTTOM_PADDING;
} |
// Set the content size on the scroll layer, so all the rows will fit onto the content layer:
const GSize frame_size = menu_layer->scroll_layer.layer.frame.size;
scroll_layer_set_content_size(&menu_layer->scroll_layer, GSize(frame_size.w, total_height));
// Set the selected cell again:
const bool animated ... |
/*
* 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(e.phone.type, subtype) | ;
if (check_cookie) {
cl_assert_equal_i(e.phone.call_identifier, expected_cookie);
}
if (check_name_number) {
cl_assert_equal_s(e.phone.caller->name, name);
cl_assert_equal_s(e.phone.caller->number, number);
}
}
// Tests
///////////////////////////////////////////////////////////
static Transport ... |
32},
{ 1312, 280, 16},
{ 1200, 344, -72},
{ 992, 376, -72},
{ 1216, 496, 48},
{ 1040, 688, 40},
{ 1280, 448, 40},
{ 1056, 440, -104},
{ 1080, 312, -8},
{ 1248, 344, 72},
{ 1552, 320, 96},
{ 1432, 224, 48},
{ 1296, 112, 112},
{ 1280, 32, 128},
{ 1216, 16, -16},
... | { 1296, 504, 96},
// 111 seconds
{ 912, 696, 40},
{ 1168, 368, -24},
{ 1048, 496, -128},
{ 1072, 408, -8},
{ 1240, 408, 104},
{ 1568, 336, 120},
{ 1416, 192, 88},
{ 1360, 64, 152},
{ 1312, -16, 136},
{ 1216, 0, 24},
{ 1080, 56, -40},
{ 920, 48, 8},
{ 1040, -24... |
{ 904, -40, 104},
{ 808, -40, 88},
{ 1136, -96, 128},
{ 1232, 40, 88},
{ 1280, 168, -112},
{ 1280, 96, -48},
{ 1312, 120, -88},
// 114 seconds
{ 1160, 152, -152},
{ 1160, 128, -112},
{ 1304, 184, -8},
{ 1288, 296, 72},
{ 1136, 328, -80},
{ 1104, 328, -72},
{ ... |
ute_file_get_settings_key(k_newest_valid_utc) + 1,
.oldest_valid_utc = k_oldest_valid_utc,
.newest_valid_utc = k_newest_valid_utc,
};
// Feed in the saved data, reading chunks out of the saved minute data and compressing
// it into algorithm sleep minute structures.
status_t status = settings_file_each... | PBL_LOG(LOG_LEVEL_WARNING, "Detected invalid minute data file, deleting it");
pfs_remove(ALG_MINUTE_DATA_FILE_NAME);
}
return file;
} |
// -------------------------------------------------------------------------------------
static void prv_init_minute_record(AlgMinuteRecordHdr *hdr, time_t utc_sec, bool for_file) {
time_t local_time = time_utc_to_local(utc_sec);
int16_t local_time_offset_15_min = (local_time - utc_sec) / (15 * SECONDS_PER_MINUT... |
nvalid DST ID. Either way just clear the DST information.
tz_info->dst_start = 0;
tz_info->dst_end = 0;
return;
}
struct tm current_tm;
gmtime_r(&utc_time, ¤t_tm);
// Calculate the timestamps of the start and ends of DST for the previous year, the current
// year, and the next year.
#defi... | if (tz_info) {
prv_handle_timezone_set(tz_info);
} | |
{ 1536, 312, -264},
{ 1512, 400, -312},
{ 1432, 440, -280},
{ 1320, 592, -256},
{ 1256, 648, -248},
{ 1288, 640, -400},
{ 1104, 752, -296},
{ 1272, 992, -232},
{ 1064, 960, -152},
{ 1312, 944, -184},
{ 1000, 648, -264},
{ 888, 504, -216},
{ 1376, 608, -72},
{ 1776... | { 1152, 520, -176},
{ 1536, 616, -64},
{ 1744, 512, -96},
{ 1632, 440, -176},
{ 1720, 384, -104},
{ 1800, 384, -48},
{ 1728, 400, -136},
{ 1464, 336, -272},
{ 1320, 48, -296},
{ 824, -344, -144},
{ 744, -264, -552},
{ 1136, -224, -360},
{ 1312, -16, -352},
{ 1328,... |
{ -1920, 408, -296},
{ 2040, 560, -224},
{ 1800, 776, -248},
{ 1744, 624, -248},
{ 1792, 344, -120},
{ 1592, 856, 152},
{ 1360, 1816, 40},
{ 800, 1384, 40},
{ 928, 1376, -240},
{ 936, 800, -368},
{ 1312, 696, -200},
{ 2000, 688, -16},
{ -1944, 616, -80},
{ 2008, ... |
/*
* 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... | (__bss_start, 0, __bss_end - __bss_start) | ;
main();
__builtin_unreachable();
}
__attribute__((__noreturn__)) void Default_Handler(void) {
// This handler is only called if we haven't defined a specific
// handler for the interrupt. This means the interrupt is unexpected,
// so we loop infinitely to preserve the system state for examination
// by... |
ueueReceive(s_pulse_task_queue, &c, 0) == pdTRUE) {
if (UNLIKELY(c == FRAME_DELIMITER)) {
size_t decoded_length = cobs_streaming_decode_finish(&frame_decode_ctx);
prv_process_received_frame(decoded_length);
cobs_streaming_decode_start(&frame_decode_ctx, s_current_rx_frame,
... | COBS_OVERHEAD(FRAME_MAX_SEND_SIZE) | |
/ Tests
static CommSession *s_session = (CommSession *)0xaabbccdd;
void test_app_message_receiver__initialize(void) {
s_kernel_receiver_available = true;
s_kernel_receiver = (Receiver *)0xffaaffaa;
s_kernel_receiver_is_receiving = false;
s_kernel_receiver_finish_called = false;
s_kernel_receiver_cleanup_cal... | s_rcv_imp->finish(r) | ;
prv_process_events();
cl_assert_equal_b(false, s_kernel_receiver_is_receiving);
cl_assert_equal_b(false, s_kernel_receiver_finish_called);
cl_assert_equal_m(&s_push, s_app_message_pp_buffer, sizeof(s_push));
cl_assert_equal_i(s_app_message_pp_received_length, sizeof(s_push));
cl_assert_equal_b(true, s_c... |
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 "applib/cpu_cache.h"
... | (s_flush_size, 0x08) | ;
cl_assert_equal_i(s_invalidate_addr, 0x20);
cl_assert_equal_i(s_invalidate_size, 0x08);
cl_assert_equal_i(s_addr_result, UserSpaceBuffer_Invalid);
}
void test_cpu_cache__userspace_ignore(void) {
cl_will_return(icache_is_enabled, true);
cl_will_return(dcache_is_enabled, true);
cl_will_return(icache_line... |
s_manager_state.system_task_event_storage,
EVENT_STORAGE_SIZE);
event_service_client_subscribe(&s_manager_state.charger_subscription);
}
HRMSessionRef hrm_manager_subscribe_with_callback(AppInstallId app_id, uint32_t update_interval_s,
... | if (app_id) {
*app_id = state->app_id;
} | |
!gdraw_command_sequence_validate(sequence, size));
sequence->num_frames = 2;
sequence->version = 0xFF;
cl_assert(!gdraw_command_sequence_validate(sequence, size));
free(sequence);
}
void test_gdraw_command_sequence__get_frame_by_elapsed(void) {
GDrawCommandSequence *sequence;
prv_create_test_sequence(&se... | (&sequence) | ;
GDrawCommandSequence *clone = gdraw_command_sequence_clone(sequence);
cl_assert(clone != sequence);
size_t expected_size = gdraw_command_sequence_get_data_size(sequence);
cl_assert_equal_i(gdraw_command_sequence_get_data_size(clone), expected_size);
cl_assert_equal_i(0, memcmp(clone, sequence, expected_siz... |
/*
* 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... | circular_buffer_read(&buffer, 2, &out_buffer, &out_length) | |
time_end - time_start;
range->seconds_first_day = (range->num_days == 1) ? total_seconds : seconds_first_day;
range->seconds_last_day = (range->num_days == 1) ? total_seconds : seconds_last_day;
range->seconds_total_last_day =
(range->last_day_idx == 0) ? (now - midnight_before_end) : SECONDS_PER_DA... | (result, time_range.num_days) | ;
}
break;
case HealthAggregationMax:
result = INT32_MIN;
for (uint32_t i = 0; i < time_range.num_days; i++) {
result = MAX(result, daily_history.totals[i + time_range.last_day_idx]);
}
break;
case HealthAggregationMin:
result = INT32_MAX;
for (uint32_t ... |
_text_height_px = fonts_get_font_height(dialog_text_font);
const int max_text_line_height_px = 2 * single_line_text_height_px + 8;
const uint16_t status_layer_offset = dialog->show_status_layer ? 6 : 0;
uint16_t text_top_margin_px = icon ? icon_size.h + 22 : 6;
uint16_t subtext_top_margin_px = text_top_margin_... | layer_add_child(&window->layer, &subtext_layer->layer) | ;
}
if (show_action_bar) {
action_bar_layer_add_to_window(&workout_dialog->action_bar, window);
}
// Icon
// On rectangular displays we just center it horizontally b/w the left edge of the display and
// the left edge of the action bar
#if PBL_RECT
x = (grect_get_max_x(bounds) - action_bar_width - i... |
k(window);
cl_assert_equal_i(window->on_screen, false);
s_disappear_count++;
cl_check(s_appear_count >= 0);
}
static void prv_window_load(Window *window) {
cl_check(window);
cl_assert_equal_i(window->on_screen, true);
s_load_count++;
}
static void prv_window_unload(Window *window) {
cl_check(window);
... | app_window_stack_pop(true) | |
eStart:
if (next_state == StateWaitForReady) {
return StateStartWaitForReady;
}
break;
case StateStartWaitForReady:
if (next_state == StateRecording) {
*defer_transition = true;
// Spoof the state to StateStopForReady so the next transition takes us to
// Sta... | prv_shrink_progress_bar(data) | ;
break;
case StateTransitionToText:
// fly dot out
prv_hide_unfold_animation(data);
prv_hide_progress_bar(data);
prv_hide_mic_dot(data);
prv_fly_dot(data, false /* fly out */);
break;
case StateError:
case StateFinished:
case StateExiting:
// hide all ... |
eToCBContext *scale = context;
const ScaleToGValues * const gvalues = (command->type == GDrawCommandTypePrecisePath)
? &scale->values.precise : &scale->values.integer;
const uint16_t num_points = gdraw_command_get_num_points(command);
for (uint16_t i = 0; i < num_points; i++) {
const int32_t point_inde... | (
scale->progress, from_stroke_width.raw_value, to_stroke_width.raw_value) | ;
gdraw_command_set_stroke_width(
command, ((new_stroke_width + FIXED_S16_3_HALF.raw_value) >> FIXED_S16_3_PRECISION));
return true;
}
void gdraw_command_list_scale_stroke_width(GDrawCommandList *list, Fixed_S16_3 from, Fixed_S16_3 to,
GStrokeWidthOp from_op, GStro... |
me > now) { // future
time_t difference = timestamp - now;
if (timestamp < now || difference < SECONDS_PER_MINUTE) {
i18n_get_with_buffer("Now", word_buffer, word_buffer_size);
strncpy(number_buffer, "", number_buffer_size);
} else if (difference <= SECONDS_PER_HOUR) {
snprintf(number_buff... | if (!region_name) {
return;
} |
if (clock_is_timezone_set()) {
int region_id = clock_get_timezone_region_id();
if (region_id != UNKNOWN_TIMEZONE_ID) {
timezone_database_load_region_name(region_id, region_name);
} else {
// Show something like UTC-4 or UTC-10.25
// This will typically happen in the emulator when we kn... |
======================================================
// Functions used for collecting stats and writing them out to a csv
static const int k_stats_max_columns = 32;
typedef struct {
ListNode node;
uint32_t values[k_stats_max_columns];
} StatsRow;
typedef enum {
StatsEpochTypeNonStepping = 0,
StatsEpochTypePar... | fprintf(file, " ,%d", row->values[i]) | ;
}
fprintf(file, "\n");
}
cl_assert_equal_i(0, fclose(file));
printf("Stats written to file: %s", filename);
}
// ---------------------------------------------------------------------------------------
// Run samples through the algorithm integrated into the firmware
// @param[in] data array of sample... |
_uuid = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5
};
// Helpers
///////////////////////////////////////
static void prv_set_remote_active(void) {
static const int deadbeef = 0xdeadbeef;
s_session = (void*)&deadbeef;
s_flags = 0;
}
static void prv_set_expected(AppState app_state) {
s_app_state = app_s... | (&msg.uuid, &s_app_uuid, sizeof(s_app_uuid)) | ;
app_run_state_protocol_msg_callback(&session, (uint8_t*)&msg, sizeof(msg));
// This should be a noop since the key is invalid
cl_assert_equal_i(s_launcher_deprecated_messages, 0);
cl_assert_equal_i(s_app_run_state_messages, 0);
AppRunStateCommand commands[] = {
APP_RUN_STATE_INVALID_COMMAND,
APP_... |
xdd, 0x00, /* bytes 880 - 896 */
0x4c, 0x00, 0xde, 0x00, 0x4c, 0x00, 0xdf, 0x00, 0x4c, 0x00, 0xe0, 0x00, 0x4c, 0x00, 0xe1, 0x00, /* bytes 896 - 912 */
0x4c, 0x00, 0xe2, 0x00, 0x4c, 0x00, 0xe3, 0x00, 0x4c, 0x00, 0xe4, 0x00, 0x4c, 0x00, 0xe5, 0x00, /* bytes 912 - 928 */
0x4c, 0x00, 0xe6, 0x00, 0x4c, 0x00, 0xe7, 0x0... | aligned (8) | ))
static const uint8_t GENERIC_WARNING_TINY_builtin_bytes[] = {
0x50, 0x44, 0x43, 0x49, 0x3f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x19, 0x00, 0x19, 0x00, 0x03, 0x00, /* bytes 0 - 16 */
0x03, 0x00, 0xc0, 0x02, 0xff, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0xac, 0x00, 0x5c, 0x00, 0x0c, /* bytes 16 - 32 */
0x00, 0xb4, 0x00, ... |
ng_interrupt_count = 0;
}
static bool prv_start_loader(HRMDevice *dev) {
// check if the loader is already running
if (!prv_is_app_running(dev, AS7000AppId_Loader)) {
PBL_LOG(LOG_LEVEL_DEBUG, "Switching to loader");
// we need to start the loader
if (!prv_set_running_apps(dev, AS7000AppId_Loader)) {
... | prv_wait_for_loader_ready(dev) | ) {
PBL_LOG(LOG_LEVEL_ERROR, "Loader not ready");
return false;
}
system_task_watchdog_feed();
cursor += load_length;
write_address += load_length;
bytes_remaining -= load_length;
}
}
// Write the EOF record, telling the loader that the image has been
// fully ... |
uffer_size, end_time, end_time);
} else {
// middle day of non-all day multiday event
prv_get_relative_all_day_string(word_buffer, word_buffer_size, current_day);
strncpy(number_buffer, "", number_buffer_size);
}
}
DEFINE_SYSCALL(bool, clock_is_24h_style, void) {
return shell_prefs_get_clock_24h_styl... | {
// Use weekday name up to 5 days in the future, aka "Sunday"
prv_format_time(buffer, buf_size, i18n_noop("%A"), timestamp);
} | else {
// Otherwise use "Month Day", aka "June 21"
prv_format_time(buffer, buf_size, i18n_noop("%B %d"), timestamp);
}
}
enum {
RoundTypeHalfUp,
RoundTypeHalfDown,
RoundTypeAlwaysUp,
RoundTypeAlwaysDown,
};
static time_t prv_round(time_t round_me, time_t multiple, int round_type) {
switch (round_... |
l_assert(new_tuple->length == strlen(NEW_STRING) + 1);
cl_assert(strcmp(new_tuple->value->cstring, NEW_STRING) == 0);
cl_assert(old_tuple->type == TUPLE_CSTRING);
cl_assert(old_tuple->length == strlen(SOME_STRING) + 1);
cl_assert(strcmp(old_tuple->value->cstring, SOME_STRING) == 0);
break;... | cl_assert(tuple->value->int8 == -3) | ;
break;
default:
break;
}
tuple = dict_read_next(&dest_iter);
}
if (test_not_enough_storage || should_update_existing_keys_only) {
cl_assert(has_tuple[INT8_IDX] == false);
} else {
cl_assert(has_tuple[INT8_IDX] == true);
}
cl_assert(has_tuple[STRI... |
te.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/size.h"
#include <inttypes.h>
#include <time.h>
#define LINK_CONTROL_VERSION 1
#define TIMEOUT_MS 100
#define MAX_DATA_LENGTH 4
#define MAX_FRAME_LENGTH (sizeof(FrameHead... | {
const FrameHeader *header = mbuf_get_data(s_read_mbuf);
mbuf_free(s_read_mbuf);
s_read_mbuf = NULL;
const uint32_t data_length = length - sizeof(FrameHeader);
if (!success ||
(length < sizeof(FrameHeader)) ||
(data_length > MAX_DATA_LENGTH) ||
(header->type != s_type) ||
(header->ver... |
uint16_t *profiles = (uint16_t *)header->data;
const uint32_t num_profiles = data_length / sizeof(uint16_t);
for (uint32_t i = 0; i < num_profiles; i++) {
if ((profiles[i] > SmartstrapProfileInvalid) &&
(profiles[i] < NumSmartstrapProfiles) &&
(profiles[i] != Smartstra... |
(__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);
main();
__builtin_unreachable();
}
__attribute__((__noreturn__)) void Default_Handler(void) {
// This handler is only called if we haven't defined a specific
// handler for the interrupt. ... | |
existing_system_session->transport_imp,
CommSessionTransportType_PULSE)
&& !prv_is_transport_type(transport, implementation, CommSessionTransportType_PULSE)) {
if (!existing_system_session->transport_imp->close) {
// iAP sessions ... | bt_unlock() | ;
}
}
// -------------------------------------------------------------------------------------------------
bool comm_session_is_current_task_send_next_task(CommSession *session) {
if (session->transport_imp->schedule) {
return session->transport_imp->is_current_task_schedule_task(session->transport);
}
re... |
/*
* 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... | GRect(0, 12, window->layer.bounds.size.w, 18) | );
switch (data->test_case) {
case FLASH_TEST_CASE_RUN_DATA_TEST:
text_layer_set_text(msg_text_layer, "Data Bus Test");
break;
case FLASH_TEST_CASE_RUN_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Addr Bus Test");
break;
case FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST:
text_laye... |
/*
* 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_time() | ;
const time_t difference = timestamp - now;
size_t starts_len = 0;
if (difference <= SECONDS_PER_HOUR * max_relative_hrs &&
time_util_get_midnight_of(now) == time_util_get_midnight_of(timestamp)) {
const char *starts = i18n_get("STARTS ", layout); // Freed by `timeline_layout_deinit`
starts_len = s... |
, -88},
{ 1096, 120, -80},
{ 1264, 168, -80},
{ 1392, 208, -128},
{ 1104, 248, -216},
{ 736, 240, -216},
{ 520, 216, -216},
{ 472, 176, -160},
{ 536, 168, -120},
{ 680, 200, -144},
{ 848, 272, -176},
{ 1048, 288, -232},
{ 1088, 296, -256},
{ 1192, 288, -208},
// 3... | { 896, 64, -16},
{ 1072, 72, -24},
{ 1160, 136, -72},
{ 1136, 120, -152},
{ 1256, 176, -128},
{ 1144, 168, -176},
{ 952, 128, -160},
{ 1136, 128, -136},
{ 1224, 160, -112},
{ 1056, 184, -120},
{ 768, 192, -112},
{ 544, 216, -152},
{ 464, 168, -160},
{ 496, 128, -6... |
{ 728, 216, -224},
{ 552, 192, -216},
{ 512, 176, -216},
{ 592, 136, -176},
{ 728, 176, -200},
// 40 seconds
{ 944, 240, -232},
{ 1104, 288, -288},
{ 1016, 280, -288},
{ 1176, 296, -176},
{ 1360, 328, -224},
{ 1088, 312, -200},
{ 1080, 312, -176},
{ 1160, 288, -1... |
e STM32F2_COMPATIBLE
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
//! Deduced by looking at the prescalers in stm32f2xx_spi.h
#define SPI_FREQ_LOG_TO_PRESCALER(LG) (((LG) - 1) * 0x8)
//! Bits in CR1 we intend to keep when updating it
#define CR1_CLEAR_MASK ((uint16_t)0x3040)
//! SPI / I2S DM... | if (bus->spi == SPI6) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI6;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
} |
}
static uint16_t prv_spi_find_prescaler(const SPIBus *bus) {
int lg;
if (bus->state->spi_clock_speed_hz > (bus->state->spi_clock_periph_speed / 2)) {
lg = 1; // Underclock to the highest possible frequency
} else {
uint32_t divisor = bus->state->spi_clock_periph_speed / bus->state->spi_clock_speed_hz;
... |
_text_reset_state();
rocky_api_graphics_path2d_reset_state();
JS_VAR event = rocky_global_create_event(ROCKY_EVENT_DRAW);
JS_VAR context_2d = prv_create_canvas_context_2d_for_layer(layer);
jerry_set_object_field(event, ROCKY_EVENT_DRAW_CONTEXT, context_2d);
rocky_global_call_event_handlers(event);
rocky_api... | prv_graphics_color_to_char_buffer(color, buf) | ;
return jerry_create_string((const jerry_char_t *)buf);
}
JERRY_FUNCTION(prv_set_stroke_style) {
return prv_graphics_set_color(argc, argv, graphics_context_set_stroke_color);
}
JERRY_FUNCTION(prv_get_stroke_style) {
return prv_graphics_get_color_string(rocky_api_graphics_get_gcontext()->draw_state.stroke_color... |
e66b7", },
{ 2147483646LL, 16, "7FFFFFFE", },
{ 2147483646LL, 16, "7ffffffe", },
{ -2147483647LL, 16, "-7FFFFFFF", },
{ -2147483647LL, 16, "-7fffffff", },
{ 2147483646LL, 17, "53G7F547", },
{ 2147483646LL, 17, "53g7f547", },
{ -2147483647LL, 17, "-53G7F548", },
{ -2147483647LL, 17, "-53g7f548", },
{ 2... | cl_assert_equal_i(strtol("-", NULL, 10), 0) | ;
cl_assert_equal_i(strtol(" +", NULL, 10), 0);
cl_assert_equal_i(strtol("+", NULL, 10), 0);
cl_assert_equal_i(strtol(" -+123", NULL, 10), 0);
cl_assert_equal_i(strtol("+-123", NULL, 10), 0);
}
void test_strtol__end(void) {
char *end;
char *s;
s = "";
strtol(s, &end, 10);
cl_assert_equal_p(s, end);
... |
_init(AttributeList *attr_list,
TimelineItemActionGroup *action_group,
uint8_t **buffer,
uint8_t num_attributes,
uint8_t num_actions,
const uint8_t *attributes_per_actions) {
... | attribute_list_get_buffer_size(src_attr_list) | ;
if (src_attr_list && dest_attr_list) {
rv = attribute_list_copy(dest_attr_list, src_attr_list,
buffer, MIN(buffer + attr_list_size, buf_end));
if (!rv) {
PBL_LOG(LOG_LEVEL_ERROR, "Error deep-copying pin attribute list");
return false;
}
}
if (src_action_grou... |
EST_FLASH_LOCK_PROTECTION
#include "flash_region/flash_region.h"
#include "drivers/task_watchdog.h"
#include "drivers/watchdog.h"
// This test attempts to write over every region of the flash.
// If we can still boot PRF after running this, it means we have successfully
// protected those regions
void flash_expect_pro... | dbgserial_putstr("woah, failed to enter stop mode") | |
data starts
prv_convert_accel_raw_data_to_mgs(&frame_buf[a_begin], data);
}
static void prv_drain_fifo(void) {
// we can't drain the fifo if we are in low power mode so we have
// to temporarily enter normal mode
bool was_low_power = (s_accel_power_mode == BMI160_Accel_Mode_Low);
if (was_low_power) {
bmi... | (BOARD_CONFIG_ACCEL.accel_ints[i]) | |
OR_ELSE(GColorOxfordBlue, GColorWhite))
#define TWELVE_HOURS (SECONDS_PER_HOUR * 12)
static void prv_render_sleep_sessions(GContext *ctx, HealthSleepSummaryCardData *data) {
const int num_sessions = health_data_sleep_get_num_sessions(data->health_data);
ActivitySession *sessions = health_data_sleep_get_sessions(... | health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
0, HEALTH_PROGRESS_BAR_MAX_VALUE) | ;
prv_render_sleep_sessions(ctx, data);
prv_render_typical_markers(ctx, data);
// This is required to get the rounded corners on the outside of the rectangle
graphics_context_set_stroke_width(ctx, 2);
graphics_context_set_stroke_color(ctx, CARD_BACKGROUND_COLOR);
graphics_draw_round_rect(ctx, &s_sleep_su... |
cating the current BLE connectivity role to the phone, from Pebble's point of view.
typedef enum {
GAPLERoleSlave,
GAPLERoleMaster,
} GAPLERole;
// -------------------------------------------------------------------------------------------------
// Static Variables -- MUST be protected with bt_lock/unlock!
//! Th... | for (GAPLEClient c = 0; c < GAPLEClientNum; ++c) {
GAPLEConnectionClient *client = &intent->client[c];
if (client->is_used) {
*task_mask &= ~gap_le_pebble_task_bit_for_client(c);
}
} |
}
//! extern'd for gatt.c, used to determine to what tasks a "Buffer Empty" event should be sent.
//! Helper function to build a PebbleTaskBitset task_mask of the clients' tasks that are virtually
//! connected to specified real connection and therefore need to receive events for it.
//! bt_lock is assumed to be take... |
zero digits outputting zero)
snprintf(dstbuf, 256, "%.1Xzero%.1X", 0, 1);
cl_assert_equal_s(dstbuf, "0zero1");
// Variable length character output
snprintf(dstbuf, 256, "There are %*X lights", 3, 16);
cl_assert_equal_s(dstbuf, "There are 10 lights");
// Variable length digits output
snprintf(dstbuf, 25... | snprintf(dstbuf, 256, "%n", &val) | ;
cl_assert_equal_i(val, 0);
snprintf(dstbuf, 256, "Incredible mechanical monster%n comming soon%n!!", &val, &val2);
cl_assert_equal_i(val, 29);
cl_assert_equal_i(val2, 42);
// Note: Newlib actually doesn't support %hhn, breaking standard.
hhntest[0] = hhntest[1] = hhntest[2] = hhntest[3] = 0;
snprintf(... |
/*
* 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_WARNING, "Discovery service_changed_handle but no device connected?");
return;
} |
bt_driver_cb_gatt_client_discovery_handle_service_changed(connection, payload->handle);
}
void hc_endpoint_discovery_handler(const HcProtocolMessage *msg) {
bt_lock();
{
switch (msg->command_id) {
case HcMessageID_Discovery_Service_Found:
prv_handle_new_service_found((HcProtocolDiscoveryServi... |
/*
* 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(!animation_private_using_legacy_2(NULL)) | ;
PropertyAnimationPrivate *property_animation = prv_find_property_animation(property_animation_h);
if (!property_animation) {
return;
}
uint32_t result = interpolate_uint32(distance_normalized,
property_animation->values.from.uint32,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_permission_mappings) | ; ++i) {
if (s_permission_mappings[i].priv_read == region->priv_read &&
s_permission_mappings[i].priv_write == region->priv_write &&
s_permission_mappings[i].user_read == region->user_read &&
s_permission_mappings[i].user_write == region->user_write) {
return s_permission_mappings[i].v... |
e {
health_util_format_hours_and_minutes(duration_str, duration_buffer_size,
duration_s, headings);
}
const char *activity_label;
if (session->type == ActivitySessionType_Run) {
activity_label = i18n_get("Run", headings);
} else if (session->type == ActivitySess... | i18n_get("Avg HR", headings) | , headings_buf_size);
string_list_add_string(values, values_buf_size, hr_str, values_buf_size);
}
if (hr_zone_time_s) {
const int zone_1_minutes = ROUND(hr_zone_time_s[HRZone_Zone1], SECONDS_PER_MINUTE);
if (zone_1_minutes) {
snprintf(hr_str, hr_buf_size, i18n_get("%d Min", headings), zone_1_minu... |
te: We could probably skip this check altogether but I think it will
// prevent the BT controller from continously doing a status exchange
// only to find out it can't send any data
if (!prv_handle_rx_buffer_full()) {
prv_handle_int_idle();
}
break;
case SPITransportState_Wait... | prv_indicate_has_data_if_idle() | |
/*
* 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 (!same_adc) {
ADC_Init(device->adc, &ADC_InitStruct);
} |
// Regular channel configuration
ADC_RegularChannelConfig(VREF_ADC, ADC_Channel_Vrefint, 1, ADC_SampleTime_144Cycles);
ADC_RegularChannelConfig(device->adc, device->adc_channel, same_adc ? 2 : 1,
ADC_SampleTime_144Cycles);
if (same_adc) {
// ScanConvMode enabled, so need to reque... |
PBL_LOG(LOG_LEVEL_INFO, "Starting App Throttling for %s", curr_task);
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Starting App Throttling for %s", curr_task);
}
analytics_inc(ANALYTICS_DEVICE_METRIC_APP_THROTTLED_COUNT, AnalyticsClient_System);
vTaskPrioritySet(pebble_task_get_handle_for_task(PebbleTask_App),
... | {
// The timer is on ABP1 which is clocked by PCLK1
RCC_ClocksTypeDef clocks;
RCC_GetClocksFreq(&clocks);
uint32_t timer_clock = clocks.PCLK1_Frequency; // Hz
uint32_t prescale = RCC->CFGR & RCC_CFGR_PPRE1;
if (prescale != RCC_CFGR_PPRE1_DIV1) {
// per the stm32 'clock tree' diagram, if the prescaler f... |
// Setup another unused interrupt vector to handle our low priority interrupts. When we need to do higher
// level functions (like PBL_LOG), we trigger this lower-priority interrupt to fire. Since it runs at
// configMAX_SYSCALL_INTERRUPT_PRIORITY or lower, it can at least call FreeRTOS ISR functions.
NVIC_Ini... |
: %"PRIu32 " MMP: %"PRIu32,
size, dma_time, pol_time, mmap_time);
kernel_free(buffer_dma_ptr);
kernel_free(buffer_pol);
kernel_free(buffer_mmap);
return success;
}
struct FlashReadTestValues {
int size;
int offset;
};
const struct FlashReadTestValues FLASH_READ_TEST_TABLE[] =... | prompt_send_response("FAILURE: sector not blank!?!") | ;
} else {
++passes;
}
profiler_start();
is_blank = flash_impl_blank_check_subsector(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN);
profiler_stop();
blank = profiler_get_total_duration(true);
prompt_send_response_fmt(buf, buf_size, "Subsector blank check via read took: %"PRIu32,
bl... |
/*
* 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... | watch_app_prefs_db_init() | ;
// Set up our test prefs with some random data
SerializedSendTextPrefs *prefs = (SerializedSendTextPrefs *)s_send_text_prefs;
prefs->num_contacts = NUM_SEND_TEXT_CONTACTS;
for (int i = 0; i < NUM_SEND_TEXT_CONTACTS; ++i) {
prefs->contacts[i] = (SerializedSendTextContact) {
.is_fav = (i < (NUM_SEND_... |
true;
}
static bool prv_legacy_handle_progress(PebblePutBytesEvent *event) {
if (!s_current_completion_status.use_legacy_mode) {
return false;
}
LegacyFwUpdateCompletionStatus *status = &s_current_completion_status.legacy_status;
switch (event->object_type) {
case ObjectFirmware:
status->firmwa... | (s_firmware_update_semaphore) | ;
}
unsigned int firmware_update_get_percent_progress(void) {
if (!firmware_update_is_in_progress()) {
return 0;
}
uint32_t progress = 0;
if (prv_legacy_firmware_update_get_percent_progress(&progress)) {
return progress;
}
FwUpdateCompletionStatus *status = &s_current_completion_status.status;
... |
1);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_rmax_aa_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
#endif
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS ==... | (&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 3) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r3_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT)) / 2) - 1);
cl_check(gbitmap_pb... |
ght_x100_out = state->hr.metrics.previous_median_total_weight_x100;
}
}
// --------------------------------------------------------------------------------------------
void activity_metrics_prv_reset_hr_stats(void) {
ActivityState *state = activity_private_state();
mutex_lock_recursive(state->mutex);
{
sta... | (full_day_resting_calories, ACTIVITY_CALORIES_PER_KCAL) | ;
}
}
}
// Copy values from old history into correct slot in new history
for (int i = 0; i < ACTIVITY_HISTORY_DAYS; i++) {
int new_index = i + old_age;
if (new_index >= 0 && new_index < ACTIVITY_HISTORY_DAYS) {
new_history.values[new_index] = old_history.va... |
char error_code_buffer[12];
itoa_hex(error_code, error_code_buffer, sizeof(error_code_buffer));
dbgserial_putstr(error_code_buffer);
display_error_code(error_code);
static uint8_t prev_button_state = 0;
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK;
while (1) {
// See if we shou... | ("Force-booting recovery mode...") | ;
}
if (force_boot_recovery_mode || check_for_fw_start_failure()) {
if (!switch_to_recovery_fw()) {
// We've failed to load recovery mode too many times.
sad_watch(ERROR_CANT_LOAD_FW);
}
} else {
check_update_fw();
}
if (check_and_increment_reset_loop_detection_bits()) {
sad_watc... |
space character.
void word_trim_preceeding_whitespace(GContext* ctx, Word* word, const TextBoxParams* const text_box_params) {
while (word_trim_preceeding_codepoint(ctx, word, SPACE_CODEPOINT, text_box_params));
}
////////////////////////////////////////////////////////////
// Walk Line
typedef void (*CharVisitorCa... | while (walked_width_px + next_glyph_width_px + suffix_width_px <= available_horiz_px) {
GRect cursor = {
.origin = line->origin,
.size.w = next_glyph_width_px,
.size.h = fonts_get_font_height(text_box_params->font)
};
cursor.origin.x += walked_width_px;
char_visitor_cb(ctx, text_box_p... |
// Trim trailing whitespace
if (last_visited_char) {
while ((current_codepoint == NEWLINE_CODEPOINT || current_codepoint == SPACE_CODEPOINT)) {
// Newlines should not adjust the width
if (current_codepoint == NEWLINE_CODEPOINT) {
next_glyph_width_px = 0;
} else {
next_glyph_w... |
bytes);
s_num_captured_activity_sessions = 0;
time_t now = rtc_get_time();
int walk_len = 15;
KAlgTestActivitySession exp_session_walk = {
.activity = KAlgActivityType_Walk,
.start_utc = now + 5 * SECONDS_PER_MINUTE,
.steps = walk_len * 80, // 80 steps/min
.len_minutes = walk_le... | (s_kalg_state) | ;
s_kalg_state = NULL;
}
|
/*
* 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->window, &(WindowHandlers) {
.load = prv_window_load }) | ;
const bool animated = true;
app_window_stack_push(&data->window, animated);
accel_double_tap_service_subscribe(prv_handle_tap);
}
static void prv_handle_deinit(void) {
AppData *data = app_state_get_user_data();
app_free(data);
}
static void s_main(void) {
prv_handle_init();
app_event_loop();
prv... |
de <stdint.h>
#include <string.h>
#include "console/cobs.h"
#include "console/console_internal.h"
#include "console/dbgserial.h"
#include "console/pulse_internal.h"
#include "console/pulse_llc.h"
#include "console/pulse_protocol_impl.h"
#include "kernel/pbl_malloc.h"
#include "os/mutex.h"
#include "services/common/new... | new_timer_delete(s_keepalive_timer) | ;
s_keepalive_timer = TIMER_INVALID_ID;
mutex_destroy(s_tx_buffer_mutex);
dbgserial_restore_baud_rate();
serial_console_set_state(SERIAL_CONSOLE_STATE_LOGGING);
}
void pulse_prepare_to_crash(void) {
}
static void prv_process_received_frame(void *frame_ptr) {
IncomingPulseFrame *frame = frame_ptr;
uint32... |
_DEPTH_BITS == 1
ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GRect(20, 80, 40, 10), 4, GCornersAll, GColorBlack));
#else
ASSERT_CALLED(prv_fill_rect_aa(&context, &GRect(20, 80, 40, 10), 4, GCornersAll, GColorBlack));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__lock(void) {
// Test all the setup test... | (&context, GColorBlue) | ;
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Fill Color
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_fill_color(&context, GColorGreen);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Compositing Mode... |
R_CORRECTION_VAL 16
#define CORRECTION_VAL_MASK ((1 << BITS_PER_CORRECTION_VAL) - 1)
static CompassStatus s_current_cal_status = CompassStatusDataInvalid;
static int16_t s_active_corr[3] = { 0 };
static bool s_service_init = false;
static bool s_saved_corr_present = false;
static int16_t s_saved_corr[3... | {
// the watch has been flipped over. If someone is viewing the watch
// at a pitch > 90 degrees, this means the heading will rotate around
// on them (since technically, the 'front' of the watch is pointing
// at them.) Flip the heading back around in this case.
corr = TRIG_MAX_ANGLE / 2;
} |
mx_rot = (mx * cos_lookup(pitch)) / TRIG_MAX_RATIO;
mx_rot += (((my * sin_lookup(pitch)) / TRIG_MAX_RATIO) * sin_lookup(roll)) /
TRIG_MAX_RATIO;
mx_rot += (((mz * sin_lookup(pitch)) / TRIG_MAX_RATIO) * cos_lookup(roll)) /
TRIG_MAX_RATIO;
my_rot = mz * sin_lookup(roll) - my * cos_lookup(roll);
m... |
/*
* 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... | content_indicator_init_buffer(buffer) | ;
}
void test_health_hr_summary_card__cleanup(void) {
}
// Helpers
//////////////////////
static void prv_create_card_and_render(HealthData *health_data) {
Window window;
window_init(&window, WINDOW_NAME("Health"));
Layer *window_layer = window_get_root_layer(&window);
Layer *card_layer = health_hr_summary_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... | memchr(str, 0, length) | |
olor_boundary(void *subject, int16_t boundary) {
s_phone_ui_data->bg_color.boundary = boundary;
layer_mark_dirty(&s_phone_ui_data->window.layer);
}
static int16_t prv_get_color_boundary(void *subject) {
return s_phone_ui_data->bg_color.boundary;
}
static const PropertyAnimationImplementation s_color_slide_anima... | phone_format_caller_name(caller_text, s_phone_ui_data->caller_id_text_buf, NAME_BUFFER_LENGTH) | |
eBuffer));
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
}
// Teardown
void test_graphics_draw_line__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_c... | (&ctx, fb) | ;
layer_set_update_proc(&layer, &across_y_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_y_offset_layer")));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback)... |
272, -96, -984},
{ -280, -88, -992},
{ -288, -80, -968},
{ -280, -104, -992},
{ -280, -88, -960},
{ -280, -88, -968},
{ -312, -64, -1024},
{ -520, -24, -944},
{ -312, 16, -1056},
{ -280, -72, -888},
// 34 seconds
{ -240, 16, -1024},
{ -272, -8, -1008},
{ -280, 8, -101... | { 72, 392, -992},
{ 88, 248, -984},
{ 80, 272, -960},
{ 8, 216, -952},
{ 40, 192, -992},
{ 40, 208, -968},
{ 72, 144, -1000},
{ 104, 152, -1008},
{ 112, 112, -1024},
{ 128, 144, -1008},
{ 152, -32, -1144},
{ 96, -216, -920},
{ 72, -32, -1088},
{ -24, 112, -1016},
... |
{ 1272, -64, -112},
{ 776, -8, -144},
{ 624, -8, -424},
{ 952, -24, -328},
{ 920, 40, -280},
{ 848, 40, -360},
{ 736, 192, -336},
{ 672, 272, -336},
{ 776, 328, -312},
{ 848, 408, -368},
{ 840, 320, -392},
{ 1048, 552, -488},
{ 1168, 704, -528},
{ 1040, 832, -488... |
lay_lookup_creator(
KinoReel *reel, GPointIndexLookupCreator creator, void *userdata, bool take_ownership) {
ScaleSegmentedData *data = kino_reel_transform_get_context(reel);
if (!data) {
return;
}
if (data->lookup.owns_userdata) {
applib_free(data->lookup.userdata);
}
data->lookup.creator = cre... | kino_reel_scale_segmented_set_stroke_width_curve(reel, prv_ease_in_out_last_half) | |
CON_BOX_WIDTH,
timeline_layout->layout_layer.layer.frame.size.h);
}
const GRect frame = { icon_frame->origin, icon_size };
// create the static reel
timeline_layout->icon_size = frame.size;
// init the kino layer
KinoLayer *icon_layer = &timeline_layout->icon_layer;
kino_layer_init... | layout_create_text_node_from_config(
&layout->layout_layer, &s_all_day_config.text.extent.node) | ;
// TODO: PBL-30522 Enable timeline list view text flow
// Remove when text flow is enabled
if (PBL_IF_ROUND_ELSE(layout->layout_layer.mode == LayoutLayerModePinnedThin, false)) {
const bool is_future = (layout->info->scroll_direction == TimelineScrollDirectionDown);
const int padding_left = is_future ? ... |
har buffer[80];
char time_buffer[26];
prompt_send_response_fmt(buffer, 80, "Time is now <%s>", rtc_get_time_string(time_buffer));
}
void clock_get_timezone_region(char* region_name, const size_t buffer_size) {
if (!region_name) {
return;
}
if (clock_is_timezone_set()) {
int region_id = clock_get_tim... | ("%l:%M %p") | |
ase the length is not what it should be, do not add data element.
return true; // continue parsing
}
const int8_t tx_power_level = *(int8_t *)elem->data;
// Call back to client with parsed data:
return callbacks->tx_power_level_cb(tx_power_level, cb_data);
}
// -------------------------------------------... | if (uuid_equal(ctx->service_uuid, &uuids[i])) {
// Found!
ctx->included = true;
return false; // stop parsing
} |
}
return true; // continue parsing
}
bool ble_ad_includes_service(const BLEAdData *ad, const Uuid *service_uuid) {
struct IncludesServiceCtx ctx = {
.service_uuid = service_uuid,
.included = false,
};
const BLEAdParseCallbacks callbacks = (const BLEAdParseCallbacks) {
.services_cb = includes_se... |
rv_hline_pattern_blend_horizontal_line_raw(GContext *ctx, int16_t y, int16_t x1,
int16_t x2, GColor color) {
prv_blend_horizontal_line_raw(&ctx->dest_bitmap, y, x1, x2, color);
}
void test_graphics_draw_core__blend_horizontal_line_raw(void) {
GContext ctx;
... | {
prv_blend_vertical_line_raw(&ctx->dest_bitmap, x, y1, y2, color);
} |
void test_graphics_draw_core__blend_vertical_line_raw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
setup_test_aa_sw(&ctx, fb, CLIP_RECT_CLIP_BOX, CLIP_RECT_DRAW_BOX, false, 1);
prv_draw_vline_test_pattern(&ctx, prv_vline_pattern_blend_vertical_line_raw);
cl_check(gbitmap_pbi_eq(&ctx.dest_bi... |
{
BLEAdData *ad = create_ad(NULL, NULL);
GAPLEAdvertisingJobTerm advert_term = {
.min_interval_slots = 160,
.max_interval_slots = 320,
.duration_secs = 10,
};
GAPLEAdvertisingJobRef job;
job = gap_le_advert_schedule(ad, &advert_term, sizeof(advert_term)/sizeof(GAPLEAdvertisingJobTerm),
... | gap_le_advert_unschedule_job_types(&tag, 1) | ;
// should have 3 jobs unscheduled at this point and 1 still running
cl_assert_equal_i(s_unscheduled_cb_count, 3);
cl_assert_equal_b(gap_le_is_advertising_enabled(), true);
// make sure after we unschedule all the jobs no more are running
tag = GAPLEAdvertisingJobTagDiscovery;
gap_le_advert_unschedule_jo... |
stem_flash_write(FIRMWARE_BASE + i, buffer, chunk_size, NULL, NULL)) {
dbgserial_putstr("We're dead");
return false;
}
prv_display_write_progress(i + chunk_size, firmware_length, NULL);
}
return true;
}
static bool check_firmware_crc(FirmwareDescription* firmware_description) {
dbgserial_prin... | (BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_ONE) | |
misc.h"
#include "util/delay.h"
#include <inttypes.h>
#include <stdint.h>
#define MAX_CHUNK_SIZE 65536
static bool check_valid_firmware_crc(uint32_t flash_address, FirmwareDescription* desc) {
dbgserial_putstr("Checksumming firmware update");
const uint32_t crc = flash_calculate_checksum(flash_address, desc->fir... | boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS) | ;
boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
boot_bit_clear(BOOT_BIT_NEW_FW_INSTALLED);
return;
}
dbgserial_putstr("New firmware is available!");
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
boot_bit_clear(BOOT_BIT_RECOVERY_LOAD_FAIL_STRI... |
/*
* 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... | {
static uint8_t last_bar_fill = UINT8_MAX;
// Scale progress to the number of pixels in the progress bar,
// rounding half upwards.
uint8_t bar_fill =
((numerator * UPDATE_PROGRESS_MAX) + ((denominator+1)/2)) / denominator;
// Don't waste time and power redrawing the same screen repeatedly.
if (bar_f... |
bool boot_display_show_error_code(uint32_t error_code) {
prv_set_parameter(error_code);
prv_draw_scene(SCENE_ERROR);
if (prv_wait_busy()) {
prv_screen_on();
return true;
} else {
return false;
}
}
void boot_display_screen_off(void) {
prv_screen_off();
prv_draw_scene(SCENE_BLACK);
prv_wait... |
/*
* 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... | (global_lock) | ;
printf("blah %p", global_lock);
mutex_unlock(global_lock);
}
void nest() {
nest2();
}
void cond(void *glob_ptr) {
mutex_lock(global_lock);
while (glob_ptr) {
printf("blah %p", glob_ptr);
}
mutex_unlock(global_lock);
}
void timeout() {
mutex_lock_with_timeout(global_lock);
mutex_unlock(glob... |
ARRAY_LENGTH(samples) | ;
return samples;
}
| |
break;
case SPISlavePortDMAState_ReadWrite:
slave->slave_state->dma_state = SPISlavePortDMAState_ReadWriteOneInterrupt;
break;
case SPISlavePortDMAState_Idle:
default:
WTF;
}
SPIDMACompleteHandler handler = slave->slave_state->dma_complete_handler;
if (is_done && handler) {
r... | (slave->tx_dma, (void *)&slave->spi_bus->spi->DR, out, len,
prv_dma_irq_handler, (void *)slave) | ;
}
void spi_ll_slave_read_write_dma_stop(const SPISlavePort *slave) {
if ((slave->slave_state->dma_state != SPISlavePortDMAState_ReadWrite) &&
(slave->slave_state->dma_state != SPISlavePortDMAState_ReadWriteOneInterrupt)) {
return;
}
PBL_ASSERTN(slave->tx_dma && slave->rx_dma);
PBL_ASSERTN(slave->sl... |
assert_equal_p(aaa, stack[2]);
// go to child if possible
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(aaaa, actual);
cl_assert_equal_i(3, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(aa, stack[1]);
cl_assert_... | (&parent, &GPoint(9, 9)) | , &child_a);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(10, 10)), &parent);
layer_add_child(&child_a, &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(9, 9)), &child_f);
cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(1, 1)), &child_... |
ric metric = (HealthMetric)alert;
if (prv_is_heart_rate_metric(metric) && !sys_activity_prefs_heart_rate_is_enabled()) {
return false;
}
switch (metric) {
case HealthMetricHeartRateBPM:
state->cache->alert_threshold_heart_rate = (HealthServiceMetricAlertInfo) {};
return true;
default:
... | sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Walk) | ) {
result |= HealthActivityWalk;
}
if (sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Run)) {
result |= HealthActivityRun;
}
if (sys_activity_sessions_is_session_type_ongoing(ActivitySessionType_Open)) {
result |= HealthActivityOpenWorkout;
}
return result;
#endif
}
// --... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.