prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
e License for the specific language governing permissions and
* limitations under the License.
*/
#if PULSE_EVERYWHERE
#include "pulse_protocol_impl.h"
#include "console/control_protocol.h"
#include "console/control_protocol_impl.h"
#include "console/pulse.h"
#include "console/pulse2_transport_impl.h"
#include "co... | (packet_size) | ;
pulse_link_send(packet, packet_size);
}
// Shared events
// =============
void pulse2_best_effort_on_link_up(void) {
ppp_control_protocol_lower_layer_is_up(PULSE2_BECP);
}
void pulse2_best_effort_on_link_down(void) {
ppp_control_protocol_lower_layer_is_down(PULSE2_BECP);
}
void pulse2_best_effort_init(void) ... |
t_distance = ANIMATION_NORMALIZED_MAX / 2;
if (distance_normalized < contract_to_dot_distance) {
// Switch to the "contract from modal" animation if necessary (e.g. if the animation was
// reversed in the future)
if (s_data.expanding) {
prv_modal_transition_animation_init_sequence(MODAL_CONTRACT_FRO... | {
const uint32_t resource_id = s_data.modal_is_destination ?
MODAL_CONTRACT_TO_MODAL_ANIMATION :
MODAL_CONTRACT_FROM_MODAL_ANIMATION;
prv_modal_transition_animation_init_sequence(resource_id);
// Tweaked from observations by the design team
co... |
static void prv_modal_push_transition_animation_init_round(Animation *animation) {
const uint32_t duration_ms = 8 * ANIMATION_TARGET_FRAME_INTERVAL_MS;
animation_set_duration(animation, duration_ms);
animation_set_curve(animation, AnimationCurveLinear);
}
static void prv_modal_transition_animation_teardown_rec... |
/*
* 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... | (attr_list, action_group,
actual_buf, buf_size) | |
ic(ActivityMetricHeartRateFilteredBPM, 1, &last_median);
activity_get_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc);
cl_assert_equal_i(last_median, 0);
cl_assert_equal_i(last_update_utc, 0);
// Simulate some HRM callbacks with non-zero heart rate
prv_advance_time_hr(3 /*sec*/, 50... | cl_assert_equal_i(s_num_hr_events, 4) | ;
}
// ---------------------------------------------------------------------------------------
// Today is Thursday
void test_activity__prv_set_metric(void) {
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
int32_t metric_values[ACTIVITY_HISTORY_DAYS] = {0};
// Set ... |
/*
* 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... | (GROUP_TYPE,
num_attributes,
num_actions,
attributes_per_actions,
required_size_for_strings) | |
Timing" subtitle and submenu option.
i18n_noop("10 Min Before"),
/// Shows up in the Timeline settings as a "Timing" subtitle and submenu option.
i18n_noop("15 Min Before"),
/// Shows up in the Timeline settings as a "Timing" subtitle and submenu option.
i18n_noop("30 Min Before"),
};
static uint16_t s_befor... | (sizeof(*data)) | |
aphics_draw_pixel(ctx, GPoint(-5, 5));
}
void outside_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_pixel(ctx, GPoint(5, 15));
}
void outside_ny_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColo... | layer_set_update_proc(&layer, &outside_x_ny_layer_update_callback) | ;
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_x_ny_offset_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_nx_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("ou... |
(ctx, &layer->bounds) | ;
}
static void prv_fill_cols(GContext *ctx, uint8_t color, int16_t *row, int16_t column,
uint8_t num_pixels) {
const GRect rect = { { column, *row }, { 1, num_pixels } };
// Set alpha bits to make it opaque
graphics_context_set_fill_color(ctx, (GColor) { .argb = (0b11000000 | color) }... | |
ytes is %"PRIu32, num_bytes);
PBL_LOG(LOG_LEVEL_WARNING, "Calculated the CRC again, got 0x%"PRIx32, calculated_crc_again);
return calculated_crc_again == manifest->version.crc;
}
return true;
}
static void prv_get_store_entry(ResAppNum app_num, uint32_t resource_id,
Resour... | {
*entry = (ResourceStoreEntry){0};
return;
} |
if (!entry->impl->get_resource(entry)) {
*entry = (ResourceStoreEntry){0};
return;
}
PBL_ASSERTN(entry->length != ENTRY_LENGTH_UNSET);
}
ResourceCallbackHandle resource_watch(ResAppNum app_num, uint32_t resource_id,
ResourceChangedCallback callback, void* data) {
... |
alse, true, false, 0x6 },
{ true, false, true, false, 0x7 } // Both 0x6 and 0x7 map to the same permissions.
};
static const uint32_t s_cache_settings[MpuCachePolicyNum] = {
[MpuCachePolicy_NotCacheable] = (0x1 << MPU_RASR_TEX_Pos) | (MPU_RASR_S_Msk),
[MpuCachePolicy_WriteThrough] = (MPU_RASR_S_Msk | MPU_RASR... | {
if (s_permission_mappings[i].value == access_permissions) {
region.priv_read = s_permission_mappings[i].priv_read;
region.priv_write = s_permission_mappings[i].priv_write;
region.user_read = s_permission_mappings[i].user_read;
region.user_write = s_permission_mappings[i].user_wri... |
}
return region;
}
// Fill in the task parameters for a new task with the configurable memory regions we want.
void mpu_set_task_configurable_regions(MemoryRegion_t *memory_regions,
const MpuRegion **region_ptrs) {
unsigned int region_num, region_idx;
uint32_t base_reg... |
job);
cl_assert_equal_b(s_unscheduled_completed, true);
free(ad);
}
void test_gap_le_advert__invalid_params(void) {
GAPLEAdvertisingJobRef job;
BLEAdData *ad = create_ad(NULL, NULL);
GAPLEAdvertisingJobTerm advert_term = {
.min_interval_slots = 31,
.max_interval_slots = 31,
.duration_secs = 1,... | gap_le_advert_schedule(ad, &advert_term, sizeof(advert_term)/sizeof(GAPLEAdvertisingJobTerm),
unscheduled_callback, s_unscheduled_cb_data, 0) | |
p_type_element_attribtue_list)) {
return false;
}
}
return true;
}
bool attribute_group_deserialize(AttributeGroupType type,
AttributeList *attr_list,
void *group_ptr,
uint8_t *buffer,
... | prv_serialize_action(
&((TimelineItemActionGroup *)group_ptr)->actions[i], &buffer) | ;
} else {
group_type_element_attribtue_list = prv_serialize_address(
&((AddressList *)group_ptr)->addresses[i], &buffer);
}
PBL_ASSERTN(buffer <= buf_end);
buffer += attribute_list_serialize(group_type_element_attribtue_list,
buffer, buf_end);
}... |
ndly_date(char *buffer, int buf_size, time_t timestamp) {
const time_t now = rtc_get_time();
const time_t midnight = time_util_get_midnight_of(timestamp);
const time_t today_midnight = time_util_get_midnight_of(now);
if (midnight == today_midnight) {
i18n_get_with_buffer("Today", buffer, buf_size);
} el... | i18n_noop("%A") | ;
}
break;
case FullStyleLower24h:
case FullStyleCapital24h:
if (with_fulltime) {
time_fmt = i18n_noop("%a, %R");
} else {
time_fmt = i18n_noop("%A");
}
break;
}
}
prv_format_time(buffer, buf_size, time_fmt, timestamp);
}
static vo... |
sable it.
if (rv && config->kind == ALARM_KIND_JUST_ONCE) {
config->is_disabled = true;
prv_alarm_set_config(file, id, config); // This will reload the alarms
} else {
prv_reload_alarms(file);
}
cleanup:
prv_file_close_and_unlock(file);
kernel_free(file);
PBL_LOG(LOG_LEVEL_INFO, "Alarm %u tim... | if (hour < local_time.tm_hour || (hour == local_time.tm_hour && minute <= local_time.tm_min)) {
// The time is before or equal to the current time. Sechedule the alarm for tomorrow
return (local_time.tm_wday + 1) % DAYS_PER_WEEK;
} else {
// The time hasn't happend yet today. Schedule it for today
ret... |
}
static void prv_set_day_for_just_once_alarm(AlarmConfig *config, int hour, int minute) {
const bool scheduled_days[DAYS_PER_WEEK] = {false, false, false, false, false, false, false};
memcpy(&config->scheduled_days, scheduled_days, sizeof(scheduled_days));
int wday = prv_get_day_for_just_once_alarm(hour, minu... |
/*
* 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, "Dispatching smartstrap connection event (connected=%d)", connected) | ;
const SmartstrapProfileInfo *info;
FOREACH_PROFILE_INFO(info) {
if (info->connected) {
info->connected(connected);
}
}
if (connected) {
smartstrap_connection_got_valid_data();
}
}
static const SmartstrapProfileInfo *prv_get_info_by_service_id(uint16_t service_id) {
// find the profile w... |
t = error->next;
clar_print_error(i++, error);
free(error->description);
free(error);
error = next;
}
_clar.errors = _clar.last_error = NULL;
}
static void
clar_run_test(
const struct clar_func *test,
const struct clar_func *initialize,
const struct clar_func *cleanup)
{
int error_st = _cl... | ("No suite matching '%s' found.\n", argument) | ;
exit(-1);
}
break;
}
// Run a particular test only. This code was added on top of base clar.
case 't': {
int offset = (argument[2] == '=') ? 3 : 2;
char *test_name = argument + offset;
const struct clar_suite *suite = &_clar_suites[0];
const struct clar_func *... |
RT_TASK(PebbleTask_KernelMain);
prv_event_service_subscribe(subscription);
}
static bool prv_event_service_send_event(QueueHandle_t queue, PebbleEvent *e) {
PBL_ASSERTN(queue != NULL);
bool success = (xQueueSendToBack(queue, e, 0) == pdTRUE);
return success;
}
void event_service_handle_subscription(PebbleSubs... | {
worker_manager_close_current_worker(false);
} | |
/*
* 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... | TEST_PBI_FILE_FMT(8bit) | ));
cl_assert_equal_i(gbitmap_get_format(bitmap), GBitmapFormat8Bit);
}
// Tests 1-bit transparent palettized PNG loading into gbitmap
// Result:
// - gbitmap matches platform loaded PNG
void test_png__color_1_bit_transparent(void) {
GBitmap *bitmap = setup_png_test(TEST_PNG_FILE_FMT(1bitpalette));
cl_assert(g... |
stination(client), metas[i].expected_destination);
ppogatt_close(client);
}
}
void test_ppogatt__handles_unsupported_meta_ppogatt_version(void) {
PPoGATTMetaV0 future_meta_non_compatible = s_meta_v0_system;
future_meta_non_compatible.ppogatt_min_version = 0xaa;
future_meta_non_compatible.ppogatt_max_versio... | ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta],
NULL, 0,
BLEGATTErrorInvalidHandle) | |
AD_SIZE UINT16_MAX
// Empirically, it seems to take 24ms for the revAD silicon to come out of
// reset and send the start message. This is way longer than its going to
// take to get a response to other bootROM messages so let's assume that's
// the max worst case wait time. To account for some variance, let's wait
//... | (bytes_left, sizeof(data_buf)) | ;
if (!resource_load_byte_range_system(SYSTEM_APP, RESOURCE_ID_BT_BOOT_IMAGE, curr_offset,
data_buf, read_len)) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to load patch from system resources");
return false;
}
for (uint32_t i = 0; i < read_len; i++) {
run... |
/*
* 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... | reboot_reason_set(&reason) | ;
system_reset();
}
static void prv_factory_reset_post(bool should_shutdown) {
if (should_shutdown) {
enter_standby(RebootReasonCode_FactoryResetShutdown);
} else {
factory_reset_set_reason_and_reset();
}
}
void factory_reset(bool should_shutdown) {
s_in_factory_reset = true;
prv_factory_reset_no... |
/*
* 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... | task_free(context) | ;
}
static uint16_t prv_menu_get_num_rows(OptionMenu *option_menu, void *context) {
return ((SettingsOptionMenuData *)context)->num_rows;
}
static void prv_menu_draw_row(OptionMenu *option_menu, GContext *ctx, const Layer *cell_layer,
const GRect *cell_frame, uint32_t row, bool selecte... |
536},
// 191 seconds
{ 1392, 536, -728},
{ 944, 408, -472},
{ 936, 600, -464},
{ 992, 552, -488},
{ 960, 472, -376},
{ 792, 344, -288},
{ 768, 304, -224},
{ 960, 208, -232},
{ 1208, 120, -192},
{ 1728, 160, -64},
{ 1472, 192, -32},
{ 1520, 176, -88},
{ 1280, 120, ... | { 1136, 152, -208},
{ 1456, 80, -168},
{ 1504, 112, -80},
{ 1296, 168, -40},
{ 1184, 192, -216},
{ 1160, -136, 312},
{ 704, -208, -88},
{ 696, -112, -392},
{ 992, -264, -232},
{ 1040, -32, -256},
{ 768, 24, -400},
{ 752, 152, -352},
{ 960, 200, -320},
{ 1272, 248,... |
{ -480, 728, -448},
{ -592, 832, -536},
{ -592, 800, -640},
{ -464, 784, -752},
{ -328, 600, -816},
{ -256, 168, -768},
{ -224, -160, -800},
{ -200, -312, -744},
{ -176, -464, -776},
{ -224, -464, -784},
{ -248, -464, -816},
{ -264, -384, -912},
{ -312, -320, -944},
... |
vent(0, 0);
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(10, 10), 20, 5, true);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_even... | {
TouchEventContext ctx = {
.idx = 0
};
touch_dispatch_touch_events(0, prv_touch_event_dispatch_cb, &ctx);
cl_assert_equal_i(ctx.idx, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
touch_handl... |
void test_touch__cancel_touches(void) {
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
touch_handle_update(1, TouchState_FingerDo... |
REGION_SIZE);
shared_prf_storage_init();
shared_prf_storage_set_getting_started_complete(true);
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), true);
}
void test_shared_prf_storage_v3__find_first_valid_sector(void) {
SharedPRFData data;
// These are the pages that this test will place ... | (PAIRING_INFO.is_remote_signing_info_valid,
pairing_info_out.is_remote_signing_info_valid) | ;
cl_assert_equal_b(PAIRING_INFO.is_remote_identity_info_valid,
pairing_info_out.is_remote_identity_info_valid);
cl_assert_equal_b(PAIRING_INFO.is_remote_encryption_info_valid,
pairing_info_out.is_remote_encryption_info_valid);
cl_assert_equal_b(PAIRING_INFO.is_local_encryp... |
1_time + op_2_time and does so by counting the number of times
the app window's update callback got called within a set amount of time. The window update
callback only does op1, but the app_render_handler() method in app.c insures that a window
update is not called again until op_2 has completed for the previous ... | (scroll_layer) | ;
scroll_layer_set_content_offset((ScrollLayer *)data->action_list1, offset, false);
}
static void prv_window_load(Window *window) {
// creates a structure as outlined at
// https://pebbletechnology.atlassian.net/wiki/display/DEV/3.0+Notifications+UI+MVP
// it's one full screen background image .background_la... |
void prv_pin_to_card_second_half_stopped(KinoLayer *layer, bool finished, void *context) {
TimelineLayout *layout = context;
KinoReel *new_reel = kino_reel_create_with_resource_system(layout->icon_res_info.res_app_num,
layout->icon_res_info.res_id);
prv... | (new_reel, GPoint(0, icon_from.size.h / 2)) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
str[i] = toupper((unsigned char)str[i]);
} |
}
void byte_stream_to_hex_string(char *out_buf, size_t out_buf_len,
const uint8_t *byte_stream, size_t byte_stream_len, bool print_backward) {
size_t bytes_left = byte_stream_len;
if (print_backward) {
byte_stream += (byte_stream_len - 1); // addr of the last element
}
while (out_buf_len >= 3 /* 2 he... |
/*
* 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 (!memory_layout_is_pointer_in_region(memory_layout_get_readonly_bss_region(), fontinfo)) {
syscall_failed();
} |
}
text_resources_init_font(fontinfo->base.app_num, fontinfo->base.resource_id,
fontinfo->extension.resource_id, fontinfo);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gpio_af_init(&dev->tx_gpio, otype, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL) | ;
}
if (dev->rx_gpio.gpio) {
// half-duplex should only define a TX pin
PBL_ASSERTN(!dev->half_duplex);
gpio_af_init(&dev->rx_gpio, otype, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL);
}
// clear any lingering errors
prv_clear_all_errors(dev);
// configure the UART peripheral control registers
// - 8... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
s_free_list = m;
} |
prv_check_free_list();
mutex_unlock(s_free_list_lock);
}
// Basic setters and getters
////////////////////////////////////////////////////////////////////////////////
void mbuf_set_data(MBuf *m, void *data, uint32_t length) {
PBL_ASSERTN(m);
//! We should never be trying to set the data on an mbuf in the fr... |
{ 776, -40, -8},
{ 1352, 0, -8},
{ 1344, -144, 296},
{ 976, -704, 408},
{ 952, -216, 136},
{ 952, 120, -80},
{ 952, 112, -80},
{ 984, 104, -192},
{ 928, 64, -224},
{ 976, 72, -296},
{ 968, 64, -328},
{ 976, 32, -208},
{ 1048, 16, -176},
{ 1080, 104, -152},
// 1... | { 1040, -24, -64},
{ 1080, -120, 72},
{ 1056, -80, 64},
{ 976, -16, 8},
{ 936, 64, -112},
{ 944, 80, -88},
{ 1048, 40, -112},
{ 1040, 32, -112},
{ 1144, -72, -144},
{ 1104, 24, -88},
{ 1120, 288, -264},
{ 1672, 144, -304},
{ 1472, -160, 56},
{ 1056, 80, 232},
... |
{ 936, 408, -168},
{ 992, 256, -376},
{ 912, 160, -216},
// 139 seconds
{ 920, 224, -120},
{ 1016, 304, -144},
{ 1096, 352, -96},
{ 1088, 352, 24},
{ 984, 328, 104},
{ 1088, 336, 200},
{ 1280, 328, 192},
{ 960, 296, 176},
{ 1104, 264, 72},
{ 944, 104, 0},
{ 9... |
stallEntry *entry) {
*entry = (AppInstallEntry) {
.install_id = id,
.type = AppInstallStorageFlash,
.visibility = process_metadata_flags_visibility(db_entry->info_flags),
// PebbleTask_App because the flag parsing function needs it, and we can assume all
// applications registered with the manage... | app_db_get_app_entry_for_install_id(install_id, db_entry) | == S_SUCCESS);
if (rv) {
rv = prv_app_install_entry_from_app_db_entry(install_id, db_entry, entry);
}
kernel_free(db_entry);
return rv;
}
PBL_LOG(LOG_LEVEL_ERROR, "Failed to get entry for id %"PRId32, install_id);
return false;
}
bool app_install_get_uuid_for_install_id(AppInstallId insta... |
/*
* 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(locale, new, ISO_LOCALE_LENGTH);
} |
}
char *pbl_setlocale(int category, const char *locale) {
LocaleInfo *info = app_state_get_locale_info();
if (locale == NULL) {
switch (category) {
case LC_ALL:
return info->app_locale_strings;
case LC_TIME:
return info->app_locale_time;
default:
return NULL;
}
... |
_duration_a);
cl_assert_equal_i(animation_get_duration(b, false, false), duration_b);
cl_assert_equal_i(animation_get_duration(b, false, true), play_count_b * duration_b);
cl_assert_equal_i(animation_get_duration(b, true, false), delay_b + duration_b);
cl_assert_equal_i(animation_get_duration(b, true, true), t... | animation_schedule(spawn) | |
offset in milliseconds from the
// current time would overflow the argument to AppTimer, so just ignore this slice because it's
// not worth setting a timer for it
return;
}
prv_reset_slice_expiration_timer(service);
service->slice_expiration_timer =
app_timer_register((uint32_t)time_until_sli... | list_insert_before(service->glance_cache, &new_cache_entry->node) | |
ne.width_px == HORIZ_ADVANCE_PX * 0);
cl_assert(line.origin.x == 0);
cl_assert(line.suffix_codepoint == 0);
cl_assert(*line.start == '\n');
// \n
cl_assert(*word_iter_state.current.start == '\n');
cl_assert(*word_iter_state.current.end == 'a');
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_... | {
// Should not get here
cl_assert(false);
break;
} |
}
}
|
x06,
.write_disable = 0x04,
.read_status = 0x05,
.read_flag_status = 0x2B,
.erase_suspend = 0xB0,
.erase_resume = 0x30,
.enter_low_power = 0xB9,
.exit_low_power = 0xAB,
.enter_quad_mode = 0x35,
.reset_enable = 0x66,
.reset = 0x99,
.qspi_id = 0xAF,
.block_lock = 0x36,
... | qspi_flash_erase_resume(QSPI_FLASH, sector_addr) | |
DFSDM_SelectRegularChannel(this->filter, this->regular_channel) | ;
DFSDM_FastModeCmd(this->filter, ENABLE);
}
// must have initialized both the DFSDM and DMA
static void prv_dfsdm_enable(MicDevice *this) {
// Enable DFSDM and DMA
DFSDM_Cmd(ENABLE);
DFSDM_ChannelCmd(this->channel, ENABLE);
// Wait for microphone to power up
psleep(this->power_on_delay_ms);
// Config... | |
cl_assert_equal_i(s_cb_events_1[0].bpm.quality, s_hrm_event_data.hrm_quality) | ;
// Now advance time to just before the expiration time
rtc_set_time(rtc_get_time() + expire_s - 1);
// Send more data, the callback should get the expiring event
prv_fake_send_new_data();
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(s_num_cb_events_1, 3);
cl_assert_equal_i(s_cb_eve... | |
t8_t *data) {
PBL_ASSERTN(s_initialized);
PBL_ASSERTN(device_id < BOARD_CONFIG.i2c_device_count);
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
// Take control of bus; only one task may use bus at a time
bus_lock(bus);
if (bus->user_count == 0) {
PBL_L... | PBL_LOG(LOG_LEVEL_ERROR, "Read failed on bus %" PRId8, BOARD_CONFIG.i2c_device_map[device_id]) | ;
}
return result;
}
bool i2c_write_register(I2cDevice device_id, uint8_t i2c_device_address, uint8_t register_address,
uint8_t value) {
return i2c_write_register_block(device_id, i2c_device_address, register_address, 1, &value);
}
bool i2c_write_register_block(I2cDevice device_id, uin... |
string(&characteristic_uuid, uuid_buffer);
APP_LOG(APP_LOG_LEVEL_INFO, "Read Characteristic %s, %u bytes, error: %u",
uuid_buffer, value_length, error);
for (size_t i = 0; i < value_length; ++i) {
APP_LOG(APP_LOG_LEVEL_INFO, "0x%02x", value[i]);
}
}
static void write_handler(BLECharacteristic char... | // APP_LOG(APP_LOG_LEVEL_INFO, "---- Descriptor: %s (0x%08x)", uuid_buffer, descriptors[d]);
//
// // If the characteristic is the Heart Rate Measurement,
// // attempt to subscribe to it by writing to the CCCD:
// const Uuid hrm_uuid = bt_uuid_expand_16bit(0x2A37);
// const Uuid cccd... |
}
}
static void connection_handler(BTDevice device, BTErrno connection_status) {
const BTDeviceAddress address = bt_device_get_address(device);
const bool connected = (connection_status == BTErrnoConnected);
APP_LOG(APP_LOG_LEVEL_INFO, "%s " BT_DEVICE_ADDRESS_FMT " (status=%d)",
connected ? "Conne... |
"
#include "drivers/flash.h"
#include "drivers/task_watchdog.h"
#include "flash_region/filesystem_regions.h"
#include "flash_region/flash_region.h"
#include "services/normal/filesystem/pfs.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/size.h"
//! Flash translation op... | for (unsigned int i = s_next_region_idx; i < TOTAL_NUM_FLASH_REGIONS; i++) {
ftl_add_region(s_region_list[i].start, s_region_list[i].end, true);
} |
PBL_LOG(LOG_LEVEL_DEBUG, "Filesystem: New size - %"PRId32" Kb", (s_ftl_size / 1024));
}
uint32_t ftl_get_size(void) {
return s_ftl_size;
}
static void prv_ftl_operation(uint8_t *buffer, uint32_t size, uint32_t offset,
FTLOperation operation) {
uint32_t curr_virt_offset_begin = 0;
uint32_t curr_virt_off... |
0},
{ -848, 720, -264},
{ -928, 584, -48},
{ -904, 560, -24},
{ -1288, 720, -104},
{ -1336, 736, -80},
{ -1192, 616, 0},
{ -1160, 528, 8},
{ -920, 408, 56},
{ -624, 328, 64},
{ -472, 328, 24},
{ -440, 288, 40},
// 68 seconds
{ -400, 248, 72},
{ -432, 256, 40},
... | { 72, 720, -1008},
{ 160, 592, -824},
{ 280, 696, -736},
{ 328, 800, -680},
{ 368, 656, -648},
{ 328, 528, -576},
{ 336, 304, -576},
{ 328, 352, -528},
{ 304, 568, -624},
{ 288, 856, -656},
{ 328, 96, -616},
{ 400, 800, -728},
{ 368, 680, -592},
{ 480, 720, -584},... |
{ 376, 720, -512},
{ 344, 736, -512},
{ 368, 768, -472},
{ 328, 776, -520},
{ 296, 880, -464},
{ 352, 776, -296},
// 5 seconds
{ 288, 912, -440},
{ 232, 1024, -464},
{ 416, 584, 56},
{ 296, 936, -344},
{ 240, 664, -424},
{ 320, 640, -208},
{ 240, 976, -512},
... |
/*
* 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... | event_put(&e) | ;
}
break;
case PebbleTask_App:
if (!s_app_event_pending) {
e.callback.data = (void *)app_state_get_animation_state();
s_app_event_pending = process_manager_send_event_to_process(task, &e);
}
break;
default:
PBL_CROAK("Invalid task %s", pebble_task_get_name(pe... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_stored_keys, keys_in, sizeof(SM128BitKey) * SMRootKeyTypeNum) | ;
}
static uint32_t s_rng_output;
#define RNG_ROUNDS (sizeof(SM128BitKey) / sizeof(uint32_t))
#define RNG_MAX_RETRIES (20)
bool rng_rand(uint32_t *rand_out) {
bool rv = cl_mock_type(bool);
if (rv) {
*rand_out = s_rng_output;
++s_rng_output;
}
return rv;
}
int rand(void) {
return cl_mock_type(int);
... |
_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_assert(!ret);
}
void test_bluetooth_persistent_storage_prf__delete_bt_classic_pairing_by_addr(void) {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key... | (id_2 != BT_BONDING_ID_INVALID) | |
ep 27th 2014 14:00 UTC ~ Apr 4th 2015 14:00 UTC, GMT+12 */
[24]={ 1411826400, 1428156000,12 * SECONDS_PER_HOUR },
/* Namibia (Namibia) [Africa/Windhoek]
Rule Namibia 1994 max - Sep Sun>=1 2:00 1:00 S
Rule Namibia 1995 max - Apr Sun>=1 2:00 0 -
Sep 7th 2014 01:00 UTC ~ Ap... | for (int dstid = 0; dstid < DST_ID_COUNT; dstid++) {
TimezoneInfo tz_info = {
.dst_id = dstid,
.tm_gmtoff = s_dst_correct_values[dstid][2]
};
prv_update_dstrule_timestamps_by_dstzone_id(&tz_info, jan1st_noon_2015);
if (tz_info.dst_start != s_dst_correct_values[dstid][0]) {
printf("st... |
}
void test_clock__next_monday(void) {
struct tm jan_1 = {
.tm_sec = 0, // 0 seconds after the minute
.tm_min = 0, // 0 minutes after the hour
.tm_hour = 0, // 0 hours since midnight
.tm_mday = 1, // 1st day of the month
.tm_mon = 0, // January
.tm_year = 2014 - 1900,
.tm_isdst = 0,
};... |
---------------------
// Sample captured: 2015-10-16 12:36:34 local
AccelRawData *activity_sample_walk_100_pbl_28397_9(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_28397_9
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 80
//> TEST_EXPECTED_MAX 120
/... | { 1064, 104, -360},
{ 1304, 96, -368},
{ 1232, 136, -376},
{ 944, 216, -272},
{ 816, 232, -320},
// 5 seconds
{ 928, 280, -224},
{ 1192, 328, -280},
{ 1296, 384, -280},
{ 1264, 400, -328},
{ 1512, 704, -448},
{ 1056, 832, -472},
{ 936, 616, -472},
{ 1032, 608, -41... | |
leep_events = 0;
static void prv_fake_sleep_event_cb(PebbleEvent *event) {
if ((event->type == PEBBLE_HEALTH_SERVICE_EVENT)
&& (event->health_event.type == HealthEventSleepUpdate)) {
s_captured_sleep_event = *event;
s_num_captured_sleep_events++;
}
}
// ----------------------------------------------... | (event.health_event.type, HealthEventSignificantUpdate) | ;
}
// ---------------------------------------------------------------------------------------
// Test derived sleep metrics after the watch goes through a timezone change.
void test_activity__sleep_after_timezone_change(void) {
int32_t value;
// ------------------------------------------------------------------... |
g.background_color;
if (config.collapse_starting_animation) {
// Don't blank here because this intended to be an "in place" operation. The data the makes up
// the center of the collapse is only present in the system framebuffer at this point so we
// need to be careful not to wipe it all out.
// Dr... | {
PBL_IF_RECT_ELSE(prv_collapse_animation_update_rect,
prv_collapse_animation_update_round)(ctx, config, distance_normalized);
} |
static void prv_static_dot_transition_animation_update(
GContext *ctx, Animation *animation, uint32_t distance_normalized) {
DotTransitionAnimationConfiguration config = {
.data = animation_get_context(animation)
};
const uint32_t COLLAPSE_END_DISTANCE = 7 * (ANIMATION_NORMALIZED_MAX / 8);
const GRec... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return true;
} |
const TimelineEventImpl *timeline_peek_get_event_service(void) {
return NULL;
}
// Helpers
////////////////////////////////////////////////////////////////
static bool s_in_calendar_event = false;
static bool prv_get_calendar_ongoing(void) {
PebbleEvent event = fake_event_get_last();
if (event.type == PEBBLE_... |
/*
* 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... | (GColorFromHEX(0xff0000)) | .argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x00aaff)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0xaa0055)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x55aa55)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5555)).argb);
cl_assert_equa... |
/*
* 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... | {
int fd = prv_pmap_open_debug_wrapper(s_map_filename, OP_FLAG_READ, 0, 0);
if (fd < 0) {
PBL_LOG(LOG_LEVEL_WARNING, "pmap search (open) failed: %d", fd);
return (fd);
}
int seek_result = seek_map(fd, callback, data);
pfs_close(fd);
return (seek_result);
} |
static bool walk_max_used_id(PersistMapIdField *field, void *data) {
int *max_used_id = data;
if (field->id > *max_used_id) {
*max_used_id = field->id;
}
return false;
}
static int get_next_id() {
int max_used_id = -1;
search_map(walk_max_used_id, &max_used_id);
return (max_used_id + 1);
}
// grow... |
{ -1472, 264, 168},
{ -1464, 176, 200},
// 50 seconds
{ -1504, 152, 232},
{ -1376, 208, 192},
{ -1288, 288, 320},
{ -1336, 656, 328},
{ -968, 400, 288},
{ -864, 760, 392},
{ -408, 760, 304},
{ -72, 1024, 240},
{ -120, 856, 336},
{ -64, 784, 288},
{ 72, 672, 232},... | { -1344, 480, 128},
{ -1192, 336, 224},
{ -1232, 184, 296},
{ -1080, 168, 280},
{ -1232, 64, 360},
{ -1200, -256, 280},
{ -1176, -152, 120},
{ -1168, 64, -24},
{ -1104, 456, -288},
{ -1392, 344, -56},
{ -1496, 72, 152},
{ -1360, -96, 16},
{ -1464, 304, 240},
{ -10... |
{ -1104, 328, 280},
{ -720, 256, 192},
{ -488, 224, 88},
{ -512, 168, 72},
{ -728, 328, 64},
{ -920, 424, -24},
{ -920, 424, 0},
{ -1136, 376, -56},
{ -1344, 296, -88},
{ -1976, 416, -200},
{ -1368, 344, -168},
{ -1432, 176, -320},
{ -1464, 288, -64},
{ -1400, 96... |
/*
* 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_malloc_check(sizeof(ActivityMetricAverages)) | ;
strcpy(data->debug_card.dialog_text, "Hourly avgs:");
activity_get_step_averages(day, averages);
// Sum into hours
const int k_avgs_per_hour = ACTIVITY_NUM_METRIC_AVERAGES / HOURS_PER_DAY;
for (int i = 0; i < HOURS_PER_DAY; i++) {
int value = 0;
for (int j = i * k_avgs_per_hour; j < (i + 1) * k_avg... |
mation_interpolate.h"
#include "applib/graphics/gdraw_command_transforms.h"
#include "util.h"
#include "test_graphics.h"
#include "8bit/test_framebuffer.h"
#include "weather_app_resources.h"
// Stubs
////////////////////////////////////
#include "stubs_applib_resource.h"
#include "stubs_app_state.h"
#include "stubs_... | {
InterpolateInt64Function interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(181, 1, 1, 181, 0, 0, ANIMATION_NORMALIZED_MAX,
interp);
cl_assert_equal_i(y, 181 * 181);
} |
void test_gdraw_command_transforms__int_scale_to_scale_overflow_neg(void) {
InterpolateInt64Function interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(-181, 1, 1, 181, 0, 0, ANIMATION_NORMALIZED_MAX,
interp);
cl_assert_equal_i(y, -181 * 181);
}
vo... |
e_dotted(&ctx, GPoint(50, 90), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(46, 95), 5);
// T facing right - odd vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(71, 91), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(67, 96), 5);
// T facing left - even vert, even horiz
g... | ("draw_dotted_line_cross_color") | ));
}
static void draw_lines_same_point(GContext *ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_stroke_width(ctx, 1);
graphics_draw_line(ctx, GPoint(10,10), GPoint(10,10));
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, 1);
graphics_draw_lin... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i((timingr & 0xFF) + 1, expected_scl_low) | ;
cl_assert_equal_i(((timingr >> 8) & 0xFF) + 1, expected_scl_high);
cl_assert_equal_i(((timingr >> 20) & 0xF) + 1, expected_scl_delay);
}
void test_i2c_timingr__valid_no_prescaler_no_rise_fall_time(void) {
// We'll use a base clock speed of 36Mhz and try to get to 400kHz I2C. We should be able to do
// this w... |
/*
* 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_layer_destroy(time_layer);
text_layer_destroy(gmtime_layer);
text_layer_destroy(localtime_layer);
} |
static void init(void) {
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animated);
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
in... |
CT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NULL_H,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_null_h", fb, GColorWhite));
// Test n... | GRect(10, 10, 100, 30) | |
0},
{ 1080, 24, 64},
{ 1264, 72, 200},
{ 1592, 64, 264},
{ 1584, 136, 248},
{ 960, 224, 184},
{ 808, -56, 8},
{ 896, -544, -112},
{ 656, -256, 16},
{ 840, -256, 144},
{ 856, -72, 192},
{ 808, 0, 128},
{ 880, 24, 96},
{ 904, 56, 136},
{ 912, 120, 120},
{ 1016, ... | { 1008, 128, 88},
{ 1224, 232, -32},
{ 1304, 224, 0},
{ 1624, 440, -56},
{ 1288, 400, 8},
{ 864, 208, -32},
{ 1016, 168, -64},
{ 968, -48, 144},
{ 952, 104, 160},
{ 904, 144, 80},
{ 800, 152, -24},
{ 752, 80, 0},
{ 752, -104, 208},
{ 712, -16, 112},
{ 768, 16,... |
{ 768, -40, 168},
{ 992, 8, 144},
{ 1288, 144, 136},
{ 1496, 240, 136},
{ 1872, 312, 152},
{ 944, 920, -136},
{ 848, 120, 152},
{ 904, -88, 256},
{ 760, -312, 256},
{ 736, -264, 184},
{ 664, 32, 32},
{ 696, 144, 8},
{ 744, 144, -48},
{ 864, 256, -152},
{ 920,... |
/*
* 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... | ((uint8_t *)&hdr, UUID_SIZE) | , 0);
}
void test_notif_db__flush(void) {
SerializedTimelineItemHeader hdr1 = {
.common = {
.ancs_uid = 1,
.layout = 0,
.flags = 0,
.timestamp = 0,
},
};
uuid_generate(&hdr1.common.id);
SerializedTimelineItemHeader hdr2 = {
.common = {
.ancs_uid = 1,
.layout = 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... | rocky_runtime_context_init() | |
v_bytes_len -= 3;
}
ble_error_t rv = ble_gap_adv_mode_set(disc_mode);
if (rv != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "Error: ble_gap_adv_mode_set - rv: %d", rv);
// Not returning, probably better to try to advertise regardless of this error.
}
rv = ble_gap_adv_data_set(adv_bytes_len, adv_bytes,... | local_addr_handle_adverts_stopped() | ;
prv_lock();
{
// Make sure we never stay paused once local_addr has a chance to do whatever it needs to do
// while advertisements were paused.
if (s_adv_state == AdvertState_Paused) {
prv_resume_if_needed();
}
}
prv_unlock();
}
//! @note This is here exclusively for local_addr.c!
//! ... |
than the other bars
// Note that Thursday is the center bar, not Wednesday since drawing begins with Monday
// S M T W T F S
const int bar_widths[DAYS_PER_WEEK] = { w, w, w, w + 1, w + 1, w + 1, w };
const int bar_width = bar_widths[weekday];
#else
const... | prv_bar_should_be_wide(i, graph_card->current_day) | |
e_y_offset_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &outside_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("outside_ny_offset_layer", ctx.parent_framebuffer, GColorWhite));
test_graphics_co... | graphics_draw_pixel(ctx, GPoint(p.x + 4, p.y + 3)) | ;
graphics_draw_pixel(ctx, GPoint(p.x + 5, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 6, p.y + 3));
graphics_draw_pixel(ctx, GPoint(p.x + 7, p.y + 3));
}
// Draws two columns of colors (first 32 colors in first column, second 32 colors in second column)
// Offsets the two color columns based on input trans... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&s_task_timer_manager, timer_id) | ;
}
// ========================================================================================
// Service Implementation
static void new_timer_service_loop(void *data) {
task_init();
while (1) {
TickType_t ticks_to_wait = task_timer_manager_execute_expired_timers(&s_task_timer_manager);
xSemaphoreTake(... |
up = {
.num_actions = 0,
.actions = NULL,
},
.allocated_buffer = NULL,
}
};
static const int s_feb_5_midnight = 1423123200; // 2015 PST
static const int s_feb_5_midnight_utc = 1423094400; // 2015 UTC
// extra case -- one all day event, one event from 8:00 to 10:00, and one from 8:15-8:16
// ... | (state.node) | |
/*
* 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... | (layer, &frame) | ;
}
return layer;
}
void menu_layer_legacy2_set_callbacks(MenuLayer *menu_layer,
void *callback_context,
MenuLayerCallbacksLegacy2 callbacks) {
menu_layer_set_callbacks(menu_layer, callback_context, &(MenuLayerCallbacks) {
.get_n... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
crc = crc ^ *((uint32_t*)data);
for(int bit = 0; bit < 32; ++bit) {
if ((crc & 0x80000000) != 0) {
crc = (crc << 1) ^ CRC_POLY;
} else {
crc = (crc << 1);
}
}
data += 4;
} |
if (num_remainder_bytes) {
uint32_t last_word = 0;
for (unsigned int i = 0; i < num_remainder_bytes; ++i) {
last_word = (last_word << 8) | data[i];
}
return crc_update(crc, (uint8_t*)&last_word, 4);
}
return crc & 0xffffffff;
}
/*
* Data Logging Test App
*/
struct DataLoggingInfo {
... |
_BUILTIN_HRM
const bool use_hrm_payload = (cur_type == ReconnectType_BleHrm);
#else
const bool use_hrm_payload = false;
#endif
BLEAdData *ad;
if (use_hrm_payload) {
// Create adv payload with only flags + HR service UUID. This is enough for various mobile
// fitness apps to be able to recon... | (&s_is_hrm_reconnection_enabled, true) | ;
// Always restart the timer:
if (!regular_timer_is_scheduled(&s_hrm_reconnect_timer)) {
s_hrm_reconnect_timer = (RegularTimerInfo) {
.cb = prv_hrm_reconnect_timeout_timer_callback,
};
regular_timer_add_multisecond_callback(&s_hrm_reconnect_timer, RECONNECT_HRM_TIMEOUT_SECS);
}
... |
/*
* 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_iter) | );
cl_assert(!iter_next(&utf8_iter));
cl_assert(i == NUM_VALID_CODEPOINTS);
cl_assert(utf8_iter_state.current == utf8_bounds.end);
cl_assert(*utf8_iter_state.current == '\0');
cl_assert(utf8_iter_state.codepoint == 0);
}
void test_utf8_iterator__decode_valid_string_backwards(void) {
// Mutable types
Ite... |
/*
* 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, GColorBlack) | ;
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2, 12, 28, 20), 4);
}
void across_ny_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2... |
r_deinit(status_bar_layer);
applib_free(status_bar_layer);
}
void status_bar_layer_deinit(StatusBarLayer *status_bar_layer) {
layer_deinit(&status_bar_layer->layer);
if (status_bar_layer->title_timer_id != TIMER_INVALID_ID) {
app_timer_cancel(status_bar_layer->title_timer_id);
}
event_service_client_unsu... | {
PBL_ASSERTN(status_bar_layer);
return status_bar_layer->config.info_text_buffer;
} |
void status_bar_layer_reset_info(StatusBarLayer *status_bar_layer) {
PBL_ASSERTN(status_bar_layer);
memset(status_bar_layer->config.info_text_buffer, 0,
sizeof(status_bar_layer->config.info_text_buffer));
layer_mark_dirty(&status_bar_layer->layer);
}
void status_bar_layer_set_separator_mode(StatusBarL... |
;
prv_issue_command_argument(sector_addr, num_shorts - 1);
// We're now ready to write the words. Subsequent writes to the sector will
// actually write the data through to the write buffer.
__IO uint16_t *flash_write_dest = (__IO uint16_t*)
(FMC_BANK_1_BASE_ADDRESS + (start_addr & ~0x1));
uint32_t by... | {
// it's ok to access s_num_flash_uses here directly, as only caller enter_stop_mode() is called
// only while interrupts are disabled
prv_flash_idle_gpios(s_num_flash_uses > 0);
return S_SUCCESS;
} |
static void prv_switch_flash_mode(FMC_NORSRAMInitTypeDef *nor_init) {
FMC_NORSRAMCmd(FMC_Bank1_NORSRAM1, DISABLE);
FMC_NORSRAMInit(nor_init);
FMC_NORSRAMCmd(FMC_Bank1_NORSRAM1, ENABLE);
}
static uint16_t prv_get_num_wait_cycles(uint32_t flash_clock_freq) {
// wait_cycle table based on frequency (table 7.1)
... |
al_b(fake_gatt_is_service_discovery_running(), false);
}
void test_gatt_client_discovery__already_in_progress(void) {
BTDeviceInternal device = prv_connected_dummy_device(1);
// Start discovery for device:
cl_assert_equal_i(gatt_client_discovery_discover_all(&device), BTErrnoOK);
cl_assert_equal_b(fake_gatt_i... | fake_gatt_is_service_discovery_start_count() | );
// No client event:
prv_assert_no_event();
} else {
// Last iteration: expect event with error status and 0 services:
prv_assert_event(device, BTErrnoServiceDiscoveryTimeout);
}
}
}
void test_gatt_client_discovery__watchdog_error_out_after_max_retries(void) {
BTDeviceInternal dev... |
for error in transition to Suspend / Standby
if (mode == BMA255PowerMode_Suspend || mode == BMA255PowerMode_Standby) {
// Write to FIFO_CONFIG_1 to exit some unknown "intermittent state"
// NOTE: This will clear the FIFO & FIFO status.
bma255_read_modify_write(BMA255Register_FIFO_CONFIG_1, 0, 0);
... | accel_get_sampling_interval() | ;
}
static void prv_configure_operating_mode(void) {
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 ... |
em->data + sizeof(*company_id),
manufacturer_data_size,
cb_data);
}
return true; // continue parsing
}
// -----------------------------------------------------------------------------
//! @param ad_data The advertising data and scan respo... | (&ctx->uuids_out[ctx->copied++], uuid, sizeof(Uuid)) | ;
}
++ctx->total;
}
return false; // stop parsing, only one Services UUID element allowed by spec
}
uint8_t ble_ad_copy_service_uuids(const BLEAdData *ad,
Uuid *uuids_out,
uint8_t num_uuids) {
struct CopyServiceUUIDsCtx ctx = {
.uuid... |
const int16_t num_bytes = max_x - min_x + 1;
if (num_bytes > 0) {
memset(row_info.data + min_x, 0, num_bytes);
}
}
}
apng_fctl fctl = {0}; // Defaults work for IDAT frame without fctl data
// If this frame doesn't have fctl, use the full width & height
if (!upng_get_apng_fctl(upng, &f... | }
}
}
} | |
er_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Just before A completes
prv_advance_to_ms_with_timers(start_ms + duration_a - 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_co... | cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MIN) | ;
#endif
}
// --------------------------------------------------------------------------------------
// Test a sequence within a sequence where the imbedded one has a play count of 0
void test_animation__nested_sequence_with_0_play_count(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int d... |
ww.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions... | hton16(sizeof(PushPacket) + sizeof(s_message_header) +
s_message_length) | ;
unsigned char *app = transport->information;
memcpy(app, s_message_header, sizeof(s_message_header));
memcpy(&app[sizeof(s_message_header)], s_message_buffer,
s_message_length);
crc = crc32(CRC32_INIT, raw_packet, raw_length - sizeof(crc));
memcpy(&raw_packet[raw_length - sizeof(crc)], &crc, size... |
0},
{ 192, 808, 272},
{ 256, 912, 344},
{ 224, 960, 312},
{ 288, 800, 232},
{ 256, 768, 168},
{ 240, 720, -104},
{ 160, 1032, 120},
{ 72, 840, 320},
{ 200, 1160, 152},
{ -72, 1256, 656},
{ 248, 1272, -112},
// 27 seconds
{ 272, 704, -24},
{ 200, 632, 120},
{ 1... | { 232, 880, 224},
{ 272, 848, 240},
{ 320, 848, 344},
{ 256, 1096, 160},
{ 200, 1008, 312},
{ 112, 1104, 280},
{ 128, 1192, 256},
{ 56, 1144, 392},
{ 0, 1000, 80},
{ 24, 856, 72},
{ 8, 824, 184},
{ 80, 960, 112},
{ 160, 824, 88},
{ 192, 808, 80},
{ 200, 808, 5... | |
{ 1232, 816, -120},
{ 1320, 592, -248},
{ 1216, 416, -240},
{ 1144, 280, -248},
{ 1208, 128, -256},
{ 1408, 160, -216},
{ 1440, 40, -152},
{ 1248, 80, -152},
{ 1104, 72, -136},
{ 584, -280, 64},
{ 560, -200, 72},
{ 632, 168, -496},
{ 896, 8, -576},
{ 1584, -160, ... | { 1048, -40, -296},
{ 1384, 224, -280},
{ 1280, 200, -336},
{ 1144, 224, -280},
{ 1184, 336, -248},
{ 1416, 432, -184},
{ 1600, 664, -264},
{ 1528, 816, -296},
// 47 seconds
{ 1104, 896, -528},
{ 928, 1088, -544},
{ 1064, 1136, -488},
{ 1024, 920, -344},
{ 960, 72... |
{ 1480, 408, -128},
{ 1184, 200, -80},
{ 1072, 64, 16},
{ 1240, 176, -144},
{ 1376, 168, -48},
{ 1344, 200, -88},
{ 1136, 104, -200},
{ 864, -224, -120},
{ 576, -192, -152},
{ 896, -272, -144},
{ 1040, 0, -304},
{ 1376, 72, -304},
{ 1520, 240, -416},
{ 1312, 168,... |
test_num = (int32_t)((float)-0.250 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.integer == -1);
cl_assert(num.fraction == 6);
test_num = (int32_t)((float)-0.125 * (1 << FIXED_S16_3_PRECISION));
num = (Fixed_S16_3){ .raw_value = test_num };
cl_assert(num.inte... | (-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-4))) | ;
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-5)));
cl_assert_equal_i(-1, Fixed_S16_3_rounded_int(Fixed_S16_3(-8)));
cl_assert_equal_i(-2, Fixed_S16_3_rounded_int(Fixed_S16_3(-12)));
}
void test_math_fixed__S16_3_rounding(void) {
Fixed_S16_3 num;
int16_t test_num;
// This test shows how the... |
e StateRecording:
// do nothing
break;
case StateStopRecording:
prv_set_mic_window_state(data, StateWaitForResponse);
break;
case StateStopWaitForResponse:
prv_set_mic_window_state(data, StateTransitionToText);
break;
case StateTransitionToText: {
prv_set_mic_win... | if (next_state == StateWaitForResponse) {
return next_state;
} |
break;
case StateWaitForResponse:
if (next_state == StateTransitionToText) {
return StateStopWaitForResponse;
}
break;
case StateStopWaitForResponse:
if (next_state == StateTransitionToText) {
return next_state;
}
break;
case StateTransitionToTex... |
/*
* 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... | jerry_create_undefined() | ;
}
JERRY_FUNCTION(method_func_imp) {
++s_method_func_imp_call_count;
return jerry_create_undefined();
}
void test_rocky_api_util__rocky_add_constructor(void) {
static const RockyGlobalAPI *s_api[] = {
NULL,
};
rocky_global_init(s_api);
JS_VAR prototype = rocky_add_constructor("test", test_func_imp);... |
mory(JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH, 0, true);
jmem_pools_collect_empty();
}
static void prv_memorypressure_app_log(const char *level, const jmem_heap_stats_t *stats) {
APP_LOG(LOG_LEVEL_WARNING, "Memory pressure level: %s", level);
APP_LOG(LOG_LEVEL_WARNING,
"heap size: %zu, alloc'd: %zu, waste... | prv_allocate_headroom_or_die(ctx) | |
origin_layer.${BIT_DEPTH_NAME}.pbi"));
layer_set_update_proc(&layer, &white_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(framebuffer_is_empty("white_over_black", ctx.parent_framebuffer, GColorWhite));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &inside_layer_upda... | graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_NXNY) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_aa_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 5
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 5);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "... |
5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
// 165: Local time: 2016-05-19 11:50:00 PM
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141, 0},
{ 0, 0x5b, 0, 141... | { 0, 0x79, 0, 141, 0},
{ 0, 0x79, 0, 141, 0},
{ 0, 0x7a, 512, 141, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 0, 134, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 0, 141, 0},
{ 0, 0x6a, 244, 141, 0... |
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
{ 0, 0x6b, 0, 141, 0},
// 315: Local time: 2016-05-20 02:21:00 AM
{ 0, 0x6b, 1650, 141, 0},
... |
b,
0x16,
0x17,
0x01,
0x02,
0x03,
0x13,
0x27,
0x12,
0x23,
0x3b,
0x26,
0x37,
0x11,
0x22,
0x33,
0x32,
0x36,
0x21,
0x31,
};
typedef enum {
PROPERTY_FG_COLOR,
PROPERTY_BG_COLOR,
PROPERTY_ALPHA,
// Add more above here
PROPERTY_MAX,
PROPERTY_COLOR_TABLE, // Currently don't a... | GPoint(point.x, point.y + 1) | );
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
} else if (alpha == ALPHA_66) {
graphics_context_set_stroke_color(ctx, fg_color);
graphics_draw_pixel(ctx, point);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
graphics_context_set_stroke_color(ctx, bg_color);
graphi... |
{
if (region == MemoryRegionTag_Text && text_crc_matches) {
continue;
}
// Write out a chunk header
chunk_hdr.key = CORE_DUMP_CHUNK_KEY_MEMORY;
chunk_hdr.size = region_buf[region].length + sizeof(CoreDumpMemoryHeader);
if (flash_addr_max < (flash_addr + sizeof(chunk_hdr) + chunk_hdr.size)... |
// Read the Thread Info
chunk_hdr.key = CORE_DUMP_CHUNK_KEY_THREAD;
chunk_hdr.size = sizeof(CoreDumpThreadInfo);
if (flash_addr_max < (flash_addr + sizeof(chunk_hdr) + chunk_hdr.size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Insufficient space for BLE core dump -- TIB");
goto powerdown;
}
cmd.cmd = CoreDumpCm... | |
/*
* 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 10;
} |
static void prv_menu_draw_header_callback(GContext *ctx, const Layer *cell_layer,
uint16_t section_index, void *callback_context) {
menu_cell_basic_header_draw(ctx, cell_layer, section_names[section_index]);
}
static void prv_menu_draw_row_callback(GContext *ctx, const Layer *cell_layer,
MenuIndex *cell_in... |
points are from one another (>
// t), the less that errors due to noise, fixed point mathematics, & motion
// render bad solutions. (empirically, this seems to be the behavior as
// well). However, the greater the the threshold, the more orientations one
// must put their watch through in order to get solution sets
//
... | ABS(saved_solution[1] - solution[1]) | |
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 PLATFORM_SP... | (serial, ranges[i], strlen(ranges[i])) | == 0) {
return true;
}
}
return false;
}
static bool prv_is_potentially_misaligned_watch() {
return !prv_display_has_user_offset() &&
prv_is_known_misaligned_serial_number(mfg_get_serial_number());
}
void display_calibration_prompt_show_if_needed(void) {
if (!prv_is_potentially_misaligned_... |
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 "accessory_imaging.h"
#include "console/prompt.h"
#include "drivers/accessory.h"
#include ... | (s_timeout_timer, TIMEOUT_MS, prv_timeout_timer_cb, NULL, 0 /* flags */) | ;
PBL_LOG(LOG_LEVEL_DEBUG, "Starting accessory imaging");
}
static void prv_stop(void *context) {
if (s_no_buffer_count > 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Ran out of buffers %d times and dropped %d bytes while imaging",
s_no_buffer_count, s_dropped_char_count);
}
flash_prf_set_protection(true);
... |
i < s_data.num_sessions; i++) {
if (num_sessions_returned >= *session_entries) {
// No more room
break;
}
time_t session_end = s_data.activity_sessions[i].start_utc
+ s_data.activity_sessions[i].length_min * SECONDS_PER_MINUTE;
if (session_end >= sleep_earliest_end_utc... | {
fake_settings_file_reset();
} |
// ---------------------------------------------------------------------------------------
// Test that we correctly calculate the statistics (# days of history, median, etc)
void test_activity_insights__calculate_metric_history_stats(void) {
// Construct history
static const int32_t complete_history[ACTIVITY_HIS... |
_card.dialog_text),
"Error getting sleep sessions");
goto exit;
}
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Sleep sessions\n");
// Print info on each one
ActivitySession *session = sessions;
for (uint32_t i = 0; i < num_sessions; i++, session++) {... | safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text)) | ;
}
exit:
// Free session info memory
app_free(sessions);
prv_display_alert(data->debug_card.dialog_text);
}
// -----------------------------------------------------------------------------------------
static void prv_debug_cmd_weekday_averages(int index, void *context) {
ActivityDemoAppData *data = cont... |
,
src_ic.x - src->bounds.origin.x);
const int16_t max_height = MAX(src->bounds.origin.y + src->bounds.size.h - src_ic.y,
src_ic.y - src->bounds.origin.y);
const int32_t width = 2 * (max_width + 1); // Add one more pixel in case on the edge
... | (src_color, dst_color) | ;
break;
}
case GCompOpOr: {
const GColor dst_color = get_bitmap_color(dest_bitmap, x, y);
if (tint_color.a != 0) {
GColor actual_color = tint_color;
actual_color.a = src_color.a;
ctx->draw_state.stroke_color = gcolor_alpha_blend(actual_c... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR) | ;
current_value |= bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
void boot_bit_clear(BootBitValue bit) {
uint32_t current_value = RTC_ReadBackupRegister(RTC_BKP_BOOTBIT_DR);
current_value &= ~bit;
RTC_WriteBackupRegister(RTC_BKP_BOOTBIT_DR, current_value);
}
bool boot_bit_test(BootBitVa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.