prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
PBL_LOG(LOG_LEVEL_ERROR, "Unable to get Build ID");
goto spi_failed;
}
memcpy(build_id, s_rx_buffer, sizeof(build_id));
// Get the memory region table
cmd = (CoreDumpSPICmd) { .cmd = CoreDumpCmd_ReadRegionTable };
if (!prv_spi_transaction(&cmd, s_rx_buffer, region_buf_size)) {
PBL_LOG(LOG_LEVEL_E... | (s_rx_buffer, flash_addr, sizeof(CoreDumpExtraRegInfo)) | ;
flash_addr += sizeof(CoreDumpExtraRegInfo);
// Terminate the core dump
chunk_hdr.key = CORE_DUMP_CHUNK_KEY_TERMINATOR;
chunk_hdr.size = 0;
if (flash_addr_max < (flash_addr + sizeof(chunk_hdr) + chunk_hdr.size)) {
PBL_LOG(LOG_LEVEL_ERROR, "Insufficient space for BLE core dump terminator");
goto powe... |
HRZone hr_zone = hr_util_get_hr_zone(active_window->workout_controller->get_metric_value(
metric_type, active_window->workout_data));
const bool draw_zones = (metric_type == WorkoutMetricType_Hr) && hr_zone > HRZone_Zone0;
const bool prefer_larger_font = active_window->layout == WorkoutLayout_SingleMetric ||
... | {
bool is_paused = false;
bool can_stop = false;
if (active_window->workout_controller) {
is_paused = active_window->workout_controller->is_paused();
can_stop = active_window->workout_controller->stop != NULL;
}
if (!is_paused || !can_stop) {
return;
}
prv_end_workout(active_window);
} |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
WorkoutActiveWindow *active_window = context;
if (active_window->pause_button == BUTTON_ID_UP) {
prv_handle_pause_button(active_window);
}
}
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {... |
_db_get_len,
.read = pin_db_read,
.del = pin_db_delete,
.flush = pin_db_flush,
.is_dirty = pin_db_is_dirty,
.get_dirty_list = pin_db_get_dirty_list,
.mark_synced = pin_db_mark_synced,
},
[BlobDBIdApps] = {
.init = app_db_init,
.insert = app_db_insert,
.get_len = app_db_get_len,
... | {
bool is_dirty = false;
if (db->is_dirty && (db->is_dirty(&is_dirty) == S_SUCCESS) && is_dirty) {
ids[*num_ids] = i;
*num_ids += 1;
}
} |
}
status_t blob_db_insert(BlobDBId db_id,
const uint8_t *key, int key_len, const uint8_t *val, int val_len) {
if (!prv_db_valid(db_id)) {
return E_RANGE;
}
const BlobDB *db = &s_blob_dbs[db_id];
if (db->insert) {
status_t rv = db->insert(key, key_len, val, val_len);
if (rv == S_SUCCESS) {
... |
list_to_serialize, buffer,
buffer + expected_attr_list_serialized_size);
cl_assert_equal_i(size, expected_attr_list_serialized_size);
cl_assert_equal_m(expected_attr_list_serialized, buffer, expected_attr_list_serialized_size);
}
void test_attribute__serialize_attr_li... | (value_uint8, attribute_get_uint8(&list, AttributeIdBgColor, 0)) | |
];
TextLayer *bg_color_text;
char bg_color_text_buffer[20];
uint8_t bg_color_index;
} AppData;
static void set_text_element(TextLayer *text_layer, char *text_buffer, bool highlight) {
GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
text_layer_set_font(text_layer, font);
if (highlight) {
te... | graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1)) | ;
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
} else if (alpha == ALPHA_0) {
graphics_context_set_stroke_color(ctx, bg_color);
graphics_draw_pixel(ctx, point);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y));
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
graphi... |
_KIND_CUSTOM;
case DayPickerMenuItemsNumItems:
break;
}
return ALARM_KIND_EVERYDAY;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Day Picker
static void prv_day_picker_window_unload(Window *window) {
AlarmEditorData *data = (AlarmEditorData*)... | {
AlarmEditorData *data = (AlarmEditorData *)callback_context;
data->day_picker_was_completed = false;
if (cell_index->row == DayPickerMenuItemsCustom) {
prv_handle_custom_day_selection(cell_index->row, callback_context);
} else {
data->day_picker_was_completed = true;
prv_handle_selection(cell_ind... |
static void prv_setup_day_picker_window(AlarmEditorData *data) {
window_init(&data->day_picker_window, WINDOW_NAME("Alarm Day Picker"));
window_set_user_data(&data->day_picker_window, data);
data->day_picker_window.window_handlers.unload = prv_day_picker_window_unload;
GRect bounds = data->day_picker_window.... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (p1.y - p0.y) | > abs(p1.x - p0.x);
if (steep) {
swap16(&p0.x, &p0.y);
swap16(&p1.x, &p1.y);
}
if (p0.x > p1.x) {
swap16(&p0.x, &p1.x);
swap16(&p0.y, &p1.y);
}
int dx = p1.x - p0.x;
int dy = abs(p1.y - p0.y);
int16_t err = dx / 2;
int16_t ystep;
if (p0.y < p1.y) {
ystep = 1;
} else {
ys... |
ext s_ctx;
static FrameBuffer *s_fb = NULL;
void test_graphics_draw_bitmap__initialize(void) {
s_fb = malloc(sizeof(FrameBuffer));
framebuffer_init(s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
test_graphics_context_init(&s_ctx, s_fb);
read_pbi("no_litter_crop.png.pbi", &test_image);
}
void test_graphics_draw_bitma... | read_pbi(pbi_filename, &result) | |
(ctx, point) | ;
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
graphics_context_set_stroke_color(ctx, bg_color);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y));
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
} else if (alpha == ALPHA_33) {
graphics_context_set_stroke_color(ctx, fg_... | |
c_buffer_size(3, 10, 100, 1000);
cl_assert(size == sizeof(Dictionary) + (3 * sizeof(Tuple)) + 10 + 100 + 1000);
}
struct SerializeTestResult {
bool okay;
uint16_t expected_size;
};
static void serialize_callback(const uint8_t * const data, const uint16_t size, void *context) {
struct SerializeTestResult *resu... | (tuple->value->data, SOME_DATA, sizeof(SOME_DATA)) | == 0);
data_found = true;
break;
case SOME_STRING_KEY:
cl_assert(tuple->length == strlen(SOME_STRING) + 1);
cl_assert(strncmp(tuple->value->cstring, SOME_STRING, strlen(SOME_STRING) + 1) == 0);
// Check zero termination:
cl_assert(tuple->value->cstring[strlen(SOME_... |
p
if (process_manager_compiled_with_legacy2_sdk()) {
ApplibInternalEventsInfo *events_info =
app_state_get_applib_internal_events_info();
// Initialize the state for the status bar handler.
events_info->minute_of_last_legacy2_statusbar_change = -1;
events_info->legacy2_status_bar_change_event ... | if (event.type == PEBBLE_RENDER_REQUEST_EVENT) {
app_request_render();
} else if (event.type == PEBBLE_RENDER_FINISHED_EVENT) {
*app_state_get_framebuffer_render_pending() = false;
} else {
event_service_client_handle_event(&event);
} |
mcu_fpu_cleanup();
event_cleanup(&event);
event_loop_upkeep();
}
}
void app_event_loop(void) {
app_event_loop_common();
app_heap_analytics_log_stats_to_app_heartbeat(false /* is_rocky_app */);
}
|
iting, 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 "text_layer_legacy2.h"
#include "applib... | gcolor_equal(native_color, bg_color) | ) {
return;
}
text_layer->background_color = get_closest_gcolor2(native_color);
layer_mark_dirty(&(text_layer->layer));
}
void text_layer_legacy2_set_text_color_2bit(TextLayerLegacy2 *text_layer, GColor2 color) {
if (text_layer == NULL) {
return;
}
GColor8 native_color = get_native_color(color);
... |
/*
* 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 (exit_on_pop) {
bool animated = false;
app_window_stack_pop_all(animated);
} | |
st another event if more data arrives.
accel_reset_pending_accel_event();
state = (AccelSubscriberState *)s_data_subscribers;
while (state) {
if (!state->raw_buffer || state->samples_per_update == 0) {
state = (AccelSubscriberState *)state->list_node.next;
continue;
}
// ... | if (rate != ACCEL_SAMPLING_10HZ && rate != ACCEL_SAMPLING_25HZ && rate != ACCEL_SAMPLING_50HZ
&& rate != ACCEL_SAMPLING_100HZ) {
return -1;
} |
mutex_lock_recursive(s_mutex);
{
AccelSubscriberState* state = prv_subscriber_state(session);
if (!state) {
PBL_LOG(LOG_LEVEL_WARNING, "not subscribed");
goto unlock;
}
state->sampling_rate = rate;
prv_update_driver_config();
}
unlock:
mutex_unlock_recursive(s_mutex);
return 0... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (grect_get_max_x(&dest_rect), dest_row_info.max_x + 1) | ;
if (dest_end_x < dest_begin_x) {
continue;
}
const GBitmapDataRowInfo src_row_info = gbitmap_get_data_row_info(src_bitmap, src_y);
const uint8_t *src = src_row_info.data;
// This is the initial position that takes into account destination delta shift
const int16_t src_initial_x = src_bi... |
le(animation, animation_legacy2_scheduler, finished);
} else {
// If this is the animation's first frame, call the 'started' handler:
if (animation->handlers.started &&
animation->abs_start_time_ms > animation_legacy2_scheduler->last_frame_time) {
animation->handlers.started(animation,... | prv_custom_curve_ptr_unpack(animation->custom_curve_function) | ;
}
static void dump_scheduler(char* buffer, int buffer_size,
AnimationLegacy2Scheduler* animation_legacy2_scheduler) {
AnimationLegacy2 *animation = (AnimationLegacy2 *) animation_legacy2_scheduler->head;
while (animation) {
dbgserial_putstr_fmt(buffer, buffer_size,
"<%p> { ... |
ta_signature,
sizeof(data_signature)) == sizeof(data_signature) &&
(ntohl(data_signature) == expected_signature))) {
return NULL;
}
// Data is the second entry after the resource signature
if (data_size) {
uint32_t output_data_size;
_Static_assert(PDCI_SIZE_OFFSET == PDCS_SIZE_OFFSET,... | {
return (GColor) {0};
} | else {
return command->fill_color;
}
}
void gdraw_command_set_stroke_color(GDrawCommand *command, GColor stroke_color) {
if (!command) {
return;
} else {
command->stroke_color = stroke_color;
}
}
GColor gdraw_command_get_stroke_color(GDrawCommand *command) {
if (!command) {
return (GColor)... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
test_graphics_context_init(&s_ctx, fb);
framebuffer_clear(fb);
}
void test_emoji_fonts__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
// Helpers
//////////////////////
static char s_emoji_string[] =
"😄😃😀😊☺😉😍😘😚😗😙😜😝😛😳😁😔😌😒😞😣😢😂😭😥😪�... |
CONFIG_SPI_POL_MODE, CONFIG_SPI_PHASE_MODE,
CONFIG_SPI_DMA_CHANNEL);
void DMA_Handler(void); // This is the Dialog SPI/DMA Interrupt handler
static volatile bool s_spi_dma_complete;
static const spi_device_config * const s_spi = &dev_CORE_DUMP_SPI;
s... | REG_SET_BIT(CRG_TOP, CLK_RADIO_REG, BLE_LP_RESET) | |
/*
* 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_external_collect_battery();
analytics_external_collect_accel_xyz_delta();
analytics_external_collect_app_cpu_stats();
analytics_external_collect_app_flash_read_stats();
analytics_external_collect_cpu_stats();
analytics_external_collect_stop_inhibitor_stats(rtc_get_ticks());
analytics_external_... | |
344, 16, 160},
// 67 seconds
{ -1120, 368, 192},
{ -896, 456, 80},
{ -792, 336, 24},
{ -864, 336, 80},
{ -888, 392, 184},
{ -1120, 640, 240},
{ -1024, 1768, 208},
{ -1576, 104, 96},
{ -1208, 96, -128},
{ -1488, 288, -24},
{ -1976, 424, 104},
{ -1992, 248, 96},
{ -... | { -1640, 144, 24},
{ -1408, 288, -56},
{ -1144, 304, -56},
{ -1336, 336, 40},
{ -1440, 344, 48},
{ -1088, 240, -24},
{ -840, 120, 0},
{ -816, -120, 384},
{ -808, -128, 192},
{ -1024, 24, 88},
{ -1240, 56, 152},
{ -1456, 40, 192},
{ -1336, -120, 328},
{ -1408, 88, ... | |
false;
storage_acquire();
device_t *dev = find_device_by_conn_idx(conn_idx);
if (dev) {
// Only enable the work-around if the bit is present in the bonding list, in other words, it
// had been set *before pairing*. Don't look at the Connection flag, because this can be set
// at any time. This way ba... | (LOG_LEVEL_DEBUG, "Invalid CCCD write offset %"PRIu16, evt->offset) | ;
}
}
}
static void prv_ppogatt_handle_read_request(ble_service_t *svc,
const ble_evt_gatts_read_req_t *evt) {
PBL_LOG(LOG_LEVEL_DEBUG, "Unexpected PPoGATT Service Read: 0x%"PRIx16, evt->handle);
// In the future, we might actually return something useful. For now... |
to be called, as we closed the context
cl_assert_equal_i(s_out_sent_call_count, 0);
cl_assert_equal_b(s_nack_sent_is_called, false);
cl_assert_equal_i(s_out_failed_call_count, 0);
cl_assert_equal_b(app_message_is_closed_outbound(), true);
}
void test_app_message__send_while_closing(void) {
prv_set_remote_rec... | app_message_outbox_begin(&iterator) | |
et_charge_state().charge_percent, percent);
}
void test_battery_monitor__curve_adjustment_when_charge_complete(void) {
int charge_mv = battery_curve_lookup_voltage_by_percent(0, true);
int full_mv = battery_curve_lookup_voltage_by_percent(100, false);
int charge_terminate_mv = battery_curve_lookup_voltage_by_per... | cl_assert(!battery_monitor_critical_lockout()) | |
gs_file_rewrite_filtered call creates a new file based on file->max_used_space
// and copies the contents of the existing file into it.
status = settings_file_rewrite_filtered(file, NULL, NULL);
if (status < 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Could not resize file %s (error %"PRId32"). Creating new one",
... | settings_raw_iter_begin(&new_file.iter) | ;
for (settings_raw_iter_begin(&file->iter); !settings_raw_iter_end(&file->iter);
settings_raw_iter_next(&file->iter)) {
SettingsRecordHeader *hdr = &file->iter.hdr;
if (partially_written(hdr)) {
// This should only happen if we reboot in the middle of writing a new
// record, and it should... |
eChalk:
// yes, this is misleading, e.g. on Spalding, these defines are always 180x180
// oh dear...
*size = GSize(LEGACY_3X_DISP_COLS, LEGACY_3X_DISP_ROWS);
return;
case PlatformTypeDiorite:
case PlatformTypeEmery:
*size = GSize(DISP_COLS, DISP_ROWS);
return;
}
WTF;
}
b... | app_manager_get_current_app_md() | );
}
DEFINE_SYSCALL(bool, sys_app_is_watchface, void) {
return app_manager_is_watchface_running();
}
DEFINE_SYSCALL(ResAppNum, sys_get_current_resource_num, void) {
if (pebble_task_get_current() == PebbleTask_KernelMain) {
return SYSTEM_APP;
}
return process_metadata_get_res_bank_num(app_manager_get_cur... |
},
{ 432, 592, -664},
{ 416, 560, -656},
{ 416, 576, -664},
{ 448, 536, -664},
{ 440, 600, -664},
{ 416, 576, -648},
{ 416, 592, -640},
{ 432, 592, -648},
{ 448, 576, -656},
{ 432, 592, -680},
{ 432, 264, -600},
{ 432, 768, -400},
{ 448, 1024, -544},
{ 432, 624, -... | { 464, 728, -424},
// 176 seconds
{ 480, 856, -472},
{ 400, 824, -368},
{ 472, 792, -352},
{ 464, 768, -384},
{ 440, 744, -440},
{ 432, 792, -424},
{ 456, 808, -400},
{ 456, 768, -376},
{ 448, 792, -360},
{ 448, 776, -432},
{ 440, 752, -408},
{ 440, 816, -416},
... |
{ 456, 800, -376},
{ 456, 768, -376},
{ 456, 792, -376},
{ 456, 784, -384},
{ 464, 784, -384},
{ 456, 784, -376},
{ 464, 776, -384},
{ 456, 784, -384},
{ 464, 784, -368},
// 179 seconds
{ 464, 776, -384},
{ 464, 784, -376},
{ 456, 784, -376},
{ 464, 776, -384},
... |
784, 888, -400},
// 144 seconds
{ 712, 824, -392},
{ 656, 776, -416},
{ 632, 704, -384},
{ 632, 680, -408},
{ 648, 688, -416},
{ 672, 712, -472},
{ 704, 752, -536},
{ 696, 824, -632},
{ 688, 856, -736},
{ 592, 808, -776},
{ 400, 600, -752},
{ 256, 312, -648},
{ 2... | { 1360, 344, -552},
{ 1344, 368, -496},
{ 1184, 392, -680},
{ 1032, 464, -696},
{ 960, 504, -592},
{ 1136, 696, -696},
{ 1040, 600, -592},
{ 1256, 576, -480},
{ 1440, 424, -464},
{ 1136, 168, -344},
{ 1000, 144, -344},
{ 1088, 104, -352},
{ 1216, 88, -336},
{ 1352... |
{ 1408, 152, -232},
{ 1040, -120, -160},
{ 880, -488, 104},
{ 888, -328, -280},
{ 952, -248, -448},
{ 1272, -328, -264},
{ 1232, 96, -408},
{ 1112, 136, -416},
{ 1208, 352, -344},
{ 1288, 488, -368},
{ 1264, 648, -432},
{ 1168, 688, -328},
{ 1056, 800, -392},
{ 8... |
rReceiving:
prv_handle_int_waiting_for_receiving();
break;
case SPITransportState_WaitingForReceiving_Footer:
prv_handle_int_waiting_for_receiving_footer();
break;
case SPITransportState_WaitingForSending:
prv_handle_int_waiting_for_sending();
break;
case SPITransportS... | {
prv_lock();
size_t rx_length = circular_buffer_get_read_space_remaining(&s_spi_transport.rx);
prv_unlock();
return rx_length;
} | |
k_size;
if (item_size > DLS_SESSION_MAX_BUFFERED_ITEM_SIZE) {
// Must be unbuffered
chunk_size = item_size;
} else {
chunk_size = MIN(num_bytes, DLS_SESSION_MAX_BUFFERED_ITEM_SIZE);
chunk_size -= (chunk_size % item_size);
}
PBL_ASSERTN(chunk_size <= num_bytes);
data_logging_l... | {
DataLoggingSessionRef logging_sessions[10];
Uuid system_uuid = UUID_SYSTEM;
// Test that we can log items > DLS_SESSION_MAX_BUFFERED_ITEM_SIZE when non-buffered
const int item_size = 2 * DLS_SESSION_MAX_BUFFERED_ITEM_SIZE;
// Create sessions
for (int i = 0; i < 10; i++) {
logging_sessions[i] = (Dat... |
// ----------------------------------------------------------------------------------------
void test_data_logging__log_consume_large_items(void) {
DataLoggingSessionRef logging_sessions[10];
int item_size[10];
// Create sessions
for (int i = 0; i < 10; i++) {
item_size[i] = 50 + (rand() % 250);
log... |
dler,
test_dropped_handler);
cl_assert_equal_p(result, NULL);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// app_inbox_service_register
void test_app_inbox__app_inbox_create_and_register_storage_already_associa... | cl_assert_equal_b(false, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE + 1, s_writer)) | |
ermissions and
* limitations under the License.
*/
#include "resource_storage_impl.h"
#include "resource_storage_file.h"
#include "kernel/util/sleep.h"
#include "services/normal/filesystem/pfs.h"
#include "system/logging.h"
#include <stdint.h>
extern const FileResourceData g_file_resource_stores[];
extern const u... | if (!file) {
return NULL;
} |
PFSCallbackHandle cb_handle = pfs_watch_file(file->name, callback, FILE_CHANGED_EVENT_ALL, data);
return cb_handle;
}
static bool resource_storage_file_unwatch(ResourceCallbackHandle cb_handle) {
pfs_unwatch_file(cb_handle);
return true;
}
static void resource_storage_file_init(void) {
// Make sure the fil... |
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 1);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw1_clip_xy.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_N... | graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY, RADIUS_DEFAULT) | |
->state != StateError) {
// Do not indicate that an error occurred when a session is interrupted by a window transition
if (data->state != StateFinished) {
data->last_session_successful = false;
}
prv_cancel_dictation(data);
}
}
static void prv_mic_window_appear(Window *window) {
VoiceUiData ... | {
if (voice_window->message) {
if (voice_window->buffer_size == 0) {
// If buffer size is set to 0, the buffer was allocated when the last transcription was
// received
applib_free(voice_window->message);
voice_window->message = NULL;
} else {
voice_window->message[0] = '\0';
... |
// Syscalls
/////////////////////////////////////////////////////////////////////////////////
DEFINE_SYSCALL(char *, sys_voice_get_transcription_from_event, PebbleVoiceServiceEvent *e,
char *buffer, size_t buffer_size, size_t *sentence_len) {
if (PRIVILEGE_WAS_ELEVATED) {
syscall_assert_userspa... |
/*
* 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... | ((data[i] & 0x03) << 4) | ;
*out++ = '=';
*out++ = '=';
}
}
if (result < out_len) {
*out++ = 0;
}
return result;
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
size_t n = strlen(s2) + 1;
return memcpy(s1, s2, n);
} |
char *strncpy(char * restrict s1, const char * restrict s2, size_t n) {
char *rc = s1;
size_t strn = strlen(s2) + 1;
if (strn > n) {
strn = n;
}
memcpy(s1, s2, strn);
if (n > strn) {
memset(s1 + strn, '\0', n - strn);
}
return rc;
}
|
pture_frame_buffer() above)
bool graphics_release_frame_buffer(GContext *ctx, GBitmap *buffer) {
PBL_ASSERTN(ctx);
ctx->lock = false;
framebuffer_dirty_all(ctx->parent_framebuffer);
return true;
}
GContext *graphics_context_get_current_context(void) {
return &s_ctx;
}
// Stubs
/////////////////////
#includ... | time_selection_window_configure(&selection_window, &s_time_config) | ;
// Set the window on screen so its window handlers will be called
window_set_on_screen(&selection_window.window, true, true);
window_render(&selection_window.window, ctx);
}
static void prv_render_time_range_selection_window(GContext *ctx,
SettingsContentSiz... |
/*
* 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... | delay_ms(200) | |
_legacy2_scheduler->timer_handle != NULL) {
app_timer_reschedule(animation_legacy2_scheduler->timer_handle, interval_ms);
// Ignore the return value of reschedule. If it fails it probably means the callback is already
// fired and we're waiting for the handler to be called. This will end up rescheduling us ... | (animation, get_current_scheduler()) | ;
}
void animation_legacy2_unschedule(AnimationLegacy2 *animation) {
animation_legacy2_private_unschedule(animation, get_current_scheduler(), false);
}
void animation_legacy2_unschedule_all(void) {
animation_legacy2_private_unschedule_all(AppTaskCtxIdxApp);
}
bool animation_legacy2_is_scheduled(AnimationLegacy2 ... |
l_out, s_sleep_data[SD_TypicalDeepSleepDuration]);
cl_assert(health_db_get_typical_value(ActivityMetricSleepEnterAtSeconds, Monday, &val_out));
cl_assert_equal_i(val_out, s_sleep_data[SD_TypicalFallAsleepTime]);
cl_assert(health_db_get_typical_value(ActivityMetricSleepExitAtSeconds, Monday, &val_out));
cl_ass... | health_db_get_monthly_average_value(ActivityMetricStepCount, &val_out) | );
cl_assert_equal_i(val_out, average_steps_val);
const char *average_sleep_key = "average_sleepDuration";
int32_t average_sleep_val = 654321;
cl_assert_equal_i(health_db_insert((uint8_t *)average_sleep_key, strlen(average_sleep_key),
(uint8_t *)&average_sleep_val, sizeof(a... |
GSize *size_out) {
if (render) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
graphics_draw_bitmap_in_rect(ctx, icon, rect);
}
if (size_out) {
*size_out = rect->size;
}
}
static void prv_draw_heart_node_callback(GContext *ctx, const GRect *box,
co... | (layer_get_window(layer)) | |
_ongoing(ActivitySessionType_Sleep));
cl_assert_equal_i(HealthActivityRun | HealthActivityWalk | HealthActivitySleep , health_service_peek_current_activities());
}
static void prv_set_median_hr_for_minutes(int bpm, int num_minutes) {
const int num_samples = 15;
activity_private_state()->hr.num_samples = num_samp... | (zone2_minutes, 2) | ;
activity_get_metric(ActivityMetricHeartRateZone3Minutes, 1, &zone3_minutes);
cl_assert_equal_i(zone3_minutes, 2);
// Ad some "Semi-active" heart rates
prv_set_median_hr_for_minutes(130 /* BPM */, 3 /* minutes */);
cl_assert_equal_b(prv_is_hr_elevated(), true);
activity_get_metric(ActivityMetricHeartRateZ... |
ng routines call into this module, we should NOT have any
// PBL_LOGs in this file, else you could generate infinite loops!
// Configuration Defines
#define LOG_REGION_SIZE (FLASH_REGION_DEBUG_DB_END - FLASH_REGION_DEBUG_DB_BEGIN)
#define ERASE_UNIT_SIZE (FLASH_DEBUG_DB_BLOCK_SIZE)
#define DEFAULT_LOG_PAGE_SIZE (0x20... | ((ERASE_UNIT_SIZE % LOG_PAGE_SIZE) == 0,
"The log page size must be divisible by the erase unit size") | |
larmEditorData*) window_get_user_data(window);
if (!data->day_picker_was_completed && data->time_picker_was_completed) {
// If we cancel the day picker go back to the time picker
data->time_picker_was_completed = false;
return;
}
if (data->creating_alarm) {
time_selection_window_deinit(&data->ti... | ("Alarm Day Picker") | );
window_set_user_data(&data->day_picker_window, data);
data->day_picker_window.window_handlers.unload = prv_day_picker_window_unload;
GRect bounds = data->day_picker_window.layer.bounds;
#if PBL_ROUND
bounds = grect_inset_internal(bounds, 0, STATUS_BAR_LAYER_HEIGHT);
#endif
menu_layer_init(&data->day_picke... |
t_mm, uint32_t weight_g, ActivityGender gender,
uint32_t age_years) {
return true;
}
bool activity_algorithm_get_steps(uint16_t *steps) {
*steps = s_test_alg_state.steps;
return true;
}
bool activity_algorithm_get_step_rate(uint16_t *steps, uint32_t *elapsed_ms, time_t *end_sec)... | if (record_start_time + SECONDS_PER_MINUTE > last_second_available) {
// This record not available yet.
break;
} |
minute_data[num_records_returned] = (HealthMinuteData) {
.steps = record_start_time % 255,
};
}
*num_records = num_records_returned;
return true;
}
time_t activity_algorithm_get_last_sleep_utc(void) {
return s_test_alg_state.last_sleep_utc;
}
bool activity_algorithm_test_send_fake_minute_data... |
RMEvent) {
.event_type = HRMEvent_SubscriptionExpiring,
.expiring.session_ref = state->session_ref,
};
state->callback_handler(&expiring_event, state->callback_context);
state->sent_expiration_event = true;
}
// See if this subscriber wants these types of events
switch (ev... | HRM_LOG("Status %"PRIx8, data->hrm_status) | ;
HRM_LOG("HRM: %"PRIu8"bpm, Quality: %d, Stable: %d", data->hrm_bpm, data->hrm_quality,
(int)stable_sensor);
HRM_LOG("PPG samples: %d", data->ppg_data.num_samples);
HRM_HEXDUMP(data->ppg_data.ppg, data->ppg_data.num_samples * sizeof(uint16_t));
HRM_LOG("TIA samples: %d", data->ppg_data.num_samples);
... |
lled_aa.${BIT_DEPTH_NAME}.pbi"));
// Special case for two points that are duplicates...
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_single_duplicate_path;
ctx.draw_state.clip_box = GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
graphics_context_set_antialiased(&ctx, true);
prv_fi... | prv_reset() | ;
s_current_path = s_infinite_path;
gpath_move_to(s_infinite_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
s_path_angle = 45;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_fille... |
(), 0);
}
// --------------------------------------------------------------------------------------
// Test that animation_destroy can be called from the stopped handler
void test_animation__destroy_from_stopped_handler_with_auto_destroy(void) {
#ifdef TEST_INCLUDE_BASIC
prv_test_destroy_from_stopped_handler(true);... | cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, a), 0) | ;
// The distance should always be at 0
cl_assert_equal_i(prv_last_update_distance(a), 0);
// Destroy it
animation_destroy(a);
#endif
}
// --------------------------------------------------------------------------------------
// Test a simple sequence animation
void test_animation__simple_sequence(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... | ASSERT(emx_resources_read(1, id_1, 0, (uint8_t *)&buf, 1) == 4) | ;
ASSERT(buf == 1);
ASSERT(s_read_1_called == 2);
// add 4
uint32_t id_4 = emx_resources_register_custom(custom_res_read_4, custom_res_size_4);
ASSERT(emx_resources_get_size(1, id_4) == 4);
buf = 0;
ASSERT(emx_resources_read(1, id_4, 0, (uint8_t *)&buf, 1) == 4);
ASSERT(buf == 4);
ASSERT(s_read_4_cal... |
ords >= 100) {
cl_assert(false);
}
cl_assert(s_num_dls_activity_records < ARRAY_LENGTH(s_dls_activity_records));
s_dls_activity_records[s_num_dls_activity_records++] = records[i];
}
} else {
return DATA_LOGGING_INVALID_PARAMS;
}
return DATA_LOGGING_SUCCESS;
}
DataLoggingSessio... | ("Expected %"PRIu32" activities, but found %"PRIu32".\n", num_expected, num_sessions) | ;
}
clar__assert(num_sessions == num_expected, file, line, "wrong number of activities", "", true);
}
// Assert that a particular step activity session is present in the sessions list
static void prv_assert_step_activity_present(ActivitySession *exp_session, char *file, int line) {
ActivitySession sessions[ACTIV... |
GPoint(5, -30) | , GPoint(45, 30));
}
void test_graphics_draw_line__origin_layer(void) {
GContext ctx;
Layer layer;
test_graphics_context_init(&ctx, fb);
layer_init(&layer, &GRect(0, 0, 60, 60));
layer_set_update_proc(&layer, &inside_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.de... | |
(sizeof(FrameBuffer)) | ;
framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS});
ctx = malloc(sizeof(GContext));
test_graphics_context_init(ctx, fb);
framebuffer_clear(fb);
}
// Teardown
void test_bitblt_circular__cleanup(void) {
free(fb);
free(ctx);
}
// Tests
////////////////////////////////////
// Reference PNGs reside in "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... | EXECUTE_SCRIPT("var size = _rocky.userPreferences.contentSize") | ;
ASSERT_JS_GLOBAL_EQUALS_S("size", "x-large");
}
|
c_name, &key, platform_bits);
}
} else if (type == BtPersistBondingTypeBLE) {
SMPairingInfo pairing_info;
char ble_name[BT_DEVICE_NAME_BUFFER_SIZE] = { };
bool requires_address_pinning = false;
uint8_t flags = 0;
if (prv_bt_persistent_storage_get_ble_smpairinginfo_by_id(
id, &pairi... | prv_lock() | ;
{
SettingsFile fd;
rv = settings_file_open(&fd, BT_PERSISTENT_STORAGE_FILE_NAME, BT_PERSISTENT_STORAGE_FILE_SIZE);
if (rv) {
goto cleanup;
}
settings_file_each(&fd, itr_cb, itr_data);
settings_file_close(&fd);
}
cleanup:
prv_unlock();
return (rv == S_SUCCESS);
}
//! Get the ne... |
rt_equal_i(prv_last_update_distance(a), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1);
cl_assert_... | // since a is embedded within seq
int32_t position;
animation_get_elapsed(seq, &position);
cl_assert_equal_i(position, 100);
// Now, advance sequence to almost the end of seq. Positions don't include the delay, so
// pass false for 'include_delay'
animation_set_elapsed(seq, animation_get_duration(seq, f... | |
.raw_value);
}
return top.x.raw_value + (bottom.x.raw_value - top.x.raw_value) *
(progress.raw_value - top.y.raw_value) /
(bottom.y.raw_value - top.y.raw_value);
}
static void prv_swap_precise_points(GPointPrecise *p0, GPointPrecise *p1) {
GPointPrecise tmp = *p0;
*p0 = *p1;
*p1 = tmp;
}
static void pr... | {
config.full_quadrants = GCornersAll;
return config;
} | |
y_cycles, buffer, length, is_ddr);
} else if (should_use_memmap) {
prv_read_mmap_with_params(dev, addr, buffer, length, instruction, dummy_cycles, is_ddr);
} else {
qspi_indirect_read(dev->qspi, instruction, addr, dummy_cycles, buffer, length, is_ddr);
}
qspi_release(dev->qspi);
}
int qspi_flash_write_... | (dev->qspi) | |
sert_equal_i(animation_get_duration(b, false, true), play_count_b * duration_b);
cl_assert_equal_i(animation_get_duration(b, true, false), delay_b + duration_b);
cl_assert_equal_i(animation_get_duration(b, true, true), total_duration_b);
cl_assert_equal_i(animation_get_duration(seq, false, false), total_duration... | (prv_count_scheduled_animations(), 7) | ;
// Unschedule all
animation_unschedule_all();
cl_assert_equal_i(prv_count_scheduled_animations(), 0);
// Make sure just the setup and teardown handlers were called
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_... |
);
switch (layout_mode) {
default:
case LayoutLayerModePinnedFat:
*size = GSize(width, style->fat_pin_height);
break;
case LayoutLayerModePinnedThin:
*size = GSize(width, style->thin_pin_height);
break;
}
}
static void prv_get_frame(TimelineLayer *layer, int index, GRect *frame)... | layer_set_frame((Layer *)&layout->icon_layer, &icon_rect) | ;
layer_add_child(&layer->layouts_layer, (Layer *)&layout->icon_layer);
layer->layouts[index] = layout;
layer->layouts_info[index] = info;
}
static void prv_destroy_layout(TimelineLayer *layer, int index) {
TimelineLayout *timeline_layout = layer->layouts[index];
timeline_layout->is_being_destroyed = true;
... |
ghts, fffffffc");
// Alternate form (adds 0x prefix)
snprintf(dstbuf, 256, "There are %#x lights, %#x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 0x10 lights, 0xfffffffc");
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %03x lights, %03x", 16, -4);
cl_assert_equal_s(dstbuf, "... | (dstbuf, "zero1") | ;
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.Xzero%.X", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3Xzero%.-3X", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits outp... |
te_animation,
};
const WindowTransitionImplementation *window_transition_get_default_pop_implementation() {
return &window_transition_default_pop_implementation;
}
Animation *window_transition_default_push_create_animation(WindowTransitioningContext *context) {
window_transition_context_disappear(context);
wind... | stub_pebble_tasks_set_current(PebbleTask_KernelMain) | ;
}
void test_window_stack__cleanup(void) {
stub_pebble_tasks_set_current(PebbleTask_App);
app_window_stack_pop_all(false);
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
modal_manager_pop_all();
fake_animation_cleanup();
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), 0);
}
// Tests
/////... |
--------------
// Count how many animations have been scheduled
static uint32_t prv_count_scheduled_animations(void) {
AnimationState *state = kernel_applib_get_animation_state();
return list_count(state->scheduled_head);
}
// --------------------------------------------------------------------------------------
s... | (h, duration) | ;
animation_set_auto_destroy(h, false);
// Clone it and make sure the clone is correct
PropertyAnimation *clone_h = (PropertyAnimation *)animation_clone((Animation *)prop_h);
property_animation_get_from_grect(clone_h, &r);
cl_assert_equal_rect(from_r, r);
property_animation_get_to_grect(clone_h, &r);
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... | (buf, "11", buf_size) | != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"I\": %s", buf);
}
r = strftime(buf, buf_size, "%j", &good_data);
if (r == 0 || strncmp(buf, "125", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"j\": %s", buf);
}
r = strftime(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp... |
, 453, -35},
{ -840, 405, 9},
{ -844, 380, 31},
{ -854, 443, 22},
{ -892, 420, 43},
{ -889, 378, 65},
{ -872, 362, 99},
{ -841, 375, 101},
{ -1106, 546, 141},
{ -936, 614, 132},
{ -945, 643, 140},
{ -825, 713, 168},
{ -854, 725, 255},
{ -891, 784, 293},
{ -835, 91... | rtc_get_time() | + SECONDS_PER_MINUTE);
prv_clear_event_queue();
}
}
// -------------------------------------------------------------------------------
static void prv_test_steps(void *context) {
bool passed = false;
// Reset all stored data
activity_test_reset(true /*reset_settings*/, true /*tracking_on*/, NULL, NULL);... |
le 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 in writing, software
* di... | (outer_point.x, frame->size.w - inset_amount) | ),
.y = MAX(inset_amount - 1, MIN(outer_point.y, frame->size.h - inset_amount))
};
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
// UI Drawing
static void prv_draw_outer_ring(GContext *ctx, int32_t current, int32_t total,
... |
/*
* 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... | bitset8_set(f->dirty_lines, y) | ;
f->is_dirty = true;
}
void framebuffer_mark_dirty_rect(FrameBuffer* f, GRect rect) {
const uint16_t y_start = rect.origin.y;
const uint16_t y_end = y_start + rect.size.h;
for (uint16_t y = y_start; y < y_end; ++y) {
bitset8_update(f->dirty_lines, y, is_dirty);
}
f->is_dirty = true;
}
void framebuf... |
n, altfunc);
GPIO_PinAFConfig(FLASH_CONFIG.spi_gpio, FLASH_CONFIG.mosi_pin, altfunc);
// Setup MISO/MOSI
GPIO_InitTypeDef gpio_cfg;
gpio_cfg.GPIO_OType = GPIO_OType_PP;
gpio_cfg.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio_cfg.GPIO_Mode = GPIO_Mode_AF;
gpio_cfg.GPIO_Speed = GPIO_Speed_50MHz;
gpio_cfg.GPIO_Pin = ... | prv_flash_start_cmd() | ;
prv_flash_send_and_receive_byte(FLASH_CMD_READ_ID);
uint32_t manufacturer = prv_flash_read_next_byte();
uint32_t type = prv_flash_read_next_byte();
uint32_t capacity = prv_flash_read_next_byte();
prv_flash_end_cmd();
prv_disable_flash_spi_clock();
return ((manufacturer << 16) | (type << 8) | capacity)... |
mation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
animation_set_auto_destroy(h, false);
// Clone it and make sure the clone is correct
PropertyAnimation *clone_h = (PropertyAnimation *)animation_clone((Animation *)prop_h);
property_animation_get_from_grect(clone_h, &r);
cl_as... | (h, delay) | |
/*
* 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_close_file_and_unlock_mutex() | ;
return prefs;
}
SerializedSendTextPrefs *watch_app_prefs_get_send_text(void) {
return (SerializedSendTextPrefs *)prv_get_prefs(PREF_KEY_SEND_TEXT_APP);
}
SerializedWeatherAppPrefs *watch_app_prefs_get_weather(void) {
return (SerializedWeatherAppPrefs *)prv_get_prefs(PREF_KEY_WEATHER_APP);
}
SerializedReminde... |
_notifications_allow_calls_only(void) {
return (alerts_get_mask() == AlertMaskPhoneCalls);
}
static uint32_t prv_get_resource_id_for_connectivity_status(
LauncherAppGlanceSettings *settings_glance) {
#if CAPABILITY_HAS_BUILTIN_HRM
if (settings_glance->glance_state.is_sharing_hrm) {
return RESOURCE_ID_CONNE... | PBL_ASSERTN(node) | |
uint16_t precise_radius, int32_t angle) {
return GPointPreciseFromGPoint(GPointZero);
}
GContext s_context;
void rocky_api_graphics_text_init(void) {}
void rocky_api_graphics_text_deinit(void) {}
void rocky_api_graphics_text_add_canvas_methods(jerry_value_t obj) {}
void rocky_api_graphics_text_re... | EXECUTE_SCRIPT("ctx.moveTo(4095.375, -4095.5);") | ;
EXECUTE_SCRIPT_EXPECT_ERROR("ctx.moveTo(4096.5, 0);", "TypeError: Value out of bounds");
EXECUTE_SCRIPT_EXPECT_ERROR("ctx.moveTo(0, -4095.625);", "TypeError: Value out of bounds");
EXECUTE_SCRIPT("ctx.lineTo(4095.375, -4095.5);");
EXECUTE_SCRIPT_EXPECT_ERROR("ctx.lineTo(4096.5, 0);", "TypeError: Value out of... |
error handling
static bool prv_read_register(uint8_t register_address, uint8_t *result) {
return i2c_read_register(I2C_LIS3DH, register_address, result);
}
// Simple write register command with no error handling
static bool prv_write_register(uint8_t register_address, uint8_t value) {
return i2c_write_register(I2C... | (LIS3DH_CTRL_REG1, ctrl_reg1) | ) {
// Write successful, low power mode enabled
accel_stop();
return;
}
}
}
PBL_LOG(LOG_LEVEL_ERROR, "Failed to enter low power mode");
}
bool accel_running(void) {
return (s_running);
}
bool accel_start(void) {
if (!s_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Failed to st... |
--------------------------------------------------------------------
uint32_t animation_get_duration(Animation *animation_h, bool include_delay,
bool include_play_count) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_legacy_2(state)... | (animation_h,
AnimationCurveCustomInterpolationFunction,
interpolate_function) | ;
}
// -------------------------------------------------------------------------------------------
static void *prv_animation_get_custom_function(Animation *animation_h, AnimationCurve curve) {
if (animation_private_using_legacy_2(NULL)) {
if (curve != AnimationCurveCustomFunction) {
// 2.x doesn't support... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&ctx->dest_bitmap.bounds, &point) | ) {
return;
}
const GBitmapDataRowInfo data_row_info = gbitmap_get_data_row_info(&ctx->dest_bitmap, point.y);
if (!WITHIN(point.x, data_row_info.min_x, data_row_info.max_x)) {
return;
}
uint8_t *line = data_row_info.data;
GColor color = ctx->draw_state.stroke_color;
if (!gcolor_is_transparent(col... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
for (int i = 0; i <= CACHE_BUFFER_SIZE / (sizeof(CacheEntry) + sizeof(uint32_t)); ++i) {
uint32_t input = i;
lru_cache_put(&s_cache, i, &input);
}
uint32_t *output = lru_cache_get(&s_cache, 0);
// check that the oldest entry got evicted
cl_assert(output == NULL);
for (int i = 1; i <= CACHE_BUFFER_... |
void test_lru_cache__use_and_evict(void) {
int i;
for (i = 0; i < CACHE_BUFFER_SIZE / (sizeof(CacheEntry) + sizeof(uint32_t)); ++i) {
uint32_t input = i;
lru_cache_put(&s_cache, i, &input);
}
// use entry 0 to keep it around
uint32_t *output = lru_cache_get(&s_cache, 0);
cl_assert(output);
cl_as... |
e <stdint.h>
#include <stdio.h>
#include <string.h>
#include "clar.h"
#include "drivers/system_flash.h"
#define KiB *1024
// Set bits n..0 in a bit-vector (zero-indexed)
#define BITS(n) ((((uint32_t)(1 << ((n) + 1)))) - 1)
// Set bits y..x in a bit-vector (x <= y; x, y >= 0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~B... | malloc(size * sizeof(uint8_t)) | ;
cl_assert(flash_written_data);
flash_written_flag = malloc(size * sizeof(bool));
cl_assert(flash_written_flag);
}
void assert_flash_unwritten(uint32_t start, uint32_t length) {
for (uint32_t i = 0; i < length; ++i) {
cl_assert(flash_written_flag[start + i] == false);
}
}
void test_system_flash__write_... |
/*
* 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_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);
}
|
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 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See ... | {
CompassServiceConfig **config = prv_get_config(PebbleTask_Unknown);
event_service_client_unsubscribe(&(*config)->info);
task_free(*config);
*config = NULL;
} | |
cl_must_pass(settings_file_compact(&file));
}
settings_file_get(&file, (uint8_t *)&j, sizeof(uint32_t),
(uint8_t *)&value, sizeof(uint32_t));
value += 1;
set_and_verify(&file, (uint8_t *)&j, sizeof(uint32_t), (uint8_t *)&value, sizeof(uint32_t));
}
}
//... | snprintf((char *)key, sizeof(key), "k%03d", i) | ;
snprintf((char *)val, sizeof(val), "v%03d", i);
printf("Iteration %d key %s val %s\n", i, key, val);
set_and_verify(&file, key, key_len, val, val_len);
// delete the first iteration
if (j < 255) {
settings_file_delete(&file, key, key_len);
}
}
printf("Making sure we handle running ou... |
buffer_size);
do_dma_transfer();
disable_flash_dma_clock();
}
flash_end_cmd();
disable_flash_spi_clock();
power_tracking_stop(PowerSystemFlashRead);
flash_unlock();
}
void flash_write_bytes(const uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
... | enable_flash_spi_clock() | ;
s_flash_state.sleep_when_idle = enable;
if (enable) {
if (!s_flash_state.deep_sleep) {
flash_deep_sleep_enter();
}
} else {
if (s_flash_state.deep_sleep) {
flash_deep_sleep_exit();
}
}
disable_flash_spi_clock();
flash_unlock();
}
bool flash_get_sleep_when_idle(void) {
boo... |
/*
* 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... | {
fake_settings_file_reset();
app_glance_db_init();
app_glance_service_init();
} |
void app_glance_db_deinit(void);
void test_app_glance_service__cleanup(void) {
app_glance_db_deinit();
}
static void prv_check_expected_slice_data(const AppGlanceSliceInternal *expected_slice_data,
time_t time) {
// Set the current time to the provided time
rtc_set_ti... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | bt_driver_cb_gatt_handle_mtu_update(&mtu_resp) | ;
}
static void prv_handle_dev_name_response(const HcProtocol_GapDeviceNameResponseHeader *resp) {
GAPLEConnection *connection = gap_le_connection_by_device(&resp->addr);
if (!connection) {
PBL_LOG(LOG_LEVEL_INFO, "HcGap: no connection for "BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE(resp->addr... |
_received += 2;
} else if (uid == message_size_attr_dict_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(s_message_size_attr_dict), (uint8_t*) s_message_size_attr_dict);
s_num_ds_notifications_received++;
} else if (uid == attribute_at_end_uid) {
prv_fake_receiving_ds_notification(ARRAY_LENGTH(me... | fake_notification_storage_reset() | |
) {
char dstbuf[256];
// Simple %u
snprintf(dstbuf, 256, "There are %u lights, %u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292");
// Alternate form
snprintf(dstbuf, 256, "There are %#u lights, %#u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292");
// Zero pa... | (dstbuf, "There are 010 lights, 37777777774") | ;
// Minimum digits output (zero digits)
snprintf(dstbuf, 256, "%.0ozero%.0o", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.ozero%.o", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits,... |
rredContentSizeExtraLarge] = &s_phone_style_large,
};
static PhoneUIData *s_phone_ui_data;
static void prv_window_pop(void);
static void prv_window_pop_with_delay(uint32_t delay_ms);
static void prv_action_bar_setup(PhoneCallActions actions);
static void prv_set_answer_window(void) {
modal_window_push(&s_phone_ui_d... | {
s_phone_ui_data->bg_color.boundary = boundary;
layer_mark_dirty(&s_phone_ui_data->window.layer);
} |
static int16_t prv_get_color_boundary(void *subject) {
return s_phone_ui_data->bg_color.boundary;
}
static const PropertyAnimationImplementation s_color_slide_animation_impl = {
.base = {
.update = (AnimationUpdateImplementation)property_animation_update_int16,
},
.accessors = {
.getter... |
nder the License.
*/
#include "unobstructed_area_service.h"
#include "unobstructed_area_service_private.h"
#include "applib/app.h"
#include "applib/graphics/framebuffer.h"
#include "kernel/events.h"
#include "kernel/pbl_malloc.h"
#include "process_state/app_state/app_state.h"
#include "syscall/syscall_internal.h"
#i... | (state, event) | |
.pbi"));
}
// re-enable this "test" to debug per-frame transitions
void _test_gdraw_command_transforms__to_square_sequence(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
graphics_context_set_antialiased(&ctx, true);
int32_t dt = ANIMATION_NORMALIZED_MAX / 16;
int32_t t = 0;
while (t <= ANIM... | GPoint(0, 192) | |
ne_idx(4));
cl_assert(timeline_model_get_iter_state(2) == timeline_model_get_iter_state_with_timeline_idx(5));
cl_assert(timeline_model_iter_prev(&new_idx, NULL));
cl_assert_equal_i(new_idx, 2);
cl_assert_equal_i(timeline_model_get_num_items(), 2);
cl_assert(uuid_equal(&s_items[s_correct_order[2]].header.id,... | timeline_model_get_iter_state(0) | |
/*
* 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 prv_get_dimensions_for_runtime_platform_default_size()->small_cell_height;
} |
int16_t menu_cell_basic_horizontal_inset(void) {
return prv_get_dimensions_for_runtime_platform_default_size()->horizontal_inset;
}
static int16_t prv_title_subtitle_left_margin(void) {
return prv_get_dimensions_for_runtime_platform_default_size()->title_subtitle_left_margin;
}
static ALWAYS_INLINE GFont prv_ge... |
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 <stdbool.h>
#include <stdint.h>
#include "drivers/flash.h"
#include "drivers/gpio.h"
#include "drivers/periph_con... | (FLASH_CONFIG.spi, byte) | ;
// Wait for the response byte to be received
while (SPI_I2S_GetFlagStatus(FLASH_CONFIG.spi, SPI_I2S_FLAG_RXNE) == RESET) {}
// Return the byte
return SPI_I2S_ReceiveData(FLASH_CONFIG.spi);
}
static void prv_flash_send_24b_address(uint32_t start_addr) {
// Ensure the high bits are not set.
prv_flash_send... |
; i++) {
char temp[32];
snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)values[i]);
safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text));
}
prv_display_alert(data->debug_card.dialog_text);
}
// --------------------------------------------------------------------------... | simple_menu_layer_get_layer(data->debug_card.menu_layer) | );
}
// -----------------------------------------------------------------------------------------
static void prv_debug_cmd_dls_sends(int index, void *context) {
ActivityDemoAppData *data = context;
bool enabled = dls_get_send_enable();
enabled = !enabled;
dls_set_send_enable_pp(enabled);
data->debug_card... |
/*
* 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... | (data->health_data) | |
_get_ticks();
if (timer->expire_time > current_ticks) {
*expire_ms_p = ((timer->expire_time - current_ticks) * 1000) / configTICK_RATE_HZ;
} else {
*expire_ms_p = 0;
}
}
mutex_unlock(manager->mutex);
return retval;
}
// ------------------------------------------------------------------... | (manager->running_timers) | ;
manager->idle_timers = list_insert_before(manager->idle_timers, &next_timer->list_node);
next_timer->executing = true;
next_timer->expire_time = 0;
// If we fell way behind (at least 1 timer period + 5 seconds) on a repeating timer
// (presumably because we were in the debugg... |
is_pairing_required */,
GAPLEClientApp);
BTErrno e = gap_le_connect_cancel_by_bonding(bonding_id, GAPLEClientApp);
cl_assert_equal_i(e, BTErrnoOK);
prv_assert_no_event();
// Verify there are no more intents:
cl_assert_equal_i(gap_le_connect_connection_intents_count(), 0)... | fake_event_clear_last() | ;
const BleAddressAndIRKChange e = {
.device = device,
.is_address_updated = true,
.new_device = device,
.is_resolved = true,
.irk = *(const SMIdentityResolvingKey *) fake_GAPAPI_get_fake_irk(),
};
bt_driver_handle_le_connection_handle_update_address_and_irk(&e);
gap_le_connection_by_devic... |
ave->slave_state->acquired);
PBL_ASSERTN(slave->slave_state->dma_state == SPISlavePortDMAState_Idle);
slave->slave_state->dma_state = SPISlavePortDMAState_Write;
slave->slave_state->dma_complete_handler = handler;
slave->slave_state->dma_complete_context = context;
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_Re... | {
const AfConfig *spi_sclk = &slave->spi_bus->spi_sclk;
if (enable) {
OutputConfig clk_as_gpio = {
.gpio = spi_sclk->gpio,
.gpio_pin = spi_sclk->gpio_pin,
.active_high = true,
};
gpio_output_init(&clk_as_gpio, GPIO_OType_PP, GPIO_Speed_50MHz);
gpio_output_set(&clk_as_gpio, false);... |
void spi_ll_slave_clear_errors(const SPISlavePort *slave) {
// First, empty the RX FIFO by reading the data. If in TX-only mode, it's possible that
// received data (0x00s) will be left in the RX FIFO.
// NOTE: Obviously, do not call this function with transfer in progress.
while (slave->spi_bus->spi->SR & S... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | display_spi_configure_default() | ;
spi_ll_slave_acquire(ICE40LP->spi_port);
spi_ll_slave_scs_assert(ICE40LP->spi_port);
gpio_output_set(&ICE40LP->creset, false); // CRESET LOW
#if !defined(TARGET_QEMU)
// Wait until we succeed in pulling CRESET down against the external pull-up
// and other external circuitry which is fighting against us.
... |
ation = MINUTES_PER_DAY,
.type = TimelineItemTypePin,
.layout = LayoutIdTest,
.all_day = 0, // this is a non-all-day event spanning 24h
},
};
cl_assert(timeline_add(&all_day_item));
Iterator iterator = {};
TimelineIterState state = {};
TimelineNode *head = NULL;
cl_assert_equal_i(ti... | {
TimelineItem multiday_item = {
.header = {
.id = {0x29, 0xac, 0xd8, 0xb5, 0x9, 0xc7, 0x4c, 0x31, 0xbf,
0x6f, 0x3, 0x64, 0xd0, 0x5b, 0x9b, 0xc2},
.parent_id = {0},
.timestamp = 1425254400, // midnight March 2 2015 UTC
.duration = 4 * MINUTES_PER_DAY,
.type = Tim... |
cl_assert_equal_i(state.node->timestamp, midnight_march_2_pst + SECONDS_PER_DAY);
cl_assert_equal_i(state.node->duration, MINUTES_PER_DAY);
cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY);
// no more
cl_assert(!iter_next(&iterator));
// 4 deletes
cl_assert(timeline_iter_rem... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (health_data) | ;
const int32_t zone2_minutes = health_data_hr_get_zone2_minutes(health_data);
const int32_t zone3_minutes = health_data_hr_get_zone3_minutes(health_data);
const int32_t zone_time_minutes = zone1_minutes + zone2_minutes + zone3_minutes;
int32_t max_progress = DEFAULT_MAX_PROGRESS;
const size_t buffer_size =... |
#include "stubs_hexdump.h"
#include "stubs_i18n.h"
#include "stubs_kino_reel.h"
#include "stubs_logging.h"
#include "stubs_memory_layout.h"
#include "stubs_menu_layer.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_persist.h"
#include... | app_db_get_install_id_for_uuid(&bg_counter_app.uuid) | ;
app_cache_add_entry(bg_counter_app_id, 10701);
cl_assert_equal_i(BG_COUNTER_APP_ID, bg_counter_app_id);
// simulate installing menu_layer_app on flash
app_db_insert((uint8_t *)&menu_layer_app.uuid, sizeof(Uuid),
(uint8_t *)&menu_layer_app, sizeof(AppDBEntry));
menu_layer_app_id = app_db_get... |
_16(value, end_value);
#endif
}
// --------------------------------------------------------------------------------------
// Test a basic uint32_t property animation
void test_animation__property_uint32(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
uint32_t value;
uint32_t start_value, end_value... | gcolor_equal(test_value, set_value) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.