prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | mutex_unlock(s_vibe_history_mutex) | ;
}
static void prv_vibe_history_start_event(void) {
if (!s_vibe_history_enabled) {
return;
}
VibeHistory *vibe = kernel_malloc(sizeof(VibeHistory));
if (vibe == NULL) {
s_vibe_history_enabled = false;
return;
}
list_init((ListNode*)vibe);
time_t s;
uint16_t ms;
rtc_get_time_ms(&s, &ms);
... |
ce->num_frames = 2;
sequence->version = 0xFF;
cl_assert(!gdraw_command_sequence_validate(sequence, size));
free(sequence);
}
void test_gdraw_command_sequence__get_frame_by_elapsed(void) {
GDrawCommandSequence *sequence;
prv_create_test_sequence(&sequence);
GDrawCommandFrame *frame = gdraw_command_sequen... | gdraw_command_sequence_clone(sequence) | ;
cl_assert(clone != sequence);
size_t expected_size = gdraw_command_sequence_get_data_size(sequence);
cl_assert_equal_i(gdraw_command_sequence_get_data_size(clone), expected_size);
cl_assert_equal_i(0, memcmp(clone, sequence, expected_size));
free(sequence);
}
|
_color(&ctx, GColorBlack);
graphics_line_draw_precise_stroked_aa(&ctx, COLOR_START_POINT, COLOR_END_POINT, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_origin_layer.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 10);
graphics_c... | setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 10) | ;
int radius = 5;
int x_offset = 10 * FIXED_S16_3_ONE.raw_value;
for (int i = 0; i < 8; i++) {
radius += 1;
x_offset += radius * FIXED_S16_3_ONE.raw_value + 4 * FIXED_S16_3_ONE.raw_value;
GPointPrecise p = GPointPrecise(x_offset, 15 * FIXED_S16_3_ONE.raw_value);
for (int j=0; j<9; j++) {
gra... |
app_size);
if (app_info->crc != calculated_crc) {
PBL_LOG(LOG_LEVEL_WARNING, "Calculated App CRC is 0x%"PRIx32", expected 0x%"PRIx32"!",
calculated_crc, app_info->crc);
return false;
} else {
return true;
}
}
static void * prv_offset_to_address(MemorySegment *segment, size_t offs... | (resource_load_byte_range_system(SYSTEM_APP, app_md->bin_resource_id, 0,
(uint8_t *)&info, sizeof(info)) == sizeof(info)) | ;
// We load the full binary (.text + .data) into ram as well as the relocation entries. These
// relocation entries will overlap with the .bss section of the loaded app, but we'll fix that
// up later.
const size_t load_size = app_storage_get_process_load_size(&info);
if (load_size > memory_segment_get_siz... |
nnection_status_notifications(const Connection *connection) {
return prv_get_flag(connection, ConnectionFlag_IsSubscribedToConnectionStatusNotifications);
}
bool connection_should_pin_address(const Connection *connection) {
return prv_get_flag(connection, ConnectionFlag_ShouldPinAddress);
}
bool connection_should... | (connection) | ) {
connection->conn_params = *params;
}
}
prv_unlock();
}
void connection_update_address(Connection *connection, const BTDeviceInternal *updated_addr) {
prv_lock();
{
if (connection_is_valid(connection)) {
connection->updated_addr = *updated_addr;
connection->has_updated_addr = true;... |
/*
* 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... | (GColorSunsetOrange, GColorDarkGray) | ,
};
int pos = snprintf(zone->label, buffer_size, "%s ", i18n_get(zone_label, i18n_owner));
if (zone->progress) {
health_util_format_hours_and_minutes(zone->label + pos, buffer_size - pos,
zone->progress, i18n_owner);
}
if (zone->progress > *max_progress) {
*... |
ts_data.custom_label_string;
}
static WorkoutController s_sports_controller = {
.is_paused = prv_is_sports_paused,
.pause = prv_sports_pause,
.stop = NULL,
.update_data = NULL,
.metric_to_string = prv_metric_to_string,
.get_metric_value = prv_sports_get_value,
.get_distance_string = health_util_get_dista... | health_util_get_pace(84, 1234) | ,
.bpm = 71,
.hr_zone = 0,
};
WorkoutActiveWindow *active_window = workout_active_create_for_activity_type(
ActivitySessionType_Run, &s_workout_data, &s_workout_controller);
prv_create_window_and_render(active_window, 0);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_w... |
;
case PutBytesCommit:
case PutBytesAbort:
case PutBytesInstall:
default:
return false;
}
}
static bool prv_is_invalid_command_for_current_state(PutBytesCommand command) {
if (!prv_is_valid_command_for_current_state(command)) {
PBL_LOG(LOG_LEVEL_ERROR, "PutBytes command 0x%x not permitted in curren... | (ResponseAck, token) | |
(unsigned j = 0; j < s_parsed_msg.msrmt.num_types; j++) {
LOG(" 0x%"PRIx32"",
s_parsed_msg.msrmt.values[i * s_parsed_msg.msrmt.num_types + j]);
}
}
}
return &s_parsed_msg;
}
// ---------------------------------------------------------------------------------------------
// ... | (a->msrmt.utc_to_local, b->msrmt.utc_to_local) | ;
cl_assert_equal_i(a->msrmt.num_types, b->msrmt.num_types);
cl_assert_equal_m(a->msrmt.types, b->msrmt.types,
b->msrmt.num_types * sizeof(ProtobufLogMeasurementType));
cl_assert_equal_i(a->msrmt.num_samples, b->msrmt.num_samples);
cl_assert_equal_m(a->msrmt.offset_sec, b->msrmt.of... |
if (!child) {
break;
}
uint32_t duration = prv_get_total_duration(state, child, true /*delay*/, true /*play_count*/);
// It is allowed that the first child may have already been scheduled and played a bit. If
// this is the case, backup the start time by reducing delay accordingly.
... | (animation->type == AnimationTypePrimitive) | ;
PBL_ASSERTN(animation->implementation->update != NULL);
}
if (now != earliest_start_time) {
// This is a complex animation that has a child that was already scheduled. We must pretend that
// the top-level animation started at earliest_start_time. add_delay_ms may end up being
// negative here if... |
-------------------
// Sample captured: 2015-10-02 15:20:44 local
AccelRawData *activity_sample_walk_100_pbl_25477_19(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25477_19
//> TEST_EXPECTED 100
//> TEST_EXPECTED_MIN 50
//> TEST_EXPECTED_MAX 120
/... | { 328, -8, -464},
{ 552, 32, -184},
{ 1016, 136, -32},
{ 2096, 464, 48},
{ 2416, 784, 464},
{ 2272, 792, 592},
// 5 seconds
{ 1736, 576, -88},
{ 1392, 288, 160},
{ 1256, 416, 384},
{ 1112, 568, 400},
{ 1008, 736, 440},
{ 712, 176, 112},
{ 624, -344, -112},
{ 9... | |
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 WARRANTI... | RTC_ITConfig(RTC_IT_TS, ENABLE) | ;
}
void enter_standby_mode(void) {
rtc_slow_down();
// Set wakeup events for the board
// If the WKUP pin is high when we enable wakeup, an additional
// wakeup event is registered (4.4.2 "PWR power control/status register"),
// which will cause the board to wake up immediately after entering standby. Ther... |
a[2], uuid_bytes, sizeof(Uuid));
// One should fit though:
cl_assert_equal_b(ble_ad_set_service_uuids(ad, uuid, 1), true);
cl_assert_equal_i(memcmp(expected_ad_data, ad->data,
sizeof(expected_ad_data)), 0);
cl_assert_equal_i(ad->ad_data_length, sizeof(expected_ad_data));
cl_assert... | ble_ad_set_manufacturer_specific_data(ad,
0x1234,
(uint8_t *) "hello world",
11) | , true);
cl_assert_equal_i(memcmp(expected_ad_data, ad->data, ad->ad_data_length), 0);
ble_ad_destroy(ad);
}
void test_ble_ad_parse__set_flags(void) {
BLEAdData *ad;
ad = ble_ad_create();
const uint8_t flags = 0x03;
const uint8_t expected_ad_data[] = {
1 /* +1 for Type byte */ + 1 /* uint8_t with va... |
NALYTICS_DEVICE_METRIC_BLE_CONNECT_TIME, AnalyticsClient_System);
bluetooth_analytics_handle_connection_params_update(conn_params);
uint8_t link_quality = 0;
int8_t rssi = 0;
bool success = bt_driver_analytics_get_connection_quality(peer_addr, &link_quality, &rssi);
if (success) {
PBL_LOG(LOG_LEVEL_DEB... | (orig_stats, &new_stats, true /* is_putbytes */) | ;
analytics_event_put_byte_stats(
comm_session_get_system_session(), successful, type,
total_size, elapsed_time_ms, new_stats.num_conn_events,
new_stats.num_sync_errors, new_stats.num_conn_events_skipped,
prv_calc_other_errors(&new_stats));
}
void bluetooth_analytics_handle_get_bytes_stats(uint8_t 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... | if (decimal_divisor > 1) {
result /= (decimal_divisor / base);
const bool round_up = ((ABS(result) % base) >= (base / 2));
result /= base;
if (round_up) {
if (result > 0) {
++result;
} else {
--result;
}
}
} |
if (is_negative) {
result *= -1;
}
if (result > INT32_MAX || result < INT32_MIN) {
return false; // overflow
}
if (number_started && number_out) {
*number_out = result;
}
return number_started;
}
// ----------------------------------------------------------------------------------------... |
er_analytics_get_conn_event_stats(&s_pb_state.conn_event_stats);
if (!success) {
PBL_LOG(LOG_LEVEL_WARNING, "Failed to init storage");
goto exit;
}
PebbleEvent event = {
.type = PEBBLE_PUT_BYTES_EVENT,
.put_bytes = {
.type = PebblePutBytesEventTypeStart,
.object_type = s_pb_state.typ... | (header->token) | |
-552},
{ 112, 912, -568},
{ 136, 912, -568},
{ 208, 912, -512},
{ 224, 896, -504},
{ 216, 896, -520},
{ 200, 872, -536},
{ 192, 880, -552},
{ 192, 872, -560},
{ 208, 880, -536},
{ 216, 880, -544},
{ 224, 880, -544},
{ 216, 880, -552},
// 247 seconds
{ 216, 888, -5... | { 200, 1400, -176},
{ 168, 1392, -256},
{ -144, 552, 184},
{ -296, 368, 320},
{ -408, 136, 512},
{ -376, 344, 528},
{ -288, 192, 504},
{ -280, 256, 328},
{ -264, 128, 296},
{ -424, 80, 664},
{ -504, 328, 976},
{ -544, 864, 984},
{ -560, 896, 728},
{ -344, 656, 616... |
{ 64, 784, -704},
{ 72, 768, -688},
{ 64, 808, -704},
{ 88, 792, -688},
{ 80, 808, -688},
// 255 seconds
{ 88, 808, -680},
{ 80, 800, -688},
{ 80, 784, -696},
{ 64, 800, -688},
{ 72, 800, -688},
{ 80, 776, -688},
{ 80, 792, -688},
{ 88, 784, -688},
{ 96, 776,... |
assert_equal_p(NULL, recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
sizeof(s_test_impl_data), NULL, NULL));
s_test_impl.handle_touch_event = NULL;
cl_assert_passert(recognizer_create_with_data(&s_test_impl, &s_test_impl_data,
... | (r, RecognizerState_Started) | );
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Updated));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Cancelled));
cl_assert_passert(recognizer_transition_state(r, RecognizerState_Completed));
r->state = RecognizerState_Updated;
recognizer_transition_state(r, Recogni... |
cl_assert(!error) | ;
time_t timestamp = 0;
ANCSAppMetadata app_metadata = {0};
TimelineItem *item = ancs_item_create_and_populate(notif_attributes,
app_attrs,
&app_metadata,
... | |
(tail == &b);
tail = list_append(&a, &c);
cl_assert(tail == &c);
cl_assert(list_get_prev(&a) == NULL);
cl_assert(list_get_next(&a) == &b);
cl_assert(list_get_prev(&b) == &a);
cl_assert(list_get_next(&b) == &c);
cl_assert(list_get_prev(&c) == &b);
cl_assert(list_get_next(&c) == NULL);
}
void test_list__... | list_find_prev(&bar[2].list_node, filter_odd, false, NULL) | == &bar[1].list_node);
// '1' is the first odd number, so NULL is prev:
cl_assert(list_find_prev(&bar[1].list_node, filter_odd, false, NULL) == NULL);
// Test wrap around, find '3' before '0':
cl_assert(list_find_prev(&bar[0].list_node, filter_odd, true, NULL) == &bar[3].list_node);
// Test wrap around match... |
required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#inc... | {
*first_icon_frame_out = first_icon_frame;
} |
if (second_icon_frame_out) {
*second_icon_frame_out = second_icon_frame;
}
const int total_space = second_icon_frame.origin.y - grect_get_max_y(&first_icon_frame);
return total_space - (REL_BAR_VERT_MARGIN * 2);
}
static int prv_get_overlap_line_length(TimelineLayer *layer, GRect *first_icon_frame_out,
... |
intptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_realloc(app_state_get_heap(), ptr, bytes, saved_lr);
}
void *app_zalloc(size_t size) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_zalloc(app_state_get_heap(), size, saved_lr);
}
void *app_zalloc_check(size_t bytes) ... | heap_free(task_heap_get_for_current_task(), ptr, saved_lr) | |
MALL);
graphics_circle_quadrant_draw_stroked_non_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornerBottomRight);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_r8_quad_bottom_right.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, fal... | (&ctx.dest_bitmap, "stroke_circle_offset_aa_r8_quads_right.${BIT_DEPTH_NAME}.pbi") | );
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, STROKE_SMALL);
graphics_circle_quadrant_draw_stroked_aa(&ctx, CENTER_OF_ORIGIN_RECT, RADIUS_MEDIUM, STROKE_SMALL,GCornersLeft);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "stroke_circle_offset_aa_r8_quads_left.${BIT_DEPTH_NAME}.pbi"));
... |
/*
* 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 (!timer_stopped) {
// We've been disconnected long enough that we've already told the app that
// we disconnected so let the app know that we are connected again.
s_debounced_state_is_connected[conn_id] = true;
prv_put_debounced_connection_event(conn_id);
} |
}
|
ib/app_comm.h"
#include "applib/app_sync/app_sync.h"
#include "kernel/event_loop.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "services/normal/activity/activity_algorithm.h"
#include "services/normal/activity/activity_private.h"
#include "services/common/i18n/i18n.h"
#includ... | {
case SPORTS_DATA_KEY:
strncpy(data->pace_string, new_tuple->value->cstring, sizeof(data->pace_string));
break;
case SPORTS_DISTANCE_KEY:
strncpy(data->distance_string, new_tuple->value->cstring, sizeof(data->distance_string));
break;
case SPORTS_TIME_KEY:
strncpy(data->durati... |
sizeof(data->custom_label_string));
prv_update_scrollable_metrics(data);
}
break;
}
case SPORTS_CUSTOM_VALUE_KEY:
{
if (strncmp(new_tuple->value->cstring,
data->custom_value_string,
sizeof(data->custom_value_string)) != 0) {
... |
LECT for 5 secs. to force-boot PRF");
for (int i = 0; i < 5000; ++i) {
if (!prv_prf_button_combination_is_pressed()) {
// 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(... | delay_us(200000) | ;
display_boot_splash();
delay_us(1000000);
}
#endif
if (is_button_stuck()) {
sad_watch(ERROR_STUCK_BUTTON);
}
if (is_flash_broken()) {
sad_watch(ERROR_BAD_SPI_FLASH);
}
boot_bit_dump();
// If the recovery firmware crashed at start-up, the watch is now a
// $150 brick. That's life!
... |
/*
* 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... | (status_t, persist_write_bool, const uint32_t key, const bool value) | {
LOCK_AND_GET_STORE(store);
status_t result = settings_file_set(store, &key, sizeof(key),
&value, sizeof(value));
return PASSED(result) ? (status_t)sizeof(value) : result;
}
DEFINE_SYSCALL(status_t, persist_write_int, const uint32_t key, const int32_t value) {
LOCK_AND_G... |
ule(seq);
// Start
prv_advance_to_ms_with_timers(start_ms + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert... | cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, b), 0) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, b), 0);
// Make sure seq, c, and d completed
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 1);
cl_assert_equal_i(prv_count_h... |
nt.h"
#include "touch_client.h"
#include "kernel/events.h"
#include "system/logging.h"
#include "os/mutex.h"
#include "system/passert.h"
#include "util/size.h"
#define TOUCH_DEBUG(fmt, args...) PBL_LOG_D(LOG_DOMAIN_TOUCH, LOG_LEVEL_DEBUG, fmt, ## args)
#define TOUCH_QUEUE_LENGTH (2)
typedef struct TouchContext {
... | {
update = true;
} |
if (update) {
TOUCH_DEBUG("Touch %"PRIu8": Position Update @ (%"PRId16", %"PRId16")", touch_idx,
pos->x, pos->y);
prv_touch_queue_add(ctx, touch_idx, TouchEvent_PositionUpdate, pos, pressure, time_ms);
}
}
ctx->state = touch_state;
bool send_event = false;
if (update && !ctx-... |
/*
* 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... | GSize(DISP_COLS, DISP_ROWS) | |
ication, &header);
int fd = prv_file_open(OP_FLAG_WRITE | OP_FLAG_READ);
if (fd < 0) {
return;
}
size_t size_needed = header.payload_length + sizeof(SerializedTimelineItemHeader);
if (size_needed > (NOTIFICATION_STORAGE_FILE_SIZE - s_write_offset)) {
if (!prv_compress(size_needed, &fd)) {
// No... | PBL_ASSERTN(item_out && (s_notif_storage_mutex != NULL)) | ;
int fd = prv_file_open(OP_FLAG_READ);
if (fd < 0) {
return false;
}
bool rv = true;
SerializedTimelineItemHeader header = { .common.id = UUID_INVALID };
char uuid_string[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(id, uuid_string);
if (!prv_find_next_notification(&header, prv_uuid_equal_func, (v... |
The app isn't cached. Fetch it!
PebbleEvent e = {
.type = PEBBLE_APP_FETCH_REQUEST_EVENT,
.app_fetch_request = {
.id = install_id,
.with_ui = false,
.fetch_args = NULL,
},
};
event_put(&e);
}
done:
return rv;
}
static status_t prv_insert_item(TimelineItem *it... | timeline_item_storage_init(&s_pin_db_storage,
PIN_DB_FILE_NAME,
PIN_DB_MAX_SIZE,
PIN_DB_MAX_AGE) | |
id(PebbleTask_App, INSTALL_ID_INVALID) == NULL);
// Unsubscribe, HRM should be disabled after
for (int i = 0; i < num_refs; ++i) {
sys_hrm_manager_unsubscribe(session_refs[i]);
cl_assert(prv_get_subscriber_state_from_ref(session_refs[i]) == NULL);
cl_assert(prv_get_subscriber_state_from_app_id(PebbleTa... | fake_system_task_callbacks_invoke_pending() | ;
// Make sure we got the expected data
cl_assert_equal_i(s_num_cb_events_1, 1);
cl_assert_equal_i(s_cb_events_1[0].event_type, HRMEvent_BPM);
cl_assert_equal_i(s_cb_events_1[0].bpm.bpm, s_hrm_event_data.hrm_bpm);
cl_assert_equal_i(s_cb_events_1[0].bpm.quality, s_hrm_event_data.hrm_quality);
sys_hrm_manag... |
/*
* 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... | (length <= BUFFER_SIZE) | ;
memcpy(s_app_message_pp_buffer, data, length);
s_app_message_pp_received_length = length;
}
static void prv_protocol_msg_callback(CommSession *session,
const uint8_t* data, size_t length) {
app_message_app_protocol_msg_callback(session, data, length, NULL);
}
void app_mes... |
----------------------------------------------------------------------------
// Find timer by id
static bool prv_id_list_filter(ListNode* node, void* data) {
TaskTimer* timer = (TaskTimer*)node;
return timer->id == (uint32_t) data;
}
static TaskTimer* prv_find_timer(TaskTimerManager *manager, TaskTimerID timer_id)... | (!timer->defer_delete) | |
rk at the top center so we can draw the text below it
const GAlign alignment = is_selected ? GAlignTop : GAlignCenter;
grect_align(&mark_rect, &rt_rect, alignment, true /* clip */);
// Draw the mark
const bool highlight = menu_cell_layer_is_highlighted(cell_layer);
prv_draw_generic_mark(ctx, mark, mark_rect.... | menu_cell_layer_is_highlighted(cell_layer) | ;
GBitmap *mark = &cd->fcc_mark;
#if PBL_RECT
menu_cell_basic_draw(ctx, cell_layer, title, subtitle, NULL);
// FCC has a mark in the top right of its cell
const GPoint mark_origin = GPoint(119, 7);
const GRect box = (GRect){.origin = mark_origin, .size = mark->bounds.size};
prv_draw_mark_with_inversion(ctx,... |
ngeVertical vertical_range, GPoint center, int32_t radius);
GRangeHorizontal perimeter_for_display_rect(const GPerimeter *perimeter,
const GSize *ctx_size,
GRangeVertical vertical_range,
u... | (fb_size, steps_x, steps_y) | ;
ctx.draw_state.avoid_text_orphans = true;
const GSize size_with_orphan_avoidance = graphics_text_layout_get_max_used_size(&ctx,
text, font, box,
over... |
n 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS I... | if (s_num_flash_uses == 0) {
periph_config_enable(FMC_Bank1, RCC_AHB3Periph_FMC); // FIXME
prv_flash_idle_gpios(true);
} |
s_num_flash_uses++;
}
void flash_impl_release_many(uint32_t num_locks) {
PBL_ASSERTN(s_num_flash_uses >= num_locks);
s_num_flash_uses -= num_locks;
if (s_num_flash_uses == 0) {
periph_config_disable(FMC_Bank1, RCC_AHB3Periph_FMC); // FIXME
}
}
void flash_impl_release(void) {
flash_impl_release_many(1... |
he License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "applib/graphics/graphics.h"
#include "applib/graphics/framebuffer.h"
#include "applib/ui/bitmap_layer.h"
#include "applib/ui/window_private.h"
#include "util/size.h"
#include <stdio.h>
//... | malloc((size_t)file_size) | ;
if (!png_data) {
goto cleanup;
}
// Go back to the start of the file and read it into the buffer
if (fseek(fp, 0L, SEEK_SET) != 0) {
goto cleanup;
}
cl_assert_equal_i(fread(png_data, 1, file_size, fp), file_size);
// Create a GBitmap using the PNG data
result = gbitmap_cr... |
nday
uint16_t day_index = cell_index->row % DAYS_PER_WEEK;
const struct lc_time_T *time_locale = time_locale_get();
cell_text = i18n_get(time_locale->weekday[day_index], &data->custom_day_picker_window);
if (data->scheduled_days[(cell_index->row) % DAYS_PER_WEEK]) {
ptr_bitmap = &data->selected_i... | menu_layer_get_layer(&data->custom_day_picker_menu_layer) | );
gbitmap_init_with_resource(&data->selected_icon, RESOURCE_ID_CHECKBOX_ICON_CHECKED);
gbitmap_init_with_resource(&data->deselected_icon, RESOURCE_ID_CHECKBOX_ICON_UNCHECKED);
gbitmap_init_with_resource(&data->checkmark_icon, RESOURCE_ID_CHECKMARK_ICON_BLACK);
data->current_checkmark_icon_resource_id = RESOURC... |
strings[i], prv_action_menu_cb,
action);
}
return emoji_level;
}
static void prv_handle_voice_transcription_result(PebbleEvent *e, void *context) {
DictationSessionStatus status = e->dictation.result;
char *transcription = e->dictation.text;
VoiceResponseData *data = context... | if (!reply_options[reply].is_leaf) {
responses_level->items[item].next_level =
level_getters[reply](responses_level, action, root_level);
} | |
v_select_reset(int index, void *context) {
system_reset();
}
static void prv_select_shutdown(int index, void *context) {
enter_standby(RebootReasonCode_ShutdownMenuItem);
}
static GBitmap * prv_get_icon_for_test(MfgTest test) {
#if MFG_INFO_RECORDS_TEST_RESULTS
const bool passed = mfg_info_get_test_result(test)... | (s_menu_items) | |
s_t rv;
uint16_t start_page = INVALID_PAGE;
PageHeader pg_hdr;
memset(&pg_hdr, 0xff, sizeof(pg_hdr));
bool use_gc_allocator = (strcmp(f->name, GC_FILE_NAME) == 0);
if ((rv = find_free_page(&start_page, use_gc_allocator, true)) != S_SUCCESS) {
return (rv);
}
pg_hdr.version = PFS_CUR_VERSION;
SET_... | (next_page, &next_page) | != S_SUCCESS) {
return (E_RANGE);
}
}
f->curr_page = next_page;
}
*pg_offset = data_offset % free_bytes_in_page(f->curr_page);
return (S_SUCCESS);
}
static int mark_fd_free(int fd) {
if (PFS_FD(fd).file.name != NULL) {
kernel_free(PFS_FD(fd).file.name);
PFS_FD(fd).file.name = NU... |
ackingMode = DFSDM_PackingMode_Standard;
DFSDM_InitStruct.DFSDM_DataRightShift = right_shift;
DFSDM_InitStruct.DFSDM_Offset = 0;
DFSDM_InitStruct.DFSDM_CLKAbsenceDetector = DFSDM_CLKAbsenceDetector_Disable;
DFSDM_InitStruct.DFSDM_ShortCircuitDetector = DFSDM_ShortCircuitDetector_Enable;
DFSDM_TransceiverInit... | stop_mode_enable(InhibitorMic) | ;
this->state->running = false;
PBL_LOG(LOG_LEVEL_DEBUG, "Stopped microphone, dropped samples: %"PRIu32" bytes received: %"PRIu32,
this->state->overflow_cnt,
this->state->bytes_received);
unlock:
mutex_unlock_recursive(this->state->mic_mutex);
}
bool mic_is_running(MicDevice *this) {
retu... |
appear' handler on window displacing modal window
window_set_on_screen(window, true, false);
window_render(window, app_state_get_graphics_context());
}
click_manager_reset(app_state_get_click_manager());
} else if (window) {
// Do not call 'disappear' handler on window displaced by modal windo... | app_state_get_window_stack() | ;
window_stack_lock_push(app_window_stack);
window_stack_pop_all(app_window_stack, false);
window_stack_unlock_push(app_window_stack);
}
// Get the app_id for the current app or worker
// @return INSTALL_ID_INVALID if unsuccessful
AppInstallId app_get_app_id(void) {
// Only support from app or workers
Pebble... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
char buffer[32];
dbgserial_putstr_fmt(buffer, sizeof(buffer), "bootbits: 0x%"PRIu32, boot_bits_get());
} |
void boot_version_write(void) {
if (boot_version_read() == TINTIN_METADATA.version_timestamp) {
return;
}
RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, TINTIN_METADATA.version_timestamp);
}
uint32_t boot_version_read(void) {
return RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
}
|
T_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw2_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 2);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_off... | (&ctx, &OFFSET_DRAW_RECT_NO_CLIP) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, false, 1);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw1_clip_xy.${BIT_... |
sitor_transition(const CompositorTransition *type) {
Window *window = modal_manager_get_top_window();
if (window) {
GContext ctx;
memset(&ctx, 0, sizeof(GContext));
modal_manager_render(&ctx);
}
}
void app_click_config_setup_with_window(ClickManager *click_manager, struct Window *window) {
s_last_c... | window_stack_push(window_stack, window, true) | ;
cl_assert_equal_i(window_stack_count(window_stack), 1);
window_stack_pop(window_stack, true);
cl_assert_equal_i(window_stack_count(window_stack), 0);
window_destroy(window);
}
void test_window_stack__basic_window_pop(void) {
Window *window1 = window_create();
Window *window2 = window_create();
// ... |
/*
* 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... | callback(data) | |
ml->num_short_items <= SHORT_COL_COUNT;
r.size.w /= is_single_short_row ? num_items : SHORT_COL_COUNT;
#else
r.size.w /= SHORT_COL_COUNT;
#endif
r.origin.y += (r.size.h - font_height) / 2 - 4;
for (int i = 0; i < num_items; i++) {
if (!items[i].label) {
break;
}
if (sel_idx == i) {
gra... | {
ActionMenuLayer *aml = subject;
aml->item_animation.current_offset_y = value;
layer_mark_dirty(&aml->layer);
} |
static void prv_cell_animation_stopped_handler(Animation *animation, bool finished, void *context) {
ActionMenuLayer *aml = context;
if (finished) {
prv_set_cell_offset(aml, aml->item_animation.bottom_offset_y);
}
}
static const PropertyAnimationImplementation s_item_animation_implementation = {
.base = ... |
d
accel_set_shake_sensitivity_high(false /* sensitivity_high */);
bma255_write_register(BMA255Register_INT_5,
BMA255_INT_5_SLOPE_DUR_MASK << BMA255_INT_5_SLOPE_DUR_SHIFT);
prv_enable_operating_mode(AccelOperatingMode_ShakeDetection, BMA255SampleInterval_83HZ);
}
static void prv_disable_s... | (LOG_LEVEL_ERROR, "Self test failed for axis %c: %d < %d",
AXIS_NAMES[axis], delta, SELFTEST_THRESHOLDS[axis]) | ;
return false;
}
if ((new_data + new_negative + new_positive) != 3) {
PBL_LOG(LOG_LEVEL_ERROR, "Self test problem? Not logging data? %d %d %d",
new_data, new_positive, new_negative);
}
return true;
}
bool bma255_selftest(void) {
// calling selftest_axis resets the device
bool pass = ... |
operty == PROPERTY_BG_COLOR) {
set_text_element(data->bg_color_text, data->bg_color_text_buffer, true);
} else {
set_text_element(data->bg_color_text, data->bg_color_text_buffer, false);
}
layer_mark_dirty(text_layer_get_layer(data->alpha_text));
layer_mark_dirty(text_layer_get_layer(data->fg_text));
... | if (compare && gcolor_equal(color, compare_color)) {
color_index_match = color_index - (row * ROW_LENGTH);
height_offset = row * (COLOR_BAR_HEIGHT + 4);
} |
GRect box = GRect(origin.x + (4 * (color_index - (row * ROW_LENGTH))),
origin.y + (row * (COLOR_BAR_HEIGHT + 4)),
COLOR_BAR_WIDTH, COLOR_BAR_HEIGHT);
graphics_context_set_fill_color(ctx, color);
graphics_fill_rect(ctx, &box);
}
}
// Draw borde... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_ERROR, "Could not create app menu order file") | ;
goto cleanup;
}
// write back the whole file
int wrote_storage_bytes = pfs_write(fd, (uint8_t *)storage, storage_size);
if (wrote_storage_bytes != storage_size) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to write all bytes of order list");
}
pfs_close(fd);
cleanup:
kernel_free(storage);
mutex_unloc... |
tatic MockCallRecordings s_graphics_context_set_stroke_color;
void graphics_context_set_stroke_color(GContext* ctx, GColor color) {
record_mock_call(s_graphics_context_set_stroke_color) {
.ctx = ctx, .color = color,
};
}
void graphics_context_set_stroke_width(GContext* ctx, uint8_t stroke_width) {}
void graph... | cl_assert_parsed_color("#1230", &GColorClear) | ;
// correctly assign different components
cl_assert_parsed_color("#00FF00", &GColorGreen);
cl_assert_parsed_color("#0000FF", &GColorBlue);
} |
p_outbox__send_max_length_exceeded(void) {
prv_register();
cl_assert_passert(app_outbox_send(s_test_data, s_test_data_length + 1,
test_app_outbox_sent_handler, s_expected_cb_ctx));
assert_syscall_failed();
}
void test_app_outbox__send_but_consumer_not_registered(void) {
prv_... | app_outbox_service_cleanup_all_pending_messages() | ;
// sent_handler shouldn't get called when cleaning up:
cl_assert_equal_i(s_num_app_outbox_events_sent, 0);
cl_assert_equal_b(true, app_outbox_service_is_message_cancelled(s_last_message));
// the consumer must call ..._consume_message(), to free the resources:
app_outbox_service_consume_message(s_last_mes... |
4},
{ 1072, 336, -376},
{ 1080, 368, -360},
{ 1064, 448, -344},
{ 896, 512, -248},
{ 672, 456, -352},
{ 600, 392, -224},
{ 800, 584, -32},
{ 1160, 544, -304},
{ 1008, 336, -120},
{ 1432, 432, -48},
{ 1616, 304, -48},
{ 1544, 280, -40},
{ 1440, 152, -64},
{ 1288, 1... | { 872, 408, -136},
{ 624, 464, -64},
{ 728, 560, -248},
{ 920, 800, -112},
{ 1192, 464, -168},
{ 1312, 400, -160},
{ 1800, 368, -128},
{ 1968, 184, -104},
{ 1704, 72, -160},
{ 1376, 112, -104},
{ 1056, 208, -208},
{ 912, 416, -144},
{ 712, 664, -160},
{ 368, 816, ... |
// ----------------------------------------------------------------
// Sample captured: 2015-10-01 09:35:29 local
AccelRawData *activity_sample_walk_100_pbl_25471_8(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25471_8
//> TEST_EXPECTED 100
//> T... |
}
void test_wakeup__time_jump(void) {
sys_wakeup_cancel_all_for_app();
// Schedule 1 event in a minute
time_t first_event = sys_get_time() + WAKEUP_EVENT_WINDOW;
WakeupId first_wakeup_id = sys_wakeup_schedule(first_event, 0, false);
cl_assert_equal_i(sys_wakeup_query(first_wakeup_id), first_event);
Timer... | sys_get_time() | + final_timeout / 1000 + time_jump_seconds);
wakeup_handle_clock_change();
// There should be a missed wakeup event and a popup displayed
cl_assert_equal_b(s_popup_occurred, true);
// Make sure the wakeup event is no longer scheduled
cl_assert_equal_i(sys_wakeup_query(first_timer), E_DOES_NOT_EXIST);
}
|
/*
* 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... | animation_set_duration(animation1, BAR_TO_TRANS_MS) | ;
animation_set_curve(animation1, AnimationCurveEaseIn);
prop_anim = property_animation_create_layer_bounds((Layer *)&data->progress_layer, &mid, &end);
Animation *animation2 = property_animation_get_animation(prop_anim);
animation_set_duration(animation2, TRANS_TO_DOT_MS);
animation_set_curve(animation2, A... |
__asm volatile (
"cpsie if\n" // Clear PRIMASK and FAULTMASK
"mov lr, 0xFFFFFFFF\n"
"mov sp, %[initial_sp]\n"
"bx %[reset_handler]\n"
: : [initial_sp] "r" (initial_stack_pointer),
[reset_handler] "r" (reset_handler)
);
__builtin_unreachable();
}
static bool check_and... | ("Firmware is erased") | ;
return true;
}
return false;
}
static void sad_watch(uint32_t error_code) {
dbgserial_putstr("SAD WATCH");
char error_code_buffer[12];
itoa(error_code, error_code_buffer, sizeof(error_code_buffer));
dbgserial_putstr(error_code_buffer);
display_error_code(error_code);
static uint8_t prev_button... |
rm__alarm_set_custom(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule);
bool custom_schedule1[7] = {true, false, true, false, false, true, true};
alarm_set_custom(id... | cl_assert_equal_i(s_num_timeline_adds, 3) | |
enabled);
if (enabled) {
connection->flags |= (1 << flag);
} else {
connection->flags &= ~(1 << flag);
}
}
}
prv_unlock();
}
void connection_set_subscribed_to_connection_status_notifications(
Connection *connection, bool is_subscribed) {
prv_set_flag(connection, is_subs... | list_get_head(list_pop_tail((ListNode *)connection->gatt_op_list)) | ;
kernel_free(tmp_tail);
}
prv_unlock();
return rv;
}
|
, 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 "kino_reel.h"
#include "kino_reel_custom.h"
#... | {
if (reel && reel->impl->get_gdraw_command_sequence) {
return reel->impl->get_gdraw_command_sequence(reel);
}
return NULL;
} |
GBitmap *kino_reel_get_gbitmap(KinoReel *reel) {
if (reel && reel->impl->get_gbitmap) {
return reel->impl->get_gbitmap(reel);
}
return NULL;
}
GBitmapSequence* kino_reel_get_gbitmap_sequence(KinoReel *reel) {
if (reel && reel->impl->get_gbitmap_sequence) {
return reel->impl->get_gbitmap_sequence(ree... |
/*
* 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_enable(RCC_AHB1PeriphClockCmd, RCC_AHB1Periph_CRC) | ;
}
static void prv_disable_crc_clock(void) {
periph_config_disable(RCC_AHB1PeriphClockCmd, RCC_AHB1Periph_CRC);
}
static void prv_calculate_incremental_start(void) {
prv_enable_crc_clock();
CRC_ResetDR();
}
static void prv_calculate_incremental_words(const uint32_t* data, unsigned int data_length) {
CRC_Cal... |
OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "flash_logging.h"
#include "console/dbgserial.h"
#include "drivers/flash.h"
#include "os/mutex.h"
#include "system/passert.h"
#include "util/shar... | if (shared_circular_buffer_get_write_space_remaining(&s_buffer) >= length + 1) {
// Ideally we could figure out a way to skip out on this copy but then you'd potentially need to sniprintf
// into a non-contiguous buffer... whatever, we have CPU to burn.
uint8_t msg_length = length;
// Do not ad... | |
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_usart.h"
#include "util/attributes.h"
#include "util/cobs.h"
#include "util/crc32.h"
#include "util/misc.h"
#include "util/misc.h"
#include "util/net.h"
#include <stdbool.h>
#define MAX_MESSAGE (256)
#define FRAME_DELIMITER '\x55'
#define PULSE_TRANSPORT_PUSH (0x5021)
... | for (size_t i = 0; i < cooked_length; ++i) {
if (cooked_packet[i] == FRAME_DELIMITER) {
prv_putchar('\0');
} else {
prv_putchar(cooked_packet[i]);
}
} |
prv_putchar(FRAME_DELIMITER);
s_message_length = 0;
}
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);
}
|
f (sdk_platform == PBL_PLATFORM_TYPE_CURRENT) {
*size = GSize(DISP_COLS, DISP_ROWS);
return;
}
// We cannot use the SDK type for this compatibility check but there's
// also no easy way to get the resolutions per platform.
// so we re-use the suboptimal defines from each display_<model>.h
switch (sdk... | (Version, sys_get_current_app_sdk_version, void) | {
return process_metadata_get_sdk_version(app_manager_get_current_app_md());
}
DEFINE_SYSCALL(bool, sys_get_current_app_is_js_allowed, void) {
return (app_manager_get_current_app_md()->allow_js);
}
DEFINE_SYSCALL(bool, sys_get_current_app_is_rocky_app, void) {
return (app_manager_get_current_app_md()->is_rocky... |
/*
* 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_app_cache_entry_exists;
} | |
dbool.h>
#include <stdio.h>
#include <string.h>
//! BlobDB Endpoint ID
static const uint16_t BLOB_DB2_ENDPOINT_ID = 0xb2db;
//! Message Length Constants
static const uint8_t DIRTY_DATABASES_LENGTH = 2;
static const uint8_t START_SYNC_LENGTH = 3;
static const uint8_t WRITE_RESPONSE_LENGTH = 3;
static const uint8_t WRI... | {
if (length < WRITE_RESPONSE_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a write response with an invalid length: %"PRIu32"", length);
return;
}
prv_handle_wb_write_response(data, length);
} |
static void prv_handle_wb_response(CommSession *session,
const uint8_t *data,
uint32_t length) {
if (length < WRITEBACK_RESPONSE_LENGTH) {
PBL_LOG(LOG_LEVEL_ERROR, "Got a writeback response with an invalid length: %"PRIu32"", length);
ret... |
_handler_calls, animation, finished, context);
DPRINTF("%"PRIu64" ms: Executing stopped handler for %d\n", prv_now_ms(), (int)animation);
animation_unschedule_all();
}
// --------------------------------------------------------------------------------------
// Test unscheduling animations arbitrarily in a stopped ... | (a, interpolation) | ;
cl_assert_equal_p(animation_private_current_interpolate_override(), interpolation);
animation_set_custom_curve(a, curve);
cl_assert_equal_p(animation_private_current_interpolate_override(), NULL);
animation_destroy(a);
}
|
s, stop the workout, 20 min, close app.
// Make sure the HR turns off right after we leave the app.
void test_workout_service__app_open_wait_close_valid_workout(void) {
// Put some time into the clock
prv_inc_time(1 * SECONDS_PER_MINUTE);
// Open the app, confirm that we are now subscribed with no end in sight
... | workout_service_get_current_workout_hr_zone_time(hr_zone_time_s) | |
i(sys_wakeup_query(early_wakeup_id), E_DOES_NOT_EXIST);
cl_assert_equal_i(sys_wakeup_query(late_wakeup_id), late_event);
// Make sure that the next scheduled timer is now the late wakeup id.
cl_assert_equal_i(late_wakeup_id, wakeup_get_next_scheduled());
// Set time 10 minutes into the future, late_event shou... | (first_wakeup_id) | , first_event);
TimerID first_timer = wakeup_get_current();
// Jump 30 seconds in the future
uint32_t initial_timeout = stub_new_timer_timeout(first_timer);
uint32_t time_jump_seconds = 30;
rtc_set_time(sys_get_time() + time_jump_seconds);
// Notify clock change and record change in new timer
wakeu... |
void test_touch__handle_update_position(void) {
touch_set_touch_state(0, TouchState_FingerDown, GPointZero, 3686380, 0);
touch_handle_update(0, TouchState_FingerDown, &GPoint(10, 10), 5, 3686400);
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_TOUCH_EVENT);
cl_assert_equal_i(e... | touch_event_queue_get_event(0, 0) | ;
prv_test_touch_event(touch_event, 0, TouchEvent_PositionUpdate, &GPointZero, 3686380, 0,
&GPoint(10, 10), 20, 5, true);
touch_handle_update(0, TouchState_FingerDown, &GPoint(13, 13), 6, 3686420);
touch_event = touch_event_queue_get_event(0, 1);
prv_test_touch_event(touch_event, 0, Touc... |
/*
* 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... | {
// pretend tests are generics for testing
PBL_ASSERTN(id != LayoutIdUnknown);
if (id == LayoutIdTest) {
id = LayoutIdGeneric;
}
return s_layout_constructors[id](config);
} |
bool layout_verify(bool existing_attributes[], LayoutId id) {
if (id == LayoutIdTest) {
return true;
} else if (id == LayoutIdUnknown || id >= NumLayoutIds) {
return false; // out of range
} else if (id == LayoutIdCommNotification) {
return false; // NYI
} else {
return s_layout_verifiers[id](... |
} else {
return 0;
}
}
// ------------------------------------------------------------------------------------
// Find timer by id
static bool prv_id_list_filter(ListNode* node, void* data) {
TaskTimer* timer = (TaskTimer*)node;
return timer->id == (uint32_t) data;
}
static TaskTimer* prv_find_timer(TaskTi... | prv_find_timer(manager, timer_id) | ;
PBL_ASSERTN(!timer->defer_delete);
// If expire timer is not 0, it means we are scheduled
bool retval = (timer->expire_time != 0);
// Figure out expire timer?
if (expire_ms_p != NULL && retval) {
RtcTicks current_ticks = rtc_get_ticks();
if (timer->expire_time > current_ticks) {
*expire_ms_p... |
ayer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40));
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorClear);
graphics_co... | ("draw_line_across_ny_offset_layer") | |
ge->timestamp)),
message->filename,
(int)htons(message->line_number),
message->message);
return true;
}
static void prv_serial_dump_completed_callback(bool success) {
prompt_command_finish();
}
void command_log_dump_current(void) {
... | if (s_abusive_timer == TIMER_INVALID_ID) {
s_abusive_timer = new_timer_create();
} |
if (new_timer_start(s_abusive_timer, 100, prv_waste_time_cb,
(void *)data_pack, 0)) {
prompt_send_response("OK");
} else {
prompt_send_response("ERROR");
}
}
#ifndef RELEASE
#include "system/profiler.h"
void command_audit_delay_us(void) {
profiler_init();
// don't let context... |
/ resource_list contains all of the resource files we found. We only
// want to delete orphans so we can remove any entries from the list that correspond
// to items in the app cache...
// prv_remove_matching_resource_file_callback scans resource_list and removes the entry
// corresponding to the passed-in app... | {
goto unlock;
} |
rv = settings_file_delete(&file, (uint8_t *)&app_id, sizeof(AppInstallId));
if (rv == S_SUCCESS) {
// Will delete an app from the filesystem.
app_storage_delete_app(app_id);
}
settings_file_close(&file);
}
if (rv == S_SUCCESS) {
PebbleEvent e = {
.type = PEBBLE_APP_CACHE_EV... |
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE)) | ;
}
// Tests 8-bit transparent PBI loading into gbitmap
// Result:
// - gbitmap matches platform loaded PBI
void test_pbi__color_8_bit_transparent(void) {
GBitmap *bitmap = setup_pbi_test(TEST_PBI_FILE);
cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE));
}
| |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gpio_use(FLASH_GPIO) | ;
// Init the hardware
flash_hw_init();
gpio_release(FLASH_GPIO);
periph_config_release_lock();
}
void flash_start_cmd(void) {
gpio_use(FLASH_GPIO);
GPIO_ResetBits(FLASH_GPIO, FLASH_PIN_SCS);
gpio_release(FLASH_GPIO);
}
void flash_end_cmd(void) {
gpio_use(FLASH_GPIO);
GPIO_SetBits(FLASH_GPIO, FLAS... |
-1392, 256, 80},
{ -1120, 384, 0},
{ -984, 216, 128},
{ -960, 360, -8},
{ -1040, 736, -264},
{ -1160, 480, 16},
{ -896, 328, 160},
{ -736, 304, 104},
{ -744, 280, 24},
{ -856, 344, 96},
{ -792, 248, 128},
{ -728, 272, 136},
{ -1016, 264, 128},
{ -1192, 440, 304},
... | { -1016, 72, 176},
{ -872, 56, 192},
{ -848, -200, 120},
{ -704, -208, 32},
{ -1104, 8, -8},
{ -1440, 216, 80},
// 60 seconds
// elapsed: 1 minutes
{ -1496, 608, -80},
{ -1472, 528, -136},
{ -1512, 96, 184},
{ -1544, 72, 248},
{ -1384, 416, 264},
{ -1200, 440, 240... |
{ -1352, 528, -160},
{ -1672, 184, 216},
{ -1664, 128, 384},
{ -1456, 400, 376},
{ -1216, 416, 416},
{ -1160, 552, 144},
{ -1344, 176, 232},
{ -1256, 184, 360},
{ -1144, 200, 328},
{ -1152, 200, 480},
{ -912, 448, 776},
{ -1160, 512, 432},
{ -952, 272, 368},
{ -1... |
ak;
#endif
case TXMenuIdx_RunStop: // Run / Stop
if (data->current_test_step == BTLETestStep_None) {
prv_run_test(data);
} else {
prv_stop_test(data);
}
break;
}
} else if (data->current_test == BTLETestType_RX) {
if (prv_test_is_running(data) &&
... | (&data->main_menu_window) | ;
const GRect bounds = window_layer->bounds;
data->main_menu_layer =
simple_menu_layer_create(bounds, &data->main_menu_window, &data->main_menu_section, 1, data);
layer_add_child(window_layer, simple_menu_layer_get_layer(data->main_menu_layer));
}
static void prv_main(void) {
AppData *data = app_malloc_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... | (text, GColorWhite) | ;
}
}
static void raw_click_handler(ClickRecognizerRef recognizer, Window *window, const bool up) {
ClickAppData *data = window_get_user_data(window);
sniprintf(data->text_buffer, TEXT_BUFFER_SIZE, up ? "Raw UP" : "Raw DOWN");
if (up) { // PBL_LOG requires a fixed const string, so can't use ternary
PBL_LO... |
ssert_equal_s("IN 1 MIN", time_buf);
// June 9th 2015, 15:58:00 (T-00:02:00)
rtc_set_time(event_time - (2 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("IN 2 MIN", time_buf);
// June 10th 2015, 04:00:00 (T+12:00:00)
rt... | cl_assert_equal_s("16:00", time_buf) | ;
// June 8th 2015, 16:00:00 (T-48:00:00)
rtc_set_time(event_time - SECONDS_PER_DAY - (24 * SECONDS_PER_HOUR));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS);
cl_assert_equal_s("Tue, 16:00", time_buf);
// June 16th 2015, 17:00:00 (T+7DAY+01:00:00)
rtc_set_time(... |
ne_draw_stroked_non_aa(&context, GPoint(5, 5), GPoint(45, 10), SW_ODD));
#endif
setup_test(&context, true, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
#if PBL_COLOR
ASSERT_CALLED(prv_draw_rect_aa_stroked(&context, &GRect(10, 20, 40, 10), SW_ODD));
#else
ASSER... | GPoint(45, 10) | ));
ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10)));
ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10));
ASSERT_NO_CHANGE(graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, true);
ASSERT_NO_CHA... |
nvert the fractional component to be in terms of the number of samples (with rounding)
fraction = (fraction * samples + (DIV_PRECISION / 2)) / DIV_PRECISION;
if (over8) {
// 3 bits of fraction
dev->periph->BRR = (mantissa << 3) | (fraction & 0x7);
} else {
// 4 bits of fraction
dev->periph->BRR =... | PBL_ASSERTN(next_idx < dma_length) | ;
while (dev->state->rx_dma_index != next_idx) {
const uint8_t data = dev->state->rx_dma_buffer[dev->state->rx_dma_index];
if (dev->state->rx_irq_handler(dev, data, &err_flags)) {
should_context_switch = true;
}
if (++dev->state->rx_dma_index == dma_length) {
de... |
/*
* 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... | alarm_service_enable_alarms(true) | ;
}
void test_alarm_smart__cleanup(void) {
cron_service_deinit();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Smart alarms
#define SMART_ALARM_UPDATE_MIN (SMART_ALARM_SNOOZE_DELAY_S / SECONDS_PER_MINUTE)
void test_alarm_smart__trigger_30_min_early_awa... |
24, -1000},
{ 48, 24, -1000},
{ 56, 24, -992},
{ 48, 16, -1000},
{ 48, 32, -1000},
{ 48, 24, -992},
{ 48, 16, -1000},
{ 56, 32, -1000},
{ 48, 24, -1000},
{ 56, 24, -1008},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 56, 24, -1000},
... | { 56, 16, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 56, 16, -1000},
{ 56, 32, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 16, -1000},
{ 48, 32, -1000},
{ 56, 24, -992},
{ 48, 24, -992},
{ 56, 24, -1000},
{ 48, 24, -1000},
{ 56, 24, -1000},
{ 48, 24, ... |
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 56, 16, -1000},
{ 48, 24, -1000},
{ 56, 24, -1000},
{ 56, 24, -1000},
{ 48, 24, -1000},
{ 56, 16, -1000},
{ 56, 2... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (nf->callbacks.decremented != NULL) {
nf->callbacks.decremented(nf, nf->callback_context);
} |
update_output_value(nf);
}
}
static void select_click_handler(ClickRecognizerRef recognizer, NumberWindow *nf) {
if (nf->callbacks.selected != NULL) {
nf->callbacks.selected(nf, nf->callback_context);
}
}
static void click_config_provider(NumberWindow *nf) {
window_single_repeating_click_subscribe(BU... |
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "comm/ble/kernel_le_client/ams/ams_util.h"
#include "clar.h"
// Stubs
///////////////////////////////////////////////////////////
#include "stubs_logging.h"
// Helpers
////////////////////////////... | ("1.987622", -33, true, -66) | ;
}
void test_ams_util__float_string_parse_overflow_positive(void) {
// fails:
// "2147483648" * 1
assert_float_parse("2147483648", 1, false, 0);
// succeeds:
// "2147483647" * 1
assert_float_parse("2147483647", 1, true, 2147483647);
}
void test_ams_util__float_string_parse_overflow_negative(void) {
//... |
Fixed_S32_16_add3(num1, num2, num3) | ;
sum_c = (Fixed_S32_16){ .raw_value = (int32_t)((float)3 * (1 << FIXED_S32_16_PRECISION)) };
cl_assert(sum.raw_value == sum_c.raw_value);
// sum = 3.7 + 2.3 + 1.1 = 242483.2 + 150732.8 + 72089.6
// ~= 242483 + 150732 + 72089 = 465304 ~= 7.1
num1 = (Fixed_S32_16){ .raw_value = (int32_t)... | |
name);
continue;
}
// Look for and parse the expected values
if (strcmp(token, "//>") == 0) {
token = strtok(NULL, " \t\n");
if (strcmp(token, "TEST_VERSION") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.version);
} else if (strcmp(token, "TEST_ACTIVIT... | (test_files_path) | + 2);
sprintf(state->res_path, "%s/%s", CLAR_FIXTURE_PATH, test_files_path);
state->dp = opendir(state->res_path);
if (state->dp == NULL) {
printf("\nCould not open directory %s", state->res_path);
return false;
}
state->type = samples_type;
return true;
}
// -----------------------------------... |
hort(void) {
prv_receive_init_put_and_commit_fw_object();
const uint8_t incomplete_install_msg = CmdInstall;
prv_receive_data(s_session, (const uint8_t *) &incomplete_install_msg,
sizeof(incomplete_install_msg));
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_by... | put_bytes_get_timer_id() | );
fake_system_task_callbacks_invoke_pending();
// Expect only "Cleanup" event:
cl_assert_equal_i(fake_event_get_count(), 1);
assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE);
}
void test_put_bytes__expect_init_event_upon_timeout(void) {
put_bytes_expect_init(EXPECT_INIT_TIMEOUT_MS);
stub_new_time... |
dress to avoid extra erases
}
PBL_LOG(LOG_LEVEL_DEBUG, ">PASS - DATA TEST 1: Data bus test");
return status;
}
/***********************************************************/
/******************* Addr Test Functions *******************/
/***********************************************************/
// Write the te... | PBL_LOG(LOG_LEVEL_DEBUG, ">> Reading Addr 0x%"PRIx32" value is 0x%"PRIx8,
test_addr, read_buffer);
}
// Write data pattern
status = prv_write_read_verify_byte(test_addr, data_pattern, data_pattern, display_logs);
VERIFY_TEST_STATUS(status);
}
if (display_logs) { PBL_LOG(LOG_LEV... |
static FlashTestErrorType prv_run_addr_test (void) {
uint32_t base_addr = FLASH_TEST_ADDR_START;
uint32_t test_addr = base_addr;
uint32_t addr_mask = FLASH_TEST_ADDR_MSK;
uint8_t read_buffer = 0;
uint32_t bit_offset;
uint32_t test_offset = 0;
FlashTestErrorType status = FLASH_TEST_SUCCESS;
//////////... |
swap_layer->context);
}
}
static void prv_announce_layout_did_appear(SwapLayer *swap_layer, LayoutLayer *layout,
int8_t rel_change) {
swap_layer->swap_in_progress = false;
if (swap_layer->callbacks.layout_did_appea... | graphics_context_set_fill_color(ctx, GColorWhite) | ;
graphics_fill_rect(ctx, layer_bounds);
#endif
GRect arrow_bounds = arrow_layer->arrow_bitmap.bounds;
const GAlign arrow_alignment = PBL_IF_RECT_ELSE(GAlignTop, GAlignBottom);
grect_align(&arrow_bounds, layer_bounds, arrow_alignment, false /* clip */);
const int16_t arrow_nudge_y = PBL_IF_RECT_ELSE(7, -8);
... |
animate to a dot on old platforms, just finish immediately.
static const bool success = true;
prv_finished(data, success);
#endif
}
static void prv_schedule_progress_failure_animation(ProgressWindow *data, uint32_t timeline_res_id,
const char *message, uint32_t d... | prv_set_progress(window, MAX_PROGRESS_PERCENT) | ;
prv_schedule_progress_success_animation(window);
}
void progress_window_set_result_failure(ProgressWindow *window, uint32_t timeline_res,
const char *message, uint32_t delay) {
if (window->state == ProgressWindowState_Result) {
// Ignore requests to change the result o... |
lity
do_not_disturb_set_manually_enabled(false);
active = do_not_disturb_is_active();
cl_assert(active == false);
}
void test_do_not_disturb__weekday_weekend_schedule(void) {
bool active;
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
cl_assert(do_not_disturb_is_manually_enabled() == false);
... | cl_assert(active == false) | ;
// Timer will go off at 00:00 on Saturday. (47.0 hours)
cl_assert_equal_i(stub_new_timer_timeout(get_dnd_timer_id()), 169200 * MS_PER_SECOND);
do_not_disturb_set_schedule_enabled(WeekendSchedule, false);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
rtc_set_time(s_saturday_01_30);
do_not_di... |
ude "board/board.h"
#include "debug/power_tracking.h"
#include "console/prompt.h"
#include "drivers/gpio.h"
#include "drivers/led_controller.h"
#include "drivers/periph_config.h"
#include "drivers/pwm.h"
#include "drivers/timer.h"
#include "kernel/util/stop.h"
#include "system/logging.h"
#include "system/passert.h"
//... | (LEDEnablerBacklight) | ;
}
}
if (BOARD_CONFIG_BACKLIGHT.options & ActuatorOptions_Pwm) {
if (brightness == 0) {
if (s_backlight_pwm_enabled) {
prv_backlight_pwm_enable(false);
}
PWR_TRACK_BACKLIGHT("OFF", PWM_OUTPUT_FREQUENCY_HZ, 0);
} else {
if (!s_backlight_pwm_enabled) {
prv_backlig... |
izeof(app_glance_1);
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance_1, glance_1_size),
S_SUCCESS);
cl_assert_equal_i(app_glance_db_get_len((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE),
... | app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&s_app_glance_with_invalid_slice_total_sizes,
sizeof(s_app_glance_with_invalid_slice_total_sizes)) | ,
E_INVALID_ARGUMENT);
}
status_t app_glance_db_insert_stale(const uint8_t *key, int key_len, const uint8_t *val,
int val_len);
void test_app_glance_db__read_stale_glance_blob(void) {
// Force the insertion of a stale glance blob (outdated version)
const Ser... |
r = {
.id = {0xdd},
.parent_id = {0},
.timestamp = s_feb_5_midnight + 8 * 60 * 60 + 15 * 60, // 8:15-8:16 am
.duration = 1,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
}
};
// Setup
/////////////////////////
void test_timeline__initialize(void) {
... | cl_assert(iter_next(&iterator)) | ;
cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id));
// check third again
cl_assert(iter_prev(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin... |
u 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 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the... | dict_write_tuplet(iter, &updated_keys_and_values[i]) | ;
}
dict_write_end(iter);
return app_message_outbox_send();
}
const Tuple * app_sync_get(const AppSync *s, const uint32_t key) {
return dict_find(&s->current_iter, key);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.