prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ng, 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.
*/
#ifdef UI_DEBUG
#include "ui.h"
#include "applib/ui... | window_get_debug_name(window) | ;
if (window_name) {
dbgserial_putstr(window_name);
}
layer_dump_tree(window_get_root_layer(window));
}
#endif /* UI_DEBUG */
|
_size = analytics_metric_element_size(metric);
if (index > len) {
PBL_CROAK("Attempt to use array value at invalid index %" PRId32 " (len %" PRId32 ")",
index, len);
}
return heartbeat->data + analytics_metric_offset(metric) + index*element_size;
}
static void prv_location_set_value(uint8_t *lo... | {
AnalyticsHeartbeat *hb = analytics_heartbeat_create(ANALYTICS_HEARTBEAT_KIND_DEVICE);
analytics_heartbeat_set(hb, ANALYTICS_DEVICE_METRIC_BLOB_KIND,
ANALYTICS_BLOB_KIND_DEVICE_HEARTBEAT);
analytics_heartbeat_set(hb, ANALYTICS_DEVICE_METRIC_BLOB_VERSION,
ANALYT... |
AnalyticsHeartbeat *analytics_heartbeat_app_create(const Uuid *uuid) {
AnalyticsHeartbeat *hb = analytics_heartbeat_create(ANALYTICS_HEARTBEAT_KIND_APP);
analytics_heartbeat_set_entire_array(hb, ANALYTICS_APP_METRIC_UUID, uuid);
analytics_heartbeat_set(hb, ANALYTICS_APP_METRIC_BLOB_KIND,
... |
t top_rect_origin_x = rect->origin.x;
int16_t top_rect_size_w = rect->size.w;
int16_t bottom_rect_origin_x = rect->origin.x;
int16_t bottom_rect_size_w = rect->size.w;
// Fill 3 rectangles and 4 quadrants
if (corner_mask & GCornerTopLeft) {
circle_func(ctx, GPoint(rect->origin.x + radius, rec... | (rect->origin.x + rect->size.w - 1,
rect->origin.y + 1, 1, rect->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... | (center.x.raw_value - radius_x, center.y.raw_value) | ;
}
}
// This algorthm operates on angle starting at our 90° mark, so we add 90°
// and flip x/y coordinates (see last line of this function)
angle = (angle + (TRIG_MAX_ANGLE / 4)) % TRIG_MAX_ANGLE;
// This is going to be divided by fixed-point precision number so division here is unnecessary
int32_t ... |
(prv_handle_data, should_context_switch);
} else {
BMI160_DBG("%s", "We fell behind on data handling");
}
}
// in order to actually enter 'low power' mode, we have to set up accel to do
// undersampling. The more samples we use for one reading, the higher the power
// consumption but the lower the RMS noise
st... | (LOG_LEVEL_DEBUG, "- %c: %"PRId16,
accel_test_axis[i].axis_name, accel_test_axis[i].negative_value) | |
Y,
ActivityInsightType_Day1, ActivitySessionType_None);
AttributeList dismiss_action_attr_list = {0};
attribute_list_add_cstring(&dismiss_action_attr_list, AttributeIdTitle,
i18n_get("Dismiss", ¬if_attr_list));
AttributeList open_app_action_attr... | i18n_get("Wish you could get daily updates on your "
"activity and sleep progress? You can! "
"Check out your stats with Pebble Health.",
¬if_attr_list) | ;
prv_build_notification_attr_list(¬if_attr_list, body, TIMELINE_RESOURCE_ACTIVITY,
ActivityInsightType_Day10, ActivitySessionType_None);
AttributeList dismiss_action_attr_list = {0};
attribute_list_add_cstring(&dismiss_action_attr_list, AttributeIdTitle,
... |
r %"PRId8, event->status);
prv_handle_dictation_error(data, event->status);
break;
case VoiceStatusRecognizerResponseError:
VOICE_LOG("Result: speech not recognized");
prv_handle_dictation_error(data, event->status);
break;
case VoiceStatusTimeout:
VOICE_LOG("Result: timeou... | (data->dictation_timeout) | |
m->id, alarm->config.hour, alarm->config.minute, s_next_alarm_time,
alarm->config.is_smart);
}
// ----------------------------------------------------------------------------------------------
//! Checks to see if this alarm is the new next alarm. If it is, adjust the timer so it's scheduled.
static void prv... | {
s_most_recent_alarm_recorded = true;
// Read from flash since the in-memory cache can be modified
prv_alarm_operation(s_most_recent_alarm_id, prv_record_alarm_op, NULL);
} | |
== 7) {
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_TWO);
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_THREE);
return true;
}
switch (++counter) {
case 1:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 2:
boot_bit_clear(BOOT_BIT... | if (button_state != prev_button_state) {
system_reset();
} |
delay_ms(10);
}
}
static void check_and_handle_resuming_from_standby(void) {
periph_config_enable(RCC_APB1PeriphClockCmd, RCC_APB1Periph_PWR);
if (PWR_GetFlagStatus(PWR_FLAG_SB) == SET) {
// We just woke up from standby. For some reason this leaves the system in a funny state,
// so clear the flag a... |
/*
* 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... | bt_unlock() | ;
PulsePPPacket *resp = (PulsePPPacket*) pulse_reliable_send_begin(PULSE2_PEBBLE_PROTOCOL);
bt_lock();
if (resp) {
resp->opcode = PULSE_PP_OPCODE_DATA;
const size_t bytes_to_copy = MIN(bytes_remaining, mss);
comm_session_send_queue_copy(session, 0 /* start_offset */,
... |
dirty_item->key,
dirty_item->key_len,
item_buf,
item_size);
} else {
session->current_token = blob_db_endpoint_send_write(ses... | PBL_LOG(LOG_LEVEL_DEBUG, "blob_db_sync_next") | |
app_timer_register(5000, prv_pop_all_windows_cb, NULL) | ;
}
static void prv_window_unload(Window *window) {
AppData *data = window_get_user_data(window);
menu_layer_deinit(&data->action_list1);
menu_layer_deinit(&data->action_list2);
}
static void s_main(void) {
AppData *data = app_malloc_check(sizeof(AppData));
memset(data, 0, sizeof(AppData));
app_state_set_... | |
ount, 0);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(fake_system_task_count_callbacks(), 0);
cl_assert_equal_i(s_send_next_count, 1);
comm_session_send_next(session);
cl_assert_equal_i(fake_system_task_count_callbacks(), 1);
comm_session_send_next(session);
cl_assert_equal_i(fake_sys... | comm_session_is_valid(session) | , true);
comm_session_send_next(session);
cl_assert_equal_b(comm_session_send_next_is_scheduled(session), true);
// Calling comm_session_send_next_immediately should NOT result in the flag to get unset
comm_session_send_next_immediately(session);
cl_assert_equal_b(comm_session_send_next_is_scheduled(session... |
if (func) {
func(selection_layer->selected_cell_idx, selection_layer->callback_context);
}
layer_mark_dirty(&selection_layer->layer);
} else {
// Run the animation. The decrement callback will be run halfway through
selection_layer->bump_is_upwards = is_up;
prv_run_value_change... | {
selection_layer->active_background_color = color;
} |
}
void selection_layer_set_cell_padding(SelectionLayer *selection_layer, unsigned padding) {
if (selection_layer) {
selection_layer->cell_padding = padding;
}
}
void selection_layer_set_active(SelectionLayer *selection_layer, bool is_active) {
if (selection_layer) {
if (is_active && !selection_layer->i... |
const GTextOverflowMode overflow_mode,
const GTextAlignment alignment,
GTextLayoutCacheRef layout) {
return GSizeZero;
}
typedef struct {
struct {
GTextLayoutCacheRef layout;
} disable_text_flow;... | (text_layer.layout_cache == MOCKED_CREATED_LAYOUT) | ;
}
void test_text_layer__enable_text_flow_requires_successful_calc_for_paging(void) {
text_layer.layer.window = &window;
s_text_layer_calc_text_flow_paging_values_result = false;
text_layer_enable_screen_text_flow_and_paging(&text_layer, 8);
cl_assert_mocks_called(((MockValues){
.enable_text_flow.layout =... |
pache.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 and... | (s_list_mutex) | |
age(volume_is_up ? &data->image_volume_up : &data->image_volume_down);
music_command_send(volume_is_up ? MusicCommandVolumeUp : MusicCommandVolumeDown);
}
static Animation* prv_create_layer_upwards_animation(Layer *layer, int16_t offset) {
GPoint target = GPoint(0, -layer->bounds.size.h - offset);
GPoint origin ... | property_animation_create_bounds_origin(&data->cassette_container, &GPoint(-4, 0),
&GPointZero) | );
animation_set_duration(cassette_left, 4 * ANIMATION_FRAME_MS);
animation_set_curve(cassette_left, AnimationCurveEaseIn);
animation_set_duration(cassette_right, config->cassette_animation_time);
animation_set_curve(cassette_left, AnimationCurveLinear);
animation_set_duration(cassette_bounceback, 4 * ANIMATI... |
.num_samples = data->run_size,
};
if (data->first_record) {
data->record.flags |= ACTIVITY_RAW_SAMPLE_FLAG_FIRST_RECORD;
data->first_record = false;
}
}
if (finish) {
// Finishing up an existing record?
if (data->run_size > 0) {
// We started a run... | (data, 0, num_samples * sizeof(AccelRawData)) | ;
}
// Have the algorithm process the samples from KernelBG
activity_algorithm_handle_accel(data, num_samples, timestamp);
// Update our copy of the steps after grabbing the mutex. We guard these globals with a
// mutex because activity_get_metric() provides access to the current metrics from any task.
// ... |
{
return E_DOES_NOT_EXIST;
} |
}
uint8_t s_cur_itr;
static void prv_get_key(SettingsFile *file, void *key, size_t key_len) {
memcpy(key, s_settings_file.keys[s_cur_itr], key_len);
}
static void prv_get_val(SettingsFile *file, void *val, size_t val_len) {
memcpy(val, s_settings_file.values[s_cur_itr], val_len);
}
status_t settings_file_each(... | |
ount + 1, 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_erro... | prv_assert_event(&device, BTErrnoServiceDiscoveryDatabaseChanged) | ;
// Expect all services nodes to be cleaned up:
cl_assert_equal_i(list_count(&connection->gatt_remote_services->node), 0);
// Put one, expect one:
prv_simulate_and_assert_discovery_of_one_service(&device);
cl_assert_equal_i(list_count(&connection->gatt_remote_services->node), 1);
}
void test_gatt_client_di... |
return strlen(buffer);
} else {
struct tm local_tm = (struct tm) {
.tm_wday = positive_modulo(graph_card->selection, DAYS_PER_WEEK),
};
return strftime(buffer, buffer_size, i18n_get("%a: ", graph_card), &local_tm);
}
}
static void prv_draw_info_with_text(HealthGraphCard *graph_card, GContext *ct... | i18n_free_all(graph_card) | ;
app_free(graph_card);
}
void health_graph_card_configure(HealthGraphCard *graph_card, const HealthGraphCardConfig *config) {
if (!graph_card || !config) {
return;
}
if (config->title) {
graph_card->title = i18n_get(config->title, graph_card);
}
if (config->info_avg) {
graph_card->info_avg = i... |
test_app_manager__start_third_party() | ;
s_last_to_app_event = (PebbleEvent) {0};
// Make the app get stuck in a syscall. This will indicate that the app is running
// privileged.
stub_control_reg(0x0);
// Try to close the app.
app_manager_close_current_app(true /* gracefully */);
cl_assert(app_manager_get_current_app_md() == (PebbleProces... | |
MINUTE;
timeline_peek_set_show_before_time(show_before_time_s);
ADD_EVENT( .item = &s_future_item );
CHECK_EVENT( .count = 3, .item_id = s_future_item.header.id, .num_concurrent = 0,
.timeout_ms = ((s_future_item.header.timestamp - show_before_time_s) *
MS_PER_SECOND),... | {
// All day events show up if no timed event has yet passed
TimelineItem item =
DEFINE_EVENT( .id = 0x01, .timestamp = 20 * SECONDS_PER_MINUTE, .duration = 70 );
TimelineItem UNUSED item2 =
DEFINE_EVENT( .id = 0x02, .timestamp = 0, .duration = MINUTES_PER_DAY, .all_day = true );
unsigned int time... |
void test_timeline_peek_event__first_event_with_all_day_event_after(void) {
// After a timed event has passed, all day events no longer show up for the day
rtc_set_time(SECONDS_PER_HOUR);
TimelineItem item =
DEFINE_EVENT( .id = 0x01, .timestamp = SECONDS_PER_HOUR + 20 * SECONDS_PER_MINUTE,
... |
tic GPath *s_aa_clipping_path = NULL;
static void prv_filled_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
#if 0 // Guidelines
int num_segments = 4;
int segment_width = SCREEN_WIDTH / num_segments;
int segment_height = SCREEN_HEIGHT / num_segments;
for (int ... | (NULL, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled.${BIT_DEPTH_NAME}.pbi"));
printf("-- bottom\n");
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT));
ctx.draw_state.drawing_box = GRect(0, -SCREEN_... |
/*
* 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... | (false /* animated */) | |
d, BtPersistBondingType type) {
if (id == BT_BONDING_ID_INVALID) {
return;
}
if (type == BtPersistBondingTypeBTClassic) {
BTDeviceAddress addr;
SM128BitKey key;
char classic_name[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits;
if (bt_persistent_storage_get_bt_classic_pairing_by_id(
... | (&fd, key, key_len) | ;
}
settings_file_close(&fd);
}
cleanup:
prv_unlock();
if (rv != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to update gap bonding db, rv = %"PRId32, rv);
return GapBondingFileSetFail;
}
return (do_perform_update ? GapBondingFileSetUpdated : GapBondingFileSetNoUpdateNeeded);
}
//! Returns ... |
when tiling
src_x = src_bitmap->bounds.origin.x +
(((src_x - src_bitmap->bounds.origin.x)) % src_bitmap->bounds.size.w);
} else {
// Increment source but don't draw
continue;
}
}
GColor src_color = *(GColor8 *) &src[s... | {
const uint32_t bit = (1 << i);
const bool set = src & bit;
if (!set) {
dest[dest_x] = GColorWhite.argb;
}
} | |
// before exiting) reset the bus and wait for it to become not-busy
// Exit if bus remains busy. User module should reset the I2C module at this point
if((bus->i2c->SR2 & I2C_SR2_BUSY) != 0) {
bus_reset(bus_idx);
if (!wait_for_busy_clear(bus_idx)) {
// Bus did not recover after reset
bus_unlock... | PBL_LOG(LOG_LEVEL_DEBUG, "i2c writes on QEMU not supported") | ;
return false;
#endif
// Do transfer locks the bus
bool result = do_transfer(device_id, false, i2c_device_address, register_address_start, write_size, (uint8_t*)buffer);
if (!result) {
PBL_LOG(LOG_LEVEL_ERROR, "Write failed on bus %" PRId8, BOARD_CONFIG.i2c_device_map[device_id]);
}
return result;... |
e_Param_v1 *msg = (BinLogMessage_Param_v1 *)&msg_buffer[sizeof(HcProtocolMessage)];
msg->header.version = BINLOGMSG_VERSION_PARAM_V1;
msg->header.length = msg_size;
msg->header.time.millisecond = LEVEL_MAP[level]; // HACK: Carry the level in the millisecond field
// msg->header.date & msg->header.time will be ... | (args, fmt) | ;
msg->body.length = vsnprintf((char *)msg->body.string, max_str_len, fmt, args);
va_end(args);
// Temporarily force NULL termination. The buffer is already set to zero -- increment the length
// by one to reflect the increased string length
// TODO: remove NULL termination
msg->body.length++;
// Calcul... |
t!
void test_system_flash__bit_range_macros(void) {
cl_assert_equal_i(0b1, BITS(0));
cl_assert_equal_i(0b00011111, BITS(4));
cl_assert_equal_i(0b00111111, BITS_BETWEEN(0,5));
cl_assert_equal_i(0b00111000, BITS_BETWEEN(3,5));
cl_assert_equal_i(0b00010000, BITS_BETWEEN(4,4));
}
// Flash memory is organized int... | malloc(size * sizeof(uint8_t)) | |
/*
* 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... | action_bar_layer_remove_from_window(&confirmation_dialog->action_bar) | |
if (data->operation == OP_TEST3) {
int x1 = 50,
x2 = 100,
y1 = 40,
y2 = 120;
GPoint p0 = GPoint(x1, y1);
GPoint p1 = GPoint(x1, y2);
GPoint p2 = GPoint(x2, y2);
GPoint p3 = GPoint(x2, y1);
// graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiase... | (data->rotation_angle) | * line_length / TRIG_MAX_RATIO) + y1;
} else {
x1 = data->p1.x;
y1 = data->p1.y;
x2 = data->p2.x;
y2 = data->p2.y;
}
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, data->stroke_width);
graphics_draw_line(ctx, GPoint(x1, y1), GPoint(x2, y2));
}
static voi... |
ount == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted reset of disabled bus %d by device %d", bus_idx, device_id);
bus_unlock(bus);
return;
}
PBL_LOG(LOG_LEVEL_WARNING, "Resetting I2C bus %" PRId8, bus_idx);
// decrement user count for reset so that if this user is the only user, the
// bus will be pow... | PBL_LOG(LOG_LEVEL_ERROR, "I2C Error: too many NACKs received on bus %" PRId8, bus_idx) | ;
}
} else {
// Timeout, abort transfer
abort_transfer(bus);
break;
PBL_LOG(LOG_LEVEL_ERROR, "Transfer timed out on bus %" PRId8, bus_idx);
}
} while (bus->transfer.state != TRANSFER_STATE_INVALID);
// Return semaphore token so another transfer can be started
semaphore_give... |
/*
* 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... | (image != NULL) | ;
}
void test_gdraw_command_resources__load_pdcs(void) {
uint32_t resource_id = sys_resource_load_file_as_resource(TEST_IMAGES_PATH, TEST_PDC_FILE);
cl_assert(resource_id != UINT32_MAX);
GDrawCommandSequence *sequence = gdraw_command_sequence_create_with_resource(resource_id);
cl_assert(sequence != NULL);
}
/... |
(GDrawCommandImage *image, int32_t normalized) {
gdraw_command_list_attract_to_square(&image->command_list, image->size, normalized);
}
////////////////////
// gpoint index lookup creator
typedef struct {
const struct {
const GPoint *points;
uint16_t num_points;
} values;
struct {
GPointIndexLook... | {
if (delay_index < 0 || delay_index >= lookup->max_index) {
return;
}
// We are adding additional delay, the max delay index increases
lookup->max_index += delay_amount;
for (int i = 0; i < lookup->num_points; i++) {
// The lookup maps definition index => delay index
// We want to add delay to po... |
void gpoint_index_lookup_set_groups(GPointIndexLookup *lookup, int num_groups,
Fixed_S32_16 group_delay) {
const int num_points_per_group = lookup->num_points / num_groups;
const int delay_per_group = (num_points_per_group / group_delay.raw_value) /
... |
olor;
GPath path;
bool is_first_half;
int16_t animation_offset_px;
Animation *first_anim;
Animation *second_anim;
} CompositorShutterTransitionData;
static CompositorShutterTransitionData s_data;
#define PATH_WEDGE_POINTS 3
#define PATH_QUAD_POINTS 4
static GPathInfo s_path_wedge = {
.num_points = PATH_W... | graphics_context_set_stroke_width(ctx, 1) | ;
graphics_context_set_stroke_color(ctx, s_data.color);
graphics_context_set_fill_color(ctx, s_data.color);
for (int i = 0; i < PATH_WEDGE_POINTS; i++) {
prv_gpoint_interpolate(&s_path_wedge.points[i], distance,
&s_path_defs[s_data.direction].wedge_verts[i]);
}
gpath_init(&s_data.path, &s_path_wedg... |
xValue(tempa[1]);
tempa[2] = getSBoxValue(tempa[2]);
tempa[3] = getSBoxValue(tempa[3]);
}
tempa[0] = tempa[0] ^ Rcon[i/Nk];
}
else if (Nk > 6 && i % Nk == 4)
{
// Function Subword()
{
tempa[0] = getSBoxValue(tempa[0]);
tempa[1] = getSBoxValue(tempa[1... | Multiply(a, 0x0d) | ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b);
(*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e);
}
}
// The SubBytes Function Substitutes the values in the
// state matrix with values in an S-box.
static void InvSubBytes(void)
{
uint8_t i,j;
for(i... |
);
window_single_click_subscribe(BUTTON_ID_DOWN, prv_end_workout_down_click_handler);
}
static void prv_end_workout(void *context) {
WorkoutActiveWindow *active_window = context;
WorkoutDialog *workout_dialog = &active_window->end_workout_dialog;
workout_dialog_init(workout_dialog, "Workout End");
Dialog *... | (active_window->action_bar_next) | ;
gbitmap_destroy(active_window->heart_icon);
gbitmap_destroy(active_window->hr_measuring_icon);
action_bar_layer_deinit(&active_window->action_bar);
status_bar_layer_deinit(&active_window->status_layer);
layer_deinit(&active_window->top_metric_layer);
layer_deinit(&active_window->scrollable_met... |
dif
extern void * __ISR_VECTOR_TABLE__; // Defined in linker script
SCB->VTOR = (uint32_t)&__ISR_VECTOR_TABLE__;
NVIC_SetPriorityGrouping(3); // 4 bits for group priority; 0 bits for subpriority
enable_fault_handlers();
kernel_heap_init();
mbuf_init();
delay_init();
periph_config_init();
dbgseri... | (s_uptime_timer) | ;
boot_bit_set(BOOT_BIT_FW_STABLE);
}
static void prv_low_power_debug_config_callback(void* data) {
new_timer_delete(s_lowpower_timer);
// Turn off sleep and stop mode debugging if it is not explicitly enabled
// 4 cases:
// STM32F2/STM32F7, low power debug off: we need to disable it after the first 10 seco... |
or = GColorJaegerGreen;
EXECUTE_SCRIPT(
"ctx.clearRect(1, 2, 3, 4);\n"
);
cl_assert_equal_i(1, s_graphics_fill_rect.call_count);
cl_assert_equal_rect(GRect(1, 2, 3, 4), s_graphics_fill_rect.last_call.rect);
cl_assert_equal_i(GColorBlackARGB8, s_graphics_fill_rect__color.argb);
cl_assert_equal_i(GColor... | (20 * 8, lc->fill_radial_precise.radius_outer.raw_value) | ;
// inner radius capped to >= 0
EXECUTE_SCRIPT(
"ctx.rockyFillRadial(30, 40, -10, 20, 0, Math.PI);\n"
);
cl_assert_equal_i(2, s_graphics_fill_radial_precise_internal.call_count);
cl_assert_equal_point_precise((PP(29.5, 39.5)), lc->fill_radial_precise.center);
cl_assert_equal_i(0, lc->fill_radial_preci... |
/*
* 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->callbacks = (DialogCallbacks) {};
return;
} |
dialog->callbacks = *callbacks;
dialog->callback_context = callback_context;
}
void dialog_set_destroy_on_pop(Dialog *dialog, bool destroy_on_pop) {
dialog->destroy_on_pop = destroy_on_pop;
}
void dialog_appear(Dialog *dialog) {
KinoLayer *icon_layer = &dialog->icon_layer;
if (kino_layer_get_reel(icon_lay... |
lgorithm will draw lines in one way only, so non-AA should reject those too
return;
}
prv_assign_line_horizontal_non_aa(ctx, y, x1_rounded, x2_rounded);
}
void graphics_private_draw_vertical_line(GContext *ctx, int16_t x, Fixed_S16_3 y1, Fixed_S16_3 y2) {
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
... | MIN(MAX(y0, y1), clip_box->origin.y + clip_box->size.h) | ;
#if PBL_COLOR
color.a = (uint8_t)(MAX_PLOT_BRIGHTNESS - opacity);
#else
if (opacity > (MAX_PLOT_BRIGHTNESS / 2)) {
// We're not plotting anything, bail
return;
}
#endif // PBL_COLOR
ctx->draw_state.draw_implementation->blend_vertical_line(ctx, x, y_min, y_max, color);
}
void graphics_private_plot_h... |
{
prv_flash_read((uint8_t *)&hdr, sizeof(hdr), base_addr);
} |
}
// Write Page Header + DataLen
if (do_copy) {
pfs_write(fd, &hdr, sizeof(hdr));
pfs_write(fd, &data_len, sizeof(data_len));
} else { // recover
pfs_read(fd, &hdr, sizeof(hdr));
pfs_read(fd, &data_len, sizeof(data_len));
prv_flash_write(&hdr, sizeof(hdr), base_addr);
... | |
(steps, 1060);
}
// ---------------------------------------------------------------------------------------
// Open the app and close the app. Make sure the HR monitor turns off instantly
void test_workout_service__app_open_close_no_workout(void) {
// Put some time into the clock
prv_inc_time(1 * SECONDS_PER_MINUT... | {
// Put some time into the clock
prv_inc_time(1 * SECONDS_PER_MINUTE);
// Open the app, confirm that we are now subscribed with no end in sight
workout_service_frontend_opened();
cl_assert_equal_b(s_hrm_subscribed, true);
cl_assert_equal_i(s_hrm_expiration, 0);
prv_inc_time(1 * SECONDS_PER_MINUTE);
c... |
// ---------------------------------------------------------------------------------------
void test_workout_service__heart_rate_zone_time(void) {
const int ZONE_0_HR = 100;
const int ZONE_1_HR = 140;
const int ZONE_2_HR = 160;
const int ZONE_3_HR = 180;
int32_t hr_zone_time_s[HRZoneCount];
cl_assert(wo... |
ne_layout_init_view(layout, layout->layout_layer.mode);
}
void timeline_layout_init(TimelineLayout *layout, const LayoutLayerConfig *config,
const TimelineLayoutImpl *timeline_layout_impl) {
const TimelineResourceId icon_resource = timeline_layout_get_icon_resource_id(
config->mode, c... | {
// The icon is too large, use the fallback instead
kino_reel_destroy(icon_reel);
icon_reel = prv_create_kino_reel_with_timeline_resource(
timeline_layout, icon_res_size, fallback_resource, TIMELINE_RESOURCE_NOTIFICATION_FLAG,
NULL /* app_id */);
if (!icon_reel) {
return;
}
... |
if (timeline_layout->layout_layer.mode == LayoutLayerModePeek) {
icon_size = GSize(TIMELINE_PEEK_ICON_BOX_WIDTH,
timeline_layout->layout_layer.layer.frame.size.h);
}
const GRect frame = { icon_frame->origin, icon_size };
// create the static reel
timeline_layout->icon_size = frame... |
tions. False to stop iterating.
typedef bool (*EventListenerIteratorCb)(jerry_value_t event_listeners, uint32_t idx,
jerry_value_t listener, void *data);
static void prv_iterate_event_listeners(const char *event_name,
EventListenerIterator... | memset(event_name, 0, event_name_size) | ;
const jerry_size_t len = jerry_string_to_utf8_char_buffer(argv[0],
(jerry_char_t *)event_name,
event_name_size);
if (len == 0 || len == event_name_size) {
return rocky_error_argument_invalid... |
ion_timestamps();
}
/*************************************
*************************************/
static void prv_menu_layer_reload_data(void *data) {
cl_assert_equal_p(data, &menu_layer);
menu_layer_reload_data(&menu_layer);
}
void test_app_menu_data_source__pass_init(void) {
app_menu_data_source_init(&data... | pfs_open("lnc_ord", OP_FLAG_WRITE, FILE_TYPE_STATIC, file_len) | ;
pfs_write(fd, &entries_to_write, sizeof(entries_to_write));
pfs_write(fd, order, sizeof(AppInstallId) * num_entries);
AppInstallId zero_id = 0;
pfs_write(fd, &zero_id, sizeof(zero_id));
pfs_close(fd);
}
void prv_test_new_order_with_filter_callback(const AppInstallId order[], uint8_t num_entries,
... |
{
return;
} |
if (service->slice_expiration_timer) {
app_timer_cancel(service->slice_expiration_timer);
service->slice_expiration_timer = NULL;
}
// Set the next slice expiration time to "never"
service->next_slice_expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION;
}
static void prv_update_slice_expiration_timer_i... | |
/*
* 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(data.model, model, sizeof(data.model)) | ;
data.model[MFG_INFO_MODEL_STRING_LENGTH - 1] = '\0';
prv_update_struct(&data);
}
GPoint mfg_info_get_disp_offsets(void) {
// Not implemented. Can just assume no offset
return (GPoint) {};
}
void mfg_info_set_disp_offsets(GPoint p) {
// Not implemented.
}
void mfg_info_update_constant_data(void) {
// 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... | {
cl_assert(is_complete == false);
cl_assert(should_store == true);
cl_assert(c == str[i]);
} |
}
}
void test_hdlc__special_characters(void) {
// make sure the escape characters haven't changed
cl_assert(HDLC_FLAG == 0x7e);
cl_assert(HDLC_ESCAPE == 0x7d);
cl_assert(HDLC_ESCAPE_MASK == 0x20);
}
void test_hdlc__decode_empty(void) {
// consecutive empty frames
const uint8_t str[4] = {HDLC_FLAG, HDLC... |
_time = APP_GLANCE_SLICE_NO_EXPIRATION,
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
.layout.subtitle_template_string = really_long_subtitle,
};
cl_assert(app_glance_add_slice(session, slice) & APP_GLANCE_RESULT_TEMPLATE_STRING_TOO_LONG);
// Check that adding a slice with a bad template string fails
... | cl_assert_equal_i(byte, 0) | ;
}
// Request the current slice for this glance again; this should return false since there aren't
// any slices in the glance anymore
cl_assert_equal_b(app_glance_service_get_current_slice(&APP_GLANCE_TEST_UUID, &slice_out), false);
}
void test_app_glance__reload_with_null_callback_empties_slices(void) {
... |
oid test_line_layout__test_line_add_word_ideographs(void) {
// Allocate mutable types
Iterator word_iter = (Iterator) { 0 };
WordIterState word_iter_state = (WordIterState) { 0 };
Line line = (Line) { 0 };
// Allocate immutable types
bool success = false;
const char *sentence = NIHAO_JOINED NIHAO NIHAOM... | cl_assert(*word_iter_state.current.start == 'F') | ;
cl_assert(*word_iter_state.current.end == ' ');
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 3);
line_reset(&line, utf8_bounds.start);
cl_assert(line_add_words(&line, &word_iter, NULL));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 3);
cl_assert(lin... |
.overflow_mode = GTextOverflowModeTrailingEllipsis,
.text_alignment = GTextAlignmentCenter,
.font = fonts_get_system_font(font_key),
};
}
static int prv_height(void) {
const PlatformType platform = process_manager_current_platform();
return _STATUS_BAR_LAYER_HEIGHT(platform);
}
// Function prototypes
st... | if (gcolor_equal(status_bar_layer->config.background_color, background) &&
gcolor_equal(status_bar_layer->config.foreground_color, foreground)) {
return;
} |
status_bar_layer->config.background_color = background;
status_bar_layer->config.foreground_color = foreground;
layer_mark_dirty(&(status_bar_layer->layer));
}
GColor status_bar_layer_get_background_color(const StatusBarLayer *status_bar_layer) {
PBL_ASSERTN(status_bar_layer);
return status_bar_layer->conf... |
TRIBUTES] = {0};
if (length == 0) {
goto fail;
}
bool error = false;
const bool complete = ancs_util_get_attr_ptrs(data,
length,
s_fetched_app_attributes,
NUM_FET... | buffer_create(request_max_size) | ;
const size_t written_size = buffer_add(request_buffer,
(const uint8_t *) &cmd_header,
sizeof(cmd_header));
PBL_ASSERTN(written_size == sizeof(cmd_header));
prv_add_attributes_to_request(request_buffer);
bool retrying = (s_ancs... |
----
static void prv_inc_steps_and_put_event(int steps) {
s_total_step_count += steps;
PebbleEvent event = {
.type = PEBBLE_HEALTH_SERVICE_EVENT,
.health_event = {
.type = HealthEventMovementUpdate,
.data.movement_update.steps = s_total_step_count,
},
};
event_put(&event);
workout_se... | (!workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone)) | ;
}
// ---------------------------------------------------------------------------------------
void test_workout_service__takeover_activity_session(void) {
int32_t steps, duration_s, distance_m, bpm, active_kcalories;
HRZone hr_zone;
// We have a session that started at utc=10 and length_min of 10. Increment th... |
/*
* 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... | pfs_init(false) | ;
pfs_format(false);
}
void test_ancs_pebble_actions__cleanup(void) {
}
void test_ancs_pebble_actions__test_sms_reply(void) {
prv_support_sms_replies();
ANCSAttribute *notif_attributes[NUM_FETCHED_NOTIF_ATTRIBUTES] = {0};
ANCSAttribute *app_attrs[NUM_FETCHED_APP_ATTRIBUTES] = {0};
const size_t header_len... |
item, &bad_item.common.id));
}
void test_reminder_db__find_by_timestamp_title(void) {
prv_insert_default_reminders();
// Add items with title attributes for searching (out of order for worst-case scenario)
cl_assert(S_SUCCESS == reminder_db_insert_item(&title_item2));
cl_assert(S_SUCCESS == reminder_db_insert... | (reminder_db_read((uint8_t *)&item1.header.id, sizeof(Uuid), (uint8_t *)&item,
sizeof(SerializedTimelineItemHeader))) | ;
cl_assert_equal_i(item.common.status & 0xFF, TimelineItemStatusReminded);
}
|
aw_vertical_line_dotted(&ctx, GPoint(41, 33), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(37, 37), 10);
// T facing up - lined up
graphics_draw_vertical_line_dotted(&ctx, GPoint(70, 36), 5);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(66, 36), 10);
// T facing down - lined up
graphics_dra... | TEST_NAMED_PBI_FILE("draw_line_same_point") | ));
#if SCREEN_COLOR_DEPTH_BITS == 8
graphics_context_set_stroke_color(&ctx, GColorRed);
draw_lines_same_point(&ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_same_point_color")));
#endif
}
#define CLIP_RECT_DRAW_BOX GRect(10, 10, 40, 40)
#define CLIP_RECT_CLIP_BOX GRect(10, 10, ... |
{ 1368, 272, -160},
{ 1224, 264, -216},
{ 888, 280, -208},
{ 584, 248, -144},
{ 480, 200, -144},
{ 512, 256, -112},
{ 656, 272, -112},
{ 888, 248, -192},
{ 1072, 288, -232},
{ 1016, 304, -280},
{ 1056, 304, -312},
{ 1152, 376, -288},
{ 1176, 376, -256},
{ 1048, 328, -... | { 792, 208, -72},
{ 848, 168, -40},
// 18 seconds
{ 896, 80, -40},
{ 960, 80, -80},
{ 1008, 96, -128},
{ 1024, 56, -160},
{ 1192, 160, -224},
{ 1112, 160, -80},
{ 1080, 216, -152},
{ 1240, 240, -200},
{ 1304, 328, -248},
{ 1056, 192, -192},
{ 712, 208, -112},
... |
{ 1064, 240, -168},
{ 1112, 216, -152},
{ 1288, 304, -240},
{ 1104, 312, -168},
{ 784, 336, -144},
{ 528, 256, -168},
{ 432, 208, -144},
{ 432, 240, -104},
{ 584, 232, -80},
{ 792, 288, -152},
// 21 seconds
{ 1040, 376, -184},
{ 1048, 432, -232},
{ 1064, 440, -24... |
{ 1288, 120, -256},
{ 1736, 568, -376},
{ 1528, 664, -592},
{ 984, 464, -336},
{ 1344, 576, -440},
{ 1208, 400, -344},
{ 1312, 408, -248},
{ 1528, 360, -64},
{ 1384, 200, -56},
{ 1120, 184, 16},
{ 1240, 216, -88},
{ 1416, 280, -40},
{ 1328, 240, -8},
{ 1248, 112,... | { 1136, 48, 176},
{ 1168, 32, 176},
{ 944, 88, 80},
{ 1280, -40, 288},
// 21 seconds
{ 1400, 256, -16},
{ 1368, -96, -112},
{ 1264, -8, 72},
{ 1112, 104, -176},
{ 832, -24, -312},
{ 912, 224, -360},
{ 1080, 296, -288},
{ 1184, 256, -248},
{ 1176, 384, -128},
{... |
{ 1152, 384, -216},
{ 1144, 376, -200},
{ 1328, 392, -136},
{ 1152, 264, -56},
{ 1008, 184, 8},
{ 1112, 216, -32},
{ 1296, 264, -64},
{ 1312, 264, 0},
{ 1192, 40, 168},
{ 1264, -64, 168},
{ 856, -16, 104},
{ 1168, 8, 112},
// 24 seconds
{ 1240, 248, 56},
{ 12... |
quality_string(hrm->bpm.quality));
layer_mark_dirty(&app_data->window.layer);
bpm = hrm->bpm.bpm;
bpm_quality = hrm->bpm.quality;
} else if (hrm->event_type == HRMEvent_LEDCurrent) {
led_current = hrm->led.current_ua;
} else if (hrm->event_type == HRMEvent_Diagnostics) {
if (!app_... | if (status_tuple) {
prv_handle_mobile_status_request(status_tuple->value->uint8);
} |
}
static void prv_message_sent_cb(DictionaryIterator *iterator, void *context) {
AppData *app_data = app_state_get_user_data();
app_data->ready_to_send = true;
}
static void prv_message_failed_cb(DictionaryIterator *iterator,
AppMessageResult reason, void *context) {
PBL_LOG(LOG... |
GRect(
0, frame.size.h - CONTENT_DOWN_ARROW_HEIGHT,
PBL_IF_RECT_ELSE(frame.size.w - action_bar_offset, frame.size.w),
CONTENT_DOWN_ARROW_HEIGHT) | );
layer_add_child(&window->layer, &expandable_dialog->content_down_arrow_layer);
content_indicator_configure_direction(
indicator, ContentIndicatorDirectionDown,
&(ContentIndicatorConfig) {
.layer = &expandable_dialog->content_down_arrow_layer,
.times_out = false... | |
le *file) {
printf("file max used space = %d\n", file->max_used_space);
printf("file max space total = %d\n", file->max_space_total);
printf("file used space = %d\n", file->used_space);
printf("file dead space = %d\n", file->dead_space);
}
void test_settings_file__compute_stats(void) {
printf("\nTesting if c... | (&file, "test_file_used_space_tracking", 4096) | );
uint8_t key[5];
int key_len = 4;
uint8_t val[5];
int val_len = 4;
// First, fill half the file up with random keys and values. This reduces
// our usable space to slightly less than 2048 bytes.
for (int i = 0; i < 128; i++) {
snprintf((char *)key, sizeof(key), "k%03d", i);
snprintf((char *)val... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (sizeof(FrameBuffer)) | ;
fb->size = (GSize) {DISP_COLS, DISP_ROWS};
}
// Teardown
void test_kino_reel__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void test_kino_reel__resource_gbitmap(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test loading GBitmap Kino Reel
uint32_t resource_... |
al_s(dstbuf, "There are 010 lights");
// Variable length digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.*xzero%.*x", -3, 0, -3, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Length modifiers
uint64_t hurf = 0x123456789ABCDEF0ULL;
snprintf(dstbuf, 256, "%hhx,%hx,%x,%lx", hurf, hurf, hu... | cl_assert_equal_s(dstbuf, "Hur f") | |
time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 12 H", time_buf);
// June 12th 2015, 00:00:01 (T-11:59:59)
rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) + 1);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 12 H", time_buf);
// June 12th... | clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | ;
cl_assert_equal_s("10 MIN AGO", time_buf);
// June 9th 2015, 12:10:00 (T+00:10:01)
rtc_set_time(event_time + (10 * SECONDS_PER_MINUTE) + 1);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("10 MIN AGO", time_buf);
// June 9th 2015, 12:10:30 (... |
= ARRAY_LENGTH(sessions);
activity_algorithm_post_process_sleep_sessions(session_entries, sessions);
cl_assert_equal_i(sessions[0].type, ActivitySessionType_Sleep);
cl_assert_equal_i(sessions[1].type, ActivitySessionType_RestfulSleep);
}
{ // Create a 2h 39m session that starts at 11:59pm ==> should ... | cl_assert_equal_i(steps_asleep_120m, steps_awake_120m - steps_awake_100m) | ;
}
// ---------------------------------------------------------------------------------------
// Test to make sure that the minute data we save has no steps during sleep
void test_activity_algorithm_kraepelin__minute_data_steps_during_sleep(void) {
const int num_minutes = 120;
// The test data
AlgMinuteDLSSam... |
ride s_comm_override = BtCtlModeOverrideNone;
static PebbleMutex *s_comm_state_change_mutex;
bool bt_ctl_is_airplane_mode_on(void) {
return s_comm_airplane_mode_on;
}
bool bt_ctl_is_bluetooth_active(void) {
if (s_comm_enabled) {
if (s_comm_override == BtCtlModeOverrideRun) {
return true;
} else if ... | {
PBL_LOG(LOG_LEVEL_ERROR, "Error: Bluetooth isn't initialized yet");
return;
} |
mutex_lock(s_comm_state_change_mutex);
s_comm_override = override;
mutex_unlock(s_comm_state_change_mutex);
prv_comm_state_change(NULL);
}
static void prv_track_quick_airplane_mode_toggles(bool is_airplane_mode_currently_on) {
// Track when coming out of airplane mode and we've gone into airplane mode less ... |
return;
}
const AppFetchUIArgs *const fetch_args = evt->fetch_args;
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = app_fetch_ui_get_app_info(),
.common.args = fetch_args,
.common.transition = fetch_args->common.transition,
.forcefully = fetch_args->forcefully,
});
}
// -------------... | if (size == NULL) {
return;
} |
if (!s_app_task_context.app_md) {
// No app has been started yet, so just use the default system size
*size = GSize(DISP_COLS, DISP_ROWS);
return;
}
// Platform matches current platform
const PlatformType sdk_platform =
process_metadata_get_app_sdk_platform(s_app_task_context.app_md);
if (... |
t_count((ListNode *)notifications_data->notification_list) + 1;
}
static int16_t prv_get_cell_height(struct MenuLayer *menu_layer, MenuIndex *cell_index,
void *data) {
#if PBL_ROUND
MenuIndex selected_index = menu_layer_get_selected_index(menu_layer);
bool is_selected = menu_ind... | (subtitle) | |
glyph_block_bits_left <= 0) {
src = *(++glyph_block);
glyph_block_bits_left += 32;
// Need to account for the dest_shift when loading up the new glyph block
rotl32(src, glyph_block_bits_left + dest_shift);
src_rotated = glyph_block_bits_left + dest_shift;
}
dest_bloc... | (src, dest_shift % 32) | ;
src_rotated = (src_rotated + dest_shift) % 32;
}
graphics_context_mark_dirty_rect(ctx, clipped_glyph_target);
}
void text_render_set_special_codepoint_cb(SpecialCodepointHandlerCb handler, void *context) {
TextRenderState *state = app_state_get_text_render_state();
state->special_codepoint_handler_cb =... |
o a spin function and tell the app manager to kill us.
prv_return_to_landing_zone(0, 0, stacked_args); // We can't get LR or PC, so just set to 0's.
}
static void attempt_handle_generic_fault(unsigned int* stacked_args) {
uintptr_t stacked_lr = (uintptr_t) stacked_args[5];;
uintptr_t stacked_pc = (uintptr_t) ... | {
PBL_LOG_FROM_FAULT_HANDLER("\r\n\r\n[BusFault_Handler!]");
prv_save_debug_registers(stacked_args);
char buffer[80];
fault_handler_dump(buffer, stacked_args);
PBL_LOG_FROM_FAULT_HANDLER("");
attempt_handle_generic_fault(stacked_args);
} | |
}
layer_set_frame((Layer *)&layer->day_separator, &day_sep_frame);
layer_set_hidden((Layer *)&layer->day_separator, false);
}
static void prv_place_end_of_timeline(TimelineLayer *timeline_layer) {
const bool was_hidden = layer_get_hidden((Layer *)&timeline_layer->end_of_timeline);
const bool is_hidden = (tim... | graphics_fill_rect(ctx, &(GRect) { .size = bounds->size }) | ;
AnimationProgress progress;
if (timeline_layer->animating_intro_or_exit &&
animation_get_progress(timeline_layer->animation, &progress)) {
const GPoint offset = { PEEK_ANIMATIONS_SPEED_LINES_OFFSET_X,
interpolate_int64_linear(progress, 0, -DISP_ROWS) };
graphics_context_... |
"PRIu8, event_blob.event,
event_blob.bt_connection_disconnection.reason);
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------------------------------------------------
// Log a bluetooth error
void analytics_event_bt_error(AnalyticsEvent type, uint3... | ANALYTICS_LOG_DEBUG("Event %d - AMS: type:%d aux_info: %"PRId32, event_blob.event, type, aux_info) | |
file();
if (rv != S_SUCCESS) {
return;
}
AppDBEntry *db_entry = kernel_malloc_check(sizeof(AppDBEntry));
EnumerateData cb_data = {
.cb = cb,
.data = data,
.entry_buf = db_entry,
};
settings_file_each(&s_app_db.settings_file, prv_enumerate_entries, &cb_data);
prv_close_file_and_unlock_mu... | if (app_fetch_in_progress()) {
PBL_LOG(LOG_LEVEL_WARNING, "Tried to delete an app that is currently being fetched, %"PRId32,
app_id);
rv = prv_cancel_app_fetch(app_id);
} |
if (rv == S_SUCCESS) {
rv = settings_file_delete(&s_app_db.settings_file, (uint8_t *)&app_id, sizeof(AppInstallId));
}
prv_close_file_and_unlock_mutex();
if (rv == S_SUCCESS) {
// uuid will be free'd by app_install_manager
Uuid *uuid_copy = kernel_malloc_check(sizeof(Uuid));
memcpy(uuid_cop... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_ASSERTN(cell_index->row < ARRAY_LENGTH(s_tests));
menu_cell_title_draw(ctx, cell_layer, s_tests[cell_index->row]->name);
} |
static void prv_click_handler(struct MenuLayer *menu_layer, MenuIndex *cell_index,
void *callback_context) {
PBL_ASSERTN(cell_index->row < ARRAY_LENGTH(s_tests));
prv_start_test(s_tests[cell_index->row], (AppData *)callback_context);
}
static void prv_handle_results_click(ClickRecog... |
s(void) {
prv_disable_chip_select();
prv_disable_display_spi_clock();
}
//! Write a single byte synchronously to the display. This is the only practical
//! way to write to the display in the bootloader since we don't have interrupts.
static void prv_display_write_byte(uint8_t d) {
// Block until the tx buffer i... | (DISP_GPIO, DISP_PIN_LCD, Bit_SET) | ;
prv_setup_pulse_vcom();
// Don't need the GPIO peripheral clocks to be enabled anymore
gpio_release(PWR_CTL_GPIO);
gpio_release(DISP_GPIO);
}
// Clear-all mode is entered by sending 0x04 to the panel
void display_clear(void) {
prv_enable_display_access();
prv_display_write_byte(DISP_MODE_CLEAR);
prv... |
/*
* 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_handle_action(StationaryActionEnableStationary) | ;
} else {
prv_handle_action(StationaryActionDisableStationary);
}
}
void stationary_handle_battery_connection_change_event(void) {
PBL_LOG_D(DEBUG_STATIONARY, LOG_LEVEL_DEBUG,
"Stationary mode battery state change event received");
if (battery_is_usb_connected()) {
analytics_event_stationa... |
endif
}
static void prv_int_exti_cb(bool *should_context_switch) {
// The controller responded -- stop the watchdog.
prv_watchdog_stop();
switch (s_spi_transport.state) {
case SPITransportState_Idle:
// If the RX buffer is full, defer ack'ing the Dialog INT until we have
// some room to actually... | (LOG_LEVEL_INFO, "Skipping host transport enqueue .. waiting for reset") | ;
return HostTransportEnqueueStatus_Failure;
}
PBL_ASSERTN(length < HOST_TRANSPORT_HOST_TX_BUFFER_SIZE &&
length < HOST_TRANSPORT_CTLR_RX_BUFFER_SIZE);
prv_lock();
bool success = circular_buffer_write(&s_spi_transport.tx, data, length);
prv_unlock();
if (success) {
prv_indicate_has_... |
/*
* 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... | QSPI_ComConfig_StructInit(&qspi_com_config) | ;
qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;
qspi_com_config.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_1Line;
qspi_com_config.QSPI_ComConfig_Ins = MX25UCommand_QSPIEnable;
QSPI_ComConfig_Init(&qspi_com_config);
prv_wait_for_qspi_transfer_complete(QSPIFlag_ClearTC);
prv_w... |
ted_msg = s_msg.msg_arr[s_msg.curr_msg_idx - 1];
}
s_msg.curr_msg_idx++;
s_msg.num_processed++;
return (expected_msg);
}
static bool prv_flash_log_line_dump(uint8_t *msg, uint32_t tot_len) {
char buf[tot_len + 1];
memcpy(&buf, (char*)msg, tot_len);
buf[tot_len] = '\0';
// printf("-%s\n", buf);
char ... | test_flash_logging_get_info(&tot_size, &erase_size, &page_size,
&page_hdr_size) | ;
int num_pages = tot_size / page_size;
uint32_t space_avail = tot_size - num_pages * page_hdr_size;
// make sure the logs are of an appropriate size such that each page will
// be entirely filled
int log_len = 2;
cl_assert((page_size - page_hdr_size) % (2 + log_len) == 0);
// fill up all of our log r... |
ayout);
compare_attr_list(a->attr_list, b->attr_list);
cl_assert_equal_i(a->action_group.num_actions, b->action_group.num_actions);
for (int i = 0; i < a->action_group.num_actions; i++) {
cl_assert_equal_i(a->action_group.actions[i].id, b->action_group.actions[i].id);
cl_assert_equal_i(a->action_group.act... | compare_notifications(&e, &r) | ;
free(r.allocated_buffer);
notification_storage_remove(&i);
cl_assert_equal_b(notification_storage_get(&i, &r), false);
}
void test_notification_storage__set_actioned_flag(void) {
Uuid i;
uuid_generate(&i);
TimelineItem e = {
.header = {
.id = i,
.type = TimelineItemTypeNotification,
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kernel_malloc_check(buffer_size) | ;
circular_buffer_init(&s_circular_buffer, s_reports_buffer, buffer_size);
s_is_scanning = true;
}
}
}
bt_unlock();
return success;
}
// -----------------------------------------------------------------------------
bool gap_le_stop_scan(void) {
bool success = false;
bt_lock();
{
... |
orners
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 0, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r0_aa_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, OR... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1) | ;
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, 0, GCornersAll);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_origin_r0_aa_clip_xy.${BIT_DEPTH_NAME}.pbi"));
// TODO: Remove these #ifdefs in PBL-15916 when support for non-antialiased rounded rect
#if SCREEN_COLOR_DEPTH_BITS == 8
setup_test_aa_... |
= false, .steps = 3},
},
},
};
// pass time that's not exactly on a boundary
time_t time_start = now - 10 * SECONDS_PER_MINUTE - 30;
time_t time_end = now - 20;
written = health_service_get_minute_history(data, ARRAY_LENGTH(data), &time_start, &time_end);
cl_assert_equal_i(3, written);
cl_asse... | (1, s_sys_activity_get_metric_values.in.history_len) | ;
cl_assert_equal_i(ActivityMetricSleepExitAtSeconds, s_sys_activity_get_metric_values.in.metric);
}
// Test that health_service_sum_averaged() returns the correct result when asked to get the
// average daily value of a metric
void test_health__avg_full_days(void) {
// Get the current time and day
const time_t ... |
tc_time);
// Reset the last ticks counter so we don't rollover prematurely.
// This value will be set to non-zero if anyone asked for the tick count
// before this point.
s_last_ticks = 0;
// Refresh the saved time so it's more current.
save_rtc_time_state_exact(TICKS_IN_AN_INTERVAL - (RTC_TICKS_HZ - (bef... | (alarm_expiry_time, &days, &hours, &minutes, &seconds) | ;
(void) days; // Don't care about days.
alarm_config.RTC_AlarmTime.RTC_Hours = hours;
alarm_config.RTC_AlarmTime.RTC_Minutes = minutes;
alarm_config.RTC_AlarmTime.RTC_Seconds = seconds;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &alarm_config);
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
RTC_AlarmCmd(RTC_Alarm_... |
/////////////////////////////
#define SPRF_REGION_SIZE (FLASH_REGION_SHARED_PRF_STORAGE_END - \
FLASH_REGION_SHARED_PRF_STORAGE_BEGIN)
#define SPRF_NUM_PAGES (SPRF_REGION_SIZE / sizeof(SharedPRFData))
#define SPRF_PAGE_FLASH_OFFSET(idx) (FLASH_REGION_SHARED_PRF_STORAGE_BEGIN + \
... | for (uint32_t i = 0; i < ARRAY_LENGTH(page_idx); i++) {
fake_spi_flash_erase();
// Invalidate all entries before it to simulate logging style
for (uint32_t j = 0; j < page_idx[i]; j++) {
SprfMagic inv_magic = SprfMagic_InvalidatedEntry;
flash_write_bytes((uint8_t *) &inv_magic, SPRF_PAGE_FLASH_... |
// Erase the entire region and test that it picks the first empty page
fake_spi_flash_erase();
shared_prf_storage_init();
cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 0);
// Test that it sees all pages are invalid, rewrites everything, and picks the first empty page
prv_fill_flash_random... |
erminate state.
// - written: The typical state for a record. == !partially_written
// - partially_overwritten: This record has been superceeded by another, which
// we are currently in the process of writing out to flash. Records in
// this state are restored on bootup.
// - overwritten: This record has been s... | (&new_file.iter) | ;
}
kernel_free(key);
kernel_free(val);
}
settings_file_close(file);
// We have to close and reopen the new_file so that it's temp flag is cleared.
// Before the close succeeds, if we reboot, we will just end up reading the
// old file. After the close suceeds, we will end up reading the new
// ... |
now - timestamp);
return E_INVALID_OPERATION;
}
// FIXME: PBL-39523 timeline_item_storage_insert modifies a const buffer
// Invert flags & status to store on flash
hdr->common.flags = ~hdr->common.flags;
hdr->common.status = ~hdr->common.status;
mutex_lock(storage->mutex);
status_t rv = settings... | kernel_malloc_check(info->val_len) | |
-304, -120, -208},
{ -336, 312, -392},
{ -808, 72, -272},
{ -864, 288, -384},
{ -1016, -24, -344},
{ -1032, 184, -584},
{ -1128, 256, -544},
{ -1104, -8, -256},
{ -1632, 424, -624},
{ -1104, 112, -216},
{ -1064, 224, -224},
{ -976, 392, -280},
{ -720, 80, -8},
{ -568... | { -1888, 584, -608},
{ -1104, -56, -192},
{ -976, 136, -304},
{ -880, 24, -112},
{ -616, -8, -8},
{ -616, 152, -24},
{ -760, 152, 0},
// 70 seconds
{ -992, 376, -48},
{ -1136, 48, 24},
{ -944, 152, -112},
{ -1088, 64, -144},
{ -1048, 144, 0},
{ -1192, 184, -176},
... | |
"
static int s_num_dnd_events_put = 0;
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Fakes
bool system_task_add_callback(SystemTaskEventCallback cb, void *data) {
cb(data);
return true;
}
void event_put(PebbleEvent* event) {
s_num_dnd_events_put++;
}
... | prv_assert_manually_dnd_setting_val(true) | ;
cl_assert_equal_i(s_num_dnd_events_put, 1);
do_not_disturb_set_manually_enabled(false);
enabled = do_not_disturb_is_manually_enabled();
cl_assert(do_not_disturb_is_active() == false);
cl_assert(enabled == false);
prv_assert_manually_dnd_setting_val(false);
cl_assert_equal_i(s_num_dnd_events_put, 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... | health_card_view_mark_dirty(health_app_data->health_card_view) | ;
}
// Activity change callback
static void prv_health_service_event_handler(HealthEventType event, void *context) {
HealthAppData *health_app_data = context;
if (event == HealthEventMovementUpdate) {
const uint32_t steps_today = health_service_sum_today(HealthMetricStepCount);
health_data_update_steps(hea... |
he second half
static int16_t prv_interpolate_two_ways(AnimationProgress normalized_progress, int16_t end) {
const int16_t from = s_data.is_first_half ? 0 : -end;
const int16_t to = s_data.is_first_half ? end : 0;
return interpolate_int16(normalized_progress, from, to);
}
// Draws the shutters based on the path ... | prv_move_in(ctx, draw_shutter ? movement_size : -movement_size, progress, direction_vertical) | ;
} else {
prv_draw_in(ctx, s_small_movement_size, progress, direction_vertical,
/*invert*/ draw_shutter ? direction_vertical : true);
}
// We don't draw a shutter during the Down or Left transitions
if (draw_shutter && direction_negative) {
prv_draw_shutter(ctx, progress, direction_ver... |
ssert_equal_i(s_data.pins_added, 2);
cl_assert(uuid_equal(&orig_id, &s_last_timeline_id));
// Make sure we don't trigger again for the same sleep session
s_data.metric_history[ActivityMetricSleepStateSeconds][0] = 60 * SECONDS_PER_MINUTE;
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_... | rtc_get_time() | );
cl_assert_equal_i(s_data.pins_added, 1);
// Make sure we still merge properly after a power cycle
activity_insights_init(rtc_get_time());
rtc_set_time(rtc_get_time() + 2 * SECONDS_PER_HOUR);
prv_add_sleep_session(0.5, 1.5);
activity_insights_process_sleep_data(rtc_get_time());
cl_assert_equal_i(s_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... | crc_calculate_incremental_remaining_bytes(data + (num_words * 4), num_remaining_bytes) | ;
crc_calculate_incremental_stop();
return (res);
}
uint32_t crc_calculate_flash(uint32_t address, unsigned int num_bytes) {
crc_calculate_incremental_start();
const unsigned int chunk_size = 128;
uint8_t buffer[chunk_size];
while (num_bytes > chunk_size) {
flash_read_bytes(buffer, address, chunk_si... |
evice) {
return gap_le_connection_get_gatt_mtu(&device);
}
DEFINE_SYSCALL(BTErrno, sys_ble_client_read, BLECharacteristic characteristic) {
return gatt_client_op_read(characteristic, GAPLEClientApp);
}
DEFINE_SYSCALL(bool, sys_ble_client_get_notification_value_length,
BLECharacteristic *chara... | DEFINE_SYSCALL(BTErrno, sys_ble_client_read_descriptor, BLEDescriptor descriptor) | {
return gatt_client_op_read_descriptor(descriptor, GAPLEClientApp);
}
// -----------------------------------------------------------------------------
// ble_service.h
DEFINE_SYSCALL(uint8_t, sys_ble_service_get_characteristics, BLEService service_ref,
BLECharacteristic... |
/*
* 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_text_instructions, "Press select to start 5s wakeup") | |
/*
* 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(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3) | ;
cl_assert(raw_image_get_value_for_bitdepth(test2, 5, 0, 2, 2) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 1, 1, 2, 8) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 0, 1, 3, 8) == 3);
cl_assert(raw_image_get_value_for_bitdepth(test2, 1, 1, 1, 2) == 3);
cl_assert(raw_image_get_value_fo... |
360) / TRIG_MAX_ANGLE;
if (act_ang > 180) {
roll = roll - TRIG_MAX_ANGLE;
}
int32_t pitch = atan2_lookup(-d->x,
(d->y * sin_lookup(roll) + d->z * cos_lookup(roll)) / TRIG_MAX_RATIO);
// solution repeats every 180 degrees
if (pitch > (TRIG_MAX_ANGLE / 4)) { // > 90 degrees
if (pitch < ((270 * T... | PBL_ASSERTN(s_accel_session == NULL) | ;
s_accel_session = accel_session_create();
accel_session_raw_data_subscribe(s_accel_session, ACCEL_SAMPLING_25HZ, 5,
prv_accel_for_compass_handler);
mag_start_sampling();
}
PBL_LOG(LOG_LEVEL_DEBUG, "subscribers %"PRIu8, s_compass_subscribers_count);
}
///////////... |
actionable_dialog_create("Custom Actionable Dialog");
Dialog *dialog = actionable_dialog_get_dialog(actionable_dialog);
dialog_set_text(dialog, "Custom Actionable Dialog");
dialog_set_background_color(dialog, GColorRed);
dialog_set_icon(dialog, data->resource_id_80);
// Create custom action bar for the dialo... | {
ExpandableDialog *expandable_dialog = expandable_dialog_create("Expandable Dialog");
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_text(dialog, data->lorem_ipsum);
dialog_set_background_color(dialog, GColorLightGray);
dialog_set_icon(dialog, data->resource_id_25);
dialog_sho... |
////////////////////////////////
// Expandable Dialog with icon
static void prv_show_expandable_dialog_no_icon(DialogsData *data) {
ExpandableDialog *expandable_dialog = expandable_dialog_create("Expandable Dialog");
Dialog *dialog = expandable_dialog_get_dialog(expandable_dialog);
dialog_set_text(dialog, data-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.