prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, "Invalid Ping, l=%u", length) | ;
return;
}
// Ping message
uint32_t cookie = ntohl(ping->hdr.cookie);
PBL_LOG(LOG_LEVEL_DEBUG, "Ping c=%"PRIu32"", cookie);
launcher_task_add_callback(prv_push_window, NULL);
// Send the pong response
PongMsg pong = {
.hdr = {
.cmd = 1,
.cookie = htonl(cookie)
... |
uint32_t active_calories;
uint32_t distance_mm;
} KAlgTestActivityMinute;
#define MAX_CAPTURED_SESSIONS 32
KAlgTestActivitySession s_captured_activity_sessions[MAX_CAPTURED_SESSIONS];
int s_num_captured_activity_sessions;
void prv_activity_session_callback(void *context, KAlgActivityType activity_type,
... | prv_stats_reinit() | |
size(const AttributeList *attr_list) {
if (!attr_list) {
return 0;
}
size_t size = 0;
size += (attr_list->num_attributes * sizeof(SerializedAttributeHeader));
for (int i = 0; i < attr_list->num_attributes; i++) {
switch (prv_attribute_type(attr_list->attributes[i].id)) {
case AttributeTypeStr... | prv_attribute_type(src->id) | |
VENTED_TIMER_INVALID_ID;
if (!prv_set_state(data, TimelineAppStateHideDaySeparator)) {
return;
}
animation_unschedule(data->current_animation);
Animation *day_sep_hide = timeline_layer_create_day_sep_hide(&data->timeline_layer);
animation_set_handlers(day_sep_hide, (AnimationHandlers){
.stopped = pr... | animation_spawn_create(move_animation, day_sep_show, NULL) | ;
animation_set_handlers(move_animation, (AnimationHandlers) {
.stopped = prv_day_sep_show_stopped,
}, data);
} else {
animation_set_handlers(move_animation, (AnimationHandlers) {
.stopped = prv_up_down_stopped,
}, data);
}
data->current_animation = move_animation;
animation_schedul... |
.NumberOfDescriptors = 0x1,
.DescriptorList = &cccd2,
},
};
GATT_Service_Discovery_Indication_Data_t data = {
.ConnectionID = connection_id,
.ServiceInformation = {
.Service_Handle = RANDOM_S_START_ATT_HANDLE,
.End_Group_Handle = 0x9,
.UUID = {
.UUID_Type = guUUID_1... | {
return 3; // .Characteristic_Handle = 0x3,
} |
uint16_t fake_gatt_gatt_profile_service_service_changed_cccd_att_handle(void) {
return 5; // .Characteristic_Descriptor_Handle = 0x05,
}
|
tmap_pbi_eq(&ctx.dest_bitmap, "draw_text_jja00.${BIT_DEPTH_NAME}.pbi"));
// Test when clipping/drawing are at (2, 0) and text bounds is at (0, 0)
setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info,... | framebuffer_is_empty("draw_text_neg_w", fb, GColorWhite) | );
setup_test_aa_sw(&ctx, fb, RECT_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_NEG_H,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_neg_h"... |
pared(GContext *ctx, GBitmap *framebuffer,
GRect *clip_box, int16_t y,
Fixed_S16_3 x1, Fixed_S16_3 x2,
Fixed_S16_3 delta1, Fixed_S16_3 delta2,
... | {
// do nothing
} | else if (*prev_x > new_x) {
// move to left
src_x = new_x + current.size.w - 1;
dst_x1 = src_x + 1;
dst_x2 = DISP_COLS - 1;
} else if (*prev_x < new_x) {
src_x = new_x;
dst_x1 = 0;
dst_x2 = src_x - 1;
}
*prev_x = new_x;
if (dst_x1 > dst_x2) {
return;
}
GBitmap *fb = graph... |
IGHT)) / 2;
const GEdgeInsets menu_layer_frame_insets = GEdgeInsets(top_bottom_inset, 0);
menu_layer_frame = grect_inset(menu_layer_frame, menu_layer_frame_insets);
#endif
MenuLayer *menu_layer = &launcher_menu_layer->menu_layer;
menu_layer_init(menu_layer, &menu_layer_frame);
menu_layer_set_highlight_colors... | {
return;
} |
menu_layer_reload_data(&launcher_menu_layer->menu_layer);
}
void launcher_menu_layer_set_selection_state(LauncherMenuLayer *launcher_menu_layer,
const LauncherMenuLayerSelectionState *new_state) {
if (!launcher_menu_layer || !launcher_menu_layer->data_source || !new_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... | PBL_LOG(LOG_LEVEL_DEBUG, "SELECT clicked!") | ;
(void)data;
(void)recognizer;
}
#if 0
static void select_long_click_handler(ClickRecognizerRef recognizer, ScrollAppData *data) {
PBL_LOG(LOG_LEVEL_DEBUG, "SELECT long clicked!");
(void)data;
(void)recognizer;
}
#endif
static void click_config_provider(ScrollAppData *data) {
// The config that gets pass... |
idnight
// 1421136000 is midnight Jan 13, PST
cl_assert_equal_i(state.pin.header.timestamp, 1421136000);
// second all day event
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_all_day_items[1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
... | prv_insert_all_day_items() | ;
// 1421183640 is 13:14 on Jan 13, 2015
// after first timed event of the day but not all of them
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
142118... |
"var json_str = null;\n"
"_rocky.on('message', function(e) {\n"
" json_str = JSON.stringify(e.data);\n" // stringify again to make assert simple
" event = e;\n"
"});");
JS_VAR event_null = prv_js_global_get_value("event");
cl_assert_eq... | rocky_api_app_message_get_session_closed_object_queue_timer() | ;
cl_assert(t != EVENTED_TIMER_INVALID_ID);
cl_assert_equal_b(fake_app_timer_is_scheduled(t), true);
// Connect:
prv_simulate_transport_connection_event(true /* is_connected */);
prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_session();
// Timer for the 3rd should be cancelled now:
c... |
eRate_50_HZ;
} else if (BMI160SampleRate_100_HZ <= interval_us) {
sample_rate = BMI160SampleRate_100_HZ;
} else if (BMI160SampleRate_200_HZ <= interval_us) {
sample_rate = BMI160SampleRate_200_HZ;
} else if (BMI160SampleRate_400_HZ <= interval_us) {
sample_rate = BMI160SampleRate_400_HZ;
} else if (... | prv_drain_fifo() | ;
}
if (num_samples < 2) {
prv_write_reg(BMI160_REG_FIFO_CONFIG_1, 0); // power down the fifo
curr_fifo_num_samples_wm = 0;
} else {
curr_fifo_num_samples_wm = num_samples;
// Set the new fifo watermark
// TODO: I think we will want to try and make this a multiple of the frame size
uint8_... |
ers/rtc.h"
#include "font_resource_keys.auto.h"
#include "kernel/pbl_malloc.h"
#include "kernel/ui/kernel_ui.h"
#include "process_state/app_state/app_state.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/alarms/alarm.h"
#include "system/logging.h"
#include "system/... | PBL_IF_RECT_ELSE(&s_icon_config.node, &s_time_config.text.extent.node) | ,
&s_subtitle_config.text.extent.node,
};
static const LayoutNodeVerticalConfig s_vertical_config = {
.container.extent.node.type = LayoutNodeType_Vertical,
.container.num_nodes = ARRAY_LENGTH(s_vertical_config_nodes),
.container.nodes = (LayoutNodeConfig **)&s_vertical_config_nodes,
.container.... |
alid_test_codepoints[i];
cl_assert_equal_i(decoded_codepoint, actual_codepoint);
valid_test_string_utf8 = utf8_get_next(valid_test_string_utf8);
}
}
void test_utf8__decode_malformed_test_string(void) {
bool success = false;
utf8_get_bounds(&success, s_malformed_test_string);
cl_assert(!success);
utf... | utf8_get_size_truncate("Hello World! \xF0\x9F\x98\x84", 17) | |
r_buffer_read(buffer, client, num_bytes, &read_ptr, &chunk));
memcpy(data, read_ptr, chunk);
cl_assert(shared_circular_buffer_consume(buffer, client, chunk));
buffer += chunk;
num_bytes -= chunk;
}
}
void test_shared_circular_buffer__one_client(void) {
SharedCircularBuffer buffer;
uint8_t storag... | cl_assert(shared_circular_buffer_write(&buffer, (uint8_t*) "123456", 6, false)) | |
ANCSVersion_Unknown,
ANCSVersion_iOS9OrNewer,
} ANCSVersion;
typedef struct {
ListNode list_node;
NotificationQueueOp op;
uint32_t uid;
ActionId action_id; // Only valid if op == NotificationQueueOpPerformAction
ANCSProperty properties;
} NotificationQueueNode;
typedef struct ANCSClient {
ANCSClientSta... | list_prepend((ListNode *)s_ancs_client->queue,
(ListNode *)node) | ;
prv_do_notif_queue_operation();
} else {
list_append((ListNode *)s_ancs_client->queue,
(ListNode *)node);
}
}
static void prv_notif_queue_push_action(uint32_t uid, ActionId action_id) {
NotificationQueueNode *node = kernel_malloc_check(sizeof(NotificationQueueNode));
*node = (Notificat... |
te = SessionState_WaitForSessionResult;
prv_stop_recording();
prv_start_result_timeout();
unlock:
mutex_unlock(s_lock);
}
void voice_cancel_dictation(VoiceSessionId session_id) {
mutex_lock(s_lock);
if ((session_id != s_session_id) ||
(session_id == VOICE_SESSION_ID_INVALID)) {
goto unlock;
}
... | new_timer_stop(s_timeout) | ;
if (s_state != SessionState_WaitForSessionResult) {
// This handles erroneous replies from the phone app (sometimes the phone app sends a session
// result immediately after we start streaming
PBL_LOG(LOG_LEVEL_WARNING, "Session result when not expected (result: %d, "
"session_id: %d)", result,... |
/*
* 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... | {
hc_protocol_enqueue_with_payload(HcEndpointID_GapService, HcMessageID_GapService_SetName,
(const uint8_t *)name, strlen(name) + 1);
} |
void hc_endpoint_gap_service_device_name_request(const BTDeviceInternal *device) {
hc_protocol_enqueue_with_payload(HcEndpointID_GapService,
HcMessageID_GapService_DeviceNameRequest,
(const uint8_t *)device,
siz... |
nclude <mcu.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
//! The default baudrate for the accessory UART.
#define DEFAULT_BAUD AccessoryBaud115200
//! How long each interval should be in milliseconds.
#define ACCESSORY_STOP_INTERVAL_PERIOD_MS (250)
//! How many intervals we should wait outside of ... | (s_blocked_lock) | ;
}
static void prv_enable_dma(void) {
PBL_ASSERTN(!s_dma_enabled);
s_dma_enabled = true;
uart_start_rx_dma(ACCESSORY_UART, s_rx_buffer, sizeof(s_rx_buffer));
}
static void prv_disable_dma(void) {
if (!s_dma_enabled) {
return;
}
s_dma_enabled = false;
uart_stop_rx_dma(ACCESSORY_UART);
}
//! The int... |
/*
* 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... | {
fs_rm(fixture_path(_clar_path, "*"));
} | |
e "applib/ui/window.h"
#include "applib/ui/window_private.h"
#include "comm/ble/kernel_le_client/kernel_le_client.h"
#include "console/serial_console.h"
#include "console/prompt.h"
#include "drivers/backlight.h"
#include "drivers/battery.h"
#include "drivers/button.h"
#include "drivers/task_watchdog.h"
#include "kernel... | (launcher_force_quit_app, NULL) | ;
}
static void launcher_handle_button_event(PebbleEvent* e) {
ButtonId button_id = e->button.button_id;
const bool watchface_running = app_manager_is_watchface_running();
// trigger the backlight on any button down event
if (e->type == PEBBLE_BUTTON_DOWN_EVENT) {
analytics_inc(ANALYTICS_DEVICE_METRIC_BUT... |
ERY_FW))
#if USE_SMARTSTRAP
// Event handler
////////////////////////////////////////////////////////////////////////////////
static void prv_app_smartstrap_event(PebbleEvent *e, void *context) {
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
PebbleSmartstrapEvent event = e->smartstrap;
if... | sys_smartstrap_attribute_register(service_id, attribute_id, buffer, buffer_length) | ) {
applib_free(buffer);
return NULL;
}
SmartstrapConnectionState *state = app_state_get_smartstrap_state();
state->num_attributes++;
prv_state_init();
return (SmartstrapAttribute *)buffer;
#else
return NULL;
#endif
}
void app_smartstrap_attribute_destroy(SmartstrapAttribute *attr) {
#if USE_SMARTS... |
auto.h"
//! This symbol and its contents are provided by the linker script, see the
//! .note.gnu.build-id section in src/fw/stm32f2xx_flash_fw.ld
extern const ElfExternalNote TINTIN_BUILD_ID;
const FirmwareMetadata TINTIN_METADATA SECTION(".pbl_fw_version") = {
.version_timestamp = GIT_TIMESTAMP,
.version_tag = ... | {
*major = GIT_MAJOR_VERSION;
*minor = GIT_MINOR_VERSION;
*patch_ptr = GIT_PATCH_VERBOSE_STRING;
} | |
f it's children, and if so advance it
if (!top_level_animation || animation == top_level_animation
|| prv_is_descendent_of(state, animation, top_level_animation)) {
ANIMATION_LOG_DEBUG("advancing animation %d to %"PRIu32" ms", (int)animation->handle,
now - top_level... | {
for (uint32_t i = 0; i < array_len; i++) {
if (!used_children[i]) {
continue;
}
// Undo setting of the parent and child_idx on the components we modified.
AnimationPrivate *component = prv_find_animation_by_handle(state, animation_array[i],
... |
return parent_h;
}
// -------------------------------------------------------------------------------------------
static Animation *prv_complex_create(Animation **animation_array, uint32_t array_len,
AnimationType type) {
if (array_len > ANIMATION_MAX_CHILDREN) {
// Exce... |
/*
* 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... | memset(buf, 'X', sizeof(buf)) | ;
buf[41] = '\0';
app_file_name_make(buf, sizeof(buf), app_id, suffix, strlen(suffix));
assert_file_name(buf, app_id, suffix);
}
void test_app_file__name_make_simple_1(void) {
assert_app_file_name_make(1, "app");
}
void test_app_file__name_make_simple_2(void) {
assert_app_file_name_make(7, "app_app");
}
vo... |
icensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed unde... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_y_origin_layer.${BIT_DEPTH_NAME}.pbi")) | ;
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_circle_across_ny_origin_layer.${BIT_DEPTH_NAME}.pbi"));
}
#define RADIUS_BIG 15
#define RADIUS_MEDIUM 8
#define RADIUS_MIN_... |
nclude "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_prompt.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
// Fakes
#include "fake_accel_service.h"
#include "fake_new_timer.h"
#include "fake_rtc.h"
#include "fake_spi_flash.h"
#include "fake_system_task.h"
#define ASSERT_EQUAL_I(i1,i2,file,... | (s_dls_records) | );
s_dls_records[s_num_dls_records++] = records[i];
}
return DATA_LOGGING_SUCCESS;
}
DataLoggingSession *dls_create(uint32_t tag, DataLoggingItemType item_type, uint16_t item_size,
bool buffered, bool resume, const Uuid *uuid) {
s_dls_created = true;
cl_assert_equal_i(item_s... |
prv_handle_call_end(true /* Treat this as a disconnection */);
} else {
PBL_LOG(LOG_LEVEL_INFO, "Phone call watchdog timer started");
pp_get_phone_state_set_enabled(true);
}
} else {
PBL_LOG(LOG_LEVEL_INFO, "Not starting phone call watchdog, this isn't iOS 8: %d",
s_call_source);
... | prv_call_end_common() | ;
phone_ui_handle_call_hide();
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System);
}
static void prv_handle_call_end(bool disconnected) {
if (!disconnected) {
analytics_inc(ANALYTICS_DEVICE_METRIC_PHONE_CALL_END_COUNT, AnalyticsClient_System);
}
if (s_call_in_progress) {... |
on. Creating it if not already created
static DataLoggingSession *prv_get_dls_session(void) {
if (s_plog_state.dls_session == NULL) {
const bool buffered = true;
const bool resume = false;
Uuid system_uuid = UUID_SYSTEM;
s_plog_state.dls_session = dls_create(DlsSystemTagProtobufLogSession,
... | {
case ProtobufLogType_Events:
pb_write(stream, ms_encoder_arg.buffer, ms_encoder_arg.len);
break;
case ProtobufLogType_Measurements:
payload.measurement_sets = (pb_callback_t) {
.funcs.encode = protobuf_log_util_encode_buffer,
.arg = &ms_encoder_arg,
};
break;
} |
bool success = pb_encode(stream, pebble_pipeline_Payload_fields, &payload);
if (!success) {
PBL_LOG(LOG_LEVEL_ERROR, "Error encoding payload");
}
// PBL-43622: Will revert later
PBL_LOG(LOG_LEVEL_INFO, "Logged protobuf payload type: %d, utc:%"PRIu32, config->type,
payload.send_time_utc);
re... |
Point(45, 10));
#if PBL_COLOR
ASSERT_CALLED(graphics_line_draw_1px_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#else
ASSERT_CALLED(graphics_line_draw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10)));
#endif
setup_test(&context, true, 1, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(... | (&context, false, SW_ODD, GColorBlack, GColorBlack, false) | ;
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_re... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (sizeof(DiscoveryJobQueue)) | |
/*
* 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... | (health_app_data->health_card_view) | |
eset_request(s_characteristics[0][PPoGATTCharacteristicData]);
fake_gatt_client_op_assert_no_write();
}
void test_ppogatt__ignore_server_reset_request_while_resetting_due_to_own_reset_request(void) {
prv_notify_services_discovered(1);
ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristi... | cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true) | ;
cl_assert_equal_i(fake_comm_session_close_call_count(), 0);
}
void test_ppogatt__ignore_data_during_reset(void) {
prv_notify_services_discovered(1);
ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_system,
... |
) / 2);
x2_fixed.integer -= gradient_width;
const int16_t clip_box_min_x = ctx->draw_state.clip_box.origin.x;
const int16_t clip_box_max_x = (int16_t)(grect_get_max_x(&ctx->draw_state.clip_box) - 1);
prv_assign_horizontal_line_delta_raw(ctx, y, x1_fixed, x2_fixed, gradient_width, gradient_width,
... | cl_assert(opaque_mask) | |
.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" ... | (window, &(WindowHandlers) {
.load = prv_window_load,
}) | ;
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(void) {
struct AppState* data = app_malloc_check(sizeof(struct AppState));
app_state_set_user_data(data);
push_window(data);
}
static void handle_deinit(void) {
struc... |
*)pattern_attribute->data;
}
static unsigned int prv_vibe_score_get_num_note_types(GenericAttribute *notes_attribute) {
return notes_attribute->length / sizeof(VibeNote);
}
static unsigned int prv_vibe_score_get_pattern_length(GenericAttribute *pattern_attribute) {
return pattern_attribute->length / sizeof(VibeN... | {
uint32_t data_size;
if (!prv_vibe_score_resource_is_valid(app_num, resource_id, VIBE_SIGNATURE, &data_size)) {
return NULL;
}
VibeScore *vibe_score = applib_zalloc(data_size);
if (!vibe_score || sys_resource_load_range(app_num, resource_id, VIBE_DATA_OFFSET,
... |
unsigned int vibe_score_get_duration_ms(VibeScore *score) {
if (!score) {
return 0;
}
GenericAttribute *notes_attribute = generic_attribute_find_attribute(&score->attr_list,
VibeAttributeId_Notes,
... |
mples_per_step = num_samples / num_steps;
}
int need_step_ctr = samples_per_step;
time_t utc_secs;
uint16_t ms;
rtc_get_time_ms(&utc_secs, &ms);
uint64_t start_ms = utc_secs * 1000 + ms;
uint64_t ms_per_sample = 1000 / ALGORITHM_SAMPLING_RATE;
for (int i = 0; i < num_samples; ) {
AccelData accel_d... | ACTIVITY_RAW_SAMPLE_GET_Z(encoded) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | APP_LOG(APP_LOG_LEVEL_ERROR, "Invalid timer %u used in app_timer_reschedule", (unsigned)timer) | ;
syscall_failed();
}
}
return evented_timer_get_data((EventedTimerID)timer);
}
|
/*
* 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 *src = (uint8_t *)p;
for (uint32_t i=0; i<size; i++) {
qemu_test_add_byte_from_isr(&s_state, *src++);
}
} | |
/*
* 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 (to_frame) {
animation->values.to.grect = *to_frame;
} |
return (PropertyAnimation *)animation;
}
|
nth = CRON_MONTH_ANY,
.may_be_instant = true,
.clock_change_tolerance = 0,
};
CronJob *job = &test_cron;
time_t base = s_2015_nov12_123456_gmt;
prv_set_rtc(base, &s_timezone_gmt);
// 2015 Nov 12, 12:45:00
int32_t target = 1447332300;
cron_clear_all_jobs();
cl_assert_equal_i(cron_service_get_j... | cron_service_wakeup() | ;
cl_assert_equal_i((uintptr_t)job->cb_data, 0);
cl_assert_equal_i(job->cached_execute_time, base + offset);
cl_assert_equal_i(cron_service_get_job_count(), 1);
fake_rtc_increment_time(1);
} else {
fake_rtc_increment_time(increment);
}
cron_service_wakeup();
cl_assert_equal_i((uintptr_t)job... |
text_box_params,
Line* line, GRect cursor, const Codepoint codepoint) {
(void) ctx;
PBL_ASSERT(cursor.origin.x >= line->origin.x, "Text cursor x=<%u> ahead of line origin x=<%u>",
cursor.origin.x, line->origin.x);
const int glyph_width_px = prv_codepoint_get_horizont... | if (last_visited_char) {
while ((current_codepoint == NEWLINE_CODEPOINT || current_codepoint == SPACE_CODEPOINT)) {
// Newlines should not adjust the width
if (current_codepoint == NEWLINE_CODEPOINT) {
next_glyph_width_px = 0;
} else {
next_glyph_width_px = prv_codepoint_get_horizo... | |
/*
* 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_draw_rect(ctx, &GRect(4, -5, 18, 10));
}
void test_graphics_draw_rect_${BIT_DEPTH_NAME}__origin_layer(void) {
GContext ctx;
Layer layer;
test_graphics_context_init(&ctx, fb);
layer_init(&layer, &GRect(0, 0, 20, 10));
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tr... |
24, 720, -400},
{ 1064, 688, -392},
{ 1272, 600, -304},
{ 1160, 416, -232},
{ 1032, 344, -192},
{ 1120, 160, -168},
{ 1168, 424, -176},
{ 1352, 352, -208},
{ 1352, 272, -104},
{ 1288, 376, -136},
{ 872, 520, -200},
// 5 seconds
{ 816, 824, -72},
{ 192, 656, -96},
... | { 2016, 432, -384},
{ 2384, 576, -424},
{ 1416, 640, -256},
{ 1136, 368, -200},
{ 1440, 456, -248},
{ 1056, 744, 0},
{ 864, 680, -88},
{ 976, 848, -216},
{ 1048, 1072, -256},
{ 872, 968, -344},
{ 896, 1008, -344},
{ 880, 648, -288},
{ 1176, 528, -336},
{ 1784, 520... |
{ 1720, 464, -64},
{ 1736, 72, -216},
{ 896, -488, 160},
{ 288, -432, -8},
{ 600, -88, -352},
{ 752, -48, -568},
{ 1024, -432, -96},
{ 1368, 344, -568},
// 13 seconds
{ 1184, 240, -544},
{ 1088, 168, -128},
{ 1360, 528, -384},
{ 1472, 656, -384},
{ 1336, 656, -44... |
oid test_rocky_api_graphics__canvas_offers_size(void) {
rocky_global_init(s_graphics_api);
Layer l = {.bounds = GRect(1, 2, 3, 4)};
const jerry_value_t ctx = prv_create_canvas_context_2d_for_layer(&l);
jerry_set_object_field(jerry_get_global_object(), "ctx", ctx);
EXECUTE_SCRIPT(
"var w = ctx.canvas.cli... | (30*8, lc->fill_radial_precise.radius_outer.raw_value) | ;
}
void test_rocky_api_graphics__fill_radial_not_enough_args(void) {
prv_global_init_and_set_ctx();
EXECUTE_SCRIPT_EXPECT_ERROR(
"ctx.rockyFillRadial(30, 40, 10, 20, 0);\n",
"TypeError: Not enough arguments"
);
}
void test_rocky_api_graphics__fill_radial_type_error(void) {
prv_global_init_and_set_... |
rtc_get_time();
AttributeList list = {};
attribute_list_add_uint32(&list, AttributeIdIconPin, TIMELINE_RESOURCE_RUN);
attribute_list_add_uint32(&list, AttributeIdIconTiny, TIMELINE_RESOURCE_PACE);
attribute_list_add_uint8(&list, AttributeIdHealthInsightType,
ActivityInsightType_Acti... | (2 * 24 * 60 * 60) | |
/*
* 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... | delegate_errors(s, DICT_OK, reason) | ;
}
static void in_dropped_callback(AppMessageResult reason, void *context) {
AppSync *s = context;
delegate_errors(s, DICT_OK, reason);
}
// FIXME PBL-1709: this should return an AppMessageResult ...
void app_sync_init(AppSync *s,
uint8_t *buffer, const uint16_t buffer_size,
... |
AME_BUFFER_SIZE];
uint8_t platform_bits_out;
// Store a new pairing
BTDeviceAddress addr_in = {{0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKey link_key_in = {{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}};
char name_in[BT_DEV... | bt_persistent_storage_get_active_gateway(&id_out, &type_out) | ;
cl_assert(ret);
cl_assert_equal_i(id_out, id_2);
cl_assert_equal_i(type_out, BtPersistBondingTypeBTClassic);
ret = bt_persistent_storage_has_active_bt_classic_gateway_bonding();
cl_assert(ret);
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Delete the pairing.
bt... |
ng = (BleBonding){};
bt_persistent_storage_assign_sm_pairing_info(&bonding->pairing_info,
&stored_data->ble_data.pairing_info);
bonding->is_gateway = stored_data->ble_data.is_gateway;
}
static void prv_remove_ble_bonding_from_bt_driver(const BtPersistBondingData *dele... | (itr_data->name_out, stored_data.ble_data.name, BT_DEVICE_NAME_BUFFER_SIZE) | ;
itr_data->found = true;
return false; // stop iterating
}
return true; // continue iterating
}
bool bt_persistent_storage_get_ble_pairing_by_addr(const BTDeviceInternal *device,
SMIdentityResolvingKey *irk_out,
... |
ger(GOLF_CMD_KEY, cmd);
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
if (iter == NULL)
return;
dict_write_tuplet(iter, &value);
dict_write_end(iter);
app_message_outbox_send();
}
static void up_click_handler(ClickRecognizerRef recognizer, AppData *data) {
send_golf_cmd(CMD_PREV);
}
... | layer_add_child(window_layer, background) | ;
// Set up the action bar.
data->action_bar = action_bar_layer_create();
action_bar_layer_set_context(data->action_bar, data);
action_bar_layer_set_icon(data->action_bar, BUTTON_ID_UP, data->up_bitmap);
action_bar_layer_set_icon(data->action_bar, BUTTON_ID_SELECT, data->click_bitmap);
action_bar_layer_set... |
*layer, GContext *ctx) {
Window *window = layer_get_window(layer);
AppData *data = window_get_user_data(window);
if (data->rendered_frames == 0) {
data->time_started = prv_time_64();
__profiler_init();
__profiler_start();
}
data->rendered_frames++;
}
void prv_syncing_selection_changed(MenuLayer *... | prv_deinit(data) | ;
}
|
/*
* 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... | (dev, dev->state->part->instructions.write_enable) | |
/*
* 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... | (button_id) | ) {
button_counter[button_id] = 0;
continue;
}
if (button_counter[button_id] >= STUCK_BUTTON_THRESHOLD) {
dbgserial_putstr("Stuck button register is invalid, clearing.");
char buffer[32];
itoa(button_counter_register, buffer, sizeof(buffer));
dbgserial_putstr(buffer);
... |
},
{ -88, -240, -944},
{ -104, -240, -968},
{ -96, -232, -992},
{ -112, -240, -1008},
{ -128, -256, -1016},
{ -136, -272, -1016},
{ -144, -304, -1016},
{ -136, -344, -1008},
{ -136, -368, -1000},
{ -104, -376, -1048},
{ -152, -312, -1072},
// 55 seconds
{ -136, -296, ... | { 1456, 616, -128},
{ 1280, 448, -152},
{ 1296, 360, -200},
{ 1440, 296, -192},
// 60 seconds
// elapsed: 1 minutes
{ 1592, 304, -200},
{ 1520, 256, -232},
{ 1568, 184, -256},
{ 960, -520, 32},
{ 728, -424, -224},
{ 824, -368, -104},
{ 1072, 8, -312},
{ 1384, 200,... |
{ 1200, 832, -32},
{ 896, 1080, -128},
{ 936, 1144, -40},
{ 896, 800, -96},
{ 600, 712, -176},
{ 1000, 648, -200},
{ 1264, 576, -216},
{ 1288, 440, -232},
{ 1232, 400, -232},
{ 1296, 248, -176},
{ 1416, 328, -200},
{ 1464, 168, -200},
{ 1272, 200, -200},
{ 1312, ... |
(SECOND_UNIT, prv_handle_second_tick) | ;
app_window_stack_push(window, true /* Animated */);
}
static void s_main(void) {
app_init();
app_event_loop();
}
const PebbleProcessMd* mfg_runin_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
// UUID: fbb6d0e6-2d7d-40bc-8b01-f2f8beb9c394
.c... | |
n animation_legacy2_get_custom_curve((AnimationLegacy2 *)animation_h);
}
AnimationPrivate *animation = prv_find_animation_by_handle(NULL, animation_h, false /*quiet*/);
if (!animation) {
return NULL;
}
return (animation->curve == curve) ? animation->custom_function : NULL;
}
// ------------------------... | prv_animation_state_get(PebbleTask_Current) | ;
PBL_ASSERTN(!animation_private_using_legacy_2(state));
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!animation) {
return false;
}
if (animation->play_count == ANIMATION_PLAY_COUNT_INFINITE_STORED) {
return ANIMATION_PLAY_COUNT_INFINITE;
} el... |
tf("%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
pfs_for... | cl_assert(fd >= 0) | |
t) {
return debug_db_get_logs_base_address(generation) + (chunk * CHUNK_SIZE_BYTES) + offset;
}
//! Get next 8 bit value, avoiding 0xff (all bits set)
static uint8_t get_next_chunk_id(uint8_t chunk_id) {
return (chunk_id + 1) % (1 << (CHUNK_ID_BIT_WIDTH));
}
static void format_current_chunk(void) {
uint32_t add... | if (!debug_db_is_generation_valid(generation)) {
completed_cb(false);
return (false);
} |
int lowest_chunk_index = 0;
uint8_t lowest_chunk_id = 0;
int num_valid_chunks = 0;
for (int i = 0; i < NUM_CHUNKS; ++i) {
LogChunkHeader chunk_header;
flash_read_bytes((uint8_t*) &chunk_header, get_generation_address(generation, i, 0), sizeof(chunk_header));
if (chunk_header.invalid || !chunk_he... |
d) {
// Stroke width odd > 1, non-antialiased
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10));
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_ODD));
setup_test(&context, false, SW_ODD,... | (&context, GPoint(5, 5), GPoint(45, 10), SW_ODD) | );
#else
ASSERT_CALLED(graphics_line_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_ODD));
#endif
setup_test(&context, true, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
#if PBL_COLOR
ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, ... |
auto_reset;
}
bool circular_buffer_write(CircularBuffer* buffer, const void* data, uint16_t length) {
if (get_write_length_available(buffer) < length) {
return false;
}
// Now we know the message will fit, so no more checking against buffer_read_index required.
uint16_t write_index = get_write_index(buff... | if (should_malloc_and_copy) {
*data_out = (uint8_t *) malloc_imp(length);
if (*data_out) {
circular_buffer_copy(buffer, *data_out, length);
} else {
*caller_should_free = false;
return false;
}
} else {
uint16_t length_out;
circular_buffer_read(buffer, length, (const uint8_t ... |
return true;
}
bool circular_buffer_consume(CircularBuffer* buffer, uint16_t length) {
if (buffer->data_length < length) {
return false;
}
buffer->read_index = (buffer->read_index + length) % buffer->buffer_size;
buffer->data_length -= length;
// Reset read_index if there's no more data, so any newl... |
n active
cl_assert_equal_b(s_app_idle, false);
// Assert that the window pushed onto the app stack has lost focus
// We do this by checking the last event, which should have been a focus
// lost event.
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_APP_WILL_CHANGE_FOCUS_EVE... | (window_stack_count(app_stack), 0) | ;
window_destroy(window1);
window_destroy(window2);
}
// Description:
// This test ensures that the flow of adding a window to the window stack is followed
// correctly. That is, we add the window to the window stack, its load handler is
// called, it calls to set the click config, and the click config is set pr... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&state->isr_buffer,
&state->isr_buffer_client) | ;
QEMU_LOG_DEBUG("prv_assemble_packet, state:%d, bytes:%d", state->recv_state,
bytes_avail);
// Log message if we detected any receive errors
if (state->recv_error_count) {
PBL_LOG(LOG_LEVEL_ERROR, "%"PRIu32" receive errors detected", state->recv_error_count);
state->recv_error_count = 0;
}... |
f TEST_INCLUDE_BASIC
const int duration_a = 300;
Animation *a = prv_create_test_animation();
animation_set_play_count(a, 0);
animation_set_duration(a, duration_a);
prv_clear_handler_histories();
animation_schedule(a);
uint64_t start_ms = prv_now_ms();
prv_advance_to_ms_with_timers(start_ms + duratio... | prv_count_handler_entries(&s_started_handler_calls, b) | , 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, ... |
ve day! Activity "
"makes you more focused and creative. How do you feel?"),
.text_positive_action = i18n_noop("I feel great!"),
.text_neutral_action = i18n_noop("About the same"),
.text_negative_action = i18n_noop("Not feeling it"),
.text_positive_response = i18n_noop("Awesome!"),
.t... | {
return NULL;
} |
}
// ------------------------------------------------------------------------------------------------
// Helper functions for saving insight state to settings file
static bool prv_restore_state(SettingsFile *file, ActivitySettingsKey key, void *val_out,
size_t val_out_len) {
return set... |
// Write default data pattern to address
status = prv_write_read_verify_byte(test_addr, data_pattern, data_pattern, display_logs);
VERIFY_TEST_STATUS(status);
}
}
if (!skip_base_addr) {
test_addr = base_addr;
// Read initial value
read_buffer = 0;
flash_read_bytes((uint8_t*) &r... | flash_erase_sector_blocking(special_case_addr) | ;
// Verify erase took place
status = prv_read_verify_byte(test_addr, 0xFF, FLASH_TEST_ERR_ERASE, 0, true);
VERIFY_TEST_STATUS(status);
// Verify erase took place
status = prv_read_verify_byte(special_case_addr, 0xFF, FLASH_TEST_ERR_ERASE, 0, true);
VERIFY_TEST_STATUS(status);
// Write test pattern to ... |
_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// All recognizers receive events while none hav... | (recognizers[2]->state, RecognizerState_Possible) | ;
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// Layer A recognizer's gesture does not complete because there is no active layer until a
// touchdown occurs
e.type = TouchEvent_PositionUpdate;
s_next_state = Recogni... |
sage_handler(const uint8_t *data, size_t length,
AppInboxConsumerInfo *consumer_info) {}
void test_alt_dropped_handler(uint32_t num_dropped_messages) {}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
static CommSession *s_ses... | cl_assert(r != NULL) | |
ation, mode_change, NULL);
}
static void prv_draw_round_flip(GContext *ctx, const GRect *layer_bounds, const int sidebar_x) {
// Use a radius larger than the screen's radius so we don't see the top/bottom of the circle
int16_t circle_radius = DISP_COLS * 3 / 4;
const int16_t flip_overlap_region_width = layer_bou... | PBL_IF_RECT_ELSE(timeline_layer->sidebar_color, GColorWhite) | ;
graphics_context_set_fill_color(ctx, arrow_fill_color);
gpath_draw_filled(ctx, &arrow_path);
graphics_context_set_antialiased(ctx, false);
}
/////////////////////////////////////////
// Public functions
/////////////////////////////////////////
// when we create a new next or previous item, we want it out of ... |
pp_state.h"
#include "stubs_heap.h"
#include "stubs_resources.h"
#include "stubs_syscalls.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_logging.h"
// Tests
////////////////////////////////////
// Reference PNGs reside in "tests/fw/graphics/test_images/"
// and are created at build time, ... | gbitmap_get_format(bitmap) | |
/////////////////////////////////////////////////////////////////////
// app_inbox_service_write / app_inbox_service_end
static const uint8_t s_test_data[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09,
0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19
};
static... | app_inbox_service_write(AppInboxServiceTagUnitTest, s_test_data, 1) | );
cl_assert_equal_b(true, app_inbox_service_end(AppInboxServiceTagUnitTest));
// No space:
cl_assert_equal_b(false, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE + 1, s_writer));
// Shouldn't call ..._end() here because ..._begin() failed.
... |
_init_time_tm);
fake_kernel_services_notifications_reset();
s_activation_time = 0;
s_health_app_opened_version = 0;
s_data = (StaticData) {};
}
// ---------------------------------------------------------------------------------------
void test_activity_insights__cleanup(void) {
fake_settings_file_reset();... | for (int i = 0; i < 100; ++i) {
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_MINUTE);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 0);
} |
// // These tests only make sense if the insights are enabled
// // Now we shouldn't see another notification for the next 6 days
// for (int i = 0; i < 6; ++i) {
// rtc_set_time(rtc_get_time() + SECONDS_PER_DAY);
// activity_insights_recalculate_stats();
// activity_insights_process_sleep_data(rtc_get_ti... |
init_struct.I2C_ClockSpeed = BOARD_CONFIG.i2c_bus_configs[bus_idx].clock_speed;
i2c_init_struct.I2C_Ack = I2C_Ack_Enable;
I2C_Init(i2c_buses[bus_idx].i2c, &i2c_init_struct);
I2C_Cmd(i2c_buses[bus_idx].i2c, ENABLE);
}
//! Configure the bus pins, enable the peripheral clock and initialize the I2C peripheral.
//! ... | bus_disable(bus_idx) | |
annelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
// Setup timer 3 for periodic interrupts at TIMER_INTERRUPT_HZ
TIM_TimeBaseInitTypeDef tim_config;
TIM_TimeBaseStructInit(&tim_config);
tim_config.TIM_Prescaler = timer_find_prescaler(&BOARD_BT_WATCHDOG_T... | prv_lock() | |
l_free(*buffer);
*buffer = NULL;
}
}
void event_put(PebbleEvent* event) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
// If we are posting from the KernelMain task, use the dedicated s_from_kernel_event_queue queue for that
// See comments above where s_from_kernel_event_queue is declared... | {
return (void **)&event->bluetooth.pair.confirmation_info;
} | |
h, and modify from there.
We iterate over the fields from most significant to least significant. The reasoning for this is
that we will only know how to properly adjust a less significant field based on the value of the
more significant fields.
When a field in the spec is marked as ANY (-1), we need to decide what to... | (job, local_epoch) | ;
if (job->offset_seconds != 0) {
time_t t_last = t;
time_t offset_epoch = local_epoch;
while (true) {
const time_t t_delta = (t - local_epoch) * ((job->offset_seconds > 0) ? 1 : -1);
if ((job->may_be_instant ? (t_delta <= 0) : (t_delta < 0))) {
break;
}
// Offset seconds ... |
poll_remote_init() | ;
accel_manager_init();
light_init();
cron_service_init();
shared_prf_storage_init();
bt_persistent_storage_init();
comm_default_kernel_sender_init();
comm_session_app_session_capabilities_init();
comm_session_init();
bt_ctl_init();
#if CAPABILITY_HAS_TOUCHSCREEN
touch_init();
#endif
#if CAPAB... | |
switch (this->state->link_state) {
case LinkState_Closed:
case LinkState_Stopped:
prv_send_terminate_ack(this, -1);
break;
case LinkState_Closing:
case LinkState_Stopping:
// Do nothing
break;
case LinkState_RequestSent:
this->state->restart_count = MAX_CONFIGURE;
... | if (this->state->link_state == LinkState_Starting) {
this->state->restart_count = MAX_CONFIGURE;
prv_send_configure_request(this);
prv_transition_to(this, LinkState_RequestSent);
} |
mutex_unlock(this->state->lock);
}
void ppp_control_protocol_lower_layer_is_down(PPPControlProtocol *this) {
mutex_lock(this->state->lock);
switch (this->state->link_state) {
case LinkState_Closed:
case LinkState_Closing:
prv_transition_to(this, LinkState_Initial);
break;
case LinkState_... |
peSessionResult;
prv_send_event(event_type, VoiceStatusErrorGeneric, NULL);
return false;
}
if (s_session_id != session_id) {
PBL_LOG(LOG_LEVEL_WARNING, "Received session result for wrong session (Expected: "
"%"PRIu16"; Received: %"PRIu16, s_session_id, session_id);
prv_send_event(VoiceEve... | (VoiceSessionId, sys_voice_start_dictation, VoiceEndpointSessionType session_type) | {
if (session_type >= VoiceEndpointSessionTypeCount) {
return AUDIO_ENDPOINT_SESSION_INVALID_ID;
}
return voice_start_dictation(session_type);
}
DEFINE_SYSCALL(void, sys_voice_stop_dictation, VoiceSessionId session_id) {
voice_stop_dictation(session_id);
}
DEFINE_SYSCALL(void, sys_voice_cancel_dictation,... |
range(60 * 1024, 60 * 1024, ((2 * 64) + 4) * 1024, ((2 * 64) + 8) * 1024);
cl_assert_equal_i(s_command_list_index, 3);
cl_assert_equal_i(s_command_list[0].addr, 60 * 1024);
cl_assert_equal_i(s_command_list[0].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[1].addr, 64 * 1024);
cl_assert_equal... | (s_command_list[0].type, SectorEraseCommand) | ;
cl_assert_equal_i(s_command_list[1].addr, 0x330000);
cl_assert_equal_i(s_command_list[1].type, SubsectorEraseCommand);
cl_assert_equal_i(s_command_list[2].addr, 0x331000);
cl_assert_equal_i(s_command_list[2].type, SubsectorEraseCommand);
}
|
t(rect->origin.x + rect->size.w - 1, rect->origin.y);
const GPoint bl = GPoint(rect->origin.x, rect->origin.y + rect->size.h - 1);
const GPoint br = GPoint(rect->origin.x + rect->size.w - 1, rect->origin.y + rect->size.h - 1);
graphics_line_draw_stroked_aa(ctx, tl, tr, stroke_width);
graphics_line_draw_stroked... | graphics_draw_line(ctx, right_t, right_b) | ; // right
// Draw quadrants
const GPoint tl = GPoint(origin.x + radius, origin.y + radius);
const GPoint tr = gpoint_add(tl, GPoint(width_actual - 1, 0));
const GPoint bl = gpoint_add(tl, GPoint(0, height_actual - 1));
const GPoint br = gpoint_add(tl, GPoint(width_actual - 1, height_actual - 1));
graph... |
st bool is_text_remaining = line_add_words(
line, &line_iter_state->word_iter, callbacks->last_line_cb);
// NOTE: Account for descender - assume descender is no more than half the line height
const int16_t line_spacing_delta = prv_layout_get_line_spacing_delta(layout);
const int32_t line_max_y = lin... | if (!is_overflow) {
// Add entire word
PBL_ASSERTN(line->suffix_codepoint == 0);
line->width_px += word->width_px;
return true;
} | |
analytics_event_crash(crash_report->crash_code, crash_report->link_register) | ;
kernel_free(crash_report);
}
static RebootReasonCode s_last_reboot_reason_code = RebootReasonCode_Unknown;
RebootReasonCode reboot_reason_get_last_reboot_reason(void) {
return s_last_reboot_reason_code;
}
void debug_reboot_reason_print(McuRebootReason mcu_reboot_reason) {
RebootReason reason;
reboot_reason_... | |
er_create(&s_test_impl_data, NULL);
// Copied from recognizer_manager.c
TouchEvent t;
struct ProcessTouchCtx {
Recognizer *triggered;
const TouchEvent *touch_event;
} ctx = { .triggered = NULL, .touch_event = &t };
cl_assert(prv_dispatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert(!ctx.... | {
const int k_rec_count = 4;
Recognizer **recognizers = prv_create_recognizers(k_rec_count);
Window window = {};
layer_init(&window.layer, &GRectZero);
Layer *root = &window.layer;
RecognizerManager manager;
recognizer_manager_init(&manager);
manager.window = &window;
Layer layer_a, layer_b, layer_c... |
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Cancelled);
cl_assert_equal_i(recognizers[2]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Cancelled);
// Layer C's and layer A's recognize... |
/*
* 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... | dialog_set_background_color(dialog, GColorJaegerGreen) | ;
dialog_set_timeout(dialog, DIALOG_TIMEOUT_DEFAULT);
return simple_dialog;
}
static void prv_edit_snooze_delay(ActionMenu *action_menu,
const ActionMenuItem *item,
void *context) {
alarm_set_snooze_delay((uintptr_t)item->action_data);
SimpleD... |
L, 5, 3686400));
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 0, 0);
// NULL position not valid for position update event
cl_assert_passert(touch_handle_update(0, TouchState_FingerDown, NULL, 5, 3686400));
}
void test_touch__handle_update_reset_queue_touchdown(void) {
touch_set_touch_state(0, T... | GPoint(15, 15) | , 6, 3686440);
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
touch_handle_update(1, TouchState_FingerDown, &GPoint(33, 33), 7, 3686500);
touch_handle_driver_event(TouchDriverEvent_ControllerError);
PebbleEvent event = fake_event_get_last();
// Touches cancelled event generated
... |
/*
* 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_zalloc_check(buffer_size) | ,
.progress = minutes * SECONDS_PER_MINUTE,
.fill_color = PBL_IF_COLOR_ELSE(GColorSunsetOrange, GColorDarkGray),
};
int pos = snprintf(zone->label, buffer_size, "%s ", i18n_get(zone_label, i18n_owner));
if (zone->progress) {
health_util_format_hours_and_minutes(zone->label + pos, buffer_size - pos,
... |
It does not support %s, nor %+
// %z totally breaks down if the GMT offset is in the range -1s ~ -59m
// This is because for minute it does an abs(), but doesn't change the sign of the output.
// We support the 0 and + (sorta) flag and minimum field width, but no other flag modifiers
// The code supports %O* and %E*,... | (tmbuf, "Fri Friday Jan January") | ;
}
void test_strftime__abusive(void) {
char tmbuf[512];
struct tm gobbledygook = {
.tm_hour = 13, .tm_min = 0, .tm_sec = 0, // 13:00:00
.tm_year = 2015 - 1900, .tm_mon = 0+MONTHS_PER_YEAR, .tm_mday = 2, // 2015/01/02
.tm_wday = 5+DAYS_PER_WEEK, .tm_yday = 1, // Friday, 2nd day of the year
.tm_gmt... |
/*
* 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... | applib_type_zalloc(HealthServiceCache) | ;
}
return result;
}
// ----------------------------------------------------------------------------------------------
static void prv_health_service_deinit_cache(HealthServiceState *state) {
if (state) {
applib_free(state->cache);
state->cache = NULL;
}
}
// -----------------------------------------... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (entry->key, key, key_len) | ;
entry->val = kernel_malloc_check(val_len);
memcpy(entry->val, val, val_len);
entry->key_len = key_len;
entry->val_len = val_len;
entry->flags |= RamStorageFlagDirty;
// Add to list
storage->entries = (RamStorageEntry *)list_prepend((ListNode *)storage->entries, &entry->node);
return 0;
}
int ram_sto... |
stdio.h>
// How long after test pass / fail to wait before popping the window
#define WINDOW_POP_TIME_S (3)
typedef struct {
Window window;
PathLayer arrows[NUM_BUTTONS];
//! bitset of buttons pressed so far
uint32_t buttons_pressed;
TextLayer title;
TextLayer status;
char status_string[35];
uint3... | (5, 110,
window->layer.bounds.size.w - 5, window->layer.bounds.size.h - 110) | );
text_layer_set_font(status, fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_text_alignment(status, GTextAlignmentCenter);
layer_add_child(&window->layer, &status->layer);
for (ButtonId id = 0; id < NUM_BUTTONS; ++id) {
init_arrow_layer_for_button(data, id);
}
app_window_stack_push(window... |
IWDG_SetPrescaler(IWDG_Prescaler_64) | ; // ~8 seconds
IWDG_SetReload(0xfff);
IWDG_WriteAccessCmd(IWDG_WriteAccess_Disable);
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP, ENABLE);
}
void watchdog_start(void) {
IWDG_Enable();
watchdog_feed();
}
// This behaves differently from the bootloader and the firmware.
void watchdog_feed(void) {
IWDG_Reloa... | |
DD_1_REG, DCDC_VDD_IDLE_HYST, 0x4);
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_IDLE_MIN, 0x10);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_FAST_RAMPING, 0x1);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_VOLTAGE, 0x18);
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MAX_HV, 0x1F);
REG_SETF(DCDC, DCDC_V18P_0_REG,... | (QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_QUAD, 0x0) | ;
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_DUAL, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_SINGLE, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_USE_32BA, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_FORCENSEQ_EN, 0x0);
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_PCLK_MD, 0x0);
REG_SETF(QSP... |
r timers are deregistered:
cl_assert_equal_p(s_seconds_callbacks.next, NULL);
cl_assert_equal_p(s_minutes_callbacks.next, NULL);
}
#define TEST_DEVICE_NAME "iPhone Martijn"
static GAPLEConnection s_conn_a;
static GAPLEConnection s_conn_b;
static const BTDeviceInternal *s_device_a;
static const BTDeviceInternal *s... | (&s_conn_a) | ;
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
prv_assert_event_service_subscribed(true);
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 1);
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 0);
// Device B unsubscribes, expect to be unsubscribed from ... |
ow_stack_get_top_window;
Window *app_window_stack_get_top_window() {
return &s_app_window_stack_get_top_window;
}
static int s_prv_api_init__callcount;
static void prv_api_init(void) {
s_prv_api_init__callcount++;
}
static int s_prv_api_add__callcount;
static bool s_prv_api_add__result;
static bool prv_api_add(co... | EXECUTE_SCRIPT(
"t = typeof _rocky.off;\n"
"var eq = _rocky.off === _rocky.removeEventListener;\n"
) | ;
ASSERT_JS_GLOBAL_EQUALS_S("t", "function");
ASSERT_JS_GLOBAL_EQUALS_B("eq", true);
// from MDN docs:
// Calling removeEventListener() with arguments that do not identify
// any currently registered EventListener on the EventTarget has no effect.
EXECUTE_SCRIPT(
"_rocky.off('foo', f2);\n"
"_rocky.... |
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw11_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 11);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq... | graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// AA = true, SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 5);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "... |
else if (shape == RECTANGLE) {
// Move the rectangle X per 2*Y
data->rect.origin.x += (data->rect_velocity_x * PIXEL_SPEED_PER_FRAME);
if (data->rect.origin.x < 0 ||
data->rect.origin.x + data->rect.size.w > data->window.layer.bounds.size.w) {
data->rect_velocity_x = data->rect_veloc... | {
graphics_fill_round_rect(ctx, &data->rectr, data->rectr_radius, GCornersAll);
} | else if (shape == CIRCLE) {
graphics_context_set_fill_color(ctx, data->circle_color);
graphics_context_set_stroke_color(ctx, data->circle_color);
graphics_fill_circle(ctx, data->circle_origin, data->circle_radius);
} else if (shape == GPATH_TRIANGLE) {
gpath_draw_filled(ctx, data->triangle)... |
ut_data);
if (strlen(number_text_node->text) > 5) {
// text is long so use smaller font
number_text_node->font = prv_get_number_font(false);
}
break;
}
case WorkoutMetricType_Pace:
case WorkoutMetricType_AvgPace:
{
if (active_window->workout_controller->get_metri... | if (window_manager_is_window_visible(&active_window->window)) {
layer_mark_dirty(&active_window->base_layer);
// Update the action bar in case another client updated the workout's status
prv_set_action_bar_icons(active_window);
} |
}
static void prv_hr_measuring_timer_callback(void *data) {
WorkoutActiveWindow *active_window = data;
active_window->cur_hr_measuring_width_idx = (active_window->cur_hr_measuring_width_idx + 1)
% ARRAY_LENGTH(s_hr_measuring_widths);
prv_update_ui(active_window);
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_configure_click(BUTTON_ID_UP, prv_launch_timeline) | |
imation_by_handle(NULL, animation_h, false /*quiet*/);
if (!animation) {
return 0;
}
return animation->abs_start_time_ms;
}
// -------------------------------------------------------------------------------------------
bool animation_set_duration(Animation *animation_h, uint32_t duration_ms) {
AnimationSt... | (state, animation) | ) {
return false;
}
animation->custom_function = function;
if (function) {
animation->curve = curve;
} else {
animation->curve = AnimationCurveDefault;
}
return true;
}
// -------------------------------------------------------------------------------------------
bool animation_set_custom_curv... |
p_state.h"
#include "stubs_applib_resource.h"
#include "stubs_compiled_with_legacy2_sdk.h"
#include "stubs_heap.h"
#include "stubs_logging.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_print.h"
#include "stubs_resources.h"
#include "stubs_serial.h"
#include ... | (gtransform_is_only_scale(&t)) | ;
cl_assert(gtransform_is_only_scale(&t_c));
t_c = GTransformScaleFromNumber(2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
// Test Translation Matrix
t = GTransformTranslation(GTransformNumberFromNumber(2), GTransformNumberFromNumber(5));
t_c = GTransformFromNumbers(1, 0, 0, 1, 2, 5);
cl_assert(gtra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.