prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
_horizontal_line(ctx, GPoint(x0, y0 - x), y + 1);
}
}
}
static void graphics_fill_half_circle(GContext* ctx, int x0, int y0, uint16_t radius,
uint8_t section) {
int f = 1 - radius;
int ddF_x = 1;
int ddF_y = -2 * radius;
int x = 0;
uint16_t y = radius;
while (x ... | {
quadrants_solid = quadrants_solid | radius_quadrants[i % QUADRANTS_NUM];
} |
return quadrants_solid;
}
static void prv_get_angles_mask_edge(Fixed_S16_3 y, GPointPrecise center, GCornerMask quadrant,
int16_t *top_edge, int16_t *bottom_edge,
GPointPrecise top, GPointPrecise bottom) {
// This function determines where... |
chedule3);
// FIXME:
bool custom_schedule4[7] = {false, false, false, false, false, false, false};
id = alarm_create(&(AlarmInfo) { .hour = 6, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule4 });
prv_assert_alarm_config(id, 6, 14, false, ALARM_KIND_CUSTOM, custom_schedule4);
}
void... | (&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_WEEKENDS }) | |
only show non ACNS actions. Once iOS9 is more widespread we can look at updating this
return !timeline_item_action_is_ancs(action);
}
} else { // Android
// Show all actions unless the item has already been acted upon, in which case show none
return (!item->header.actioned &&
!item->head... | (ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_MUTED_COUNT, AnalyticsClient_System) | ;
} else {
// This is a very unlikely case. We store some default prefs which includes the mute
// attribute when we receive the notification so either someone deleted the entry
// in the DB or the mute attribute (neither of which should happen)
PBL_LOG(LOG_LEVEL_WARNING, "Could not mute 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... | ASSERT(s_read_2_called == 1) | ;
ASSERT(s_size_2_called == 1);
// 3rd res
uint32_t id_3 = emx_resources_register_custom(custom_res_read_3, custom_res_size_3);
ASSERT(emx_resources_get_size(1, id_3) == 4);
buf = 0;
ASSERT(emx_resources_read(1, id_3, 0, (uint8_t *)&buf, 1) == 4);
ASSERT(buf == 3);
ASSERT(s_read_3_called == 1);
ASSER... |
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distribut... | (app_data->window, animated) | |
, -864},
{ 56, 312, -864},
{ 56, 320, -864},
{ 56, 328, -872},
{ 56, 312, -872},
{ 40, 256, -880},
{ 56, 376, -840},
{ 72, 512, -888},
{ 64, 304, -872},
{ 48, 192, -888},
{ 56, 208, -872},
{ 80, 280, -928},
{ -32, 128, -888},
{ 48, 248, -816},
{ 24, 224, -936},
... | { 24, 152, -928},
{ 16, 144, -904},
{ 32, 184, -920},
{ 32, 160, -904},
{ 24, 136, -904},
{ 32, 168, -904},
{ 8, 144, -920},
{ 24, 168, -912},
{ 24, 176, -928},
{ 24, 176, -912},
{ 16, 168, -920},
{ 32, 168, -912},
{ 16, 160, -912},
{ 16, 192, -912},
{ 24, 192... |
{ 16, 144, -936},
{ 48, 120, -904},
{ -16, 160, -944},
{ 32, 160, -872},
{ 24, 64, -864},
{ 16, 192, -920},
{ 24, 160, -904},
{ 24, 184, -904},
{ 24, 224, -896},
{ 40, 184, -912},
{ 80, 160, -856},
{ 48, 168, -904},
{ 32, 224, -912},
{ 16, 208, -904},
{ 16, 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... | (PATH_STRING_LENGTH) | ;
if (index) {
snprintf(filename, PATH_STRING_LENGTH, "%s_%u.%s", func_name, index, extension);
} else {
snprintf(filename, PATH_STRING_LENGTH, "%s.%s", func_name, extension);
}
return filename;
}
// Tests
////////////////////////////////////
// Reference PNGs reside in "tests/test_images/"
// and are... |
/*
* 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 ((idx < MAX_GPIO) && s_gpio_clock_count[idx] && !(--s_gpio_clock_count[idx])) {
CLEAR_BIT(RCC->AHB1ENR, (0x1 << idx));
} |
}
|
---------------------------------------------------
// Parse and encoded message and return a TestPLParsedMsg structure pointer pointing to it's
// parsed contents. The contents are valid until prv_parse_encoded_msg is called again.
static TestPLParsedMsg *prv_parse_encoded_event_payload(void *buffer) {
static TestPL... | (a->msrmt.num_samples, b->msrmt.num_samples) | ;
cl_assert_equal_m(a->msrmt.offset_sec, b->msrmt.offset_sec,
b->msrmt.num_samples * sizeof(uint32_t));
cl_assert_equal_i(a->msrmt.num_values, b->msrmt.num_values);
cl_assert_equal_m(a->msrmt.values, b->msrmt.values, b->msrmt.num_values * sizeof(uint32_t));
} else if (a->type == Prot... |
_finish(DataLoggingSession *logging_session) {
if (logging_session == (DataLoggingSession *)TEST_PL_DLS_SESSION_ID) {
s_dls_session_created = false;
} else {
cl_assert(false);
}
}
//
// MFG/Version Fakes
//
#define TEST_PL_SERIAL_NUM "ABC01234567"
const char* mfg_get_serial_number(void) {
return TEST_... | ("payload_sender_type: %s", s_parsed_msg.payload_sender_type) | ;
LOG("payload_sender_id: %s", s_parsed_msg.payload_sender_id);
LOG("payload_sender_version: major: %"PRIu32", minor: %"PRIu32", patch: %s",
s_parsed_msg.payload_sender_v_major, s_parsed_msg.payload_sender_v_minor, s_parsed_msg.payload_sender_version_patch);
LOG("payload_send_time: %"PRIu32"", s_par... |
et);
};
static void prv_destructor(void *context) {
ScaleSegmentedData *data = context;
if (data->lookup.owns_userdata) {
applib_free(data->lookup.userdata);
}
applib_free(context);
}
static void prv_apply_transform(GDrawCommandList *list, GSize size, const GRect *from,
con... | {
ScaleSegmentedData *data = kino_reel_transform_get_context(reel);
if (!data) {
return;
}
if (data->lookup.owns_userdata) {
applib_free(data->lookup.userdata);
}
data->lookup.creator = creator;
data->lookup.userdata = userdata;
data->lookup.owns_userdata = take_ownership;
} | |
//Add another notification. Compression should free up another 4k block
e.header.id = uuids[i];
e.header.timestamp = timestamp + i;
notification_storage_store(&e);
cl_assert(notification_storage_get(&uuids[i], &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
// Check that an expected number... | notification_storage_store(&e2) | ;
notification_storage_store(&e3);
TimelineItem test = e1;
test.header.id = UUID_INVALID;
test.header.ancs_uid = 51;
CommonTimelineItemHeader h;
cl_assert(notification_storage_find_ancs_notification_by_timestamp(&test, &h));
cl_assert_equal_m(&e1.header, &h, sizeof(CommonTimelineItemHeader));
test.ac... |
ddress, followed by a repeat start for reads
NoRegisterAddress // Do not send a register address
} TransferType;
static uint32_t s_max_transfer_duration_ticks;
static void prv_analytics_track_i2c_error(void);
/*----------------SEMAPHORE/LOCKING FUNCTIONS--------------------------*/
static bool prv_semapho... | I2C_DEBUG("Waiting %"PRIu32"ms before enabling I2C bus %s rail.",
(uint32_t)(MIN_STOP_TIME_MS - time_stopped_ms), bus->name) | ;
psleep(MIN_STOP_TIME_MS - time_stopped_ms);
}
prv_bus_pins_cfg_input(bus);
prv_rail_ctl(bus, true);
}
//! Configure the bus pins, enable the peripheral clock and initialize the I2C peripheral.
//! Always lock the bus and peripheral config access before enabling it
static void prv_bus_enable(I2CBus *bus) ... |
}
}
static void prv_error_dialog_unload(void *context) {
VoiceUiData *data = context;
prv_handle_error_retries(data);
}
static void prv_init_dialog(VoiceUiData *data, Dialog *dialog, const char *text,
uint32_t resource_id, bool has_timeout, GColor color) {
dialog_set_callbacks(dialog, &(DialogCallbacks) ... | {
BtConnDialog *bt_dialog = &data->bt_dialog;
bt_conn_dialog_init(bt_dialog, data->error_text_buffer, sizeof(data->error_text_buffer));
Dialog *dialog = &bt_dialog->dialog.dialog;
dialog_set_destroy_on_pop(dialog, false /* free_on_pop */);
bt_conn_dialog_push(bt_dialog, prv_handle_bt_conn_result, data);
} |
static uint64_t prv_get_time_ms(void) {
time_t now_s;
uint16_t now_ms;
sys_get_time_ms(&now_s, &now_ms);
uint64_t ms = (now_s * 1000) + now_ms;
return ms;
}
static void prv_update_analytics_metrics(VoiceUiData *data) {
data->elapsed_ms = prv_get_time_ms() - data->start_ms;
data->num_sessions++;
}
stat... |
{
return (jerry_value_t)EM_ASM_INT({
return __jerry_create_external_function($0);
}, handler_p);
} |
jerry_value_t jerry_create_number(double value) {
return (jerry_value_t)EM_ASM_INT({
return __jerryRefs.ref($0);
}, value);
}
jerry_value_t jerry_create_number_infinity(bool negative) {
if (negative) {
return JERRY_CREATE_VALUE(-Infinity);
} else {
return JERRY_CREATE_VALUE(Infinity);
}
}
... | |
ctx;
// Setup resources
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
pfs_init(false /* run filesystem check */);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next ... | gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_kickstart__render_PBL_43717(void) {
prv_set_data(&s_data, 7, 0, 7, 0);
window_set_on_screen(&s_data.window, true, true);
window_render(&s_data.window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
|
ation(GContext *ctx, uint32_t distance_normalized, bool inner,
GPathDrawFilledCallback ring_fill_cb) {
const GRect bounds = ctx->draw_state.clip_box;
PBL_ASSERTN(bounds.origin.x == 0 && bounds.origin.y == 0);
int32_t rel_p = distance_normalized;
// calculate dynamic positio... | (sizeof(DotTransitionAnimationConfiguration) == sizeof(void *), "") | ;
static void prv_collapse_animation_update_rect(GContext *ctx,
DotTransitionAnimationConfiguration config,
uint32_t distance_normalized) {
GPathDrawFilledCallback draw_filled_cb;
bool inner;
ctx->draw_state.fill_color... |
OMPATIBLE
#include <mcu.h>
#include <stdbool.h>
//! Tracks whether we've disabled interrupts as part of locking out other people from our EXTI
//! registers.
static bool s_exti_locked = false;
//! Have we already configured the EXTI9_5_IRQn interrupt?
static bool s_9_5_nvic_configured = false;
//! Have we already co... | NVIC_SetPendingIRQ(irq) | ;
}
void exti_clear_pending_other(ExtiLineOther exti_line) {
uint32_t exti_bit = prv_exti_line_to_bit(exti_line);
EXTI->PR = exti_bit;
}
// Helper functions for handling ISRs
///////////////////////////////////////////////////////////////////////////////
static void prv_handle_exti(int exti_line) {
// Clear IT... |
gin.x) + ctx->angle), TRIG_MAX_ANGLE) -
TRIG_MAX_ANGLE / 2);
return (angle_a > angle_b ? 1 : -1);
}
GPointIndexLookup *gdraw_command_list_create_index_lookup_by_angle(GDrawCommandList *list,
GPoint origin, int32_t angle) {
AngleComparatorCont... | animation_timing_curve(normalized, AnimationCurveEaseInOut) | ;
return interpolate_int64_linear(curved, from, to);
}
T_STATIC bool prv_gdraw_command_scale_segmented(GDrawCommand *command, uint32_t index,
void *context) {
ScaleToCBContext *scale = context;
const ScaleToGValues * const gvalues = (command->type == GDrawCommandTy... |
ude "applib/ui/ui.h"
#include "applib/voice/transcription_dialog.h"
#include "applib/voice/voice_window.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "resource/resource_ids.auto.h"
#include "resource/timeline_resource_ids.auto.h"
#include "services/... | (simple_dialog) | ;
i18n_free_all(dialog);
}
static void prv_confirm_cb(void *context) {
ReminderAppData *data = context;
data->ui_state = ReminderAppUIState_Exit;
prv_create_reminder(data);
prv_push_success_dialog();
}
static void prv_push_transcription_dialog(ReminderAppData *data) {
TranscriptionDialog *transcription_di... |
vmc;
const bool rv = activity_get_metric(ActivityMetricLastVMC, 1, &vmc);
return rv ? vmc : 0;
#else
return 0;
#endif
}
// ----------------------------------------------------------------------------------------------
static bool prv_should_smart_alarm_trigger(const AlarmConfig *config) {
if (s_smart_snooze_co... | {
last_alarm = alarm_time;
localtime_r(&alarm_time, local_alarm_time);
if (alarm->config.scheduled_days[local_alarm_time->tm_wday]) {
Uuid *pinid = (Uuid *)&settings_file_buffer[num_pin_adds++ * UUID_SIZE];
prv_add_pin(alarm->id, &alarm->config, alarm_time, pinid);
if (updated... |
alarm_time = prv_get_alarm_time(
alarm, cron_job_get_execute_time_from_epoch(cron, current_time + (i * SECONDS_PER_DAY)));
}
AlarmStorageKey key = { .id = alarm->id, .type = ALARM_DATA_PINS };
settings_file_set(file, &key, sizeof(key),
settings_file_buffer, UUID_SIZE * num_pin_ad... |
/*
* 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... | ((utf8_t *)&destination[pos], (utf8_t *)space,
length - pos - 2) | ; // 2 = ".\0"
// If we couldn't fit anything, stop here.
if (initial_size == 0) {
pos--; // the space we previously added should be omitted from our string.
break;
}
pos += initial_size;
destination[pos++] = '.';
} while ((space = strchr(space, ' ')));
destination[pos] = '\0';
}
//... |
/*
* 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_DEBUG, "App Fetch: Putting launch event") | ;
// if this was launched by the phone, it's probably a new install
if ((data->next_app_args.common.reason == APP_LAUNCH_PHONE) &&
!battery_is_usb_connected()) {
vibes_short_pulse();
}
// Allocate and inialize the data that would have been sent to the app originally before the
// fetch request.
... |
e_sampling_interval;
uint32_t accel_set_sampling_interval(uint32_t interval_us) {
if (!s_force_sampling_interval) {
s_sampling_interval_us = interval_us;
}
return accel_get_sampling_interval();
}
uint32_t accel_get_sampling_interval(void) {
return s_sampling_interval_us;
}
void accel_set_num_samples(uint... | {
int sample_rates[] = { ACCEL_SAMPLING_10HZ, ACCEL_SAMPLING_25HZ,
ACCEL_SAMPLING_50HZ, ACCEL_SAMPLING_100HZ};
prv_validate_sample_rates(sample_rates, ARRAY_LENGTH(sample_rates));
int poss_rates = ARRAY_LENGTH(sample_rates);
int max_permutations = 0x1 << poss_rates;
for (int mask = ... | |
witch to the kernel to push a modal window
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
window_stack_push(modal_stack, window2, true);
cl_assert_equal_i(window_stack_count(modal_stack), 1);
cl_assert_equal_i(window2->on_screen, true);
cl_assert_equal_p(s_last_click_configured_window, window1);
/... | (dump[1].addr, window2) | ;
cl_assert_equal_s(dump[1].name, "Window2");
cl_assert_equal_p(dump[2].addr, window1);
cl_assert_equal_s(dump[2].name, "Window1");
kernel_free(dump);
}
void test_window_stack__pop_all_modals(void) {
Window *windows[NumModalPriorities];
WindowStack *window_stacks[NumModalPriorities];
for (ModalPriority ... |
/*
* 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... | strncpy(buffer, data->custom_value_string, buffer_size) | ;
break;
}
// Not supported by the sports API
case WorkoutMetricType_Steps:
case WorkoutMetricType_AvgPace:
case WorkoutMetricType_None:
case WorkoutMetricTypeCount:
break;
}
}
static int32_t prv_sports_get_value(WorkoutMetricType type, void *sports_data) {
SportsData *data = sp... |
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WAR... | {
struct tm *localtime_tm = NULL;
char *localtime_zone = NULL;
if (pebble_task_get_current() == PebbleTask_App) {
localtime_tm = app_state_get_localtime_tm();
localtime_zone = app_state_get_localtime_zone();
} else {
localtime_tm = worker_state_get_localtime_tm();
localtime_zone = worker_state_... |
int pbl_strftime(char* s, size_t maxsize, const char* format, const struct tm* tim_p) {
char *locale = app_state_get_locale_info()->app_locale_time;
return sys_strftime(s, maxsize, format, tim_p, locale);
}
DEFINE_SYSCALL(int, sys_strftime, char* s, size_t maxsize, const char* format,
... |
tput was generated, it's an error.
state->error->status = TemplateStringErrorStatus_CantResolve;
}
// format() must be the last filter, and ends the sequence.
state->filters_complete = true;
}
static void prv_filter_time_until(TemplateStringState *state) {
char *endptr;
time_t target_time = strtol(state... | if (!state.output || !state.output_remaining) {
state.output = NULL;
state.output_remaining = 0;
} else {
// Subtract 1 for the null terminator.
state.output_remaining--;
} |
if (state.eval_cond) {
state.eval_cond->eval_time = INT_MAX;
state.eval_cond->force_eval_on_time = false;
}
state.error->status = TemplateStringErrorStatus_Success;
while (*state.position != '\0') {
if (*state.position != '{') {
prv_handle_escape_character(&state);
if (state.error->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... | iter_next(&char_iter) | );
}
void test_char_iterator__decode_test_string_length_one(void) {
Iterator char_iter;
CharIterState char_iter_state;
Utf8IterState* utf8_iter_state = (Utf8IterState*) &char_iter_state.utf8_iter_state;
// Single-byte/ASCII
bool success = false;
const Utf8Bounds utf8_bounds_single_byte = utf8_get_bounds(&... |
/*
* 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... | (normalized - delay, 0, ANIMATION_NORMALIZED_MAX) | |
ise
// Allow updates iff:
// - We are charging
// - We are discharging and:
// - The readings have stabilized and the battery percent did not go up
// - The readings have not yet stablized
// TL;DR: Allow updates unless we're stable and discharging but the % went up.
if (!charging && likely_stable &... | MIN(10 * ((percent_normalized + rounding_factor) / 10), 100) | ,
.is_charging = is_plugged && percent_normalized < 100,
.is_plugged = is_plugged,
};
return state;
}
// For unit tests
TimerID battery_state_get_periodic_timer_id(void) {
return s_periodic_timer_id;
}
uint16_t battery_state_get_voltage(void) {
return s_last_battery_state.voltage;
}
#include "consol... |
oid *buffer, uint32_t size, uint32_t offset) {
if ((offset + size) <= s_pfs_size) {
ftl_read(buffer, size, offset);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "FS read out of bounds 0x%x", (int)offset);
}
}
// Invalidates s_pfs_page_flags_cache for a given range of bytes. This should be called after the
// conten... | ((uint8_t *)&curr_state, sizeof(state), offset) | |
esObjectType type = s_pb_state.type;
s_pb_state = (PutBytesState) {
.type = type
};
}
static void prv_cleanup_from_system_task(void* data) {
xSemaphoreTake(s_pb_semaphore, portMAX_DELAY);
prv_cleanup();
xSemaphoreGive(s_pb_semaphore);
}
static void prv_cleanup_async(void) {
system_task_add_callback(pr... | (LOG_LEVEL_DEBUG, "Got both FW bin and sys resources!") | ;
s_ready_to_install[ObjectFirmware - 1].type = 0;
s_ready_to_install[ObjectSysResources - 1].type = 0;
bool set_res_bit = true;
if (set_res_bit) {
boot_bit_set(BOOT_BIT_NEW_SYSTEM_RESOURCES_AVAILABLE);
}
boot_bit_set(BOOT_BIT_NEW_FW_AVAILABLE);
}
static void prv_do_install(uint32_t token) {
stru... |
{ -656, -24, -776},
{ -528, -104, -704},
{ -616, -120, -816},
{ -544, -96, -712},
{ -552, -304, -832},
{ -552, -72, -744},
{ -520, -296, -784},
{ -584, -64, -744},
{ -496, -280, -848},
{ -664, -96, -776},
{ -464, -296, -768},
{ -656, -128, -840},
{ -456, -232, -744},
... | { -528, -184, -712},
{ -584, -144, -752},
{ -552, -224, -696},
{ -584, -176, -808},
{ -544, -152, -712},
{ -624, -176, -760},
{ -552, -80, -664},
{ -520, -192, -720},
{ -608, -88, -728},
{ -512, -136, -680},
{ -616, -192, -824},
{ -568, -56, -696},
{ -632, -224, -832}... |
{ -544, -168, -752},
{ -536, -216, -744},
{ -544, -80, -800},
{ -560, -184, -720},
{ -496, -160, -840},
{ -528, -104, -672},
{ -520, -232, -808},
{ -552, -112, -768},
{ -520, -304, -792},
{ -648, -160, -824},
{ -536, -216, -696},
{ -640, -136, -744},
{ -664, 8, -768}... |
/*
* 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... | (SOME_UINT32_KEY, (uint32_t) 32) | |
s[num_scrollable_metrics++] = WorkoutMetricType_Custom;
}
workout_active_update_scrollable_metrics(data->active_window,
num_scrollable_metrics,
scrollable_metrics);
}
static void prv_sync_tuple_changed_callback(uint32_t key, con... | {
strncpy(buffer, data->distance_string, MIN(buffer_size, sizeof(data->distance_string)));
break;
} |
case WorkoutMetricType_Duration:
{
strncpy(buffer, data->duration_string, MIN(buffer_size, sizeof(data->duration_string)));
break;
}
case WorkoutMetricType_Custom:
{
strncpy(buffer,
data->custom_value_string,
MIN(buffer_size, sizeof(data->custom_value_s... |
, PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite));
const GSize WINDOW_SIZE = window->layer.bounds.size;
const GTextAlignment ARTIST_TITLE_TEXT_ALIGNMENT = PBL_IF_RECT_ELSE(GTextAlignmentLeft,
GTextAlignmentRight);
const MusicAppSizeConfig *... | status_bar_layer_set_colors(&data->status_layer, GColorClear, GColorBlack) | ;
layer_add_child(&data->window.layer, &status_layer->layer);
music_get_pos(&data->track_pos, &data->track_length);
#if CAPABILITY_HAS_VIBE_SCORES
data->score = vibe_score_create_with_resource(RESOURCE_ID_VIBE_SCORE_HAPTIC_FEEDBACK);
#endif
prv_update_now_playing(data);
prv_update_layout(data);
prv_updat... |
/*
* 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 (!gdraw_command_sequence_validate(draw_command_sequence, data_size)) {
gdraw_command_sequence_destroy(draw_command_sequence);
return NULL;
} | |
/////////////////////////////////////////////////////////////////////////////////////////////////
//! Time Picker
static void prv_time_picker_window_unload(Window *window) {
AlarmEditorData *data = (AlarmEditorData *)window_get_user_data(window);
if (data->creating_alarm) {
#if !CAPABILITY_HAS_HEALTH_TRACKING
... | {
app_window_stack_push(&data->time_picker_window.window, true);
} | else {
alarm_set_smart(data->alarm_id, (data->alarm_type == AlarmType_Smart));
app_window_stack_remove(&option_menu->window, true);
}
}
static void prv_setup_type_menu_window(AlarmEditorData *data) {
const OptionMenuCallbacks callbacks = {
.select = prv_type_menu_select,
.unload = prv_type_menu_un... |
full-strength forward rotation.
//!
//! For a 1-direction vibe:
//! 0 : No vibration strength.
//! [1, 100] : Zero strength vibration to full-strength vibration.
//!
//! This must be an even value so that a half-way point exists as an edge between an equal number of
//! clock cycles on either side.
#define PWM_TIME... | (ANALYTICS_DEVICE_METRIC_VIBRATOR_ON_TIME) | ;
}
s_on = on;
PBL_LOG(LOG_LEVEL_DEBUG, "Vibe status <%s>", on ? "on" : "off");
prv_vibe_raw_ctl(on);
}
void vibe_force_off(void) {
if (!s_initialized) {
return;
}
prv_vibe_raw_ctl(false);
}
int8_t vibe_get_braking_strength(void) {
if (BOARD_CONFIG_VIBE.options & ActuatorOptions_HBridge) {
... |
/*
* 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... | (layout.max_used_size.w, 8 * HORIZ_ADVANCE_PX) | |
, -280},
{ 1024, 56, -288},
{ 880, 96, -312},
{ 912, 104, -304},
{ 1032, 128, -328},
{ 1088, 216, -304},
{ 1024, 296, -304},
{ 1320, 408, -328},
{ 1248, 464, -216},
{ 1248, 432, -192},
{ 1248, 512, -264},
{ 968, 456, -272},
{ 984, 400, -264},
{ 1208, 376, -240},
{... | { 1368, 656, -296},
{ 1040, 568, -328},
{ 1056, 392, -272},
{ 1224, 344, -248},
{ 1352, 248, -240},
{ 1352, 184, -80},
{ 1192, -16, -8},
{ 1160, 16, 0},
{ 1248, 136, -224},
{ 1176, 96, -80},
{ 1048, -72, 8},
// 37 seconds
{ 1120, -144, 8},
{ 752, -224, -64},
{... |
{ 1136, -64, -104},
{ 1296, 40, -160},
{ 1416, 56, -240},
{ 1256, 128, -272},
{ 1032, 152, -264},
{ 1056, 208, -240},
{ 1112, 264, -208},
{ 1192, 320, -232},
{ 1136, 312, -256},
{ 1336, 400, -296},
{ 1112, 536, -280},
{ 1152, 528, -360},
{ 1152, 464, -352},
{ 984... |
r->request_type == SmartstrapRequestTypeWrite) {
// This is a generic service write, which will be ACK'd by the smartstrap so we shouldn't
// send the event yet.
return true;
}
} else {
// Either the request was not written successfully, or we are not waiting for a response for it.
prv_s... | mbuf_set_data(&new_attr->mbuf, buffer, buffer_length) | ;
// add the node to our list
mutex_lock(s_attr_list_lock);
s_attr_head = (SmartstrapAttributeInternal *)list_prepend(&s_attr_head->list_node,
&new_attr->list_node);
mutex_unlock(s_attr_list_lock);
return true;
}
//! NOTE: the caller must hold s_at... |
tifications_data);
return;
}
// shift index since the first one is hard coded to Clear
int16_t notif_idx = cell_index->row - 1;
NotificationNode *node = (NotificationNode*) list_get_at(
(ListNode*) notifications_data->notification_list, notif_idx);
if (!node) {
return;
}
bool success = pr... | attribute_get_string(¬ification->attr_list, AttributeIdSubtitle, "") | ;
const char *app_name = attribute_get_string(¬ification->attr_list, AttributeIdAppName, "");
const char *body = attribute_get_string(¬ification->attr_list, AttributeIdBody, "");
// We show the app name if we don't have a custom icon, otherwise we use the title
if (!IS_EMPTY_STRING(app_name) && loaded_no... |
re eros. Nulla eros urna, vestibulum "
"a dictum a, maximus sed nibh. Ut ut dui finibus, tincidunt ligula quis, "
"ornare mi. Pellentesque sagittis suscipit lacus nec consectetur. Nunc et "
"commodo neque. Vestibulum vitae dignissim sapien. Nulla scelerisque "
"finibus nisl. Suspendisse ac massa lacus. In hac h... | {
cl_assert_(buf[i] == '~',
"persist_read_data writes past the end of destination buffer");
} |
}
void test_persist__string_does_not_exist(void) {
char string_buffer[PERSIST_STRING_MAX_LENGTH];
memset(string_buffer, '~', sizeof(string_buffer));
cl_assert_equal_i(
persist_read_string(0, string_buffer, sizeof(string_buffer)),
E_DOES_NOT_EXIST);
for (size_t i = 0; i < sizeof(string_buffer); +... |
cl_assert_equal_s(str, "abc 42b") | ;
//----------------------------------------------------
pbl_snprintf(str, STR_SIZE, "abc %hf%s", "a", 1.0, "b");
cl_assert_equal_s(str, fp_msg);
pbl_snprintf(str, STR_SIZE, "abc %hd%s", 42, "b");
cl_assert_equal_s(str, "abc 42b");
//----------------------------------------------------
pbl_snprintf(str,... | |
property_animation_update_int16,
.accessors.setter.int16 = prv_sidebar_setter,
.accessors.getter.int16 = prv_sidebar_getter,
};
Animation *animation = (Animation *)property_animation_create(
&s_implementation, timeline_layer, &timeline_layer->sidebar_width, &to_sidebar_width);
animation_set_duration... | prv_get_scroll_delta(layer) | ;
if (scroll_direction == TimelineScrollDirectionUp) {
s_height_offsets[0] = (PAST_TOP_MARGIN_EXTRA + style->thin_pin_height +
(2 * style->fat_pin_height));
s_height_offsets[1] = (style->past_top_margin + style->thin_pin_height +
style->past_thin_pin_margi... |
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/righ... | graphics_capture_frame_buffer(ctx) | ;
if (dest_bitmap == NULL) {
return;
}
GRect dest_clip = ctx->draw_state.clip_box;
dest_ic.x += ctx->draw_state.drawing_box.origin.x;
dest_ic.y += ctx->draw_state.drawing_box.origin.y;
GCompOp compositing_mode = ctx->draw_state.compositing_mode;
#if PBL_BW
GColor foreground, background;
switch (co... |
the accel
bma255_write_register(BMA255Register_INT_EN_0, 0);
prv_disable_operating_mode(AccelOperatingMode_ShakeDetection);
}
void accel_enable_shake_detection(bool enable) {
if (s_shake_detection_enabled == enable) {
// the requested change matches what we already have!
return;
}
PBL_LOG(LOG_LEVEL... | (BMA255Axis_X) | ;
pass &= prv_selftest_axis(BMA255Axis_Y);
pass &= prv_selftest_axis(BMA255Axis_Z);
// g-range should be 4g to copy the BMI160
bma255_set_scale(BMA255Scale_4G);
return pass;
}
bool accel_run_selftest(void) {
return bma255_selftest();
}
////////////////////////////////////////////////////////////////////... |
/*
* 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 NULL;} | |
t32_t angle_start = TRIG_MAX_ANGLE / 8;
uint32_t angle_end = angle_start + (TRIG_MAX_ANGLE / 4);
GPointPrecise center = GPointPrecise(CENTER_OF_ORIGIN_RECT.x * 8, CENTER_OF_ORIGIN_RECT.y * 8);
Fixed_S16_3 radius = (Fixed_S16_3){.integer = RADIUS_BIG};
for (int precision_mode = 0; precision_mode < 2; precision_... | (TO_TRIG(270), TO_TRIG(360)) | , ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCornerTopLeft},
.full_quadrants = GCornerTopLeft,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerTopRight}
}));
// Tests for pairs of quadrants
cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(0), T... |
ys_copy_timezone_abbr(char* timezone_abbr, time_t time) {
const char* sys_tz = get_timezone_abbr();
strncpy(timezone_abbr, sys_tz, TZ_LEN);
}
struct tm *sys_gmtime_r(const time_t *timep, struct tm *result) {
return gmtime_r(timep, result);
}
struct tm *sys_localtime_r(const time_t *timep, struct tm *result) {
... | cl_assert_equal_i(to, 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... | (*timer_id, ms, prv_timer_callback, (void *)(uintptr_t)task,
0 /*flags */) | ;
}
if (!success) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Error scheduling timer");
}
}
// ---------------------------------------------------------------------------
// Used for unit tests only
TimerID animation_service_test_get_timer_id(void) {
return s_kernel_main_timer_id;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
assert_checksum(0xffffffff);
} | |
32},
{ 1144, -24, -128},
{ 864, -72, -152},
{ 952, 64, -192},
{ 1024, 112, -48},
{ 1048, 144, -296},
{ 1240, 104, -344},
{ 1480, 16, -360},
{ 1232, 104, -392},
{ 928, 168, -456},
{ 976, 256, -448},
{ 1184, 208, -424},
{ 1240, 288, -392},
{ 1200, 416, -424},
{ 1472... | { 848, 192, -296},
{ 960, 264, -312},
{ 1168, 272, -352},
{ 1240, 344, -352},
// 44 seconds
{ 1408, 552, -536},
{ 1328, 944, -712},
{ 1184, 224, -528},
{ 1288, 624, -560},
{ 1096, 448, -456},
{ 1136, 376, -392},
{ 1224, 312, -344},
{ 1120, 240, -288},
{ 1024, 184,... | |
{
// we weren't previously connected
return;
} |
PBL_LOG(LOG_LEVEL_INFO, "Connection state for service (0x%x) changed to %d", service_id,
connected);
PebbleEvent event = {
.type = PEBBLE_SMARTSTRAP_EVENT,
.smartstrap = {
.type = SmartstrapConnectionEvent,
.result = connected ? SmartstrapResultOk : SmartstrapResultServiceUnavailable... | |
("s", "20") | ;
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, "
"{hour: 'numeric', hour12: true});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "8 PM");
EXECUTE_SCRIPT("s = d.toLocaleTimeString(undefined, "
"{hour: 'numeric', hour12: false});");
ASSERT_JS_GLOBAL_EQUALS_S("s", "20");
EXECUTE... | |
wer of 2 addresses within it still have the
// data pattern, so only the first sector will end up being re-erased.
status = write_initial_pattern(true /*display_logs*/, false /*skip_base_addr*/,
NULL /*erase_addr*/);
VERIFY_TEST_STATUS(status);
bool stuck_at_low = false;
for ... | (stress_addr1, 0xFFFF, FLASH_TEST_ERR_ERASE, false) | ;
VERIFY_TEST_STATUS(status);
flash_erase_sector_blocking(stress_addr2);
status = prv_read_verify_halfword(stress_addr2, 0xFFFF, FLASH_TEST_ERR_ERASE, false);
VERIFY_TEST_STATUS(status);
// Write data to stress address locations
PBL_LOG(LOG_LEVEL_DEBUG, ">> Writing Addr 0x%"PRIx32" to value 0x%"PRIx16,
... |
/*
* 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... | (_path + root_len,
fixture_name,
sizeof(_path) - root_len) | ;
return _path;
}
#ifdef CLAR_FIXTURE_PATH
const char *cl_fixture(const char *fixture_name)
{
return fixture_path(CLAR_FIXTURE_PATH, fixture_name);
}
void cl_fixture_sandbox(const char *fixture_name)
{
fs_copy(cl_fixture(fixture_name), _clar_path);
}
void cl_fixture_cleanup(const char *fixture_name)
{
fs_rm(fix... |
false;
}
}
static void prv_erase_suspend_timer_cb(void *unused) {
mutex_lock(s_flash_lock);
prv_erase_resume();
mutex_unlock(s_flash_lock);
}
void flash_read_bytes(uint8_t* buffer, uint32_t start_addr,
uint32_t buffer_size) {
mutex_lock(s_flash_lock);
s_analytics_read_count++;
s_an... | stop_mode_disable(InhibitorFlash) | |
);
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, false, 2);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw2_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// SW = 3
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_R... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw1_no_clip.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 1);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, t... |
(checksum, payload, length) | ;
}
prv_encode_and_send_data(&checksum, sizeof(checksum));
accessory_send_byte(HDLC_FLAG);
accessory_enable_input();
}
// Request processing
////////////////////////////////////////////////////////////////////
static void prv_erase_complete(void *ignored, status_t result) {
s_flash_erase_in_progress = 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... | {
new_connectivity_icon_id = RESOURCE_ID_CONNECTIVITY_BLUETOOTH_AIRPLANE_MODE;
} | |
EXPECT_ERROR(
"ctx.arc(1, 2, 3, 4, 5);\n"
"ctx.fill();\n"
, "TypeError: fill() does not support arc()");
}
void test_rocky_api_graphics_path2d__fill_oom(void) {
rocky_global_init(s_graphics_api);
prv_create_global_ctx();
EXECUTE_SCRIPT(
"ctx.moveTo(1, 2);\n"
"ctx.lineTo(3, 4);\n"
"ctx.lin... | ((GVectorPrecise(0, 8)), s_rocky_path_steps[1].pt.fill_delta) | ;
cl_assert_equal_vector_precise((GVectorPrecise(8, 0)), s_rocky_path_steps[3].pt.fill_delta);
cl_assert_equal_vector_precise((GVectorPrecise(0, 8)), s_rocky_path_steps[5].pt.fill_delta);
}
void test_rocky_api_graphics_path2d__close_path(void) {
rocky_global_init(s_graphics_api);
prv_create_global_ctx();
c... |
BMA255PowerMode_Standby);
// Workaround for entering Normal Mode
// LPM1 => Normal requires us to go through Suspend mode
// LPM2 => Normal requires us to go through Standby mode
if (mode == BMA255PowerMode_Normal) {
if (s_accel_power_mode == BMA255PowerMode_LowPower1) {
prv_enter_power_mode(BMA255Po... | {
BMA255SampleInterval interval_us = accel_get_sampling_interval();
const uint8_t odr = (uint8_t)prv_get_odr(interval_us);
const uint8_t bw = s_odr_settings[odr].bw;
const uint8_t tsleep = s_odr_settings[odr].tsleep;
// Set the BW and TSleep to get the ODR we expect.
bma255_write_register(BMA255Register_PM... |
int accel_peek(AccelDriverSample *data) {
prv_read_curr_accel_data(data);
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// FIFO Support
////////////////////////////////////////////////////////////////////////////////
static void prv_program_fifo_register(uint8_t ad... |
GOvalScaleMode scale_mode,
int32_t angle_start, int32_t angle_end) {
GPointPrecise center;
Fixed_S16_3 radius;
grect_polar_calc_values(&rect, scale_mode, ¢er, &radius);
graphics_draw_arc_precise_internal(ctx, center, radius, angle_start, angle_end);
}
MOCKABLE void graphics_fill_radi... | {
return;
} |
if (radius == 0) {
// Filling a circle of radius zero should just draw a single pixel.
// Backup the stroke color and set that to the current fill color since the stroke color
// is what is used for draw pixel. Restore the stroke color afterwards.
GColor backup_stroke_color = ctx->draw_state.stroke_... |
HRMEvent_BPM);
cl_assert_equal_i(s_cb_events_1[0].bpm.bpm, s_hrm_event_data.hrm_bpm);
cl_assert_equal_i(s_cb_events_1[0].bpm.quality, s_hrm_event_data.hrm_quality);
cl_assert_equal_i(s_num_cb_events_1, 1);
cl_assert_equal_i(s_cb_events_1[0].event_type, HRMEvent_BPM);
cl_assert_equal_i(s_cb_events_1[0].bpm.bp... | cl_assert_equal_b(hrm_is_enabled(HRM), false) | |
attery_set_millivolts(discharge_mv);
fake_battery_set_connected(false);
cl_assert_equal_i(battery_get_charge_state().charge_percent, percent);
}
void test_battery_monitor__curve_adjustment_when_charge_complete(void) {
int charge_mv = battery_curve_lookup_voltage_by_percent(0, true);
int full_mv = battery_curve... | fake_battery_init(good_mv, false, false) | ;
battery_monitor_init();
periodic_timer_trigger(1);
cl_assert(!battery_monitor_critical_lockout());
fake_battery_set_millivolts(critical_mv);
periodic_timer_trigger(25);
cl_assert(battery_monitor_critical_lockout());
cl_assert_equal_i(standby_timer_get_timeout(), 30000);
standby_timer_trigger(1);
... |
/*
* 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->button, INSTALL_ID_INVALID) | ;
quick_launch_set_enabled(data->button, false);
app_window_stack_pop(true);
} else {
AppMenuNode* app_menu_node =
app_menu_data_source_get_node_at_index(&data->data_source, selection - NUM_CUSTOM_CELLS);
quick_launch_set_app(data->button, app_menu_node->install_id);
app_window_stack_pop(t... |
me_t intime;
const char *instr;
const char *output;
} s_truncation_tests[] = {
{ .size = 1, .intime = 1000,
.instr = "foo",
.output = "",
},
{ .size = 3, .intime = 1000,
.instr = "foo",
.output = "fo",
},
{ .size = 3, .intime = 1000,
.instr = "{format('foo')}",
.output = "fo",
},... | {
TemplateStringVars vars = {};
TemplateStringError err = {};
vars.current_time = 0;
bool ret = template_string_evaluate("test string {time_until(5)|format('%uS',)}", NULL, 0,
NULL, &vars, &err);
cl_assert_equal_b(ret, false);
cl_assert_equal_i(err.status... |
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test `time_since` and `time_until` filters
static const struct {
time_t current_time;
const char *params;
intmax_t done_state;
} s_time_since_tests[] = {
{ .current_time = 1234567,
.params = "1234567... |
= { 0x1D, 0x6C, 0x7F, 0x01, 0xD9, 0x48, 0x42, 0xA6, 0xAA, 0x4E, 0xB2, 0x08, 0x42, 0x10, 0xEB, 0xBC };
static PebbleProcessMd __pbl_app_info = {
.uuid = TEST_UUID_A,
};
const char lipsum[] = "Lorem ipsum dolor sit amet, consectetur "
"adipiscing elit. Nam dignissim ullamcorper sollicitudin. Suspendisse at "
"urn... | (0, lipsum, sizeof(lipsum)) | ,
PERSIST_DATA_MAX_LENGTH);
cl_assert_equal_i(persist_read_data(0, buf, sizeof(buf)),
PERSIST_DATA_MAX_LENGTH);
cl_assert(memcmp(lipsum, buf, PERSIST_DATA_MAX_LENGTH) == 0);
for (size_t i = PERSIST_DATA_MAX_LENGTH; i < sizeof(buf); ++i) {
cl_assert_(buf[i] == '~',
... |
ring_1;
memset(&pairing_1, 0x00, sizeof(pairing_1));
pairing_1 = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00
},
},
.identity = (BTDeviceInternal) {
.address ... | (id_2, &irk_out, &device_out, NULL /* name */) | |
2c_release(I2C_AS3701B);
return rv;
}
static bool prv_write_register(uint8_t register_address, uint8_t value) {
i2c_use(I2C_AS3701B);
bool rv = i2c_write_register(I2C_AS3701B, register_address, value);
i2c_release(I2C_AS3701B);
return rv;
}
static bool prv_set_register_bit(uint8_t register_address, uint8_t ... | if (prv_set_register_bit(PmicRegisters_CHARGE_CNTL, 7, true)) {
uint8_t cntl;
if (prv_read_register(PmicRegisters_CHARGE_CURRENT_CNTL, &cntl)) {
cntl = (cntl & 0xf0) | 0x09; // 118mA when cc_range_select = 1
success = prv_write_register(PmicRegisters_CHARGE_CURRENT_CNTL, cntl);
}
} |
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not set pmic charge current.");
}
// Set EOC current to 5% of ConstantCurrent
prv_set_register_bit(PmicRegisters_CHARGE_CONFIG_2, 5, false);
if (BOARD_CONFIG_POWER.charging_cutoff_voltage == 4300) {
// Set EOC to 4.30V, keep Vsup_min at 4.20V
// ... |
regular_timer_fire_seconds(1);
assert_ad_data("C");
}
// Introduce a second non-infinite job "D" for 10 seconds:
BLEAdData *ad_d = create_ad("D", NULL);
GAPLEAdvertisingJobRef infinite_job_d;
infinite_job_d = gap_le_advert_schedule(ad_d,
&advert_term, sizeof(a... | create_ad("B", NULL) | |
nable() {
QSPI_ComConfig_InitTypeDef qspi_com_config;
QSPI_ComConfig_StructInit(&qspi_com_config);
qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;
qspi_com_config.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_1Line;
qspi_com_config.QSPI_ComConfig_Ins = MT25QCommand_QSPIEnable;
QSPI... | QSPI_ComConfig_StructInit(&qspi_com_config) | ;
qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Read;
qspi_com_config.QSPI_ComConfig_DMode = QSPI_ComConfig_DMode_4Line;
qspi_com_config.QSPI_ComConfig_DummyCycles = MT25Q_FASTREAD_DUMMYCYCLES;
qspi_com_config.QSPI_ComConfig_ADMode = QSPI_ComConfig_ADMode_4Line;
qspi_com_config.QSPI_Com... |
h"
#include "stubs_passert.h"
#include "stubs_pebble_tasks.h"
#include "stubs_prompt.h"
#include "stubs_simple_dialog.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
#include "stubs_vibe_score_info.h"
#include "stubs_vibes.h"
#include "stubs_window_manager.h"
#include "fake_new_timer.h"
#include "fake_pbl... | (WeekendSchedule, false) | |
e of the screen
const MenuRowAlign row_align = PBL_IF_RECT_ELSE(MenuRowAlignTop, MenuRowAlignCenter);
prv_launcher_menu_layer_set_selection_index(&launcher_menu_layer, selected_index,
row_align, animated);
layer_render_tree(launcher_menu_layer_get_layer(&launcher_men... | (&s_ctx.dest_bitmap, TEST_PBI_FILE) | );
}
void test_launcher_menu_layer__interior_app_pdc(void) {
s_use_pdc_icons = true;
prv_render_launcher_menu_layer(LauncherMenuLayerTestApp_InteriorApp);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_launcher_menu_layer__no_icon_app_with_glance_pdc(void) {
s_use_pdc_icons = true;
... |
should_perform_dismiss) {
// Call this directly so that we don't get another action result
ancs_perform_action(ancs_uid, ActionIDNegative);
}
break;
}
case ActionResultTypeChaining:
prv_handle_chaining_response(data, e);
break;
case ActionResultTypeDoResponse:
p... | if (sender_attr) {
// Copy the sender attribute - note: this assumes the timeline item is not freed until
// the message is sent
attributes[1] = *sender_attr;
} |
AttributeList response_attributes = {
.num_attributes = num_attributes,
.attributes = attributes,
};
timeline_invoke_action(pin, action, &response_attributes);
break;
}
case TimelineItemActionTypePostpone: {
Attribute timestamp_attr = {
.id = AttributeIdTim... |
p_install_has_worker(tictoc_id));
cl_assert_equal_b(false, app_install_has_worker(music_id));
cl_assert_equal_b(false, app_install_has_worker(sports_id));
cl_assert_equal_b(true, app_install_has_worker(bg_counter_id));
cl_assert_equal_b(false, app_install_has_worker(menu_layer_id));
cl_assert_equal_b(false,... | (12, num_entries) | ;
}
void test_app_install_manager__hidden_app_recently_communicated(void) {
static const uint32_t INIT_TIME = 1388563200;
fake_rtc_init(0, INIT_TIME);
AppInstallEntry entry;
cl_assert(true == app_install_get_entry_for_install_id(sports_id, &entry));
// hidden before communication
cl_assert(true == app_in... |
;
app_unobstructed_area_service_subscribe(handlers, s_data.context);
cl_assert(fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.change, prv_change);
const GRect area = GRect(0, 0, DISP_COLS, 200);
const AnimationProgres... | cl_assert_equal_grect(unobstructed_bounds, root_layer.bounds) | ;
}
void test_unobstructed_area_service__layer_clip_x_y(void) {
app_state_get_unobstructed_area_state()->area = GRect(0, 0, 400, 400);
Layer root_layer = {
.bounds = GRect(210, 220, 300, 300),
};
GRect unobstructed_bounds;
layer_get_unobstructed_bounds(&root_layer, &unobstructed_bounds);
cl_assert_equ... |
cific language governing permissions and
* limitations under the License.
*/
#include "drivers/led_controller.h"
#include "board/board.h"
#include "drivers/gpio.h"
#include "drivers/i2c.h"
#include "drivers/periph_config.h"
#include "system/logging.h"
#include "system/passert.h"
#define STM32F2_COMPATIBLE
#define ... | {
return s_rgb_current_color;
} |
void command_rgb_set_color(const char* color) {
uint32_t color_val = strtol(color, NULL, 16);
led_controller_rgb_set_color(color_val);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (ctx, GColorWhite) | ;
graphics_fill_round_rect(ctx, &GRect(2, 2, 28, 20), 4, GCornersAll);
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorClear);
graphics_fill_round_rect(ctx, &GRect(2, 2, 28, 20), 4, GCornersAll);
}
void cor... |
sion should free up another 4k block
e.header.id = uuids[i];
e.header.timestamp = timestamp + i;
notification_storage_store(&e);
cl_assert(notification_storage_get(&uuids[i], &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
// Check that an expected number of notifications were removed
er... | notification_storage_store(&e3) | |
/*
* 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 app_state_get_animation_state();
} | else if (task == PebbleTask_KernelMain) {
return kernel_applib_get_animation_state();
} else {
WTF;
}
}
// -------------------------------------------------------------------------------------------
T_STATIC AnimationPrivate *prv_animation_get_current(void) {
AnimationState *state = prv_animation_state_... |
_close(-1);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(0);
cl_assert(rv == E_INVALID_ARGUMENT);
rv = pfs_close(1000000);
cl_assert(rv == E_INVALID_ARGUMENT);
int fd = pfs_open("file", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
rv = pfs_close(fd);
cl_assert(rv == S_SUCCESS);
... | (name, OP_FLAG_WRITE, FILE_TYPE_STATIC, pfs_get_size() - (num_pages()*128)) | ;
printf("%d\n", pfs_get_size() - 1024);
cl_assert(fd >= 0);
cl_assert(pfs_close(fd) == S_SUCCESS);
cl_assert(pfs_remove(name) == S_SUCCESS);
}
void test_pfs__active_regions(void) {
pfs_format(false);
cl_assert(!pfs_active_in_region(0, pfs_get_size()));
// erase every page and make sure pfs is active
... |
/*
* 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... | {
Connection *conn = connection_by_idx(conn_idx);
if (conn) {
connection_set_gateway(conn, false);
}
} |
PBL_LOG(LOG_LEVEL_DEBUG, "Removed pairing for "BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE(info->identity.address));
}
void bonding_sync_handle_pairing_completed(Connection *connection, uint16_t conn_idx) {
BleBonding bonding = {};
SMPairingInfo *info = &bonding.pairing_info;
bool success = fal... |
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WA... | if (!p) {
return HrmSharingPermission_Unknown;
} | |
.header.id, &s_items[4].header.id));
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check second again
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[4].header.id));
// check fourth
cl_assert(it... | (&state.pin.header.id, &s_extra_case_items[1].header.id) | );
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[2].header.id));
cl_assert(!iter_next(&iterator));
}
// 5am, no events passed
void test_timeline__extra_case_none_backwards(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState ... |
xt);
void test_recognizer_manager__fail_recognizer(void) {
NEW_RECOGNIZER(r1) = test_recognizer_create(&s_test_impl_data, NULL);
NEW_RECOGNIZER(r2) = test_recognizer_create(&s_test_impl_data, NULL);
r2->state = RecognizerState_Started;
// copied from recognizer_manager.c
struct FailRecognizerCtx {
Recog... | prv_set_all_states(recognizers, k_rec_count, RecognizerState_Possible) | ;
prv_cancel_layer_tree_recognizers(&manager, NULL, &layer_c);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, Reco... |
e(ctx, prev_state);
}
}
//! helper struct to move displacement logic out of window_render()
typedef struct {
GPoint drawing_box_origin;
GRect clip_box;
} DrawingStateOrigins;
static void prv_adjust_drawing_state_for_legacy2_apps(DrawingStateOrigins *saved_state,
... | {
GContext *ctx = graphics_context_get_current_context();
GRect result = (GRect) {
.origin = { 0, 0 },
.size = graphics_context_get_framebuffer_size(ctx)
};
result.size.h -= fullscreen ? 0 : STATUS_BAR_HEIGHT;
return result;
} |
// FIXME: there is a problem in this function:
// This function initializes the root layer to be the screen size. So, on a
// new window with a status bar, unless otherwise forced to with something
// like window_set_on_screen(), the window is first rendered at position (0,0);
// then this function shifts it to its ... |
_pointer);
dbgserial_print("Booting firmware @ ");
dbgserial_print_hex((uintptr_t)reset_handler);
dbgserial_newline();
dbgserial_newline();
prv_hw_reset();
// The Cortex-M user guide states that the reset values for the core registers
// are as follows:
// R0-R12 = Unknown
// MSP = VECTOR_TABLE... | boot_bit_clear(BOOT_BIT_FORCE_PRF) | ;
return true;
}
if (button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK)) {
dbgserial_putstr("Hold down UP + BACK for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!(button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK))) {
// stop waiti... |
/*
* 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... | timeline_layer_create_day_sep_show(&timeline_layer) | |
{
hrm_init(HRM);
} |
#endif
// The display has to be initialized before bluetooth because on Snowy the
// display FPGA shares the 32 kHz clock signal with bluetooth. If the FPGA is
// not programmed when we attempt to initialize bluetooth, it prevents the
// clock from reaching the bluetooth module and initialization fails.
dis... | |
const uint8_t *buf_end) {
SerializedActionHeader *serialized_action = (SerializedActionHeader *)*cursor;
*cursor += sizeof(SerializedActionHeader);
action->id = serialized_action->id;
action->type = serialized_action->type;
action->attr_list.num_attributes = serialized_action->num_... | ((AttributeList *)&addr_list->addresses[i].attr_list) | ;
}
return size;
}
size_t attribute_group_get_serialized_payload_size(AttributeGroupType type,
AttributeList *attr_list,
void *group_ptr) {
size_t size = 0;
if (attr_list) {
size += attribute_list_get_ser... |
s &= commit_succeeded;
prv_mark_pb_jobs_complete(1);
prv_cleanup_and_send_response((commit_succeeded) ? ResponseAck : ResponseNack);
}
static bool prv_is_valid_command_for_current_state(PutBytesCommand command) {
switch (s_pb_state.current_command) {
case PutBytesIdle:
return (command == PutBytesInit || co... | (new_timer_start(s_pb_state.timer_id, PUT_TIMEOUT_MS, prv_timer_callback,
&s_pb_state, 0 /*flags*/)) | |
/*
* 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... | helper_check_buffer_for_content_indicator(i, content_indicator) | ;
}
// Creating more content indicators than the buffer can hold should return NULL
cl_assert_equal_p(content_indicator_create(), NULL);
}
void test_content_indicator__init_should_add_to_buffer(void) {
ContentIndicator content_indicator;
for (size_t i = 0; i < CONTENT_INDICATOR_BUFFER_SIZE; i++) {
conte... |
iph_HASH
| RCC_AHB2Periph_RNG | RCC_AHB2Periph_OTGFS;
const uint32_t ahb3_periphs = RCC_AHB3Periph_FMC | RCC_AHB3Periph_QSPI;
const uint32_t apb1_periphs =
RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4| RCC_APB1Periph_TIM5
| RCC_APB1Periph_TIM6 | RCC_APB1Periph_TIM7 | RCC_APB1Periph_TI... | boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE) | |
_assert_equal_b(s_prv_activity_cb__args[0].activity, HealthActivitySleep);
// order direction past
s_prv_activity_cb__call_count = 0;
health_service_activities_iterate(HealthActivityMaskAll, now - (200 * SECONDS_PER_MINUTE), now,
HealthIterationDirectionPast, prv_activity_cb, ... | rtc_get_time() | ;
HealthMinuteData data[5] = {};
uint32_t written;
// null pointer
time_t time_start = now - 10 * 60 - 30;
time_t time_end = now - 20;
written = health_service_get_minute_history(NULL, ARRAY_LENGTH(data), &time_start, &time_end);
cl_assert_equal_i(0, written);
// empty boundary
written = health_ser... |
quired 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.
*/
#inclu... | (&timeline_layout->icon_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... | {
cl_assert_equal_b(s_mutex_locked, false);
} |
// Tests
///////////////////////////////////////////////////////////
void test_shared_prf_storage_v3__initialize(void) {
fake_spi_flash_init(FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
SPRF_REGION_SIZE);
shared_prf_storage_init();
}
void test_shared_prf_storage_v3__cleanup(void) {
fake_spi_fla... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.