prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
= center;
gdraw_command_draw(NULL, command);
cl_assert_equal_i(s_stroke_color.argb, GColorGreenARGB8);
cl_assert_equal_i(s_fill_color.argb, GColorOrangeARGB8);
cl_assert_equal_i(s_stroke_width, 1);
cl_assert_equal_i(s_path_num_points, 1);
cl_assert_equal_b(s_radius, 300);
cl_assert_equal_i(s_circle_fill... | gdraw_command_set_hidden(command, true) | |
nal, and b)
// we can't be sure that the host isn't still clocking out data from the previous command.
// Shift incoming data through a pattern buffer. When we get a match, send our response.
static bool prv_initial_handshake(void) {
uint8_t rx_index = 0;
uint8_t tx_index = 0;
uint8_t buffer[sizeof(core_dump_conn... | hw_spi_write_buf(s_spi->bus_id, (void *)&crc, sizeof(crc), prv_spi_dma_tx_cb, NULL) | |
ell
int list_idx = 1;
while (cur_node) {
if (cur_node->id == id) {
return list_idx;
}
list_idx++;
cur_node = (AlarmNode* )list_get_next((ListNode*) cur_node);
}
return 0;
}
static void prv_update_menu_layer(AlarmsAppData* data, AlarmId select_alarm) {
MenuIndex selected_menu_index = {... | graphics_text_layout_get_max_used_size(ctx, text, font, box,
GTextOverflowModeTrailingEllipsis,
GTextAlignmentCenter, NULL) | ;
grect_align(&box, &cell_layer->bounds, GAlignCenter, true /* clip */);
box.origin.y -= fonts_get_font_cap_offset(font);
graphics_draw_text(ctx, text, font, box,
GTextOverflowModeFill, GTextAlignmentCenter, NULL);
return;
} else { // "add al... |
;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
cl_assert_equal_i(s_num_alarm_events_put, 1);
cl_assert_equal_i(s_num_timeline_adds, 8);
cl_assert_equal_i(s_num_timeline_removes, 4);
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
// Second alarm goes o... | (s_num_timeline_removes, 3) | ;
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm__custom_alarm_everyday(void) {
AlarmId id1;
bool schedule_1[7] = {true, true, true, true, true, true, true};
id1 = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_CUSTOM, .scheduled_da... |
/*
* 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... | (result, sizeof(*result)) | ;
}
return localtime_r(timep, result);
}
//! System call to exit an application gracefully.
DEFINE_SYSCALL(NORETURN, sys_exit, void) {
process_manager_task_exit();
}
DEFINE_SYSCALL(void, sys_psleep, int millis) {
vTaskDelay(milliseconds_to_ticks(millis));
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return NULL;
} |
void alarm_set_snooze_delay(int delay_ms) {
}
const void* const g_pbl_system_tbl[] = {};
const FileResourceData g_file_resource_stores[] = {};
const uint32_t g_num_file_resource_stores = 0;
void persist_service_client_open(const Uuid *uuid) {
}
void persist_service_client_close(const Uuid *uuid) {
}
SettingsFile... |
/*
* 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... | hrs_notify_measurement(&s_hrs.svc, gap_device->conn_idx, &hrs_measurement) | ;
}
}
}
}
void hrm_service_handle_enable(bool enable) {
if (s_is_hrm_enabled == enable) {
return;
}
PBL_LOG(LOG_LEVEL_DEBUG, "hrm_service_handle_enable %u", enable);
s_is_hrm_enabled = enable;
if (enable) {
hrm_service_register(HRM_SERVICE_EXPECTED_ATT_STARTING_HANDLE);
service_chang... |
pe = PEBBLE_APP_FETCH_EVENT,
.app_fetch = {
.type = AppFetchEventTypeProgress,
.id = s_fetch_state.app_id,
.progress_percent = percent,
}
};
event_put(&event);
}
//! Simply posts the type of event given.
static void prv_put_event_simple(AppFetchEventType type) {
PebbleEvent event = {
... | app_cache_add_entry(s_fetch_state.app_id, s_fetch_state.total_size) | ;
if (added == S_SUCCESS) {
const PebbleProcessMd *md = app_install_get_md(s_fetch_state.app_id, false);
if (rocky_app_validate_resources(md) == RockyResourceValidation_Invalid) {
PBL_LOG(LOG_LEVEL_ERROR, "Received app contains invalid JS bytecode");
prv_put_event_error(AppFetchResultInc... |
P_SLEEP);
flash_end_cmd();
// guarantee we have actually transitioned to deep sleep
delay_us(5);
s_flash_state.deep_sleep = true;
}
}
static void flash_deep_sleep_exit(void) {
assert_usable_state();
if (s_flash_state.deep_sleep) {
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD... | ("Detected SPI Flash Size: %u bytes", flash_get_size()) | ;
}
void flash_stop(void) {
if (s_flash_state.mutex == NULL) {
return;
}
flash_lock();
s_flash_state.enabled = false;
flash_unlock();
}
void flash_read_bytes(uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
assert_usable_state();
flash_lock();
... |
/*
* 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... | analytics_set(ANALYTICS_APP_METRIC_FLASH_READ_BYTES_COUNT, analytics_read_bytes_count, AnalyticsClient_App) | ;
analytics_set(ANALYTICS_APP_METRIC_FLASH_WRITE_BYTES_COUNT, analytics_write_bytes_count, AnalyticsClient_App);
// The overhead cost of tracking whether each flash read was due to the foreground
// or background app is large, so the best we can do is to attribute to both of them
if (worker_manager_get_current... |
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_timeline_peek__peek_title_only_concurrent_1(void) {
prv_render_timeline_peek(&(TimelinePeekItemConfig) {
.title = "No Watch No Life",
.icon = TIMELINE_RESOURCE_DAY_SEPARATOR,
.num_concurrent = 1,
});
cl_check(gbitmap_pbi_eq(s_dest_... | cl_assert(layer->frame.origin.y >= DISP_ROWS) | ;
// Peek service shows the peek UI using the animated code path.
TimelineItem *item = prv_set_timeline_item(&(TimelinePeekItemConfig) {
.title = "CoreUX Design x Eng",
.subtitle = "ConfRM-Missile Command",
.icon = TIMELINE_RESOURCE_TIMELINE_CALENDAR,
.num_concurrent = 0,
}, true /* animated */);... |
rectionRight,
GColorWhite);
}
void test_graphics_window_stack_animation__right_flip_first_quarter_frame_clipping(void) {
prv_test_clipping_mask(prv_right_flip_first_quarter_frame_clipping,
"right_flip_first_quarter_frame_clipping");
}... | gbitmap_pbi_eq(bitmap, TEST_NAMED_PBI_FILE("move_horizontal_left_filled")) | );
free(ctx);
}
|
_delete_cb(void *context) {
s_deferred_delete_queued = false;
mutex_lock(s_attr_list_lock);
SmartstrapAttributeInternal *attr = s_attr_head;
while (attr) {
SmartstrapAttributeInternal *next = NEXT_ATTR(attr);
if (attr->deferred_delete) {
list_remove(&attr->list_node, (ListNode **)&s_attr_head, NUL... | {
syscall_assert_userspace_buffer(attribute_id, sizeof(uint16_t));
} |
if (length) {
syscall_assert_userspace_buffer(length, sizeof(size_t));
}
}
if (service_id) {
*service_id = attr->service_id;
}
if (attribute_id) {
*attribute_id = attr->attribute_id;
}
if (length) {
*length = mbuf_get_length(&attr->mbuf);
}
}
DEFINE_SYSCALL(SmartstrapResult, sy... |
e "syscall/syscall_internal.h"
#include "system/passert.h"
#include "system/status_codes.h"
#include "util/math.h"
//! Return true to continue iteration and false to stop it.
typedef bool (*SliceForEachCb)(AppGlanceSliceInternal *slice, void *context);
static void prv_slice_for_each(AppGlance *glance, SliceForEachCb ... | event_service_client_subscribe(&s_blob_db_event_info) | ;
static EventServiceInfo s_app_cache_event_info = {
.type = PEBBLE_APP_CACHE_EVENT,
.handler = prv_handle_app_cache_event,
};
event_service_client_subscribe(&s_app_cache_event_info);
}
bool app_glance_service_get_current_slice(const Uuid *app_uuid, AppGlanceSliceInternal *slice_out) {
if (!slice_out)... |
int i2 = (i + 1) % path->num_points;
GPoint rot_start = rotate_offset_point(&path->points[i], path->rotation, &path->offset);
GPoint rot_end = rotate_offset_point(&path->points[i2], path->rotation, &path->offset);
graphics_draw_line(ctx, rot_start, rot_end);
}
}
void gpath_rotate_to(GPath *path, int3... | if (rot_end.y.integer != rot_start.y.integer) {
start_is_down = rot_end.y.integer > rot_start.y.integer;
found_start_direction = true;
} |
rot_end = rot_start;
}
const int16_t clip_min_x = ctx->draw_state.clip_box.origin.x
- ctx->draw_state.drawing_box.origin.x;
const int16_t clip_max_x = ctx->draw_state.clip_box.size.w + clip_min_x;
if (!prv_is_in_range(min_x, max_x, clip_min_x, clip_max_x)) {
goto cleanup;
}
// x-intersecti... |
/*
* 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... | FLASH_Lock() | ;
return false;
}
if (progress_callback && i % 128 == 0) {
progress_callback(i/128, length/128, progress_context);
}
}
FLASH_Lock();
return true;
}
uint32_t system_flash_read(uint32_t address) {
uint32_t data = *(volatile uint32_t*) address;
return 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... | framebuffer_clear(s_framebuffer) | ;
if (s_pixels) {
gbitmap_destroy(s_pixels);
}
s_pixels = gbitmap_create_blank(size, GBITMAP_NATIVE_FORMAT);
memset(s_pixels->addr, 0xff, size.h * s_pixels->row_size_bytes);
s_context.dest_bitmap = *s_pixels;
s_context.draw_state.clip_box = (GRect){.size = size};
s_context.draw_state.drawing_box = s_c... |
otalSeconds, 1, &sleep_total_seconds);
// If this is a session we've already created a pin for, send the notification for it now if
// we haven't already.
if (sleep_exit_utc <= s_sleep_pin_state.last_triggered_utc) {
// Notify about the sleep pin
prv_do_sleep_notification(now_utc, sleep_exit_utc, sleep_t... | (¬if_attr_list, AttributeIdHeadings, config->headings) | |
pen=%d, destination=%s, app_uuid=%s",
is_open, prv_string_for_destination(session->destination), uuid_string);
}
static bool prv_is_transport_type(Transport *transport,
const TransportImplementation *implementation,
CommSessionTransportType ... | (false, is_system) | ;
if (is_system && (session->destination == TransportDestinationHybrid)) {
prv_put_comm_session_event(true, false);
}
// Cleanup:
comm_session_receive_router_cleanup(session);
comm_session_send_queue_cleanup(session);
list_remove(&session->node, (ListNode **) &s_session_head, NULL);
kernel_free(sess... |
www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permission... | (success, length) | ) {
smartstrap_connection_got_valid_data();
}
smartstrap_state_unlock();
// If we are connected, kick the connection monitor right away. Otherwise, just let it wake up
// itself based on its own timer. This prevents us spamming the smartstrap with connection
// requests.
if (smartstrap_is_connected()) {... |
_bottom - center.y.integer, 0);
int draw_min_top = MAX(center.y.integer - adjusted_bottom, 0);
// In case of odd line, center is with half pixel so we have to subtract one more more full line
int draw_min_bottom = MAX(adjusted_top - center.y.integer - 1, 0);
// Apply clipped distances
draw_max = MIN(draw_max... | (ctx, center.y.integer, left, right,
starting_edge, ending_edge, ignore_close_angles) | ;
}
// After drawing the line we move scanline edge calculation offset
y.integer++;
} else {
// If theres no line in the middle, we move edge calculation offset by half (to stay
// in the middle of the pixel) and change bottom offset to zero (to evenly mirror lines)
y.fraction = 4;
spec... |
duty_cycle_low = 2;
duty_cycle_high = 1;
} else {
WTF; // It might be possible to encode a duty cycle differently from the legacy I2C, if it's
// ever necessary. Currently it's not, so just maintain the previous implementation
}
}
RCC_ClocksTypeDef rcc_clocks;
RCC_GetClocksFreq(&... | {
// For writes, we'll reload with the payload once we send the address. Otherwise, we'd need to
// send a repeated start, which we don't want to do.
const bool reload = bus->state->transfer.direction == I2CTransferDirection_Write;
bus->hal->i2c->CR2 = (bus->state->transfer.device_address & I2C_CR2_SADD... | else {
prv_resume_transfer(bus, true /* generate_start */);
}
}
/*------------------------INTERRUPT FUNCTIONS--------------------------*/
static void prv_end_transfer_irq(I2CBus *bus, I2CTransferEvent event) {
prv_disable_all_interrupts(bus);
// Generate stop condition
bus->hal->i2c->CR2 |= I2C_CR2_STOP;... |
graphics_draw_text.last_call.draw_text.text,
text, sizeof(s_graphics_draw_text.last_call.draw_text.text));
}
static MockCallRecordings s_graphics_text_attributes_destroy;
void graphics_text_attributes_destroy(GTextAttributes *text_attributes) {
record_mock_call(s_graphics_text_attributes_destroy){};
}
sta... | (true, rocky_global_has_event_handlers("draw")) | ;
}
void test_rocky_api_graphics__draw_event_has_ctx(void) {
rocky_global_init(s_graphics_api);
EXECUTE_SCRIPT(
"var event = null;\n"
"_rocky.on('draw', function(e) {event = e;});"
);
const jerry_value_t event_null = prv_js_global_get_value("event");
cl_assert_equal_b(true, jerry_value_is_null(even... |
(ctx, &line) | ;
// Top Notch for Bar 2
// Filled rect used to draw line of REL_BAR_LINE_WIDTH stroke width
line2.origin.x = line.origin.x - REL_BAR_LINE_NOTCH_HORIZ_OFFSET + 1;
line2.origin.y = line.origin.y;
line2.size.w = REL_BAR_LINE_CHECK_LENGTH + REL_BAR_LINE_WIDTH;
line2.size.h = REL_BAR_LINE_WIDTH;
graphics_fil... | |
int32_t sign_extend(uint32_t a, int bits) {
if (bits == 32) {
return a;
}
// http://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend
int const m = 1U << (bits - 1); // mask can be pre-computed if b is fixed
a = a & ((1U << bits) - 1); // (Skip this if bits in x above position b are alrea... | {
return "no";
} |
}
// Override libgcc's table-driven __builtin_popcount implementation
#ifdef __arm__
int __popcountsi2(uint32_t val) {
// Adapted from http://www.sciencezero.org/index.php?title=ARM%3a_Count_ones_%28bit_count%29
uint32_t tmp;
__asm("and %[tmp], %[val], #0xaaaaaaaa\n\t"
"sub %[val], %[val], %[tmp], lsr... |
d button_id, uint16_t repeat_interval_ms, ClickHandler handler) {}
// Internal definitions
////////////////////////////////////
extern bool prv_scroll_layer_is_paging_enabled(ScrollLayer *scroll_layer);
extern void prv_scroll_layer_set_content_offset_internal(ScrollLayer *scroll_layer, GPoint offset);
extern uint16_t ... | cl_assert_equal_i(page_height, -((int32_t)scroll_layer_get_content_offset(scroll_layer).y)) | ;
}
void test_scroll_layer__paging_last_pages_content(void) {
uint16_t page_height = 86;
ScrollLayer *scroll_layer = scroll_layer_create(GRect(0,0,180,page_height));
// validate enable paging works for paging height
scroll_layer_set_paging(scroll_layer, true);
cl_assert_equal_i(page_height, prv_scroll_layer... |
ame->size.w - UNFOLD_DOT_SIZE_PX) / 2,
.origin.y = layer_frame->origin.y + (layer_frame->size.h - UNFOLD_DOT_SIZE_PX) / 2,
.size = UNFOLD_DOT_SIZE,
};
#elif ANIMATION_SLIDE
GRect icon_frame;
TimelineLayout *first_timeline_layout = timeline_layer_get_current_layout(&data->timeline_layer);
if (first_timel... | prv_create_peek_exit_anim(data, prev_state, duration) | ;
// Just play them at the same time
animation_schedule(sidebar_slide);
if (peek_anim) {
animation_schedule(peek_anim);
}
#endif
}
static void prv_inactive_timer_callack(void *data) {
prv_set_state(data, TimelineAppStateInactive);
prv_exit(data);
}
static void prv_inactive_timer_refresh(TimelineAppDa... |
ize.w, frame.size.h));
text_layer_set_background_color(&data->text_layer, GColorWhite);
text_layer_set_text_color(&data->text_layer, GColorBlack);
text_layer_set_text(&data->text_layer, text_buffer);
GFont gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
text_layer_set_font(&data->text_layer, ... | layer_init(&data->canvas, &GRect(40, 40, data->canvas_size.w, data->canvas_size.h)) | ;
layer_add_child(&data->window.layer, &data->canvas);
// Init text layer
init_text_layer(data, GRect(4, 4, 72, 32));
// Init direction layer
text_layer_init(&data->direction_layer, &GRect(5, 100, 135, 20));
text_layer_set_background_color(&data->direction_layer, GColorWhite);
text_layer_set_text_color(... |
ECTOR_TABLE[0] (main stack pointer)
// PSP = Unknown (process stack pointer)
// LR = 0xFFFFFFFF
// PC = VECTOR_TABLE[1]
// PRIMASK = 0x0
// FAULTMASK = 0x0
// BASEPRI = 0x0
// CONTROL = 0x0
//
// Attempt to put the processor into as close to the reset state as possible
... | ("Hold down UP + BACK for 5 secs. to force-boot PRF") | ;
for (int i = 0; i < 5000; ++i) {
if (!(button_is_pressed(BUTTON_ID_UP) && button_is_pressed(BUTTON_ID_BACK))) {
// stop waiting if not held down any longer
return false;
}
delay_ms(1);
}
return true;
}
void *reset_vector, *initial_sp;
prv_get_fw_reset_vector(&rese... |
ding error from breaking the scanline when angles are on same side but
// in reversed order (scanline first hits end angle then hits start angle
const bool ignore_close_angles = (angle_end - angle_start > (TRIG_MAX_ANGLE / 2));
// Clipping insets to prevent negative values
radius_inner_x.raw_value = MAX(radi... | (adjusted_bottom, clip_box.origin.y + clip_box.size.h) | ;
// Remove offset from adjusted values
adjusted_top -= ctx->draw_state.drawing_box.origin.y;
adjusted_bottom -= ctx->draw_state.drawing_box.origin.y;
// Calculate distances from the middle of the circle (discard negative values)
int draw_max_top = MAX(center.y.integer - adjusted_top, 0);
int draw_max_bot... |
/*
* 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... | GRect(0, 0, 300, 400) | );
// keeps size in sync
layer_set_frame(&l, &GRect(10, 20, 200, 500));
cl_assert_equal_grect(l.bounds, GRect(0, 0, 200, 500));
// act as 2.x once bounds.origin is different from (0, 0)
layer_set_bounds(&l, &GRect(1, 1, 200, 500));
layer_set_frame(&l, &GRect(10, 20, 100, 600));
cl_assert_equal_grect(l.b... |
/*
* 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... | (size_t, sys_resource_size, ResAppNum app_num, uint32_t resource_id) | |
(LOG_LEVEL_WARNING, "no readers") | ;
return false;
}
// If this is bigger than the queue would allow, error
if (length >= buffer->buffer_size) {
return false;
}
// Make sure there's room, deleting bytes from slackers if requested
SharedCircularBufferClient *slacker;
uint32_t max_data = prv_get_max_data_length(buffer, &slacker);
... | |
(md)) {
PBL_LOG(LOG_LEVEL_WARNING, "Tried to launch an app with an unsupported SDK version.");
AppInstallEntry entry;
if (!app_install_get_entry_for_install_id(id, &entry)) {
// can't retrieve app install entry for id
PBL_LOG(LOG_LEVEL_ERROR, "Failed to get entry for id %"PRId32, id);
... | prv_get_context_for_task(task) | ;
// If already safe to kill, we're done
if (context->safe_to_kill) {
prv_handle_app_stop_analytics(context, task, gracefully);
return true;
}
PBL_LOG(LOG_LEVEL_DEBUG, "make %s process safe to kill: state %u", pebble_task_get_name(task),
context->closing_state);
if (gr... |
ext));
cl_assert(!has_next);
cl_assert_equal_i(timeline_model_get_num_items(), 1);
cl_assert(uuid_equal(&s_items[s_correct_order[4]].header.id,
&timeline_model_get_iter_state(-1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[5]].header.id,
&timeline_model_get_iter_state(0)->pin.hea... | cl_assert(uuid_equal(&s_items[s_correct_order[0]].header.id,
&timeline_model_get_iter_state(0)->pin.header.id)) | ;
cl_assert(uuid_equal(&s_items[s_correct_order[1]].header.id,
&timeline_model_get_iter_state(1)->pin.header.id));
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,
&timeline_model_get_iter_state(2)->pin.header.id));
cl_assert(timeline_model_get_iter_state(0) == timeline_model_get_iter_stat... |
ngServiceGATTError_ConnParamsSupervisionTimeoutTooSmall;
}
}
}
return ATT_ERROR_OK;
}
static att_error_t prv_validate_set_desired_state_cmd(
const PebblePairingServiceRemoteDesiredState *desired_state, size_t length) {
if (length < sizeof(PebblePairingServiceRemoteDesiredState)) {
return ATT_ER... | {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gatts_write_cfm: %u", e);
} |
}
void pebble_pairing_service_handle_status_change(Connection *connection, uint16_t conn_idx) {
if (!connection_is_subscribed_to_connection_status_notifications(connection)) {
return;
}
prv_send_notification(conn_idx, s_pps_ctx.att_hdl.conn_status);
}
void pebble_pairing_service_handle_gatt_mtu_change(Conn... |
/*
* 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_pref_set(PREF_KEY_CLOCK_24H, &s_is_24h_style, sizeof(s_is_24h_style)) | |
nst GSize *max_size,
const GPoint *center, const GFont font,
const GColor color, const char *text) {
GSize text_size = app_graphics_text_layout_get_content_size(
text, font, (GRect) { .size = *max_size }, GTextOverflowModeFi... | (ctx, face->bob_center_color) | ;
graphics_fill_oval(ctx, bob_center_rect, GOvalScaleModeFitCircle);
}
static void prv_draw_non_local_clock(GContext *ctx, NonLocalClockFace *clock) {
// TODO: The non-local clock text is currently baked into the background image.
prv_draw_clock_face(ctx, &clock->face);
}
static void prv_update_proc(Layer *lay... |
uint32_t largest_free_block) {
PBL_ASSERTN(type == AnalyticsEvent_AppOOMNative || type == AnalyticsEvent_AppOOMRocky);
AnalyticsEventBlob event_blob = {
.event = type,
.app_oom = {
.requested_size = requested_size,
.total_size = total_size,
.total_free = MIN(total_free, UINT16_M... | (&event_blob.pin_action.parent_id, uuid_string) | |
// reset the first half of the animation
kino_reel_set_elapsed(kino_layer_get_reel(&timeline_layout->icon_layer), 0);
// Clip for the static icon
layer_set_clips(&layer->layer, true);
if (finished) {
// begin the second half of the animation
prv_pin_to_card_second_half(timeline_layout, timeline_lay... | timeline_animation_layer_stopped_cut_to_end(animation, finished, context) | ;
// move the icon layer to where it transformed to
KinoReel *prev_reel = kino_layer_get_reel(&layout->icon_layer);
if (prev_reel) {
GRect frame = ((Layer *)&layout->icon_layer)->frame;
GRect global_frame;
layer_get_global_frame((Layer *)&layout->icon_layer, &global_frame);
GRect icon_to = kino_r... |
rtbeat_set(heartbeat, metric, value);
}
analytics_storage_give_lock();
}
void analytics_set_entire_array(AnalyticsMetric metric, const void *value, AnalyticsClient client) {
analytics_storage_take_lock();
AnalyticsHeartbeat *heartbeat = analytics_storage_find(metric, NULL, client);
if (heartbeat) {
// ... | (&stopwatch->node, &s_stopwatch_list, NULL) | ;
kernel_free(stopwatch);
unlock:
analytics_storage_give_lock();
}
void analytics_stopwatches_update(uint64_t current_ticks) {
PBL_ASSERTN(analytics_storage_has_lock());
ListNode *cur = s_stopwatch_list;
while (cur != NULL) {
AnalyticsStopwatchNode *node = (AnalyticsStopwatchNode*)cur;
analytics_ad... |
a->finished_dialog, app_state_get_window_stack());
app_timer_cancel(data->timer);
}
static void prv_update_progress_text(ProgressUIData *data) {
sniprintf(data->percent_done_text_buffer,
sizeof(data->percent_done_text_buffer), "%u%%", data->percent_complete);
layer_mark_dirty(&data->percent_done_tex... | (UPDATE_FREQ_MS, prv_refresh_progress, data) | ;
prv_update_progress(data);
}
static void prv_progress_ui_window_push(void) {
ProgressUIData *data = app_zalloc_check(sizeof(ProgressUIData));
Window* window = &data->window;
window_init(window, WINDOW_NAME("Progress UI App"));
window_set_user_data(window, data);
window_set_overrides_back_button(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... | GPoint(5, -5) | );
}
void outside_x_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_pixel(ctx, GPoint(15, 15));
}
void outside_nx_y_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_pixel(... |
eof(s_meta_v0_system),
BLEGATTErrorSuccess);
// Client created:
cl_assert_equal_i(ppogatt_client_count(), 1);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
Transport *client = ppogatt_client_for_uuid(&s_meta_v0_system.app_uuid);
// Red... | (&s_meta_v0_system.app_uuid) | , false);
}
static void prv_discover_and_read_meta_and_reset(void) {
prv_notify_services_discovered(1);
ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta],
(const uint8_t *) &s_meta_v0_system,
sizeof(s_met... |
/*
* 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... | mutex_create() | ;
}
status_t weather_db_flush(void) {
if (!weather_service_supported_by_phone()) {
// return E_RANGE, so the phone receives BLOB_DB_INVALID_DATABASE_ID and stops sending
// unwelcome weather records
return E_RANGE;
}
mutex_lock(s_weather_db.mutex);
pfs_remove(SETTINGS_FILE_NAME);
mutex_unlock(s_w... |
d charging, reset the filter since we're
// probably switching to a new curve.
battery_state_reset_filter();
bool is_charging = battery_charge_controller_thinks_we_are_charging();
if (is_charging) {
analytics_stopwatch_start(ANALYTICS_DEVICE_METRIC_BATTERY_CHARGE_TIME, AnalyticsClient_System);
} else {
... | prv_transition(&s_last_battery_state, next_state) | ;
state_changed = true;
}
}
s_last_battery_state.voltage = prv_filter_voltage(s_last_battery_state.voltage,
battery_get_millivolts());
bool charging = (s_last_battery_state.connection == ConnectionStateChargingPlugged);
// Update Percent & Filterin... |
0x2d, 0, 148, 0},
{ 0, 0x2d, 0, 147, 0},
{ 0, 0x2d, 0, 148, 0},
{ 0, 0x2d, 0, 148, 0},
{ 0, 0x2d, 0, 149, 0},
{ 0, 0x2d, 0, 148, 0},
{ 0, 0x2d, 0, 151, 0},
{ 0, 0x2d, 0, 149, 0},
{ 0, 0x2d, 0, 150, 0},
// 555: Local time: 2016-05-20 06:21:00 AM
{ 0, 0x2d, 0, 1... | { 0, 0xe, 0, 122, 0},
// 645: Local time: 2016-05-20 07:52:00 AM
{ 0, 0xe, 0, 123, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, 121, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, 122, 0},
{ 0, 0xe, 0, ... | |
get(&timer, &average_ms);
cl_assert_equal_i(num_intervals, 3);
cl_assert_equal_i(average_ms, 1015);
}
void test_interval_timer__invalid_samples(void) {
IntervalTimer timer;
interval_timer_init(&timer, 800, 1200, 2);
uint32_t num_intervals;
uint32_t average_ms;
interval_timer_take_sample(&timer);
fak... | (&timer, &average_ms) | ;
cl_assert_equal_i(num_intervals, 6);
cl_assert_equal_i(average_ms, 1016);
// Take a bunch of samples to make sure the moving average moves up to the new interval
for (int i = 0; i < 10; ++i) {
fake_rtc_increment_time_ms(1030);
interval_timer_take_sample(&timer);
}
num_intervals = interval_timer_... |
"
#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 "stubs_syscalls.h"
#include "stubs_ui_window.h"
#include "stubs_unobstructed_area.h"
// Tests
////////////////////////////////////
//////... | (&t, &t_c) | );
// Test Translation Matrix
t = GTransformTranslation(GTransformNumberFromNumber(2), GTransformNumberFromNumber(5));
t_c = GTransformFromNumbers(1, 0, 0, 1, 2, 5);
cl_assert(gtransform_is_equal(&t, &t_c));
cl_assert(gtransform_is_only_translation(&t));
cl_assert(gtransform_is_only_translation(&t_c));
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ERROR, "Error: ble_gap_adv_mode_set - rv: %d", rv) | ;
// Not returning, probably better to try to advertise regardless of this error.
}
rv = ble_gap_adv_data_set(adv_bytes_len, adv_bytes,
ad_data->scan_resp_data_length,
&ad_data->data[ad_data->ad_data_length]);
if (rv != BLE_STATUS_OK) {
PBL_LOG(LOG_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | pbl_log(LOG_LEVEL_INFO, filename, line, string) | ;
}
NORETURN os_assertion_failed(const char *filename, int line) {
passert_failed_no_message(filename, line);
}
NORETURN os_assertion_failed_lr(const char *filename, int line, uint32_t lr) {
passert_failed_no_message_with_lr(filename, line, lr);
}
void *os_malloc(size_t size) {
return kernel_malloc(size);
}
v... |
/*
* 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... | graphics_context_set_fill_color(ctx, highlighted_color) | ;
GCornerMask corner;
switch (index) {
case 0: corner = GCornerTopLeft; break;
case NUM_ACTION_BAR_LEGACY2_ITEMS - 1: corner = GCornerBottomLeft; break;
default: corner = GCornerNone; break;
}
graphics_fill_round_rect(ctx, &rect, radius - margin, corner);
... |
/*
* 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... | battery_convert_reading_to_millivolts(reading, 1, 1) | ;
cl_assert_equal_i(result, 0);
}
// Make sure our new method for calculating battery usage matches the old one for stm32f2
///////////////////////////////////////////////////////////
static int prv_legacy_f2_calculation_millivolts(ADCVoltageMonitorReading reading) {
return (int) ((reading.vmon_total * (2730) / re... |
st char* length_str, const char* value_str) {
int32_t address = str_to_address(address_str);
if (address == -1) {
prompt_send_response("Invalid address");
return;
}
int length = atoi(length_str);
if (length <= 0) {
prompt_send_response("Invalid length");
return;
}
int value = atoi(value_... | const uint32_t SHORT_TEST_LENGTH = 1000; // single byte reads are slow so do a shorter test length
for (uint32_t offset = 0; offset < SHORT_TEST_LENGTH ; offset++) {
uint8_t memmap_buffer[130]; // > 128 bytes, triggers a memmap read for QSPI
memset(memmap_buffer, 0x00, sizeof(memmap_buffer));
const uin... |
//! Some flash chips have an accelerated method of checking for erased sectors. This is a sanity
//! check against that method. It reads the bytes in raw form and makes sure it is really erased.
static bool prv_is_really_erased(uint32_t addr, bool is_subsector) {
bool erased = (is_subsector) ? flash_subsector_is_e... |
pairing_2));
pairing_2 = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x08,
0x09, 0x02, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x20,
},
},
.identity = (BTDeviceInternal) {
.address = (BTDeviceAddress) {
.octets = {... | cl_assert_equal_m(&device_out, &pairing_1.identity, sizeof(device_out)) | ;
ret = bt_persistent_storage_get_ble_pairing_by_id(id_2, &irk_out, &device_out, NULL /* name */);
cl_assert(ret);
cl_assert_equal_m(&irk_out, &pairing_2.irk, sizeof(irk_out));
cl_assert_equal_m(&device_out, &pairing_2.identity, sizeof(device_out));
ret = bt_persistent_storage_get_ble_pairing_by_id(id_3, &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... | app_install_is_watchface(shell_sdk_get_last_installed_app()) | ;
}
|
{ 744, 1360, -184},
{ 880, 1032, -112},
{ 1144, 976, -120},
{ 1600, 968, -120},
// 417 seconds
{ 1680, 728, -96},
{ 1616, 544, -72},
{ 1640, 472, -104},
{ 1688, 424, -40},
{ 1664, 376, -8},
{ 1504, 336, 64},
{ 1120, 288, 24},
{ 864, -288, 24},
{ 888, -272, 248},
... |
{ 1176, 328, -216},
{ 1288, 544, -152},
{ 1432, 696, -344},
{ 1600, 1016, -288},
{ 1352, 1040, -136},
{ 1056, 1016, -152},
{ 752, 1176, -240},
{ 968, 1296, -240},
{ 880, 936, -136},
{ 1128, 904, -104},
{ 1336, 832, -88},
{ 1288, 616, -144},
{ 1224, 424, -120},
//... | |
/*
* 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... | {
flash_erase_subsector_blocking(addr + (i * SUBSECTOR_SIZE_BYTES));
} |
LogChunkHeader chunk_header = {
.invalid = false,
.valid = true,
.chunk_id = s_current_chunk_id
};
flash_write_bytes((const uint8_t*) &chunk_header, get_current_address(s_current_chunk, 0), sizeof(chunk_header));
s_current_offset = sizeof(LogChunkHeader);
}
static void make_space_for_log(int len... |
scroll_layer_set_content_offset(&card->scroll_layer, offset, false) | ;
#endif
window_render(&card->window, &s_ctx);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_sleep_detail_card__render_sleep_data_2(void) {
HealthData health_data = {
.sleep_data[0] = (7 * SECONDS_PER_HOUR) + (14 * SECONDS_PER_MINUTE),
.sleep_data[1] = (4 * SECONDS_PER... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return s_read_return_value;
} |
Read *read = malloc(sizeof(Read));
*read = (const Read) {
.characteristic = characteristic,
.client = client,
};
if (s_read_head) {
list_append((ListNode *)s_read_head, &read->node);
} else {
s_read_head = read;
}
return BTErrnoOK;
}
void gatt_client_consume_read_response(uintptr_t objec... |
Point(20,20), GPoint(20,20));
graphics_context_set_antialiased(ctx, false);
graphics_context_set_stroke_width(ctx, 2);
graphics_draw_line(ctx, GPoint(30,30), GPoint(30,30));
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, 2);
graphics_draw_line(ctx, GPoint(40,40), GPoin... | (&ctx, 1, 0, 0) | ;
// Draw lines around boundaries of clipping box - AA true, SW 2
prv_draw_lines(&ctx, 2, CLIP_OFFSET, 0);
// Draw lines around boundaries of clipping box - AA true, SW 3
prv_draw_lines(&ctx, 3, 0, CLIP_OFFSET);
// Draw lines around boundaries of clipping box - AA true, SW 4
prv_draw_lines(&ctx, 4, CLIP_... |
ib/ui/kino/kino_layer.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "resource/resource_ids.auto.h"
#include "services/common/battery/battery_monitor.h"
#include "services/common/clock.h"
#include "util/time/time.h"
#include <string.h>
typedef struc... | app_event_loop() | ;
deinit();
}
const PebbleProcessMd* low_power_face_get_app_info() {
static const PebbleProcessMdSystem s_app_md = {
.common = {
// UUID: e9475244-5bbe-4e0f-a637-a218af4c3110
.uuid = {0xe9, 0x47, 0x52, 0x44, 0x5b, 0xbe, 0x4e, 0x0f, 0xa6, 0x37, 0xa2, 0x18, 0xaf, 0x4c, 0x31, 0x10},
.main_func ... |
rsive(s_pfs_mutex);
// go to offset
pfs_seek(fd, offset, FSeekSet);
const unsigned int chunk_size = 128;
uint8_t buffer[chunk_size];
while (num_bytes > chunk_size) {
pfs_read(fd, buffer, chunk_size);
legacy_defective_checksum_update(&checksum, buffer, chunk_size);
num_bytes -= chunk_size;
}
... | pfs_close(fd) | ;
}
void pfs_command_crc(const char *filename) {
int fd = pfs_open(filename, OP_FLAG_READ, 0, 0);
char buffer[32];
if (fd < 0) {
prompt_send_response_fmt(buffer, sizeof(buffer), "fd open err: %d", fd);
return;
}
size_t num_bytes = pfs_get_file_size(fd);
uint32_t crc = pfs_crc_calculate_file(fd, 0, ... |
s_raw_iter_next(&file->iter)) {
SettingsRecordHeader *hdr = &file->iter.hdr;
if (partially_written(hdr)) {
// This should only happen if we reboot in the middle of writing a new
// record, and it should always be the most recently written record, so
// we shouldn't lose any data here (except f... | {
// Compact will remove partially written records. We could be smarter,
// but this is something of an edge case.
return settings_file_compact(file);
} |
if (!partially_overwritten(&file->iter.hdr)) {
continue;
}
int partially_overwritten_record_pos =
settings_raw_iter_get_current_record_pos(&file->iter);
uint8_t key[file->iter.hdr.key_len];
settings_raw_iter_read_key(&file->iter, key);
settings_raw_iter_next(&file->iter); // Ski... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return (recognizer->config.multi_click.handler != NULL);
} |
inline static bool prv_is_long_click_enabled(ClickRecognizer *recognizer) {
return (recognizer->config.long_click.handler != NULL || recognizer->config.long_click.release_handler != NULL);
}
static void prv_auto_repeat_single_click(ClickRecognizer *recognizer) {
if (!recognizer->is_button_down) {
// If this ... |
/*
* 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, "Idle: <%c> Match! State %u", c, s_knocking_state) | ;
// If we reach the null terminator, we're done!
if (KNOCKING_CODE[s_knocking_state] == 0) {
system_task_add_callback_from_isr(
prv_knocking_complete, NULL, &should_context_switch);
s_knocking_state = 0;
}
} else {
PBL_LOG(LOG_LEVEL_DEBUG, "Idle: <%c> Mismatch!", c);
// W... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
const uint8_t ppb = 8 / bpp;
uint8_t idx = y*line_stride + (x/(ppb));
const uint8_t shift = (8 - bpp) - bpp * (x % ppb);
const uint8_t mask = ~(((1 << bpp) - 1) << shift);
buf[idx] = buf[idx] & mask;
buf[idx] |= ((color_index & ((1 << bpp) - 1)) << shift);
} |
static bool prv_check_source_stripe_blit(const uint8_t *data,
const GBitmap *src_bmp, GColor surround_color) {
for (uint8_t y = 0; y < (FRAMEBUFFER_SIZE_BYTES / FRAMEBUFFER_BYTES_PER_ROW); ++y) {
for (uint8_t x = 0; x < FRAMEBUFFER_BYTES_PER_ROW; ++x) {
uint8_t col... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
PBL_LOG(LOG_LEVEL_INFO, "Updating PRF!");
flash_prf_set_protection(false);
bool saved_sleep_when_idle = flash_get_sleep_when_idle();
flash_sleep_when_idle(false);
FirmwareDescription description =
firmware_storage_read_firmware_description(FLASH_REGION_FIRMWARE_SCRATCH_BEGIN);
if (!firmware_stora... |
#endif
void check_prf_update(void) {
if (!boot_bit_test(BOOT_BIT_NEW_PRF_AVAILABLE)) {
return;
}
boot_bit_clear(BOOT_BIT_NEW_PRF_AVAILABLE);
#ifndef RECOVERY_FW
prv_do_update();
#endif
}
|
_HRS);
cl_assert_equal_s("Tue, 12:00 PM", time_buf);
// June 16th 2015, 13:00:00 (T+7DAY+01:00:00)
rtc_set_time(event_time + (7 * SECONDS_PER_DAY) + (1 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Jun 9, 12:00 PM", time_... | (time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS) | |
djust_drawing_state_for_legacy2_apps()
// so all we need to alter is the height of the frame
frame.size.h = STATUS_BAR_HEIGHT;
if (window_stack_is_animating_with_fixed_status_bar(window->parent_window_stack)) {
frame.origin.x = 0;
}
status_bar_layer_render(ctx, &frame, &config);
ctx->dr... | window_manager_get_top_window() | );
}
static void prv_call_click_provider(Window *window) {
window->is_waiting_for_click_config = false;
app_click_config_setup_with_window(prv_get_current_click_manager(), window);
window->is_click_configured = true;
}
static void prv_check_is_in_click_config_provider(Window *window, char *type) {
PBL_ASSERT(... |
0,
.tm_hour = 5,
.tm_mday = 31,
.tm_mon = 4, // May
.tm_year = 2016 - 1900,
.tm_isdst = 1,
.tm_gmtoff = -5 * SECONDS_PER_HOUR,
};
// DST info for US/Canada 2016
TimezoneInfo tz_info = {
.dst_id = 0,
.dst_start = 1457834400, // Sun, 13 Mar 2016 02:00
.dst_end = 1478397600, // S... | ("IN 1 H", time_buf) | ;
// June 10th 2015, 13:01:00 (T-00:59:00)
rtc_set_time(event_time - (59 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 59 MIN", time_buf);
// June 10th 2015, 13:01:59 (T-00:58:01)
rtc_set_time(event_time - (58 * SE... |
erDown, &GPoint(13, 13), 6, 3686420);
touch_handle_update(0, TouchState_FingerDown, &GPoint(15, 15), 6, 3686440);
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
touch_handle_update(1, TouchState_FingerDown, &GPoint(33, 33), 7, 3686500);
touch_dispatch_touch_events(0, prv_touch_event... | {
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_handle_update(1, TouchState_FingerDown, &GPoint(55, 55), 2, 3686480);
fake_event_set_callback(prv_handle_palm_events);
touch_handle_driver_event(TouchDriverEvent_PalmDetect);
// Cancelled event, followed by a palm detection ... | |
char *get_timezone_abbr(void) {
static const char s_timezone_abbr[] = "A";
return s_timezone_abbr;
}
void sys_copy_timezone_abbr(char* timezone_abbr, time_t time) {
const char* sys_tz = get_timezone_abbr();
strncpy(timezone_abbr, sys_tz, TZ_LEN);
}
struct tm *sys_gmtime_r(const time_t *timep, struct tm *resul... | (tmbuf, "2015-01-02") | ;
#endif
#if EXTENSION_TZ
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%G %g", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "2015 15");
tmbuf[0] = '\0';
strftime(tmbuf, sizeof(tmbuf), "%k %l", &jan_2_2015__13_00_00);
cl_assert_equal_s(tmbuf, "13 1");
#endif
tmbuf[0] = '\0';
strftime(tmbuf, 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... | (QSPI_FLASH) | );
return S_SUCCESS;
}
static void prv_set_high_drive_strength(void) {
// Match the impedance of the traces (~50 ohms) by configuring the drive strength of the data
// output pins on the MT25Q to the 45 ohm setting This avoids signal integreity issues. This is
// done by setting bits 2:0 in the "Enhanced Volat... |
/*
* 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... | (1, -32768) | ; // <- causes overflow for int16
check_atan2(20001, 20000); // <- causes overflow if numbers are added in an int16
check_atan2(32767, 1);
check_atan2(1, 32767);
check_atan2(32767, 0);
check_atan2(0, 32767);
check_atan2(23400, -25300);
check_atan2(30500, -1930);
check_atan2(-6, -310);
check_atan2(1500... |
_next(CommSession *session, bool is_callback) {
bt_lock();
{
if (!comm_session_is_valid(session)) {
// Session closed in the mean time
goto unlock;
}
// Flip the flag before the send_next callback, so it can schedule again if needed.
// Only flip the flag, if this called as a thread call... | {
return NULL;
} |
FindByAppUUIDContext ctx = (FindByAppUUIDContext) {
.app_uuid = app_uuid,
};
// Try most specific first:
CommSession *session = (CommSession *) list_find((ListNode *) s_session_head,
prv_find_session_by_app_uuid_comparator, &ctx);
if (!session) {
ret... |
);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
#endif
}
// --------------------------------------------------------------------------------------
// Test a sequence animation with a component that has a pl... | animation_spawn_create(a, b, NULL) | |
der_mbuf));
mbuf_iterator_init(&s_read_consumer.mbuf_iter, &s_header_mbuf);
system_task_add_callback_from_isr(prv_schedule_notify_timeout, NULL, &should_context_switch);
}
return should_context_switch;
}
// Sending functions
////////////////////////////////////////////////////////////////////////////////
... | mbuf_set_flag(&start_flag_mbuf, MBUF_FLAG_IS_FRAMING, true) | ;
// Header
FrameHeader header = (FrameHeader) {
.version = SMARTSTRAP_PROTOCOL_VERSION,
.flags = {
.is_read = is_read,
.is_master = true,
},
.profile = profile
};
MBuf header_mbuf = MBUF_EMPTY;
mbuf_set_data(&header_mbuf, &header, sizeof(header));
mbuf_append(&start_flag_mbuf, ... |
attr->request_type == SmartstrapRequestTypeWrite) ? NULL : &attr->mbuf,
.timeout_ms = attr->timeout_ms
};
// send the request
SmartstrapResult result = smartstrap_profiles_handle_request(&request);
if (result == SmartstrapResultBusy) {
// there was another request in progress so we'll try again later
... | (s_attr_list_lock) | |
ze - 1));
graphics_draw_line(
ctx, GPoint(radial_padding_size, layer->bounds.size.h / 2),
GPoint(layer->bounds.size.w - radial_padding_size - 1, layer->bounds.size.h / 2));
prv_draw_border(layer, ctx, radial_padding_size);
}
static void prv_draw_bitmap(struct Layer *layer, GContext *ctx, uint32_t res)... | {
if (app_manager_get_current_app_md() == mfg_display_app_get_info()) {
process_manager_send_callback_event_to_process(PebbleTask_App, prv_change_pattern, data);
} else {
app_manager_launch_new_app(&(AppLaunchConfig) {
.md = mfg_display_app_get_info(),
.common.args = data,
});
}
} |
void command_display_set(const char *color) {
const char * const ARGS[] = {
[TestPattern_Black] = "black",
[TestPattern_Gray] = "gray",
[TestPattern_White] = "white",
[TestPattern_Crosshair] = "crosshair",
#if PBL_COLOR
[TestPattern_Veggies] = "veggies",
[TestPattern_Pinwheel] = "pinwheel",
... |
/*
* 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 (!list_contains(g_profiler.nodes, (ListNode *)node)) {
// Instead of calling syscall_failed(), simply return. If PROFILE_INIT has not been
// executed yet, there won't be any nodes in the list.
return;
}
} |
node->start = DWT->CYCCNT;
}
DEFINE_SYSCALL(void, sys_profiler_node_stop, ProfilerNode *node) {
// Capture the cycle count as soon as possible, before we validate the node argument
uint32_t dwt_cyc_cnt = DWT->CYCCNT;
if (PRIVILEGE_WAS_ELEVATED) {
if (!list_contains(g_profiler.nodes, (ListNode *)node)) ... |
void prv_update_name_text(RecoveryFUAppData *data) {
const GAPLEConnection *gap_conn = gap_le_connection_any();
// Set the name text
if (data->is_showing_version) {
strncpy(data->name_text_buffer, GIT_TAG, sizeof(data->name_text_buffer));
} else if (bt_driver_classic_is_connected()) {
// If BT Classic ... | GRect(0, 124, window->layer.bounds.size.w, 64) | ,
NULL, fonts_get_system_font(url_font_key),
GColorBlack, GColorClear, GTextAlignmentCenter,
GTextOverflowModeTrailingEllipsis);
layer_add_child(&window->layer, &url_text_layer->layer);
TextLayer* name_text_layer ... |
S_SUCCESS == reminders_insert(&item1));
cl_assert_equal_m(&item1.header.id, stub_new_timer_callback_data(get_reminder_timer_id()), sizeof(TimelineItemId));
cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 0);
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_remi... | (stub_new_timer_timeout(get_reminder_timer_id()), 5 * 60 * 60 * 1000) | ;
cl_assert(uuid_equal(&s_reminder_before_all_day_reminder.header.id,
(Uuid *)stub_new_timer_callback_data(get_reminder_timer_id())));
// set time to 21:00 PST March 4
now = 1425531600;
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id()));
stub_peb... |
/*
* 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... | (PebbleTask_KernelBackground) | ;
const uint8_t cmd = data[0];
switch (cmd) {
case ResetCmdNormal:
PBL_LOG(LOG_LEVEL_WARNING, "Rebooting");
system_reset();
break;
case ResetCmdCoreDump:
PBL_LOG(LOG_LEVEL_INFO, "Core dump + Reboot triggered");
core_dump_reset(true /* force overwrite any existing core dump *... |
aw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
ASSERT_NO_CHANGE(graphics_fill_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_fill_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_fill_round_rect(&cont... | (&ctx, framebuffer) | ;
cl_assert(ctx.lock == false);
cl_assert(fb.is_dirty == true);
};
void test_graphics_context_${BIT_DEPTH_NAME}__lock_framebuffer_8BitCircular(void) {
// Test for locking of requested framebuffer format
GContext ctx = {.dest_bitmap.info.format = GBitmapFormat8BitCircular};
GBitmap *bmp = graphics_capture_fra... |
b, 0x7c, 0x75, 0x8a, 0x35, 0x44, 0x87,
0x90, 0xa4, 0x91, 0x3f, 0x1f, 0xa6, 0x76, 0x01},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0x01},
.timestamp = 3,
.duration = 0,
.type = TimelineItemTypeReminder,
.layout = ... | (uuid_equal(&item1.header.id, &temp.header.id)) | ;
temp.attr_list.attributes = NULL;
cl_assert(memcmp(&item1, &temp, sizeof(TimelineItem)) == 0);
cl_assert(S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */));
cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) == 0);
// check item 2
memset(&temp, 0, sizeof(T... |
rt_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, c), 1);
cl_asse... | (seq, delay_seq) | |
ASHED
#include "applib/app.h"
#include "applib/ui/ui.h"
#include "kernel/pbl_malloc.h"
#include "kernel/util/sleep.h"
#include "process_management/pebble_process_md.h"
#include "process_management/pebble_process_md.h"
#include "process_state/app_state/app_state.h"
#include "services/common/new_timer/new_timer.h"
#incl... | app_timer_cancel(s_app_data->app_timer) | ;
s_app_data->app_timer = 0;
}
// Cancel and delete old regular timers if present
for (int i=0; i<NUM_MAX_TIMERS; i++) {
if (s_app_data->reg_timers[i].cb != NULL) {
PBL_LOG(LOG_LEVEL_DEBUG, "STT deleting previous regular timer %d", i);
regular_timer_remove_callback(&s_app_data->reg_timers[i])... |
fake_pbl_malloc_clear_tracking() | ;
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
}
void test_rocky_text_encoding__cleanup(void) {
jerry_cleanup();
rocky_runtime_context_deinit();
fake_pbl_malloc_check_net_allocs();
}
void test_rocky_text_encoding__jerry_handles_cesu8_strings_in_source(void) {
// Although CESU-8 and UTF-8 ar... | |
en;
top_rects_color.a = 2;
const GRect top_left_rect = (GRect) {
.origin = GPoint(top_rects_x_offset, 0),
.size = top_rects_size
};
prv_draw_hlines_in_rect(ctx, draw_func, &top_left_rect, top_rects_color);
const GRect top_right_rect = (GRect) {
.origin = GPoint((bitmap_bounds_size->w / 2) + top_re... | TEST_NAMED_PBI_FILE("draw_core_assign_horizontal_line_raw") | ));
};
void prv_blend_horizontal_line_raw(GBitmap *framebuffer, int16_t y, int16_t x1, int16_t x2,
GColor color);
static void prv_hline_pattern_blend_horizontal_line_raw(GContext *ctx, int16_t y, int16_t x1,
int16_t x2, GColor ... |
/////
#include "fake_GAPAPI.h"
#include "fake_GATTAPI.h"
#include "fake_GATTAPI_test_vectors.h"
#include "fake_pbl_malloc.h"
#include "fake_new_timer.h"
#include "fake_rtc.h"
#include "fake_system_task.h"
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_bluetopia_interface.h"
#inc... | fake_gatt_put_discovery_indication_blood_pressure_service(TEST_GATT_CONNECTION_ID) | |
GRect *clip_box, int y, int x0, int x1,
uint16_t opacity, GColor color) {
// Plots pixel directly to framebuffer
// Pixel position have to be adjusted to drawing_box before calling this!
// Checking for clip_box
if (!WITHIN(y, clip_box->origin.y, ... | (ctx, framebuffer, &ctx->draw_state.clip_box, x,
y1.integer, y2.integer, opacity,
ctx->draw_state.stroke_color) | |
TALL_CELL_HEIGHT : MENU_CELL_ROUND_UNFOCUSED_SHORT_CELL_HEIGHT;
}
static uint16_t get_num_rows_callback(struct MenuLayer *menu_layer, uint16_t section_index, SettingsWatchfacesData *data) {
return app_menu_data_source_get_count(&data->data_source);
}
static void draw_row_callback(GContext* ctx, const Layer *cell_la... | app_malloc_check(sizeof(SettingsWatchfacesData)) | ;
*data = (SettingsWatchfacesData){};
app_state_set_user_data(data);
Window *window = &data->window;
window_init(window, WINDOW_NAME("Watchfaces"));
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appear,
... |
ta *data, GContext *ctx, GPoint offset,
KinoReelProcessor *processor) {
KinoReel *reel = prv_get_current_reel(data);
GDrawCommandList *source_list = kino_reel_get_gdraw_command_list(reel);
GDrawCommandList *list = prv_get_or_create_list_copy(data, source_list);
if (data->... | {
kino_reel_destroy(data->from_reel);
} |
data->from_reel = from_reel;
data->owns_from_reel = take_ownership;
prv_free_list_copy(data);
}
KinoReel *kino_reel_transform_get_from_reel(KinoReel *reel) {
KinoReelTransformData *data = kino_reel_custom_get_data(reel);
if (data) {
return data->from_reel;
}
return NULL;
}
void kino_reel_transform_... |
er overflows
for (int mv = 3000; mv < 5000; mv++) {
int32_t res = battery_curve_lookup_percent_with_scaling_factor(
mv, false, scaling_factor);
cl_assert(prev_reading <= res);
prev_reading = res;
}
// make sure that when we compute the largest possible (100% - 0%) and lowest possible
// (... | battery_monitor_init() | ;
periodic_timer_trigger(1);
fake_battery_set_millivolts(charge_terminate_mv);
fake_battery_set_charging(false);
periodic_timer_trigger(1);
cl_assert_equal_i(battery_get_charge_state().charge_percent, 80);
}
/*
good -> lpm
lpm -> good
good -> critical
critical -> lpm
lpm -> critical
critical -> good
*/
t... |
e == true);
// Timer will go off at 09:00 on Saturday. (7.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 27000 * MS_PER_SECOND);
rtc_set_time(s_saturday_10_30);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go ... | (active == true) | ;
// Timer will go off at 10:00 on Sunday. (0.5 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 1800 * MS_PER_SECOND);
rtc_set_time(s_sunday_10_00);
do_not_disturb_handle_clock_change();
active = do_not_disturb_is_active();
cl_assert(active == false);
// Timer will go off at 01:00 on... |
onfig access before initialization
static void bus_init(uint8_t bus_idx) {
// Initialize peripheral
I2C_InitTypeDef i2c_init_struct;
I2C_StructInit(&i2c_init_struct);
if (BOARD_CONFIG.i2c_bus_configs[bus_idx].clock_speed > I2C_NORMAL_MODE_CLOCK_SPEED_MAX) { //Fast mode
i2c_init_struct.I2C_DutyCycle = BOAR... | (device_id < BOARD_CONFIG.i2c_device_count) | ;
uint8_t bus_idx = BOARD_CONFIG.i2c_device_map[device_id];
I2cBus *bus = &i2c_buses[bus_idx];
bus_lock(bus);
if (bus->user_count == 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Attempted release of disabled bus %d by device %d", bus_idx, device_id);
bus_unlock(bus);
return;
}
bus->user_count--;
if (bus... |
けこさしすせそたちつてとなに"
"ぬねのはひふへほまみむめもやゆよらりるれろわ"
"をんアイウエオサシスセソタチツテトナニヌネノ"
"ハヒフヘホマミムメモヤユヨラリルレロワヲン",
.lengths = {
#if PLATFORM_ROBERT
[TestStringFont_Gothic18] = 579,
[TestStringFont_Gothic24B] = 291,
[TestStringFont_Other] = STRING_LENGTH_MAX,
#elif PLATFORM_SNOWY
... | if (length == 0) {
length = STRING_LENGTH_MAX;
} | |
(data->creating_alarm) {
app_window_stack_push(&data->day_picker_window, true);
} else {
alarm_set_time(data->alarm_id, data->alarm_hour, data->alarm_minute);
app_window_stack_remove(&time_picker_window->window, true);
}
}
static void prv_setup_time_picker_window(AlarmEditorData *data) {
const TimeS... | {
AlarmEditorData* data = task_malloc_check(sizeof(AlarmEditorData));
*data = (AlarmEditorData) {
.alarm_id = alarm_id,
.alarm_type = alarm_type,
.complete_callback = complete_callback,
.callback_context = callback_context,
};
prv_setup_time_picker_window(data);
app_window_stack_push(&data->... |
void alarm_editor_update_alarm_days(AlarmId alarm_id, AlarmEditorCompleteCallback complete_callback,
void *callback_context) {
AlarmEditorData* data = task_malloc_check(sizeof(AlarmEditorData));
*data = (AlarmEditorData) {
.alarm_id = alarm_id,
.complete_callback = comp... |
/*
* 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... | settings_display_calibration_push(modal_manager_get_window_stack(MODAL_PRIORITY)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.