prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
data, copied_size);
ctx->copied_size = copied_size;
ctx->company_id = company_id;
return false; // stop parsing
}
size_t ble_ad_copy_manufacturer_specific_data(const BLEAdData *ad,
uint16_t *company_id,
uint8_t *buffer,... | if (*length == BLE_AD_DATA_FINALIZED) {
*length = 0;
} |
// Append the element to the end:
uint8_t * const end = ad_data->data +
ad_data->ad_data_length +
ad_data->scan_resp_data_length;
memcpy(end, (const uint8_t *) element, size_to_write);
// Length book-keeping:
*length += size_to_write;
return true;
}
// --... |
bitblt_bitmap_into_bitmap(&dest_bitmap, &src_bitmap, GPointZero, GCompOpAssign, GColorWhite);
#endif
} else {
// On Robert, we support running older apps which have a smaller framebuffer in "bezel mode"
// where we center them and draw a black bezel around them. Using memset to set the bezel to
// b... | prv_animation_update(s_animation_state.animation, s_deferred_render.animation.progress) | ;
}
if (s_deferred_render.app.pending) {
s_deferred_render.app.pending = false;
compositor_app_render_ready();
}
if (s_deferred_render.transition_start.pending) {
s_deferred_render.transition_start.pending = false;
compositor_transition(s_deferred_render.transition_start.compositor_animation);
... |
/*
* 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_database_read(offsetof(TimezoneDatabaseFlashHeader, link_count),
&link_count, sizeof(link_count)) | ;
return link_count;
}
int timezone_database_get_region_count(void) {
uint16_t region_count;
prv_database_read(offsetof(TimezoneDatabaseFlashHeader, region_count),
®ion_count, sizeof(region_count));
return region_count;
}
bool timezone_database_load_region_info(uint16_t region_id, Timez... |
ivity != ActivitySessionTypeCount);
ActivitySession session = {
.type = activity,
.start_utc = start_utc,
.length_min = len_sec / SECONDS_PER_MINUTE,
.ongoing = ongoing,
.step_data = {
.steps = steps,
.active_kcalories = ROUND(active_calories, ACTIVITY_CALORIES_PER_KCAL),
.resti... | if (!file) {
goto exit;
} |
// Figure out the oldest and newest possible time stamp for chunks that go into these buffers
time_t now = rtc_get_time();
const time_t k_oldest_valid_utc = now
- ALG_SLEEP_HISTORY_HOURS_FOR_TODAY * SECONDS_PER_HOUR;
const time_t k_newest_valid_utc = now;
AlgLogMinuteFileC... |
ation(now_utc, notif_config);
notif_config->state->last_triggered_utc = time_util_get_midnight_of(now_utc);
analytics_event_health_insight_created(now_utc, notif_config->insight_type, 0);
// Save out the trigger time
prv_save_state(notif_config->settings_key,
¬if_config->state->last_trigger... | activity_prefs_get_health_app_opened_version() | != 0) {
// The user already knows about the Health app
return NULL;
}
AttributeList notif_attr_list = {0};
const char *body = i18n_get("Wanna know more about you? "
"Track your activity and sleep with Pebble Health.",
¬if_attr_list);
prv_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... | periph_config_acquire_lock() | ;
// Init PMIC_INTN
gpio_input_init_pull_up_down(&BOARD_CONFIG_POWER.pmic_int_gpio, GPIO_PuPd_UP);
periph_config_release_lock();
return true;
}
//! Interrupt masks for InterruptStatus1 and InterruptMask1 registers
enum PmicInt1 {
PmicInt1_Trickle = (1 << 0), //!< Trickle charge
PmicInt1_NoBat = (1 << 1),... |
_from_polar_precise(center, distance << GPOINT_PRECISE_PRECISION, angle);
}
static void prv_graphics_draw_centered_text(GContext *ctx, const GSize *max_size,
const GPoint *center, const GFont font,
const GColor color, const char *t... | graphics_context_set_fill_color(ctx, face->bob_color) | ;
graphics_fill_oval(ctx, bob_rect, GOvalScaleModeFitCircle);
graphics_context_set_fill_color(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 c... |
_buffer, " %x");
}
}
va_end(args);
// Log to host if the level is sufficient
if (LEVEL_MAP[level] <= s_log_buffer.level) {
// Craft the HcProtocolMessage & send to the host
hc_msg->message_length = sizeof(HcProtocolMessage) + msg->header.length;
if (!hc_endpoint_logging_send_msg(hc_msg)) {
... | prv_get_log_level_char(msg->body.level) | , msg->body.task_id,
pad_length, ' ', filename_max_len, msg->body.filename,
msg->body.line_number, msg->body.length, msg->body.string);
const unsigned length_with_null = length + 1;
if (length_with_null >= msg_buffer_size) {
length--;
}
msg_buffer[length++] =... |
/*
* 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 timer_cb;
} |
return s_current_work_cb;
}
//=========================================================================================
// Initialize the timer service
void new_timer_service_init(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "NT: Initializing");
vSemaphoreCreateBinary(s_wake_srv_loop);
task_timer_manager_init(&s_task_t... |
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governi... | {
uint32_t crc;
size_t raw_length = sizeof(PulseFrame) + sizeof(PushPacket) +
sizeof(s_message_header) + s_message_length + sizeof(crc);
unsigned char raw_packet[raw_length];
PulseFrame *frame = (PulseFrame *)raw_packet;
frame->protocol = hton16(PULSE_TRANSPORT_PUSH);
PushPacket *tra... |
void dbgserial_putstr(const char* str) {
dbgserial_print(str);
dbgserial_newline();
}
void dbgserial_print_hex(uint32_t value) {
char buf[12];
itoa_hex(value, buf, sizeof(buf));
dbgserial_print(buf);
}
|
_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_even_rows_no_clip")));
// Odd rows of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotte... | graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 22), MAX_NUM_COLS + 1) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_even_rows_no_clip")));
// Odd rows of different lengths
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_EVEN, OFFSET_RECT_EVEN, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS);
... |
, framebuffer);
}
// ## Line blending wrappers:
void graphics_private_draw_horizontal_line_prepared(GContext *ctx, GBitmap *framebuffer,
GRect *clip_box, int16_t y, Fixed_S16_3 x1,
Fixed_S16_3 x2, GColor color) {
... | (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) {
// apply draw box and clipping
y1.integer += ctx->draw_state.drawing_box.origin.y;
y2.integer += ctx->draw_state.drawing_box.origin.y;
x += ctx->dr... |
;
break;
}
default:
WTF;
}
}
static bool prv_event_put(HRMSubscriberState *state, PebbleHRMEvent *event) {
bool success;
if (state->queue) {
PebbleEvent e = {
.type = PEBBLE_HRM_EVENT,
.hrm = *event,
};
success = xQueueSendToBack(state->queue, &e, 0);
... | PBL_LOG(LOG_LEVEL_DEBUG, "Subscription %"PRIu32" expired", expired_state->session_ref) | |
if (!has_more) {
s_is_notification_event_pending[client] = false;
} |
if (has_more_out) {
*has_more_out = has_more;
}
prv_unlock();
// In the interest of simplicity, just give unconditionally (regardless of the number of bytes
// consumed and regardless of which buffer was freed) to make
// prv_wait_until_write_space_available() "poll" once whether there's enough... | |
GPointPrecise pointP_c = GPointPrecise((2 % GPOINT_PRECISE_MAX) << GPOINT_PRECISE_PRECISION,
(5 % GPOINT_PRECISE_MAX) << GPOINT_PRECISE_PRECISION);
cl_assert(gpointprecise_equal(&pointP, &pointP_c));
GVectorPrecise vectorP = GVectorPreciseFromGVector(GVector(2, 5));
... | (&t1, &t_c) | );
// Test concatenation of two non-identity matrices
t1 = GTransformFromNumbers(3, 5, 7, 11, 13, 17);
t2 = GTransformFromNumbers(1, 2, 3, 4, 5, 6);
t_c = GTransformFromNumbers(18, 26, 40, 58, 69, 100);
gtransform_concat(&t_new, &t1, &t2);
cl_assert(gtransform_is_equal(&t_new, &t_c));
}
void test_gra... |
mmand_list_draw(ctx, command_list);
cl_assert_equal_i(s_path_stroke_count, 0);
cl_assert_equal_i(s_path_fill_count, 0);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_i(s_circle_fill_count, 0);
free(command_list);
}
void test_gdraw_command__validate_list(void) {
GDrawCommandList *command_lis... | GPoint(4, -4) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (new_icon_resource_id) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kernel_free(buf) | ;
}
static void prv_assert_mutexes_unlocked(void) {
cl_assert_equal_b(s_mutex_locked, false);
}
// Tests
///////////////////////////////////////////////////////////
void test_shared_prf_storage_v3__initialize(void) {
fake_spi_flash_init(FLASH_REGION_SHARED_PRF_STORAGE_BEGIN,
SPRF_REGION_SIZE... |
/*
* 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... | {
// Switch to the "contract from modal" animation if necessary (e.g. if the animation was
// reversed in the future)
if (s_data.expanding) {
prv_modal_transition_animation_init_sequence(MODAL_CONTRACT_FROM_MODAL_ANIMATION);
s_data.expanding = false;
}
distance_normalized = animation_tim... | else {
// For the second half of the animation where the app is the destination, draw the "expand to
// app" frame and fill its inner ring with the app's frame buffer
// Switch to the "expand to app" animation if necessary
if (!s_data.expanding) {
prv_modal_transition_animation_init_sequence(MODA... |
cl_assert_equal_i(s_hrm_manager_subscribe_with_callback_call_count, 1);
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count, 0);
// Device B unsubscribes, expect to be unsubscribed from HRM manager, because there are no more
// devices subscribed to the BLE HRM service:
bt_driver_cb_hrm_service_update_s... | bt_driver_cb_hrm_service_update_subscription(s_device_a, true) | ;
// No sharing request UI:
cl_assert_equal_p(NULL, s_last_sharing_request);
// Still declined:
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
}
void test_ble_hrm__unsub_upon_deinit(void) {
// Device A subscribes:
bt_driver_cb_hrm_service_update_subscription(s_device_a, true);
p... |
g, 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.
*/
#include <string.h>
#include <stdlib.h>
#include "dr... | (&bufcmp[0], i, sizeof(bufcmp)) | ;
int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, sizeof(buf));
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_read(fd, &buf[0], sizeof(buf)), sizeof(buf));
cl_assert(memcmp(buf, bufcmp, sizeof(buf)) == 0);
cl_assert_equal_i(pfs_close(fd), S_SUCCESS);
}
}
void test_pfs__garbage_collecti... |
cess from ble_task, so no locking needed.
static LocalAddressPolicy s_local_addr_desired_policy;
static LocalAddressState s_local_addr_state;
static void prv_get_desired_own_address(own_address_t *desired_address_out) {
if (s_local_addr_desired_policy.allow_cycling) {
PBL_LOG(LOG_LEVEL_DEBUG,
"Trying... | prv_assert_is_executing_on_ble_task() | ;
if (s_local_addr_state == LocalAddressState_InSync &&
(!s_local_addr_desired_policy.allow_cycling)) {
PBL_LOG(LOG_LEVEL_ERROR,
"Address cycled even though it was expected not to! " BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE_PTR(updated_address));
}
}
void local_addr_handle... |
void *data) {
NotificationsData *notifications_data = data;
NotificationNode *node = notifications_data->notification_list;
// There's no notifications, don't draw anything
if (!node) {
return 0;
}
// add one for the CLEAR ALL at the top
return list_count((ListNode *)notificatio... | if (IS_EMPTY_STRING(body)) {
// we're screwed... empty message
title = "[Empty]";
} else {
// try to show as much content as possible in title + subtitle
title = body;
subtitle = strchr(body, '\n'); // NULL handled gracefully downstream
} |
} else if (IS_EMPTY_STRING(title)) {
// no title, but yes subtitle.
title = subtitle;
subtitle = body;
} else if (IS_EMPTY_STRING(subtitle)) {
// no subtitle, but yes title
subtitle = body;
} else {
WTF;
}
draw_cell(ctx, cell_layer, title, subtitle, loaded_node->icon);
}
// Display ... |
/*
* 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_get_empty_struct(data_out) | ;
}
}
static void prv_perform_write(SharedPRFData *data, bool should_erase) {
if (should_erase) {
flash_erase_subsector_blocking(FLASH_REGION_SHARED_PRF_STORAGE_BEGIN);
}
flash_write_bytes((const uint8_t*) data, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, sizeof(*data));
}
static void prv_apply_patch_to_struc... |
/*
* 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_DEVICE_METRIC_BATTERY_CHARGE_TIME, expected_value,
AnalyticsClient_System) | ;
// After calling analytics_logging_system_task_cb, the analytics code should call into
// dls_log with the device heartbeat data, where we check that the value
// therein is stored correctly.
analytics_logging_system_task_cb(NULL);
cl_assert(dls_log_called);
}
DataLoggingResult dls_log(DataLoggingSession ... |
LE
#define STM32F7_COMPATIBLE
#include <mcu.h>
#include "FreeRTOS.h"
#include "task.h"
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#ifdef NO_WATCHDOG
#include "debug/setup.h"
#endif
#define APP_THROTTLE_TIME_MS 300
// These bits get set by calls to task_watchdog_bit_set and checked and cleared pe... | {
prv_log_stuck_task(reboot_reason, task_index);
if (task_index == PebbleTask_NewTimers) {
prv_log_stuck_timer_task(reboot_reason);
} else if (task_index == PebbleTask_KernelBackground) {
prv_log_stuck_system_task(reboot_reason);
}
} |
}
}
// -------------------------------------------------------------------------------------------------
// The Timer ISR. This runs at super high priority (higher than configMAX_SYSCALL_INTERRUPT_PRIORITY), so
// it is not safe to call ANY FreeRTOS functions from here.
void TIM2_IRQHandler(void) {
// Workaround ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | ((Layer *)&layer, &ctx) | ;
expected_rect = BITMAP_LAYER_BOUNDS;
cl_assert(grect_equal(&s_graphics_draw_bitmap_in_rect__rect, &expected_rect));
}
|
clude "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_logging.h"
#include "test_recognizer_impl.h"
static bool s_manager_state_change = false;
void recognizer_manager_handle_state_change(RecognizerManager *manager, Recognizer *changed) {
s_manager_state_change = true;
}
static TestImplData s_test_im... | recognizer_transition_state(r, RecognizerState_Completed) | |
should_context_switch);
return;
}
if (UNLIKELY(c == 0x7f)) { // Backspace
if (s_dbgserial_prompt_context.write_index != 0) {
s_dbgserial_prompt_context.write_index--;
dbgserial_putchar(0x8); // move cursor back one character
dbgserial_putchar(0x20); // replace that ... | (PROMPT_RESP_DONE, NULL) | ;
}
return;
}
// ACK the command
pulse_send_message(PROMPT_RESP_ACK, NULL);
s_latest_cookie = command->cookie;
s_executing_command = ExecutingCommandPulse;
// Discount the size of the cookie
size_t command_length = length - sizeof(PromptCommand);
strncpy(s_dbgserial_prompt_context.buffer, com... |
eof(expanded_fmt_buffer));
// Craft a buffer that will hold HcProtocolMessage followed by BinLogMessage.
int msg_buffer_size = MAX((msg_size + sizeof(HcProtocolMessage)), 130);
uint8_t msg_buffer[msg_buffer_size];
memset(msg_buffer, 0, msg_buffer_size);
HcProtocolMessage *hc_msg = (HcProtocolMessage *)&msg_... | MEMBER_SIZE(BinLogMessage_UnhashedBody, filename) | );
msg->body.core_number = CORE_ID_BLE;
msg->body.task_id = task_get_dialogtask();
msg->body.level = log_level;
// Temporarily reserve space for a NULL terminator
// TODO: remove NULL termination
uint8_t max_str_len = msg_buffer_size - sizeof(BinLogMessage_Unhashed_v1) - 1;
va_list args;
va_start(args... |
ModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_wordwrap_clip_outside_nx(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(-80, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentC... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_ellipsis_clip_outside_x.${BIT_DEPTH_NAME}.pbi")) | ;
// Word Wrap tests
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_ny);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_ny.${BIT_DEPTH_NAME}.pbi"));
test_graphics_cont... |
/*
* 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 BOARD_CONFIG_POWER.chg_en.gpio != 0;
} |
// These are the guts of battery_set_charge_enable(), called when we already have periph_config_acquire_lock
static void prv_battery_set_charge_enable(bool charging_enabled) {
if (board_has_chg_en()) {
gpio_use(BOARD_CONFIG_POWER.chg_en.gpio);
GPIO_WriteBit(BOARD_CONFIG_POWER.chg_en.gpio, BOARD_CONFIG_POWE... |
end(head, &subscription->node);
PBL_LOG(LOG_LEVEL_DEBUG, "Added BLE subscription for handle 0x%x", att_handle);
did_create_new_subscription = true;
}
// Keeping this around in case the write fails:
const BLESubscription previous_type = subscription->subscriptions[client];
// Update the client state:
... | (prv_cleanup_subscriptions_for_client, (void *)(uintptr_t) client) | ;
}
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
void gatt_client_subscriptions_cleanup_by_connection(struct GAPLEConnection *connection,
bool should_unsubscribe) {
bt_lock();
{
GATT... |
// Pop the modal window off the stack
window_stack_remove(window2, true);
cl_assert_equal_i(window_stack_count(modal_stack), 0);
cl_assert_equal_i(window2->on_screen, false);
// Switch to app happens via the compositor
compositor_transition(NULL);
// Call the upkeep function so the change in state is h... | cl_assert_equal_b(windows[idx]->on_screen, (idx == NumModalPriorities - 1)) | |
d_time_s = timestamp_ms / MS_PER_SECOND;
}
prv_unlock();
}
// ------------------------------------------------------------------------------------
// We use NOINLINE to reduce the stack requirements during the minute handler (see PBL-38130)
// Returns distance we traveled in the last minute, in mm.
static uint32_... | prv_activity_update_states(utc_sec, record_out, false /* shutting_down */) | ;
// Handle storage and logging of the minute data
prv_log_minute_data(utc_sec, record_out);
// Reset the minute stats
s_alg_state->minute_steps = 0;
prv_unlock();
}
// ------------------------------------------------------------------------------------
bool activity_algorithm_get_steps(uint16_t *steps) {... |
/*
* 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... | {
// Unaligned start address or unaligned erase size
CD_ASSERTN(0);
} |
status_t status;
while ((status = flash_impl_get_erase_status()) == E_BUSY) delay_us(100);
CD_ASSERTN(status == S_SUCCESS);
total_bytes -= erase_size;
start_addr += erase_size;
}
watchdog_feed();
}
uint32_t cd_flash_write_bytes(const void *buffer_ptr, uint32_t start_addr,
... |
(task == PebbleTask_App || task == PebbleTask_Worker);
// Enqueue it for KernelBG to process
bool success = system_task_add_callback(cb, context);
if (!success) {
return false;
}
RtcTicks end_ticks = rtc_get_ticks() + timeout_sec * configTICK_RATE_HZ;
while (!(*cb_completed)) {
// NOTE: we use whi... | {
return system_task_add_callback(prv_start_tracking_cb, (void *)test_mode);
} |
// ------------------------------------------------------------------------------------------------
bool activity_stop_tracking(void) {
mutex_lock_recursive(s_activity_state.mutex);
{
prv_stop_tracking_early();
}
mutex_unlock_recursive(s_activity_state.mutex);
return system_task_add_callback(prv_stop_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... | ADC_EOCOnEachRegularChannelCmd(ADC1, ENABLE) | ;
ADC_Cmd(ADC1, ENABLE);
delay_us(3); // Wait Tstab = 3us for ADC to stabilize
*reading_out = (VoltageReading) {};
int i = 0;
while (i < NUM_CONVERSIONS) {
ADC_SoftwareStartConv(ADC1); // Restart the conversion group
if (!prv_wait_for_conversion()) {
continue;
}
const uint16_t vref =... |
/*
* 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... | string_list_count(list) | );
cl_assert_equal_s("a", string_list_get_at(list, 0));
cl_assert_equal_s("bc", string_list_get_at(list, 1));
// add a string to an empty string list
list->serialized_byte_length = 0;
string_list_add_string(list, 20, "hello", 10);
cl_assert_equal_i(5, list->serialized_byte_length);
cl_assert_equal_i(1, s... |
may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIE... | (LOG_LEVEL_DEBUG, "", 0, "Test") | |
steps_y);
GRect box = {.size = GSize(DISP_COLS, height)};
const GPoint origin = GPoint(delta * sx, delta * sy);
if (mode == RenderMoveTextBox) {
box.origin = origin;
ctx.draw_state.drawing_box.origin = GPointZero;
} else {
ctx.draw_state.drawing_box.origin = origin;
... | {
TextLayoutExtended layout = {
.flow_data = {
.perimeter.impl = &(GPerimeter){.callback=perimeter_for_display_round},
.perimeter.inset = 8,
.paging.page_on_screen = {
.origin_y = 25,
.size_h = 100
}, // setting a page height != enables positioning
},
};
char first... |
"a b c d e f g h j k l m n o p q r s t u v w x y z "
"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
"a b c d e f g h j k l m n o p q r s t u v w x y z";
char *texts[] = {
first_page_one_line,
second_page_o... |
"Zzz..\ntotal: %s\ndeep: %s\nenter: %s\nexit: %s",
total_sleep_str, deep_sleep_str, bed_time_str, wake_time_str);
text_layer_set_text(data->sleep_card.text_layer, data->sleep_card.text);
}
// -------------------------------------------------------------------------------
static void sleep_win... | text_layer_set_text(data->steps_card.time_layer, data->steps_card.time_text) | ;
}
if (data->lap_steps > data->cur_steps) {
// We probably encountered a midnight rollover, reset the persistent storage too
data->lap_steps = data->cur_steps;
persist_write_int(AppPersistKeyLapSteps, data->lap_steps);
}
if (data->steps_card.delta_step_layer) {
if (data->lap_steps) {
sn... |
/*
* 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... | boot_bit_set(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS) | ;
FirmwareDescription firmware_description =
firmware_storage_read_firmware_description(flash_address);
if (!firmware_storage_check_valid_firmware_description(&firmware_description)) {
dbgserial_putstr("Invalid firmware description!");
return UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED;
}
if (!check_... |
ic.x + min_x, dest_ic.y + min_y, size_x, size_y);
grect_clip(&dest_clip, &dest_clip_min);
}
for (int y = dest_clip.origin.y; y < dest_clip.origin.y + dest_clip.size.h; ++y) {
for (int x = dest_clip.origin.x; x < dest_clip.origin.x + dest_clip.size.w; ++x) {
// only draw if within the dest range
... | graphics_release_frame_buffer(ctx, dest_bitmap) | ;
}
|
ART:
// Generate a repeat start
bus->i2c->CR1 |= I2C_CR1_START;
bus->transfer.state = TRANSFER_STATE_WRITE_ADDRESS_RX;
break;
case TRANSFER_STATE_WRITE_ADDRESS_RX:
// Write the I2C device address again, but this time in read mode.
bus->i2c->DR = bus->transfer.device_address | I2... | {
PBL_LOG(LOG_LEVEL_ERROR, "NACK received during I2C transfer; Bus: 0x%p", bus->i2c);
} |
}
return end_transfer_irq(bus, false);
}
void I2C1_EV_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_event_handler(&i2c_buses[0]));
}
void I2C1_ER_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_error_handler(&i2c_buses[0]));
}
void I2C2_EV_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_event_handler(&i2c_buse... |
o(x2, b2);\n"
"\n"
" ctx.lineWidth = i;\n"
" ctx.stroke();\n"
"}\n"
"for (var i = 1; i <= 5; i++) {\n"
" ctx.beginPath();\n"
" var y1 = 40 + i * 20;\n"
" var y2 = y1 + 10.5;\n"
" ctx.moveTo(t1, y1);\n"
" ctx.lineTo(b1, y1);\n"
" ctx.moveTo(t1, y2);\n"
... | (&s_context.dest_bitmap, TEST_NAMED_PBI_FILE("rocky_rendering_arc")) | ;
cl_check(eq_result);
} |
t, NULL);
graphics_draw_text(&gcontext, "", font, box,
GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
void test_text_layout__max_used_size(void) {
char *empty_string = "";
char *singleton = "A";
char *doubleton = "AA";
GFont font = (GFont){ 0 };
GRect box = (GRect) { (GPoint) { 0,... | cl_assert_equal_i(data1->paging.page_on_screen.size_h, 0) | ;
// change SP so that we can make sure that graphics_text_layout_get_flow_data doesn't rely on it
uint8_t change_stack[data1->paging.page_on_screen.size_h + 500];
memset(change_stack, 0xff, 500);
const TextLayoutFlowData *data2 = graphics_text_layout_get_flow_data(NULL);
cl_assert_equal_p(data1, data2);
... |
DS_PER_MINUTE;
#endif
// deal with all day events
if (node->all_day && node->timestamp == midnight) {
return show_all_day_events;
} else if (direction == TimelineIterDirectionFuture) {
return (node->timestamp >= timestamp - fudge_time);
} else { // direction == TimelineIterDirectionPast
return (node... | {
// first item has correct timestamp, duration should make it last for the rest of the day
const time_t until_midnight = midnight_first + SECONDS_PER_DAY - header->timestamp;
nodes[0]->duration = until_midnight / SECONDS_PER_MINUTE;
// last item at end of event, duration 0
time_t endtime = header-... |
nodes[0]->all_day = (nodes[0]->duration == MINUTES_PER_DAY &&
nodes[0]->timestamp == midnight_first);
// middle days are all day events
time_t midnight = time_util_get_midnight_of(header->timestamp);
for (int i = 1; i < num_nodes - 1; i++) {
midnight += SECONDS_PER_DAY;
nodes[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... | text_layer_init(&data->count_layer, &GRect(0, 0, width, 20)) | ;
layer_add_child(&data->window.layer, &data->count_layer.layer);
text_layer_init(&data->connected_layer, &GRect(0, 20, width, 20));
layer_add_child(&data->window.layer, &data->connected_layer.layer);
text_layer_set_text(&data->count_layer, "No Presses");
text_layer_set_text(&data->connected_layer, "No conne... |
416, 1552, -88},
{ -1200, 216, -112},
{ -1616, 560, 24},
{ -1168, 592, -88},
{ -1024, 432, -56},
{ -1184, 376, 56},
{ -1360, 312, 104},
{ -1152, 200, 80},
{ -1064, 160, 112},
{ -1136, 144, 160},
{ -1224, 40, 176},
// 81 seconds
{ -1152, 16, 128},
{ -1168, 72, 136},
... | { -1128, 416, -64},
{ -1336, 592, -304},
{ -1584, 592, -112},
{ -1384, 496, 32},
{ -1200, 1040, -128},
{ -1112, 920, 80},
{ -792, 912, -40},
{ -576, 1136, -32},
{ -344, 944, -152},
{ -312, 1024, -152},
{ -32, 496, 96},
{ -136, -32, -248},
{ 136, -248, -616},
{ 88,... |
{ -1992, 216, 80},
{ -2968, 272, 56},
{ -2672, 520, -456},
{ -1888, 304, -328},
{ -1616, -344, -96},
{ -1504, 128, 120},
{ -1208, 448, 96},
{ -880, 400, 80},
{ -712, 368, 24},
{ -720, 288, 32},
// 89 seconds
{ -792, 320, -24},
{ -832, 280, 88},
{ -1080, 424, 56},... |
tion is still running, fast-foward to 300ms from the end
if (animation_is_scheduled(s_animation)) {
uint32_t duration = animation_get_duration(s_animation, true, true);
animation_set_elapsed(s_animation, duration - 300);
APP_LOG(APP_LOG_LEVEL_INFO, "Advancing to 300ms from the end of %d ms", (int)duration... | window_get_root_layer(window) | |
Keep a write offset, this won't work when we try to roll over to the other 25% of the sectors
if (s_valid_page_idx == SPRF_PAGE_IDX_INVALID) {
prv_erase_region_and_save(NULL);
} else if (s_valid_page_idx > (SPRF_MAX_NUM_PAGES_MULT(SPRF_NUM_PAGES))) {
prv_erase_region_and_save(&data);
}
}
pr... | strncpy(name_out, name_data.name, BT_DEVICE_NAME_BUFFER_SIZE) | ;
} else {
name_out[0] = '\0';
}
}
rv = true;
}
unlock:
prv_unlock();
return rv;
}
void shared_prf_storage_store_ble_pairing_data(
const SMPairingInfo *pairing_info, const char *name, bool requires_address_pinning,
uint8_t flags) {
if (!pairing_info || sm_is_pairing_info_em... |
{
cd_flash_read_bytes(buffer_ptr, start_addr, buffer_size);
} | else {
flash_read_bytes(buffer_ptr, start_addr, buffer_size);
}
}
// -------------------------------------------------------------------------------------------------
// NOTE: We are explicitly avoiding use of vsniprintf and cohorts to reduce our stack
// requirements
static void prv_debug_str(const char* msg) ... | |
k = prv_rocky_tictoc_callback;
bool result = rocky_event_loop_with_string_or_snapshot(script, strlen(script));
cl_assert(result);
}
void test_js__rocky_tictoc_bw(void) {
GContext ctx = {};
s_app_state_get_graphics_context = &ctx;
prv_deinit(); // engine will be re-initialized in rocky_event_loop~
char *sc... | prv_deinit() | ;
rocky_runtime_context_init();
jerry_init(JERRY_INIT_SHOW_OPCODES);
char *const script = prv_load_js("color");
uint8_t snapshot[65536] = { 0 };
// make sure snapshot data starts with expected Rocky header
const size_t header_size = sizeof(ROCKY_EXPECTED_SNAPSHOT_HEADER);
cl_assert_equal_i(8, header_size... |
app_smartstrap_attribute_destroy(attr);
// destroy again (shouldn't do anything bad)
app_smartstrap_attribute_destroy(attr);
}
void test_app_smartstrap__read(void) {
// create the attribute
SmartstrapAttribute *attr = app_smartstrap_attribute_create(0x1111, 0x2222, 100);
// start a read request
stub_pe... | cl_assert(write_buffer == (uint8_t *)attr) | ;
cl_assert(write_length == 100);
// end the write request without sending anything
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, true));
// start the write request again
write_buffer = NULL;
write_length = 0;
assert_result_ok(app_smartstrap_attribute_begin_write(attr, &write_buffer,... |
ction.h"
#include "services/common/hrm/hrm_manager_private.h"
#include <bluetooth/hrm_service.h>
#include <btutil/bt_device.h>
#include <util/size.h>
#include <clar.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// Stubs & Fakes
#include "fake_event_service.... | ARRAY_LENGTH(s_connections) | ; ++i) {
cb(s_connections[i], data);
}
}
void launcher_task_add_callback(CallbackEventCallback callback, void *data) {
callback(data);
}
bool sys_hrm_manager_is_hrm_present(void) {
return true;
}
static int s_sys_hrm_manager_unsubscribe_call_count;
bool sys_hrm_manager_unsubscribe(HRMSessionRef session) {
... |
= INVALID_MUTEX_HANDLE);
}
void pulse_start(void) {
for (unsigned int i = 0; i < ARRAY_LENGTH(s_receive_buffers); ++i) {
s_receive_buffers[i] = kernel_malloc_check(sizeof(IncomingPulseFrame));
prv_return_receive_buffer(s_receive_buffers[i]);
}
s_current_receive_buffer = prv_take_receive_buffer();
s_dro... | if (UNLIKELY(s_current_receive_buffer->length >=
sizeof(s_current_receive_buffer->data))) {
// Frame too long; invalid.
s_drop_rest_of_frame = true;
prv_reset_receive_buffer(s_current_receive_buffer);
} else {
if (!cobs_streaming_decode(&s_frame_decode_ctx, c)) {
s_drop_rest_of_fram... |
}
void *pulse_best_effort_send_begin(const uint8_t protocol) {
mutex_lock(s_tx_buffer_mutex);
s_tx_buffer[COBS_OVERHEAD(PULSE_MAX_SEND_SIZE)] = protocol;
// Expose only the payload of the message
return s_tx_buffer + COBS_OVERHEAD(PULSE_MAX_SEND_SIZE) + 1;
}
void pulse_best_effort_send(void *buf, const size... |
/*
* 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... | (fmt_args, fmt) | |
,
{ -904, 848, 256},
{ -832, 776, 160},
{ -728, 616, 56},
{ -624, 424, 8},
{ -520, 304, -56},
{ -480, 256, 0},
{ -536, 424, -24},
{ -664, 480, 96},
{ -672, 528, 96},
{ -680, 672, 120},
{ -752, 816, 152},
{ -552, 1064, 8},
{ -792, 1104, -8},
{ -880, 944, 120},
... | { -88, -248, -952},
{ -88, -232, -952},
{ -96, -208, -936},
{ -88, -200, -944},
{ -80, -192, -952},
{ -88, -192, -968},
{ -128, -200, -952},
{ -112, -232, -936},
{ -136, -168, -952},
{ -136, 0, -968},
// 62 seconds
{ -72, 248, -880},
{ -32, 552, -776},
{ 56, 888, ... | |
(logging_sessions[i], item_size[i], rand() % 123) | ;
}
}
// ----------------------------------------------------------------------------------------
// Test writing and consuming so much that we are forced to reallocate the file partway
// through
void test_data_logging__log_realloc(void) {
DataLoggingSessionRef logging_sessions[5];
const int item_size = 1;
... | |
.id = {0xcc},
.parent_id = {0},
.timestamp = s_feb_5_midnight + 8 * 60 * 60, // 8:00-10:00 am
.duration = 120,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
}, {
.header = {
.id = {0xdd},
.parent_id = {0},
.timestamp = s_feb_5_mi... | (iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check third
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fourth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
/... |
IMELINE_LAYER; i++) {
TimelineLayout *layout = layer->layouts[i];
if (layout) {
prv_set_layout_hidden(layout, hidden);
}
}
layer_set_hidden((Layer *)&layer->end_of_timeline, hidden);
}
void timeline_layer_init(TimelineLayer *layer, const GRect *frame_ref,
TimelineScrollD... | timeline_relbar_layer_deinit(layer) | ;
#endif
}
|
/*
* 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... | dbgserial_print(expr) | |
state->aux);
AnimationPrivate *saved_current_animation = kernel_animation_state->aux->current_animation;
kernel_animation_state->aux->current_animation = animation_private;
compositor_transition_render(s_animation_state.impl->update, animation, distance_normalized);
kernel_animation_state->aux->current_animati... | {
// Modal to Modal or App to Modal
// We can start animating immediately if we're going to a modal window. This is because
// modal window content is drawn on demand so it's always available.
if (compositor_animation) {
s_state = CompositorState_Transitioning;
animation_schedule(s_animatio... | else {
// App to App
// We have to wait for the app to populate its framebuffer
s_state = CompositorState_AppTransitionPending;
}
}
FrameBuffer *compositor_get_framebuffer(void) {
return &s_framebuffer;
}
GBitmap compositor_get_framebuffer_as_bitmap(void) {
return framebuffer_get_as_bitmap(&s_fram... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | text_layer_get_layer(text_heap_info) | );
}
static void deinit(void) {
// Don't free anything
}
static void s_main(void) {
init();
app_event_loop();
deinit();
}
const PebbleProcessMd* app_heap_demo_app_get_info(void) {
static const PebbleProcessMdSystem s_app_heap_demo_app_info = {
.common.main_func = &s_main,
.name = "AppHeap"
};
r... |
millis) {
s_sys_psleep_last_millis = millis;
}
AppMessageCtx *app_state_get_app_message_ctx(void) {
return &s_app_message_ctx;
}
bool app_message_receiver_open(size_t buffer_size) {
if (s_app_receiver_oom) {
return false;
}
s_is_app_message_receiver_open = true;
return true;
}
void app_message_recei... | app_message_register_inbox_dropped(prv_in_dropped_callback) | , NULL);
cl_assert_equal_p(app_message_register_inbox_received(prv_in_received_callback), NULL);
s_out_sent_call_count = 0;
s_out_failed_call_count = 0;
s_ack_sent_is_called = false;
s_nack_sent_is_called = false;
s_in_received_is_called = false;
s_in_dropped_is_called = false;
s_ack_received_for_id_1 ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
qspi_indirect_write_no_addr(dev->qspi, cmd, NULL, 0);
} |
static void prv_write_enable(QSPIFlash *dev) {
prv_write_cmd_no_addr(dev, dev->state->part->instructions.write_enable);
// wait for writing to be enabled
qspi_poll_bit(dev->qspi, dev->state->part->instructions.read_status,
dev->state->part->status_bit_masks.write_enable, true /* set */, QSPI_NO_... |
_equal_i(s_circle_fill_count, 0);
cl_assert_equal_i(s_circle_stroke_count, 0);
cl_assert_equal_p(s_stroke_points, NULL);
cl_assert_equal_p(s_fill_points, NULL);
free(command);
}
static GDrawCommandList *prv_create_command_list_3(void) {
GDrawCommandList *command_list = malloc(sizeof(GDrawCommandList) + (3 *... | (!gdraw_command_list_validate(command_list, size)) | ;
command_list->num_commands = 3;
GDrawCommand *command = gdraw_command_list_get_command(command_list, 0);
command->num_points = 0;
cl_assert(!gdraw_command_list_validate(command_list, size));
command->num_points = 2;
command = gdraw_command_list_get_command(command_list, 2);
command->num_points = 4;
cl... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | layer_get_bounds_by_value(layer) | ;
// Fill the background
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, &layer_bounds);
// Draw the text
prv_draw_text(ctx, &layer_bounds);
// Create the mask and start recording
const bool transparent = false;
GDrawMask *mask = graphics_context_mask_create(ctx, transparen... |
/*
* 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(TimezoneInfo) <= 5 * sizeof(uint32_t),
"RTC Set Timezone invalid data size") | ;
RTC_WriteBackupRegister(RTC_TIMEZONE_ABBR_START, raw[0]);
RTC_WriteBackupRegister(RTC_TIMEZONE_ABBR_END_TZID_DSTID, raw[1]);
RTC_WriteBackupRegister(RTC_TIMEZONE_GMTOFFSET, raw[2]);
RTC_WriteBackupRegister(RTC_TIMEZONE_DST_START, raw[3]);
RTC_WriteBackupRegister(RTC_TIMEZONE_DST_END, raw[4]);
}
void rtc_... |
/*
* 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... | window_stack_push(window, animated) | ;
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
/*
* 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... | reset_due_to_software_failure() | ;
}
static __attribute__((noreturn)) void handle_passert_failed(const char* filename, int line_number,
uintptr_t lr, const char *expr, const char* fmt, ...) {
va_list fmt_args;
va_start(fmt_args, fmt);
handle_passert_failed_vargs(filename, line_number, lr, expr, fmt, fmt_args);
va_end(fmt_args);
}
void ... |
__assert_equal_i((i1),(i2),file,line,#i1 " != " #i2, 1)
// Globals
AccelSamplingRate s_sample_rate;
static bool s_dls_created;
static DataLoggingSession *s_dls_session = (DataLoggingSession *)1;
// Logged items
static bool s_capture_dls_records = true;
static int s_num_dls_records;
static AlgMinuteDLSRecord s_dls_re... | (item_size, sizeof(AlgMinuteDLSRecord)) | |
GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, true, 2, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
#if PBL_COLOR
ASSERT_CALLED(graphics_circ... | ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GRect(10, 20, 40, 10), 0, GCornerNone, GColorBlack)) | ;
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10));
setup_test(&context, false, 5, GColorBlack, GColorBlack, false);
graphics_fill_round_rect(&context, &GRect(20, 80, ... |
/*
* 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... | (&rot_bitmap_layer->layer) | ;
}
void rot_bitmap_layer_destroy(RotBitmapLayer *rot_bitmap_layer) {
if (rot_bitmap_layer == NULL) {
return;
}
rot_bitmap_layer_deinit(rot_bitmap_layer);
applib_free(rot_bitmap_layer);
}
void rot_bitmap_layer_set_corner_clip_color(RotBitmapLayer *image, GColor color) {
if (gcolor_equal(color, image->co... |
< oldest_valid_time_utc);
}
static bool prv_fill_forecast_from_entry(WeatherDBEntry *entry,
WeatherLocationForecast *forecast_out) {
PascalString16List pstring16_list;
pstring_project_list_on_serialized_array(&pstring16_list, &entry->pstring16s);
PascalString16 *location_... | (LOG_LEVEL_ERROR, "No SerializedWeatherAppPrefs available!") | ;
return false;
}
// Can occur if the user removes all weather locations from their mobile app
if (prefs->num_locations == 0) {
watch_app_prefs_destroy_weather(prefs);
return false;
}
const size_t default_location_index = 0;
*key_out = prefs->locations[default_location_index];
watch_app_pre... |
he time at which this entry will wake up at
bool utc; //!< If timezone has been set, the this is UTC time
} WakeupEntry;
typedef struct PACKED {
WakeupId current_wakeup_id;
WakeupId next_wakeup_id;
time_t timestamp;
} WakeupState;
struct prv_missed_events_s {
uint8_t missed_apps_count;
AppInstallId *misse... | (s_current_timer_id) | ;
}
mutex_lock(s_mutex);
{
// Find the next event to occur
SettingsFile wakeup_settings;
if (settings_file_open(&wakeup_settings, SETTINGS_FILE_NAME, SETTINGS_FILE_SIZE) == S_SUCCESS) {
// Reset wakeup state to use for the search
s_wakeup_state.current_wakeup_id = -1;
s_wakeup_state... |
et_ticks() + ACK_NACK_TIMEOUT_TICKS;
break;
case DataLoggingSessionCommStateIdle:
session->comm.ack_timeout = 0;
break;
}
if (reschedule) {
reschedule_ack_timeout();
}
}
static void send_timeout_msg(void *session_id_param) {
uint8_t session_id = (uint8_t)(uintptr_t)session_id_param;
CommSe... | {
PBL_ASSERTN(message != NULL);
switch (message[0]) {
case DataLoggingEndpointCmdClose:
{
DataLoggingCloseSessionMessage *msg = (DataLoggingCloseSessionMessage *)message;
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Closing session %d", msg->session_id);
break;
}
case Data... |
bool dls_endpoint_open_session(DataLoggingSession *session) {
CommSession *comm_session = comm_session_get_system_session();
if (!session) {
return false;
}
DataLoggingOpenSessionMessage msg = {
.command = DataLoggingEndpointCmdOpen,
.session_id = session->comm.session_id,
.app_uuid = session... |
/*
* 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 (app_install_get_entry_for_install_id(next_app_id, app_entry) &&
app_install_entry_is_watchface(app_entry)) {
if (current_app_id == APP_ID_LAUNCHER_MENU) {
res = prv_get_watchface_compositor_animation(CompositorTransitionDirectionLeft);
goto done;
} else if (current_app_id == APP_ID_HEALTH_... |
if (next_app_id == APP_ID_LAUNCHER_MENU) {
res = prv_app_launcher_transition_animation(CompositorTransitionDirectionLeft);
goto done;
}
// If we get here, we don't use a compositor animation for the transition
done:
kernel_free(app_entry);
return res;
}
const CompositorTransition *shell_get_open_... |
s_draw_vertical_line_dotted(&ctx, GPoint(9, 0), 2);
graphics_draw_vertical_line_dotted(&ctx, GPoint(11, 0), 3);
graphics_draw_vertical_line_dotted(&ctx, GPoint(13, 0), 4);
graphics_draw_vertical_line_dotted(&ctx, GPoint(15, 0), 20);
graphics_draw_vertical_line_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_ve... | (&ctx, GPoint(15, 0), 20) | ;
graphics_draw_vertical_line_dotted(&ctx, GPoint(17, 0), 21);
graphics_draw_vertical_line_dotted(&ctx, GPoint(19, 0), 22);
graphics_draw_vertical_line_dotted(&ctx, GPoint(21, 0), MAX_NUM_ROWS - 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(23, 0), MAX_NUM_ROWS + 1 );
cl_check(gbitmap_pbi_eq(&ctx.dest_b... |
log_text, temp, sizeof(data->debug_card.dialog_text));
// Weekly avg
avg = health_service_sum_averaged(metric, day_start, day_start + SECONDS_PER_DAY,
HealthServiceTimeScopeWeekly);
snprintf(temp, sizeof(temp), "\nweekly: %d", (int)avg);
prv_safe_strcat(data->debug_card.dial... | (APP_LOG_LEVEL_DEBUG, "Result from aggregate_averaged resting cals: %"PRIi32" ", value) | ;
if (value != 0) {
passed = false;
goto exit;
}
// Getting heart rate using sum should fail
value = health_service_aggregate_averaged(HealthMetricHeartRateBPM, time_start_of_today(),
time(NULL), HealthAggregationSum,
... |
92, -264},
{ 1240, -120, -200},
{ 856, -48, -280},
{ 752, -40, -360},
{ 1120, -128, -296},
{ 1240, -208, -120},
{ 1176, -200, -72},
{ 1128, -144, -104},
{ 1064, -88, -112},
{ 1040, -80, -160},
{ 1024, -96, -160},
// 39 seconds
{ 968, -104, -136},
{ 984, -104, -144},
... | { 952, 256, 40},
{ 904, 272, -24},
{ 824, 272, -96},
{ 848, 184, -48},
{ 928, 144, -56},
{ 896, 56, -80},
{ 920, 88, -96},
{ 968, 0, -88},
{ 1024, -48, -56},
{ 1080, -80, -80},
{ 1128, -72, -136},
{ 1528, 16, 64},
{ 1544, -48, -8},
{ 1304, -32, -48},
{ 984, -7... |
{ 1016, -80, -120},
{ 1032, -96, -160},
{ 1016, -136, -176},
{ 1032, -144, -160},
{ 1168, -72, -160},
{ 1248, -8, -184},
{ 1280, 32, -200},
{ 1248, 40, -280},
// 47 seconds
{ 1048, -16, -280},
{ 1144, -80, -224},
{ 1352, -104, -240},
{ 1304, -152, -200},
{ 1248, ... |
Alignment_t *)heap->end) - heap->begin->PrevSize);
} else {
heap_info_ptr = heap->begin;
}
/* Loop until we have walked the entire list. */
while (((n_units < LARGE_SIZE) || (heap_info_ptr > heap->begin)) && (heap_info_ptr < heap->end)) {
prv_sanity_check_block(heap, heap_info_ptr);
... | heap_malloc(heap, nbytes, client_pc) | ;
if (new_ptr && ptr) {
// Copy over old data.
const HeapInfo_t *heap_info_ptr = HEAP_INFO_FOR_PTR(ptr);
const uint16_t original_size = heap_info_ptr->Size * ALIGNMENT_SIZE;
memcpy(new_ptr, ptr, MIN(nbytes, original_size));
heap_free(heap, ptr, client_pc);
}
return new_ptr;
}
void* heap_zallo... |
andle_syscall_exit(void) {
PebbleTask task = pebble_task_get_current();
ProcessContext *context = prv_get_context_for_task(task);
if (context->closing_state == ProcessRunState_ForceClosing) {
PBL_LOG(LOG_LEVEL_DEBUG, "Hit syscall exit trap!");
context->safe_to_kill = true;
process_manager_put_kill_pr... | if (!app_cache_entry_exists(id)) {
PBL_LOG(LOG_LEVEL_DEBUG, "Cache entry did not exist on launch attempt");
return true;
} |
*md = app_install_get_md(id, is_worker);
if (!is_worker && rocky_app_validate_resources(*md) == RockyResourceValidation_Invalid) {
PBL_LOG(LOG_LEVEL_DEBUG, "App has incompatible JavaScript bytecode");
// TODO: do we need to purge the app cache here?
return true;
}
return false;
}
#endif
void ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | timeline_item_layer_set_click_config_onto_window(item_layer, window) | ;
layer_add_child(&pin_window->layer, &item_layer->layer);
layer_init(&pin_window->action_button_layer, &window_layer->bounds);
layer_set_clips(&pin_window->action_button_layer, false);
pin_window->action_button_layer.update_proc = action_button_update_proc;
layer_add_child(&pin_window->layer, &pin_window->a... |
--
//! Kills the process, giving it no chance to clean things up or exit gracefully. The proces must already be in a
//! state where it's safe to exit, so the caller must call process_manager_make_process_safe_to_kill() first and only
//! call this method if process_manager_make_process_safe_to_kill() returns true;
voi... | {
PBL_ASSERTN(callback != NULL);
PebbleEvent event = {
.type = PEBBLE_CALLBACK_EVENT,
.callback = {
.callback = callback,
.data = data,
},
};
process_manager_send_event_to_process(task, &event);
} |
// ----------------------------------------------------------------------------------------------
void *process_manager_address_to_offset(PebbleTask task, void *system_address) {
ProcessContext *context = prv_get_context_for_task(task);
if (system_address >= context->load_start &&
system_address < context->... |
am[out] stats the stats for this metric are returned here
// @param[in] weekly_day which day of the week to use when computing the weekly stats
static bool prv_get_metric_stats(HealthServiceState *state, HealthMetric metric,
HealthServiceMetricStats *stats, DayInWeek weekly_day) {
// ... | sys_activity_get_step_averages(day_in_week, averages) | |
/*
* 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... | memcpy(val_out, s_settings_file.values[key_crc8], val_out_len) | |
/*
* 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_data.order_mutex) | ;
int storage_size = sizeof(AppMenuOrderStorage) + (storage->list_length * sizeof(AppInstallId));
int fd = pfs_open(ORDER_FILE, OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, storage_size);
if (fd == E_DOES_NOT_EXIST) {
// File doesn't exist, need to create a new file.
fd = pfs_open(ORDER_FILE, OP_FLAG_WRITE, FIL... |
.min);
} else if (strcmp(token, "TEST_IN_SLEEP_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.max);
} else if (strcmp(token, "TEST_IN_DEEP_SLEEP") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_deep_sleep.value);
} else if (st... | (NULL, " \t\n") | ;
if (strcmp(token, "TEST_VERSION") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.version);
} else if (strcmp(token, "TEST_ACTIVITY_TYPE") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.value);
} else if (strcmp(token, "TEST_ACTIV... |
ppData *data, TimelineAppState prev_state,
uint32_t duration) {
PeekLayer *peek_layer = &data->peek_layer;
if (prev_state == TimelineAppStateNoEvents ||
prev_state == TimelineAppStatePeek ||
prev_state == TimelineAppStateHidePeek) {
prv_cleanup_timer(&data... | prv_set_state(data, TimelineAppStateCard) | |
Context gcontext;
FrameBuffer *fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) { DISP_COLS, DISP_ROWS });
graphics_context_init(&gcontext, fb, GContextInitializationMode_App);
framebuffer_clear(fb);
GFont font = (GFont) { 0 };
GRect box = (GRect) { (GPoint) { 0, 0 }, (GSize) { 20 * HORIZ_A... | cl_assert(layout.box.size.w == box.size.w) | ;
cl_assert_equal_i(layout.max_used_size.w, 5 * HORIZ_ADVANCE_PX); // "JR..."
cl_assert_equal_i(layout.max_used_size.h, FONT_HEIGHT);
graphics_text_layout_get_max_used_size(&gcontext, "JR Whopper", font, box, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, (void*)&layout);
cl_assert(layout.box.size.w ... |
p, "draw_text_ajj22.${BIT_DEPTH_NAME}.pbi"));
// Test when clipping/drawing and text bounds are all at (2, 0) - no negative offset
setup_test_aa_sw(&ctx, fb, RECT_TEXT_2_0, RECT_TEXT_2_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "aaa", &s_font_info, RECT_TEXT_2_0,... | (&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL) | ;
cl_check(framebuffer_is_empty("draw_text_null_null", fb, GColorWhite));
// Test negative context boxes - ensure nothing is rendered
setup_test_aa_sw(&ctx, fb, RECT_NEG, RECT_NEG, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_TEXT_0_0,
... |
ry_WFI);
// We don't use ^^ the above function because of a silicon bug which
// causes the processor to skip some instructions upon wake from STOP
// in certain sitations. See the STM32F20x and STM32F21x Errata sheet
// section 2.1.3 "Debugging Stop mode with WFE entry", or the erratum
// of the same name in... | {
// operating on 64 bit values so the load/stores will _not_ be atomic
portENTER_CRITICAL();
RtcTicks ticks = prv_get_nostop_ticks(inhibitor, now_ticks);
s_inhibitor_profile[inhibitor].total_ticks_while_disabled = 0;
portEXIT_CRITICAL();
analytics_set(metric, ticks_to_milliseconds(ticks), AnalyticsClient_S... |
void analytics_external_collect_stop_inhibitor_stats(RtcTicks now_ticks) {
prv_collect(ANALYTICS_DEVICE_METRIC_CPU_NOSTOP_MAIN_TIME, InhibitorMain, now_ticks);
// We don't care about the serial console nostop time, it should always
// be zero on watches in the field anyway. (InhibitorDbgSerial skipped)
prv_co... |
void) {
Fixed_S16_3 num1, num2;
Fixed_S16_3 sum, sum_c;
// Test number addition
num1 = FIXED_S16_3_ONE;
num2 = FIXED_S16_3_ONE;
sum = Fixed_S16_3_add(num1, num2);
sum_c = (Fixed_S16_3){ .raw_value = (int16_t)((float)2 * (1 << FIXED_S16_3_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
//... | (memcmp(&num, &test_num, sizeof(Fixed_S32_16)) == 0) | ;
num = (Fixed_S32_16){ .raw_value = (int32_t)((float)-3.5 * (1 << FIXED_S32_16_PRECISION)) };
test_num = (int32_t)((float)-3.5 * (1 << FIXED_S32_16_PRECISION));
cl_assert(memcmp(&num, &test_num, sizeof(Fixed_S32_16)) == 0);
}
void test_math_fixed__S32_16_add(void) {
Fixed_S32_16 num1, num2;
Fixed_S32_16 s... |
true);
flash_enable_write_protection();
flash_prf_set_protection(true);
#if CAPABILITY_HAS_PMIC
pmic_init();
#endif // CAPABILITY_HAS_PMIC
#if CAPABILITY_HAS_MICROPHONE
mic_init(MIC);
#endif
#if CAPABILITY_HAS_TOUCHSCREEN
touch_sensor_init();
#endif
imu_init();
backlight_init();
ambient_light_init(... | display_init() | ;
// Use the MFG calibrated display offset to adjust the display
GPoint mfg_offset = mfg_info_get_disp_offsets();
display_set_offset(mfg_offset);
// Log display offsets for use in contact support logs
PBL_LOG(LOG_LEVEL_INFO, "MFG Display Offsets (%"PRIi16",%"PRIi16").", mfg_offset.x, mfg_offset.y);
// Can... |
must be loaded and comes directly
// after the vector table, it's 128 bytes
#define IVT_TABLE_SIZE (0x40 + 32 * 4 + 0x80)
static uint8_t s_vector_table[IVT_TABLE_SIZE];
static volatile bool s_expected_bytes_received = false;
static void prv_expect_byte_spi_int_cb(void *user_data, uint16_t transferred) {
s_expected_... | if (cmd[0] == 'V' && cmd[1] == 'T') {
prv_handle_vector_table_update_command();
} else if (cmd[0] == 'R' && cmd[1] == 'T') {
prv_handle_reboot_command();
} else {
debug_print_str("Unknown CMD:");
debug_print_str_and_int(" Byte 0:", cmd[0]);
debug_print_str_and_int(" Byte 1:", cmd[1... |
}
}
static void prv_configure_pins_for_spi_transfer(void) {
hw_gpio_set_pin_function(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs.function);
hw_gpio_set_pin_function(HOST_SPI->spi.cs_2.port, HOST_SPI->spi.cs_2.pin,
HW_GPI... |
"kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "services/common/comm_session/session.h"
#include "services/common/i18n/i18n.h"
#include "services/common/regular_timer.h"
#include "services/normal/alarms/alarm.h"
#include "services/normal/timezone_database.h"
#include "services/normal/wakeup.h"
#include "she... | gmtime_r(&uxtime, &time_tm) | ;
}
if (rule->flag & TIMEZONE_FLAG_STANDARD_TIME) { // Standard time (not wall time)
time_tm.tm_gmtoff = tz_info->tm_gmtoff;
time_tm.tm_isdst = 0;
} else if (rule->flag & TIMEZONE_FLAG_UTC_TIME) { // UTC
time_tm.tm_gmtoff = 0;
time_tm.tm_isdst = 0;
} else { // Wall time
time_tm.tm_gmtoff = ... |
/*
* 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_num_event_puts, 0) | ;
cl_assert_equal_i(s_num_packets_sent, 1);
cl_assert_equal_i(s_num_bytes_sent, LOG_METADATA_LENGTH + 4);
cl_assert_equal_s(s_log_message_buffer, "Test");
s_num_bytes_sent = 0;
pulse_logging_log(LOG_LEVEL_DEBUG, "", 0, "TestTestTestTestTest");
cl_assert_equal_i(s_num_event_puts, 0);
cl_assert_equal_i(s... |
{
bt_persistent_storage_set_active_gateway(bonding_id);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Not bonded or disconnected (%p)", connection);
}
bt_lock();
bt_driver_classic_disconnect(NULL);
bt_unlock();
}
static void prv_handle_services_removed(PebbleBLEGATTClientServicesRemoved *services_removed) {
... | if (event_info->status == BTErrnoServiceDiscoveryDisconnected) {
// TODO: In the past we'd disconnect when service discovery
// failed (not due to a disconnection)
return;
} |
if (event_info->status != BTErrnoServiceDiscoveryDatabaseChanged &&
event_info->status != BTErrnoOK) {
// gatt_client_discovery.c already logs errors for this condition
return;
}
if (event_info->type != PebbleServicesRemoved) {
// For removals, we log info in the handler routine
PBL_LOG(LO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.