prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
itmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw4_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, 4);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw4_clip_nxny.${BIT_DE... | (&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, false, 3) | ;
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw3_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// SW = 4
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLI... |
// copy length from iter to out_len, then save a local copy of the length
*out_int = *(uint16_t*)iter;
iter += sizeof(uint16_t);
return iter;
}
static BlobDBToken prv_try_read_token(const uint8_t *data, uint32_t length) {
if (length < sizeof(BlobDBToken)) {
return 0;
}
return *(BlobDBToken*)data;
... | prv_handle_database_clear(session, data, data_length) | ;
break;
// Commands not implemented.
case BLOB_DB_COMMAND_READ:
case BLOB_DB_COMMAND_UPDATE:
PBL_LOG(LOG_LEVEL_ERROR, "BlobDB Command not implemented");
// Fallthrough
default:
PBL_LOG(LOG_LEVEL_ERROR, "Invalid BlobDB message received, cmd is %u", cmd);
prv_send_response(s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (msg_text_layer, "Addr Bus Test") | |
xpect_bmp_data,
.row_size_bytes = bounds.size.w,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = src_bitmap->bounds
};
// Verify that the compositing mode is correctly applied when the source is opaque and
// the tint color is not clear.
memset(dest_data, GC... | (0, y_lower, 3, 1) | |
id) {
ActivityState *state = activity_private_state();
return state->resting_calories;
}
// --------------------------------------------------------------------------------------------
uint32_t activity_metrics_prv_get_active_calories(void) {
ActivityState *state = activity_private_state();
return state->acti... | (state->mutex) | ;
}
// ------------------------------------------------------------------------------------------------
void activity_metrics_prv_init(SettingsFile *file, time_t utc_now) {
ActivityState *state = activity_private_state();
// Roll back the history if needed and init each of the metrics for today
for (ActivityMetr... |
{ 1040, 776, -72},
{ 1408, 632, 32},
{ 1776, 624, 56},
{ 1896, 528, 64},
{ 1848, 432, 64},
{ 1800, 408, 0},
{ 1728, 416, -152},
{ 1528, 264, -192},
{ 1296, 136, -208},
{ 1104, -208, -104},
{ 896, -416, -184},
{ 1016, -304, -232},
{ 1408, -104, -96},
{ 1632, 176, -224}... | { 1432, 80, -160},
{ 1624, 168, -304},
{ 1504, 248, -328},
{ 1400, 336, -296},
{ 1448, 432, -168},
{ 1544, 616, 8},
{ 1376, 728, -48},
{ 1352, 1088, -392},
{ 1304, 976, -304},
{ 944, 864, -168},
{ 1152, 896, -80},
{ 928, 744, -200},
{ 1152, 816, -200},
{ 1616, 704... |
{ 1656, 408, -192},
{ 1488, 232, -176},
{ 1344, -24, -216},
{ 1000, -368, -176},
{ 712, -472, -232},
{ 1096, -184, -320},
{ 1384, 80, -376},
{ 1488, 168, -232},
{ 1720, 296, -280},
{ 1576, 376, -304},
{ 1216, 416, -184},
{ 1096, 464, -120},
{ 1216, 480, -48},
{ 1... |
e "applib/graphics/framebuffer.h"
#include "applib/graphics/gdraw_command_image.h"
#include "applib/graphics/gdraw_command_sequence.h"
#include "applib/graphics/gdraw_command_private.h"
#include "applib/graphics/graphics_private_raw.h"
#include "stubs_applib_resource.h"
#include "stubs_app_state.h"
#include "stubs_hea... | printf("Invalid PDC image: %s\n", filename) | ;
return;
}
GContext ctx;
prv_setup_context(&ctx, gdraw_command_image_get_bounds_size(image));
gdraw_command_image_draw(&ctx, image, GPoint(0, 0));
// Write output to file of the same name with extension replaced with .png
char output[strlen(filename) + 5]; // add space for .pdc + '\0'
prv_get_bas... |
e(&context, GPoint(5, 5), GPoint(45, 10)));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, SW_EVEN, GColorB... | (&context) | ;
graphics_context_set_antialiased(&context, true);
cl_assert(memcmp(&draw_state, &context.draw_state, sizeof(GDrawState)) == 0);
// Stroke Width
draw_state = graphics_context_get_drawing_state(&context);
graphics_context_set_stroke_width(&context, 11);
cl_assert(memcmp(&draw_state, &context.draw_state, si... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (list_get_next(&c) == NULL) | |
//////////////////////////////////////////
void test_pulse_logging__initialize(void) {
s_num_event_puts = 0;
s_last_event = (PebbleEvent) { 0 };
s_num_packets_sent = 0;
s_num_bytes_sent = 0;
s_log_message_buffer[0] = '\0';
s_in_critical_section = false;
pulse_logging_init();
}
void test_pulse_logging... | pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTestD") | ;
cl_assert_equal_i(s_num_event_puts, 1);
cl_assert_equal_i(s_num_packets_sent, 0);
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTestTestTestTestTestTestE");
cl_assert_equal_i(s_num_event_puts, 1);
cl_assert_equal_i(s_num_packets_sent, 0);
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestT... |
// Minutes in zone 2
15, // Minutes in zone 3
};
// Tests
////////////////////////////////////////////////////////////////
void test_health_db__blob_db_api(void) {
const char *key = "monday_sleepData";
// insert one
cl_assert_equal_i(health_db_insert((uint8_t *)key, strlen(key),
... | cl_assert(!health_db_get_typical_value(ActivityMetricHeartRateZone1Minutes, Monday, &val_out)) | ;
cl_assert(!health_db_get_typical_value(ActivityMetricHeartRateZone2Minutes, Monday, &val_out));
cl_assert(!health_db_get_typical_value(ActivityMetricHeartRateZone3Minutes, Monday, &val_out));
}
void test_health_db__step_averages(void) {
const struct {
const char *key;
const char *val;
} entries[] = {... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// Set rect to GRectZero so the processor's .post function knows that nothing was drawn
rect = GRectZero;
goto call_processor_post_function_and_return;
} |
// TODO PBL-35694: what if src_bitmap == dest_bitmap....
// This currently works only if the regions are equal, or the dest region is
// to the bottom/right of it, since we scan from left to right, top to bottom
GBitmap *dest_bitmap = graphics_context_get_bitmap(ctx);
PBL_ASSERTN(dest_bitmap);
// Save th... |
ay not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES... | (res_path, &st) | == 0);
FILE *file = fopen(res_path, "r");
cl_assert(file);
uint8_t buf[st.st_size];
// copy file to fake flash storage
cl_assert(fread(buf, 1, st.st_size, file) > 0);
int fd = pfs_open(pfs_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, st.st_size);
cl_assert(fd >= 0);
cl_assert(st.st_size == pfs_write(fd, b... |
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
},
};
uint16_t session_entries = ARRAY_LENGTH(sessions);
activity_algorithm_post_process_sleep_sessions(session_entries, sessions);
cl_assert_equal_i(sessions[0].type, ActivitySessionType_Sleep);
}
{ // Create ... | (steps_awake_120m, exp_steps) | ;
// -------------------------------------------------------------------------------
// Try again while sleeping
time_t start_utc = rtc_get_time();
// Set to sleeping for the first 100 minutes
s_kalg_sleep_start_utc = start_utc;
s_kalg_sleep_m = 100;
activity_algorithm_metrics_changed_notification();
... |
/*
* 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... | (string, buffer, length) | ;
}
size_t sys_i18n_get_length(const char *string) {
return i18n_get_length(string);
}
// Tests
////////////////////////////////////
// (SU) = Single UNIX Specification extension
// (GNU)= glibc extension
// (TZ) = Olson's timezone package extension?
// (C99)= C99 extension
// We support them all~
#define EXTENS... |
/*
* 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_WARNING, "log: NULL data pointer") | ;
return DATA_LOGGING_INVALID_PARAMS;
}
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspace_buffer(data, num_items * session->item_size);
}
return dls_log(session, data, num_items);
}
|
{ -40, -136, -992},
{ -8, -136, -992},
{ -40, -152, -1016},
{ 0, -80, -992},
{ -48, -80, -1016},
{ -24, -128, -992},
{ -16, -136, -992},
{ -32, -136, -992},
{ -16, -144, -976},
{ -16, -128, -1008},
{ -24, -112, -992},
{ -16, -112, -1000},
{ -40, -136, -1024},
// 177 s... | { -88, 56, -1064},
{ -8, -80, -1040},
{ -72, 304, -1096},
{ -80, 104, -784},
{ -40, -16, -960},
{ -104, 152, -1120},
{ -40, 40, -744},
{ -184, 200, -1056},
{ -40, 16, -912},
{ -168, -72, -1088},
{ 8, 184, -1040},
{ -80, -104, -856},
{ -224, 536, -1200},
{ 32, -288... |
{ 32, 272, -1064},
{ 40, 184, -904},
{ 40, 248, -928},
{ 24, 216, -936},
{ 0, 216, -912},
{ -24, 272, -968},
// 185 seconds
{ -32, 232, -952},
{ -8, 232, -944},
{ 8, 224, -952},
{ 8, 224, -944},
{ 0, 208, -896},
{ -8, 248, -968},
{ 24, 216, -928},
{ 16, 256, ... |
ed;
typedef enum {
ReconnectType_None, // Not advertising for reconnection
ReconnectType_Plain, // Advertising for reconnection with empty payload
ReconnectType_BleHrm // Advertising for reconnection with HRM payload
} ReconnectType;
// --------------------------------------------------------------------------... | {
prv_set_and_evaluate(&s_is_basic_reconnection_enabled, false);
} |
bt_unlock();
}
// -----------------------------------------------------------------------------
void gap_le_slave_reconnect_start(void) {
#if RECOVERY_FW
return; // Only use discoverable packet for PRF
#endif
bt_lock();
{
if (prv_is_advertising_for_reconnection()) {
// Already advertising for reconn... |
, &first_icon_frame,
&second_icon_frame) - REL_BAR_LINE_WIDTH) / 2;
// Draw two lines that are centered in the side bar
// Bar 1
// Filled rect used to draw line of REL_BAR_LINE_WIDTH stroke width
graphics_context_set_fill_color(ctx, GColorWhite);
GRect layer_bo... | (ctx, ¬ch) | ;
const int dot_origin_y_max =
grect_get_max_y(&line) + dot_line_length + curr_offset - prev_offset;
// Dots in between two bars
GRect dot = GRect(line.origin.x, grect_get_max_y(&line) + REL_BAR_LINE_WIDTH + dot_padding,
REL_BAR_DOT_SIZE, REL_BAR_DOT_SIZE);
const int dot_advance = 2 *... |
{
if (timeout-- == 0) {
dbgserial_putstr("Display busy-wait timeout expired!");
return false;
}
delay_us(100);
}
return true;
}
static void prv_screen_on(void) {
prv_start_command(CMD_DISPLAY_ON);
prv_end_command();
}
static void prv_screen_off(void) {
prv_start_command(CMD_DISPLAY_O... | dbgserial_putstr("Display initialization failed.") | ;
prv_screen_off();
}
void display_boot_splash(void) {
prv_wait_busy();
prv_draw_scene(SCENE_SPLASH);
// Don't turn the screen on until the boot-splash is fully drawn.
prv_wait_busy();
prv_screen_on();
}
void display_firmware_update_progress(
uint32_t numerator, uint32_t denominator) {
static uint8_... |
ion.
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.
#define DST_YEARS_RANGE 3
#define DST_YEARS_OFFSET 1
tim... | {
rtc_set_time(*t);
} |
int new_gmt_offset = time_get_gmtoffset();
int new_utc_time = rtc_get_time();
PebbleEvent e = {
.type = PEBBLE_SET_TIME_EVENT,
.set_time_info = {
.utc_time_delta = new_utc_time - orig_utc_time,
.gmt_offset_delta = new_gmt_offset - orig_gmt_offset,
.dst_changed = false,
}
};
ev... |
, 80},
{ -928, 272, 112},
{ -1200, 280, 144},
{ -1248, 360, 72},
{ -1320, 368, 16},
{ -992, 512, -208},
{ -752, 472, -296},
{ -912, 336, -208},
{ -760, 272, -168},
{ -504, 248, -160},
{ -424, 296, -152},
{ -520, 304, -144},
{ -560, 272, -80},
{ -648, 256, -64},
{ ... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 15:52:37 local
AccelRawData *activity_sample_walk_100_pbl_25655_7(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25655_7
//> TEST... |
_bottom.y.raw_value) {
prv_swap_precise_points(&start_top, &start_bottom);
} else if (start_top.y.raw_value == start_bottom.y.raw_value &&
(config.start_quadrant.quadrant & GCornersBottom)) {
// Special case to make bottom edge to be on left side and keep masking algorithm happy
prv_swap_prec... | // Offsets for mirroring of scanline (they differ for even and odd height of the circle)
int special_line_offset_top = 1;
int special_line_offset_bottom = 1;
// Color hack
const GColor stroke_color = ctx->draw_state.stroke_color;
ctx->draw_state.stroke_color = ctx->draw_state.fill_color;
// In case of o... |
&starting_edge, &ending_edge, start_top, start_bottom);
prv_get_angles_mask_edge(y_middle, center, config.end_quadrant.quadrant,
&ending_edge, &starting_edge, end_top, end_bottom);
}
}
int16_t outer_edge = prv_get_ellipsis_border(... |
/*
* 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... | {
void *result = prv_malloc(size, client_pc);
if (result) {
memset(result, 0, size);
}
return result;
} |
void* applib_malloc(size_t size) {
#if defined(MALLOC_INSTRUMENTATION)
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return prv_malloc(size, saved_lr);
#else
return prv_malloc(size, 0);
#endif
}
void* applib_zalloc(size_t size) {
#if defined(MALLOC_INSTRUMENTATION)
register uintptr_t lr __asm... |
-8},
{ -696, 704, 24},
{ -696, 696, 16},
{ -688, 704, 0},
{ -688, 712, 16},
{ -680, 704, 16},
{ -688, 712, 8},
{ -672, 704, 8},
{ -680, 688, 0},
{ -680, 704, 16},
{ -680, 720, 8},
// 108 seconds
{ -672, 704, 0},
{ -688, 712, 0},
{ -664, 704, -8},
{ -664, 760,... | { -616, 704, -288},
{ -608, 736, -288},
{ -616, 736, -296},
{ -608, 736, -296},
{ -600, 728, -328},
{ -608, 712, -320},
{ -600, 736, -320},
{ -608, 712, -320},
{ -624, 704, -304},
{ -624, 728, -280},
{ -616, 712, -272},
{ -616, 688, -288},
{ -624, 720, -280},
{ -6... |
{ -592, 720, -312},
{ -616, 720, -320},
{ -600, 712, -320},
{ -600, 720, -328},
{ -600, 720, -312},
{ -608, 720, -328},
{ -592, 728, -352},
{ -600, 712, -360},
// 116 seconds
{ -600, 664, -296},
{ -640, 712, -240},
{ -584, 808, -272},
{ -648, 744, -176},
{ -656, ... |
InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
if (board_has_chg_fast()) {
gpio_use(BOARD_CONFIG_POWER.chg_fast.gpio);
GPIO_InitStructure.GPIO_Pin = BOARD_CONFIG_POWER.chg_fast.gpio_pin;
GPIO_Init(BOARD_CONFIG_POWER.chg_fast.gpio, &GPIO_InitStructur... | prv_battery_set_charge_enable(charging_enabled) | ;
periph_config_release_lock();
}
void battery_set_fast_charge(bool fast_charge_enabled) {
periph_config_acquire_lock();
prv_battery_set_fast_charge(fast_charge_enabled);
periph_config_release_lock();
}
|
ls, d), 1);
#endif
}
// --------------------------------------------------------------------------------------
// Test a spawn animation with a play count of 0
void test_animation__spawn_with_0_play_count(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_... | (b, true, false) | , delay_b + duration_b);
cl_assert_equal_i(animation_get_duration(b, true, true), total_duration_b);
cl_assert_equal_i(animation_get_duration(seq, false, false), total_duration_a + total_duration_b);
cl_assert_equal_i(animation_get_duration(seq, false, true),
play_count_seq * (total_duration_... |
prv_compare_recognizers_processed((int[]) { 4, 0, 1 }, 3, &s_recognizers_reset);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_p(manager.triggered, NULL);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, ... | (r1, &manager2) | ;
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert_equal_p(manager.active_layer, &layer_a);
cl_assert_equal_p(recognizer_get_manager(r1), &manager2);
recognizer_set_manager(r1, &manager);
recognizer_manager_deregister_recognizer(&manager, r1);
cl_assert(!recognizer_get_manager(r1));
c... |
);
cl_assert_equal_i(val_out, s_sleep_data[SD_TypicalSleepDuration]);
cl_assert(health_db_get_typical_value(ActivityMetricSleepRestfulSeconds, Monday, &val_out));
cl_assert_equal_i(val_out, s_sleep_data[SD_TypicalDeepSleepDuration]);
cl_assert(health_db_get_typical_value(ActivityMetricSleepEnterAtSeconds, Mon... | strlen(average_step_key) | ,
(uint8_t *)&average_steps_val, sizeof(average_steps_val)),
S_SUCCESS);
cl_assert(health_db_get_monthly_average_value(ActivityMetricStepCount, &val_out));
cl_assert_equal_i(val_out, average_steps_val);
const char *average_sleep_key = "average_sleepDurati... |
but if there
// is an integer remainder, the prescaler will ensure that the clock frequency is within spec.
prescaler -= 1;
}
// Make sure all the values fit in their corresponding fields
PBL_ASSERTN((duty_cycle_low <= TIMINGR_MASK_SCLL) &&
(duty_cycle_high <= TIMINGR_MASK_SCLH) &&
... | (bus, event) | ;
}
//! Handle an IRQ event on the specified \a bus
static void prv_event_irq_handler(I2CBus *bus) {
I2C_TypeDef *i2c = bus->hal->i2c;
I2CTransfer *transfer = &bus->state->transfer;
switch (transfer->state) {
case I2CTransferState_WriteRegAddress:
if ((i2c->ISR & I2C_ISR_TXIS) != 0) {
i2c->TXDR... |
{ 1040, 288, -64},
{ 1256, 272, -168},
{ 1136, 200, -440},
{ 1360, 88, -320},
{ 1048, -72, -256},
{ 1176, 8, -344},
// 13 seconds
{ 1168, 128, -472},
{ 1208, 128, -280},
{ 1184, 168, -184},
{ 1048, 240, -160},
{ 1016, 296, -176},
{ 976, 312, -96},
{ 984, 320, -56},
... | { 1088, 296, -8},
{ 1216, 320, 0},
{ 1160, 264, -8},
{ 1176, 184, -56},
{ 1352, 168, -176},
{ 1176, 192, -392},
{ 1128, 144, -280},
{ 1224, 152, -432},
{ 792, 88, -288},
{ 800, 176, -320},
{ 1176, 256, -344},
{ 1088, 272, -304},
{ 872, 152, -104},
{ 744, 184, -64}... |
{ 1136, 232, -280},
{ 1072, 224, -160},
{ 896, 160, -136},
{ 776, 200, -160},
{ 824, 256, -112},
{ 928, 296, -96},
{ 1016, 312, -80},
{ 1040, 328, -96},
{ 1168, 336, -144},
{ 1568, 400, -160},
{ 1280, 376, -48},
{ 1528, 416, -24},
{ 1056, 600, -248},
{ 824, 680, ... |
/*
* 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... | {
dma_request_init(dev->rx_dma);
} |
}
void uart_init(UARTDevice *dev) {
prv_init(dev, false /* !is_open_drain */, UARTCR1Flags_Duplex);
}
void uart_init_open_drain(UARTDevice *dev) {
prv_init(dev, true /* is_open_drain */, UARTCR1Flags_Duplex);
}
void uart_init_tx_only(UARTDevice *dev) {
prv_init(dev, false /* !is_open_drain */, UARTCR1Flags_TE... |
e_push_send(contents, payload_length);
}
static bool prv_isr_buffer_read_and_consume(void *buffer, size_t read_length) {
portENTER_CRITICAL();
const bool result = circular_buffer_copy(&s_isr_log_buffer, buffer, read_length);
if (result) {
circular_buffer_consume(&s_isr_log_buffer, read_length);
}
port... | (log_level, src_filename, src_line_number, message) | |
a_enabled) {
uart_clear_rx_dma_buffer(ACCESSORY_UART);
}
s_stream_context = context;
s_stream_cb = stream_callback;
s_has_sent_byte = false;
uart_set_tx_interrupt_enabled(ACCESSORY_UART, true);
// Block until the sending is complete, but timeout if we aren't able to send a byte for a while.
while (xSe... | accessory_manager_handle_character_from_isr((char)data) | |
.mosi, GPIO_OType_PP, GPIO_Speed_25MHz, GPIO_PuPd_NOPULL);
// Reset the SPI peripheral and enable the clock
RCC_APB2PeriphResetCmd(ICE40LP->spi.rcc_bit, ENABLE);
RCC_APB2PeriphResetCmd(ICE40LP->spi.rcc_bit, DISABLE);
periph_config_enable(ICE40LP->spi.periph, ICE40LP->spi.rcc_bit);
// Configure CR1 first:
... | set_4V5_power_state(false) | ;
delay_ms(2);
if (ICE40LP->use_6v6_rail) {
dbgserial_putstr("Disabling 6v6 (Display VDDC)");
set_6V6_power_state(false);
delay_ms(2);
}
}
void display_write_cmd(uint8_t cmd, uint8_t *arg, uint32_t arg_len) {
gpio_output_set(&ICE40LP->spi.scs, true); // SCS asserted (low)
delay_us(100);
pr... |
/*
* 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... | {
for (size_t i = 0; i < ARRAY_LENGTH(s_protocol_endpoints); ++i) {
const PebbleProtocolEndpoint* endpoint = &s_protocol_endpoints[i];
if (!endpoint || endpoint->endpoint_id > endpoint_id) {
break;
}
if (endpoint->endpoint_id == endpoint_id) {
return endpoint;
}
}
return NULL;
} | |
const bool prefer_larger_font = false;
prv_render_metric(ctx, metric_type, layer, bg_color, draw_hr_zones, prefer_larger_font);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! End Workout
static void prv_end_workout_up_click_handler(ClickRecognizerRef reco... | {
WorkoutActiveWindow *active_window = context;
prv_cycle_scrollable_metrics(active_window);
} |
static void prv_click_config_provider(void *context) {
window_set_click_context(BUTTON_ID_UP, context);
window_set_click_context(BUTTON_ID_SELECT, context);
window_set_click_context(BUTTON_ID_DOWN, context);
window_single_click_subscribe(BUTTON_ID_UP, prv_up_click_handler);
window_single_click_subscribe(BUT... |
// We need to wait a bit for the rail to stabilize before continuing to use the device.
// It takes 2.6ms for the LDO rails to ramp.
psleep(3);
return true;
}
return false;
}
} else {
if (*ref_count <= 1) {
// Set the register byte to XXXXX00X to disable the rail, ... | (PmicRegisters_CHIP_REV, chip_revision) | ;
prv_read_register(PmicRegisters_BUCK1_VSET, buck1_vset);
}
static void prv_clear_any_pending_interrupts(void) {
// Read the Int status registers to clear any pending bits.
// An interrupt wont fire if the matching bit is already set.
uint8_t throwaway_read_result;
prv_read_register(PmicRegisters_INTA, &thr... |
prompt_context);
}
bool prompt_context_append_char(PromptContext *prompt_context, char c) {
if (UNLIKELY(prompt_context->write_index + 1 >= PROMPT_BUFFER_SIZE_BYTES)) {
return false;
}
prompt_context->buffer[prompt_context->write_index++] = c;
return true;
}
// Crank up the optimization on this bad boy.
... | {
strncpy(contents->message, response, response_length);
} |
#if PULSE_EVERYWHERE
pulse_reliable_send(contents, total_size);
#else
pulse_best_effort_send(contents, total_size);
#endif
}
static void prv_pulse_done_command(void) {
pulse_send_message(PROMPT_RESP_DONE, NULL);
s_executing_command = ExecutingCommandNone;
}
#if PULSE_EVERYWHERE
void pulse2_prompt_packet_han... |
/*
* 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... | kernel_free(msg) | ;
return rv;
}
bool hc_endpoint_analytics_get_connection_quality(const BTDeviceInternal *device,
int8_t *rssi_out) {
HcProtocolMessage *msg = hc_protocol_enqueue_with_payload_and_expect(
HcEndpointID_Analytics, HcMessageID_Analytics_GetConnectionQuality,
... |
control responses before we try to reconnect
#define MAX_STRIKES 3
//! How often we'll go without some valid data from the smartstrap before sending a status message
//! and disconnecting if the smartstrap doesn't reply. This is in seconds.
#define STATUS_CHECK_INTERVAL 5
//! The minim... | (LOG_LEVEL_DEBUG, "Got link control status: Disconnect") | ;
smartstrap_link_control_disconnect();
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Got link control status: INVALID (%d)", status);
smartstrap_link_control_disconnect();
success = false;
}
} else if (header->type == LinkControlTypeProfiles) {
// profiles message
if ((data_length % si... |
/*
* 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... | distance_interpolate(distance_normalized,
property_animation->values.from.int16,
property_animation->values.to.int16) | ;
((PropertyAnimationLegacy2Implementation*)property_animation->animation.implementation)
->accessors.setter.int16(property_animation->subject, result);
}
void property_animation_legacy2_update_gpoint(PropertyAnimationLegacy2 *property_animation,
const uint32_t dis... |
ide);
}
}
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
TimelineAppData *data = context;
prv_exit(data);
}
static void prv_up_down_stopped(Animation *animation, bool finished, void *context) {
TimelineAppData *data = context;
if (finished) {
prv_set_state(data, Timel... | {
if (!timeline_model_iter_next(&new_idx, &has_new)) {
prv_set_state(data, TimelineAppStateStationary);
goto done;
}
if (has_new) {
timeline_layer_set_next_item(&data->timeline_layer, new_idx);
}
timeline_layer_move_data(&data->timeline_layer, 1);
} | else {
if (!timeline_model_iter_prev(&new_idx, &has_new)) {
prv_exit(data);
goto done;
}
if (has_new) {
timeline_layer_set_prev_item(&data->timeline_layer, new_idx);
}
timeline_layer_move_data(&data->timeline_layer, -1);
}
// If we interrupted a previous scroll, hasten this s... |
ker(entry)) {
return true;
}
return false;
}
static int16_t prv_get_chosen_row_index_for_id(SettingsActivityTrackerData *data,
AppInstallId worker_id) {
if (worker_id == INSTALL_ID_INVALID) {
return 0;
}
const uint16_t current_worker_app_index =
a... | (ctx, no_activities_string, font, box, overflow, alignment, NULL) | |
uPd_NOPULL);
gpio_af_init(&ICE40LP->spi.mosi, GPIO_OType_PP, GPIO_Speed_25MHz, GPIO_PuPd_NOPULL);
// Reset the SPI peripheral and enable the clock
RCC_APB2PeriphResetCmd(ICE40LP->spi.rcc_bit, ENABLE);
RCC_APB2PeriphResetCmd(ICE40LP->spi.rcc_bit, DISABLE);
periph_config_enable(ICE40LP->spi.periph, ICE40LP->sp... | dbgserial_putstr("Disabling 4v5 (Display VDDP)") | |
cycles, is_ddr);
} else {
qspi_indirect_read(dev->qspi, instruction, addr, dummy_cycles, buffer, length, is_ddr);
}
qspi_release(dev->qspi);
}
int qspi_flash_write_page_begin(QSPIFlash *dev, const void *buffer, uint32_t addr,
uint32_t length) {
const uint32_t offset_in_page ... | {
// make sure we're not trying to set any bits not within the mask
PBL_ASSERTN((value & mask) == value);
qspi_use(dev->qspi);
// first read the register
uint8_t reg_value;
prv_read_register(dev, read_instruction, ®_value, 1);
// set the desired bits
reg_value = (reg_value & ~mask) | value;
// ... |
static bool prv_protection_is_enabled(QSPIFlash *dev) {
uint8_t status;
prv_read_register(dev, dev->state->part->instructions.read_protection_status, &status, 1);
return (status & dev->state->part->block_lock.protection_enabled_mask);
}
status_t qspi_flash_write_protection_enable(QSPIFlash *dev) {
#if TARGET_Q... |
/*
* 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... | {
HcProtocolMessage *msg_copy = NULL;
bool buffer_allocated = *should_free;
if (!buffer_allocated) {
msg_copy = (HcProtocolMessage *)kernel_malloc_check(message->message_length);
memcpy(msg_copy, message, message->message_length);
} else {
msg_copy = message;
}
*should_free = false;
HcProto... |
void hc_protocol_cb_dispatcher_init(void) {
static const int HC_PROTOCOL_CB_DISPATCHER_MAX_JOBS_QUEUED = 15;
s_dispatcher = (HcProtocolCbDispatcher) {
.job_queue = xQueueCreate(
HC_PROTOCOL_CB_DISPATCHER_MAX_JOBS_QUEUED, sizeof(HcProtocolMessageHandlerEvent)),
};
TaskParameters_t task_params = {... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
app_timer_cancel(data->thumbsup_timer);
text_layer_set_text(&data->thumbsup_layer, "👍");
data->thumbsup_timer = app_timer_register(1000, prv_hide_thumbsup, data);
} |
static void prv_set_tap_text(AppData *data, uint32_t count, AccelAxisType axis) {
char axes[] = {'X', 'Y', 'Z'};
snprintf(data->text, sizeof(data->text), "Axis: %c\nDouble Taps: %6"PRIu32, axes[axis], count);
text_layer_set_text(&data->text_layer, data->text);
}
static void prv_window_load(Window *window) {
... |
, void *cb_data);
// -----------------------------------------------------------------------------
//! Internal parser callback. Gets called for a parsed TX Power Level element.
//! @param tx_power_level The TX Power Level value.
//! @param cb_data Pointer to arbitrary client data as passed to the parse call.
//! @ret... | {
if (elem->header.length != 2) {
// In case 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);
} |
// -----------------------------------------------------------------------------
//! Parser for Manufacturer Specific data element.
static bool parse_manufact_spec(const BLEAdElement *elem,
const BLEAdParseCallbacks *callbacks,
void *cb_data) {
if (e... |
/
[33]={ 1427590800, 1445734800, 0 * SECONDS_PER_HOUR },
/* WS (Western Samoa) [Pacific/Apia]
Rule WS 2012 max - Apr Sun>=1 4:00 0 S
Rule WS 2012 max - Sep lastSun 3:00 1 D
Sep 27th 2014 14:00 UTC ~ Apr 4th 2015 14:00 UTC, GMT+13 */
[34]={ 1411826400, ... | {
struct tm oct_31 = {
.tm_sec = 0,
.tm_min = 59,
.tm_hour = 23,
.tm_mday = 31,
.tm_mon = 9, // Oct
.tm_year = 2015 - 1900,
.tm_isdst = 1,
.tm_gmtoff = -5 * SECONDS_PER_HOUR,
};
struct tm nov_7 = {
.tm_sec = 0,
.tm_min = 15,
.tm_hour = 0,
.tm_mday = 7,
.tm_mon ... |
void test_clock__today(void) {
struct tm may_30 = {
.tm_sec = 0,
.tm_min = 59,
.tm_hour = 7,
.tm_mday = 30,
.tm_mon = 4, // May
.tm_year = 2016 - 1900,
.tm_isdst = 1,
.tm_gmtoff = -5 * SECONDS_PER_HOUR,
};
struct tm may_31 = {
.tm_sec = 0,
.tm_min = 0,
.tm_hour = 5,
... |
fer so that we can go
// back and zero out the steps in older minutes once we determine that we were definitely
// asleep for those minutes (there can be a KALG_MAX_AWAKE_LAG minute lag before we figure out
// that we woke up).
SharedCircularBuffer minute_data_cbuf;
AlgMinuteRecord minute_data_storage[ALG_MIN... | {
activity_sessions_prv_add_activity_session(&session);
} |
}
// ------------------------------------------------------------------------------------------
// Used from settings_file_each() callback to read in a chunk based on the SettingsRecordInfo
// given to the callback. Returns true if the chunk is within the designated key range and
// should be processed.
static bool ... |
char *name, uint8_t *platform_bits) {
if (address) {
if (key) {
// We should really collect all of the classic info and store once its complete
// However, since platform bits are going to be the last piece collected its ok
// to 0 it out here
uint8_t platform_... | {
return shared_prf_storage_get_root_key(key_type, key_out);
} |
void bt_persistent_storage_set_root_keys(SM128BitKey *keys_in) {
shared_prf_storage_set_root_keys(keys_in);
}
bool bt_persistent_storage_get_local_device_name(char *local_device_name_out, size_t max_size) {
return shared_prf_storage_get_local_device_name(local_device_name_out, max_size);
}
void bt_persistent_st... |
ndow_stack(data));
}
cleanup:
prv_cleanup_action_result(data, succeeded);
}
static bool prv_set_dialog_message(ActionResultData *data, TimelineResourceId timeline_res_id,
const char *message, bool success) {
const size_t message_buffer_size = strlen(message) + 1;
data->dialo... | (data->event_ref) | ;
applib_free(data);
}
static void prv_invoke_chaining_action(Window *chaining_window,
TimelineItemAction *action, void *context) {
ChainingWindowCBData *cb_data = context;
ActionResultData *data = applib_zalloc(sizeof(ActionResultData));
if (!data) {
return;
}
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info) | );
}
void test_text_resources__horiz_advance_multiple(void) {
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_assert(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info));
int8_t horiz_advance = text_resources_get_glyph_horiz_advance(&s_font_cache, 'a', &s_font_info);
cl_assert(horiz_advance !... |
tubs_queue.h"
#include "stubs_sleep.h"
#include "stubs_stop.h"
#include "stubs_task_watchdog.h"
#include "stubs_worker_manager.h"
#include "drivers/flash.h"
#include "drivers/flash/flash_impl.h"
void flash_api_reset_for_test(void);
TimerID flash_api_get_erase_poll_timer_for_test(void);
status_t return_success(void)... | stub_new_timer_cleanup() | ;
}
void test_flash_api__erase_subsector_calls_right_impl_func(void) {
flash_erase_subsector(0, callback, NULL);
cl_assert_equal_i(erase_subsector_begin_calls, 1);
cl_assert_equal_i(erase_sector_begin_calls, 0);
}
void test_flash_api__erase_sector_calls_right_impl_func(void) {
flash_erase_sector(0, callback, ... |
{
return false;
} |
GDrawState graphics_context_get_drawing_state(GContext *ctx) {
return (GDrawState) { };
}
bool graphics_release_frame_buffer(GContext *ctx, GBitmap *buffer) {
return false;
}
void graphics_context_set_drawing_state(GContext *ctx, GDrawState draw_state) {
}
void window_schedule_render(struct Window *window) {
}... | |
hs, DISABLE);
RCC_AHB3PeriphResetCmd(ahb3_periphs, ENABLE);
RCC_AHB3PeriphResetCmd(ahb3_periphs, DISABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, ENABLE);
RCC_APB1PeriphResetCmd(apb1_periphs, DISABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, ENABLE);
RCC_APB2PeriphResetCmd(apb2_periphs, DISABLE);
// The Corte... | (BOOT_BIT_FW_START_FAIL_STRIKE_TWO) | ;
} else {
dbgserial_putstr("Failed to start firmware, strike one.");
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
}
return false;
}
static bool prv_prf_button_combination_is_pressed(void) {
return (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)
&& button_is_pressed(BUT... |
/*
* 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... | {
AppData *data = app_malloc_check(sizeof(AppData));
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Bouncing Box"));
window_set_user_data(window, data);
window_set_fullscreen(window, true);
layer_set_update_proc(&window->layer, layer_update_proc);
cons... |
const PebbleProcessMd* bouncing_box_demo_get_app_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = s_main,
.name = "Bouncing Box"
};
return (const PebbleProcessMd*) &s_app_info;
}
|
hosen, bool selected) {
GFont font = fonts_get_system_font(chosen || selected?
FONT_KEY_GOTHIC_14_BOLD
: FONT_KEY_GOTHIC_14);
if (chosen && selected) {
// Draw rectangle behind text, invert text color
graphics_context_set_fill_color... | (s_window, true) | ;
window_set_window_handlers(s_window, &(WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload,
});
window_set_click_config_provider(s_window, click_config_provider);
const bool animated = true;
app_window_stack_push(s_window, animated);
}
static void deinit(void) {
AppData *da... |
///////////////////////////////////////////////////////////
#include "fake_system_task.h"
#include "fake_settings_file.h"
// Stubs
////////////////////////////////////////////////////////////////
#include "stubs_analytics.h"
#include "stubs_layout_layer.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "... | ((uint8_t *)key, key_len, &attr_list, &action_group) | ;
// Make sure we can get the data back
iOSNotifPrefs *notif_prefs = ios_notif_pref_db_get_prefs((uint8_t *)key, key_len);
cl_assert(notif_prefs);
Attribute *title = attribute_find(¬if_prefs->attr_list, AttributeIdShortTitle);
cl_assert(title);
cl_assert_equal_s(title->cstring, "Title");
Attribute *mu... |
nt32_t max_used_space = 4096;
cl_must_pass(settings_file_open(&file, "test_file_max_storage", max_used_space));
uint8_t key[5];
int key_len = 4;
uint8_t val[5];
int val_len = 4;
for (int i = 0; i < 100; i++) {
prv_print_stats(&file);
snprintf((char *)key, sizeof(key), "k%03d", i);
snprintf((char... | printf("Iteration %d val %s\n", i, val) | ;
set_and_verify(&file, key, key_len, val, val_len);
}
// Then, write to the same key many many times. This should only use up 16
// more bytes of the file if our used/free space tracking is working
// correctly, but may end up being counted as more if it's broken.
snprintf((char *)key, sizeof(key), "k%0... |
Uuid pin_uuid;
alarm_pin_add(s_monday, dummy_alarm_id, AlarmType_Basic, ALARM_KIND_WEEKENDS, &pin_uuid);
alarm_pin_remove(&pin_uuid);
cl_assert(uuid_equal(&pin_uuid, &s_last_timeline_item_removed_uuid));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//!... | cron_service_wakeup() | ;
cl_assert_equal_i(s_num_alarms_fired, 5);
cl_assert_equal_i(s_num_alarm_events_put, 5);
cl_assert_equal_i(s_num_timeline_adds, 41);
cl_assert_equal_i(s_num_timeline_removes, 30);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes off. First one should be... |
else {
*uuid_out = UUID_INVALID;
return false;
}
}
bool app_install_is_watchface(AppInstallId app_id) {
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(app_id, &entry)) {
return false;
}
return app_install_entry_is_watchface(&entry);
}
static const PebbleProcessMd *prv_get_md_fo... | app_cache_flush() | ;
}
|
/*
* 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... | (out_buf, '*', TZ_LEN) | ;
if (tz_zone_dst_char) {
*tz_zone_dst_char = (time_get_isdst(utc_time)) ? 'D' : 'S';
// Workaround for UK Winter, Greenwich Mean Time; UK Summer, British Summer Time
if (!strncmp(out_buf, "BDT", TZ_LEN)) {
strncpy(out_buf, "BST", TZ_LEN);
} else if (!strncmp(out_buf, "BST", TZ_LEN)) {
str... |
text_box_params,
Line* line, GRect cursor, const Codepoint codepoint) {
(void) ctx;
PBL_ASSERT(cursor.origin.x >= line->origin.x, "Text cursor x=<%u> ahead of line origin x=<%u>",
cursor.origin.x, line->origin.x);
const int glyph_width_px = prv_codepoint_get_horizont... | 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_width_px = prv_codepoint_get_horizo... |
if (line->suffix_codepoint) {
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;
if (char_visitor_cb) {
char_visitor_cb(ctx, text_box_params, line, cursor, line-... |
G GRect(0, 0, -20, -20)
#define RECT_NEG_W GRect(0, 0, -20, 0)
#define RECT_NEG_H GRect(0, 0, 0, -20)
void test_graphics_draw_text_${BIT_DEPTH_NAME}__zero(void) {
GContext ctx;
prv_setup_resources();
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18_BOLD;
cl_assert(text_resources_init_font(0, gothic_18_handle... | graphics_context_set_text_color(&ctx, GColorBlack) | ;
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NEG,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
setup_test_aa_sw(&ctx, fb, RECT_NEG, RECT_NEG, false, 1);
graphics_context_set_text_color(&ctx, GC... |
estroy(cur->data->mutex);
kernel_free(cur->data);
}
kernel_free(cur);
cur = next;
}
s_logging_sessions = NULL;
mutex_unlock_recursive(s_list_mutex);
}
//! Insert logging session with known id
void dls_list_insert_session(DataLoggingSession *logging_session) {
mutex_lock_recursive(s_list_mute... | {
s_list_mutex = mutex_create_recursive();
s_logging_sessions = NULL;
} |
bool dls_list_is_session_valid(DataLoggingSession *logging_session) {
mutex_lock_recursive(s_list_mutex);
DataLoggingSession *iter = s_logging_sessions;
while (iter != NULL) {
if (iter == logging_session) {
mutex_unlock_recursive(s_list_mutex);
return true;
}
iter = iter->next;
}
mu... |
re
* 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 "board/board.h"
#include "drivers/accessory.h"
#inclu... | {
uint16_t dr = uart_read_byte(BT_RX_BOOTROM_UART);
// The Dialog bootROM attempts to talk several serial protocols. While doing this it will
// reconfigure gpios as inputs and outputs and change what data it is pushing on the lines.
// For some architectures, this can result in framing errors ... | |
g_state_updated_event(s_ble_hrm_subscription_count);
}
static void prv_update_permission(GAPLEConnection *connection, HrmSharingPermission permission) {
bt_lock_assert_held(true);
if (prv_get_permission_by_device(&connection->device) == permission) {
return;
}
const bool prev_is_sharing = prv_is_sharing(co... | (sharing_request) | |
on_string),
"0x%" PRIx32, boot_version_read());
bt_local_id_copy_address_mac_string(info->bt_mac_addr);
// Ensure OTP strings are null-terminated
mfg_info_get_serialnumber(info->serial_string, MFG_SERIAL_NUMBER_SIZE + 1);
mfg_info_get_hw_version(info->hw_version_string, MFG_HW_VERSION_SIZE + 1);
... | (&mark_rect, &rt_rect, alignment, true /* clip */) | ;
// Draw the mark
const bool highlight = menu_cell_layer_is_highlighted(cell_layer);
prv_draw_generic_mark(ctx, mark, mark_rect.origin, highlight);
// Only draw the text if the cell is selected
if (is_selected) {
const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
GRect text_rect = rt_rec... |
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
... | 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.timestamp > DIALOG_CHIP_ID_MIN_TIMESTAMP);
}
bool bt_driver_test_mfi_chip_selftest(void) {
return false;
}
// A simple parser for HCI Command Complete events. If we are not in HCI
// passthrough mode, this is the only type of ... |
ivity_sessions_prv_is_sleep_activity(ActivitySessionType activity_type) {
switch (activity_type) {
case ActivitySessionType_Sleep:
case ActivitySessionType_RestfulSleep:
case ActivitySessionType_Nap:
case ActivitySessionType_RestfulNap:
return true;
case ActivitySessionType_Walk:
case Ac... | (state->mutex) | ;
}
// ------------------------------------------------------------------------------------
// Delete an ongoing activity. Called by the algorithm code when it decides that an activity
// that was previously ongoing should not be registered after all.
void activity_sessions_prv_delete_activity_session(ActivitySession... |
the
// cache is the one closest to what we are looking for without going past
// it
for (int i = 0; i < f->pg_cache_len; i++) {
FilePageCache *pgc = &f->pg_cache[i];
if (pgc->virtual_pg > pages_to_seek) {
continue;
} else if ((closest_match == -1) ||
(f->... | (file->curr_page) | |
prv_warning_dialog_dismiss_cb);
}
static void prv_handle_weather(PebbleEvent *unused_event, void *unused_context) {
// Unschedule any ongoing animations that would try to touch the weather data we're about to
// update
animation_unschedule_all();
size_t forecasts_count_out = 0;
W... | window_set_click_config_provider(window, prv_main_window_click_provider) | ;
window_set_user_data(window, data);
const GRect *layout_frame = &window->layer.bounds;
WeatherAppLayout *layout = &data->layout;
weather_app_layout_init(layout, layout_frame);
window_set_user_data(window, layout);
// Fetch initial data
prv_handle_weather(NULL, NULL);
if (data->forecasts_count == 0)... |
L_ASSERT((CHUNK_SIZE_BYTES & (SUBSECTOR_SIZE_BYTES - 1)) == 0,
"Sections divide into subsectors evenly, size is 0x%" PRIx16, CHUNK_SIZE_BYTES);
for (unsigned int i = 0; i < (CHUNK_SIZE_BYTES / SUBSECTOR_SIZE_BYTES); ++i) {
flash_erase_subsector_blocking(addr + (i * SUBSECTOR_SIZE_BYTES));
}
LogChunkHe... | (lowest_chunk_id, chunk_header.chunk_id, CHUNK_ID_BIT_WIDTH) | < 0) {
lowest_chunk_index = i;
lowest_chunk_id = chunk_header.chunk_id;
}
++num_valid_chunks;
}
bool success = true;
for (int i = 0; success && i < num_valid_chunks; ++i) {
success = dump_chunk(generation, lowest_chunk_index, cb);
lowest_chunk_index = (lowest_chunk_index + 1) % NUM_... |
;
// assert if we found the flag to be enabled
PBL_ASSERTN(!(flag_status_register & N25QFlagStatusBit_SectorLockStatus));
}
// This will clear the protection flag error from a previous error.
// We call this because the error bits persist across reboots
static void prv_clear_flag_status_register(void) {
flash_st... | disable_flash_spi_clock() | ;
power_tracking_stop(PowerSystemFlashRead);
flash_unlock();
}
void flash_write_bytes(const uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
PBL_ASSERTN((start_addr + buffer_size) <= BOARD_NOR_FLASH_SIZE);
assert_usable_state();
flash_lock();
if (!s_f... |
lack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, true, 2, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circle_draw... | (prv_fill_rect_non_aa(&context, &GRect(10, 20, 40, 10), 0, GCornerNone, GColorBlack)) | |
/*
* 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_LOG(APP_LOG_LEVEL_INFO, "0x%02x", value[i]);
} |
}
static void read_handler(BLECharacteristic characteristic,
const uint8_t *value,
size_t value_length,
uint16_t value_offset,
BLEGATTError error) {
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
Uuid characteristic_... |
ached_execute_time = UINT32_MAX;
prv_clock_change(0, 0, true);
cl_assert_equal_i(job->cached_execute_time, target);
job->cached_execute_time = UINT32_MAX;
prv_clock_change(0, 1, false);
target--; // adjust for GMT offset change
cl_assert_equal_i(job->cached_execute_time, target);
job->cached_execute_time ... | prv_basic_test(&s_timezone_gmt, &test_cron, s_2015_nov12_123456_gmt, 0, 0, 0) | |
icensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed unde... | (timeline_peek_prefs_get_before_time()) | ;
const OptionMenuCallbacks callbacks = {
.select = prv_before_time_menu_select,
};
settings_option_menu_push(
title, OptionMenuContentType_SingleLine, selected, &callbacks,
ARRAY_LENGTH(s_before_time_strings), true /* icons_enabled */, s_before_time_strings, data);
}
static void prv_deinit_cb(Se... |
} else {
file->used_space += record_size(&file->iter.hdr);
}
if (file->iter.hdr.last_modified > file->last_modified) {
file->last_modified = file->iter.hdr.last_modified;
}
}
}
status_t settings_file_rewrite_filtered(
SettingsFile *file, SettingsFileRewriteFilterCallback filter_cb, void... | prv_is_desired_hdr(iter, key, key_len) | |
{ 688, 424, -208},
{ 744, 480, -280},
{ 824, 560, -376},
{ 896, 552, -432},
{ 896, 640, -520},
// 75 seconds
{ 968, 640, -456},
{ 968, 560, -344},
{ 1176, 600, -280},
{ 1232, 720, -392},
{ 1552, 736, -280},
{ 1768, 672, -88},
{ 1752, 496, -40},
{ 1456, 408, -64},
... | { 744, 528, -384},
{ 832, 560, -528},
{ 960, 536, -504},
{ 1120, 560, -544},
{ 992, 552, -440},
{ 1176, 544, -344},
{ 1264, 576, -328},
{ 1360, 672, -376},
{ 1648, 568, -120},
{ 1680, 488, -8},
{ 1320, 352, -16},
{ 1016, 336, -24},
{ 896, 336, -32},
{ 816, 280, -1... |
{ 1088, 368, -24},
{ 928, 384, -8},
{ 832, 328, 56},
{ 792, 232, 104},
{ 792, 232, 32},
{ 808, 248, 0},
{ 952, 272, -40},
{ 968, 184, -72},
{ 992, 112, -104},
{ 1024, 24, -144},
{ 1072, 144, -248},
{ 1136, 208, -416},
{ 1320, 176, -272},
{ 1136, 184, -288},
{... |
/*
* 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... | pin_db_init() | ;
}
void test_pin_db__cleanup(void) {
pin_db_deinit();
fake_settings_file_reset();
}
// Tests
////////////////////////////////////////////////////////////////
void test_pin_db__is_dirty_insert_from_phone(void) {
// Insert a bunch of pins "from the phone"
// They should NOT be dirty (the phone is the source ... |
, 512, -928},
{ -192, 456, -832},
{ -152, 544, -992},
{ -200, 528, -808},
{ -168, 552, -960},
{ -184, 464, -912},
{ -176, 448, -976},
{ -184, 488, -928},
{ -176, 480, -904},
{ -152, 456, -872},
{ -168, 488, -864},
{ -152, 424, -864},
{ -152, 464, -880},
{ -176, 488, -... | { -216, 480, -856},
{ -112, 480, -992},
{ -168, 456, -840},
{ -152, 472, -976},
{ -168, 416, -920},
{ -152, 536, -1000},
{ -192, 488, -888},
{ -120, 560, -968},
{ -184, 440, -824},
{ -144, 512, -952},
{ -168, 480, -816},
{ -144, 448, -904},
{ -152, 424, -896},
{ -... |
{ -104, 552, -880},
{ -120, 504, -888},
// 119 seconds
{ -144, 432, -904},
{ -104, 464, -1048},
{ -192, 568, -904},
{ -128, 536, -896},
{ -160, 448, -872},
{ -96, 536, -920},
{ -184, 464, -832},
{ -96, 496, -976},
{ -216, 424, -808},
{ -96, 544, -880},
{ -152, 43... |
ess, stroke_color, quadrant);
}
#if PBL_COLOR
T_STATIC void graphics_circle_quadrant_draw_1px_aa(GContext* ctx, GPoint p, uint16_t radius,
GCornerMask quadrant) {
/* This will draw antialiased circle with width of 1px, can be drawn in quadrants
* Based on wu-xian... | (edge.integer, progress) | ,
weighting ^ weighting_compliment_mask, stroke_color, quadrant);
}
} else {
if (edge.integer > radius - stop_progress) {
prv_plot4(framebuffer, &ctx->draw_state.clip_box, p, GPoint(edge.integer, progress),
MAX_PLOT_OPACITY, stroke_color, quadrant);
}
... |
/*
* 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_INFO, "Set Discoverable Pairable: %u, %u",
cmd_data->discoverable_pairable, cmd_data->duration) | |
{
assert_usable_state();
PBL_LOG(LOG_LEVEL_DEBUG, "Erasing subsector 0x%"PRIx32" (0x%"PRIx32" - 0x%"PRIx32")",
subsector_addr,
subsector_addr & SUBSECTOR_ADDR_MASK,
(subsector_addr & SUBSECTOR_ADDR_MASK) + SUBSECTOR_SIZE_BYTES);
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock(... | (LOG_LEVEL_DEBUG, "Nonvolatile Configuration Register: 0x%x", nonvolatile_config_register) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Volatile Configuration Register: 0x%x", volatile_config_register);
#endif
}
bool flash_is_initialized(void) {
return (s_flash_state.mutex != 0);
}
size_t flash_get_size(void) {
uint32_t spi_flash_id = flash_whoami();
if (!check_whoami(spi_flash_id)) {
// Zero bytes is the best ... |
timeline_adds, 17);
cl_assert_equal_i(s_num_timeline_removes, 11);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm__just_once_alarm_timeout_ahead(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_JUST_ONCE });
... | (id1, 10, 30, false, ALARM_KIND_CUSTOM, schedule_1) | ;
// It's currently Thursday @ 00:00.
s_current_day = s_friday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 0);
s_current_day = s_saturday;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 0);
s_current_day = s_sunday;
cron_service_wakeup();
cl_assert_equal_i(s_num_a... |
format(false);
cl_assert(!pfs_active_in_region(0, pfs_get_size()));
// erase every page and make sure pfs is active
pfs_format(true);
cl_assert(pfs_active_in_region(0, pfs_get_size()));
// write something on every page and make sure pfs is active
char file_name[10];
for (int i = 0; i < num_pages(); i++)... | pfs_remove(file_small) | == S_SUCCESS);
}
}
}
int original_page_count = num_pages();
ftl_populate_region_list();
// make sure something was added
PBL_LOG(LOG_LEVEL_DEBUG, "original pages %u, num pages: %u", original_page_count, num_pages());
cl_assert(original_page_count < num_pages());
for (int i = 0; i < original_p... |
/*
* 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 (session == &s_session) && s_session_is_valid;
} |
static bool s_data_sent;
bool comm_session_send_data(CommSession *session, uint16_t endpoint_id,
const uint8_t* data, size_t length, uint32_t timeout_ms) {
// The request is just a single 0x00 byte to endpoint 0x11:
cl_assert_equal_i(endpoint_id, 0x11);
cl_assert_equal_i(length, 1);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | dbgserial_putstr("") | ;
reset_due_to_software_failure();
}
//! Assert function called by the STM peripheral library's
//! 'assert_param' method. See stm32f2xx_conf.h for more information.
void assert_failed(uint8_t* file, uint32_t line) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
handle_passert_failed((const char... |
strncpy(remote_name, remote->name, name_size);
if (name_size > max_name_size) {
const size_t ellipsis_start_offset = utf8_get_size_truncate(remote_name, name_size);
strncpy(&remote_name[ellipsis_start_offset], ellipsis, sizeof(ellipsis));
}
const char *is_sharing_heart_rate =
(settings_bluetooth... | i18n_get("Open the Pebble app on your phone to connect.", data) | |
minute");
} else {
str_fmt = i18n_noop("In %lu minutes");
}
snprintf(buffer, buf_size, i18n_get(str_fmt, buffer), num_minutes);
} else if (difference >= -(SECONDS_PER_HOUR * max_relative_hrs)) {
const int num_hrs =
prv_round(-difference, SECONDS_PER_HOUR, RoundTypeHalfDown) / SECONDS_P... | i18n_noop("tomorrow night") | }, // 9pm tomorrow
{57, i18n_noop("the day after tomorrow")}, // starting 9am 2 days from now
{72, i18n_noop("the day after tomorrow")}, // ends midnight 2 days from now
{73, i18n_noop("the foreseeable future")}, // Catchall for beyond 3 days
};
//! Daypart string is used internally for battery popups
//! and ... |
, -728},
// 72 seconds
{ 472, 408, -744},
{ 480, 440, -736},
{ 472, 448, -720},
{ 488, 448, -736},
{ 472, 440, -736},
{ 480, 440, -744},
{ 488, 448, -728},
{ 480, 448, -712},
{ 480, 432, -744},
{ 472, 424, -760},
{ 472, 440, -712},
{ 488, 432, -744},
{ 480, 448, -... | { 488, 432, -736},
{ 464, 432, -736},
{ 488, 432, -744},
{ 488, 432, -736},
{ 480, 432, -736},
{ 488, 432, -728},
{ 480, 432, -736},
{ 488, 424, -744},
{ 480, 432, -736},
{ 480, 432, -736},
{ 480, 424, -728},
// 78 seconds
{ 496, 440, -736},
{ 480, 432, -744},
... |
{ 488, 448, -720},
{ 488, 416, -744},
{ 488, 432, -752},
{ 472, 424, -736},
{ 496, 440, -728},
{ 488, 432, -728},
{ 472, 432, -736},
{ 496, 432, -744},
{ 472, 432, -736},
{ 488, 448, -728},
{ 488, 432, -728},
{ 488, 440, -736},
{ 488, 424, -744},
{ 488, 456, -744... |
s_metric_updated_count = 0;
}
void test_health_db__cleanup(void) {
}
// Dummy Data
////////////////////////////////////////////////////////////////
#define NUM_CURRENT_MOVEMENT_METRICS 5
#define NUM_CURRENT_SLEEP_METRICS 4
#define NUM_CURRENT_HR_ZONE_METRICS 3
typedef enum MovementDataFields {
MD_Version,
MD_T... | cl_assert(health_db_get_typical_value(ActivityMetricSleepTotalSeconds, Monday, &val_out)) | |
if (s_stroke_points) {
free(s_stroke_points);
s_stroke_points = NULL;
}
if (s_fill_points) {
free(s_fill_points);
s_fill_points = NULL;
}
s_path_open = false;
s_radius = 0;
s_path_stroke_count = 0;
s_path_stroke_precise_count = 0;
s_path_fill_count = 0;
s_path_fill_precise_count = ... | gdraw_command_set_stroke_color(command, color) | |
s_dst_correct_values[dstid][1]) {
printf(" end [%d] tz_info: %ld s_dst_correct_values: %ld\n",
dstid, tz_info.dst_end, s_dst_correct_values[dstid][1]);
}
cl_check(tz_info.dst_start == s_dst_correct_values[dstid][0]);
cl_check(tz_info.dst_end == s_dst_correct_values[dstid][1]);
}
}
vo... | (jun10th_noon_2015) | |
InstallId id) {
char buffer[30];
itoa_int(id, buffer, 10);
pfs_remove(buffer);
}
bool app_storage_app_exists(AppInstallId id) {
return true;
}
AppInstallId s_test_id_ql_up;
AppInstallId s_test_id_ql_down;
AppInstallId s_test_id_watchface;
AppInstallId s_test_id_worker;
AppInstallId quick_launch_get_app(Butto... | app_cache_remove_entry(app2.id) | );
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app3.id));
cl_assert_equal_i(fake_event_get_count(), 3);
// ensure the one that is evicted is INVALID_ID
cl_assert_equal_i(INSTALL_ID_INVALID, app_cache_get_next_eviction());
}
/*************************************
* Add lots, update lots, update one a... |
tch_list = NULL;
static PebbleRecursiveMutex *s_analytics_lock = NULL;
// Locking Functions
static void prv_lock(void) {
mutex_lock_recursive(s_analytics_lock);
}
static void prv_unlock(void) {
mutex_unlock_recursive(s_analytics_lock);
}
// Analytic Node Functions
static bool prv_compare_analytic(ListNode *fou... | analytics_add(metric, prv_stopwatch_elapsed_ms(stopwatch, rtc_get())) | ;
list_remove(&stopwatch->node, &s_stopwatch_list, NULL);
}
prv_unlock();
}
void analytics_stopwatches_update(uint32_t current_ticks) {
prv_lock();
ListNode *cur = s_stopwatch_list;
while (cur != NULL) {
AnalyticsStopwatchNode *node = (AnalyticsStopwatchNode *)cur;
analytics_add(node->metric, pr... |
/*
* 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 LocaleInfo locale_info = {0};
return &locale_info;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.