prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
bort. return; } timer_cb(timer_cb_data); } //! Called on the timer task. From here we need to generate a callback on the client's task. static void prv_sys_timer_callback(void* cb_data) { PBL_ASSERT_TASK(PebbleTask_NewTimers); TimerID id = (TimerID)cb_data; mutex_lock(s_mutex); EventedTimer *timer ...
mutex_unlock(s_mutex)
; return new_timer->sys_timer_id; } bool evented_timer_reschedule(EventedTimerID timer_id, uint32_t timeout_ms) { if (timeout_ms == 0) { timeout_ms = 1; } mutex_lock(s_mutex); // This will detect an invalid timer ID, or one that already ran on the client's task and got deleted // already EventedTi...
/* * 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)
/* * 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...
(title, BUFFER_SIZE, "Only Title %i/%i", cell_index->section, cell_index->row)
; menu_cell_title_draw(ctx, cell_layer, title); break; } (void)data; } static void draw_header_callback(GContext* ctx, Layer *cell_layer, uint16_t section_index, AppData *data) { char title[BUFFER_SIZE]; sniprintf(title, BUFFER_SIZE, "Section Header (%i)", section_index); menu_cell_basic_header_d...
se for the specific language governing permissions and * limitations under the License. */ #include "health_data.h" #include "health_data_private.h" #include "applib/app_logging.h" #include "applib/health_service_private.h" #include "drivers/rtc.h" #include "kernel/pbl_malloc.h" #include "syscall/syscall.h" #includ...
(ActivityMetricSleepEnterAtSeconds, 1, &health_data->sleep_start)
; activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &health_data->sleep_end); activity_get_metric_typical(ActivityMetricSleepEnterAtSeconds, local_tm.tm_wday, &health_data->typical_sleep_start); activity_get_metric_typical(ActivityMetricSleepExitAtSeconds, local_tm.tm_wday, ...
org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * li...
qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)
); prv_send_bytes(msg_data, sizeof(msg_data)); cl_assert(qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)); prv_send_footer(); cl_assert(!qemu_serial_private_assemble_message(&s_state, &rcv_bytes, &rcv_protocol)); // ------------------------------------------------------------------...
andle its KernelBG callback. activity_start_tracking(false /*test_mode*/); fake_system_task_callbacks_invoke_pending(); // All tests start at 5pm, which is 1020 minutes into a 1440 minute day. The BMR for // the above user is 1859 kcalories per day, so we expect to get: // 1859 * 1020/1440 = 1328 kcalorie...
(PebbleTask_App)
; activity_get_metric(ActivityMetricSleepTotalSeconds, 1, &value); cl_assert_equal_i(value, 220 * SECONDS_PER_MINUTE); cl_assert_equal_i(health_service_sum_today(HealthMetricSleepSeconds), 220 * SECONDS_PER_MINUTE); activity_get_metric(ActivityMetricSleepRestfulSeconds, 1, &value); cl_assert_equal_i(value, 1...
nimation *animation, const AnimationImplementation *implementation) { s_animation_implementation = implementation; return true; } static int s_count_compositor_init_func_a = 0; static void prv_compositor_init_func_a(Animation *animation) { ++s_count_compositor_init_func_a; } st...
compositor_app_render_ready()
; cl_assert_equal_i(s_count_display_update, 2); cl_assert_equal_i(s_count_animation_schedule, 0); // transition is started from the deferred transition event s_display_update_in_progress = false; prv_handle_display_update_complete(); cl_assert_equal_i(s_count_display_update, 3); // subsequent app render...
raphics_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_context_set_antialiased(ctx, false); graphics_draw_line(ctx, GPoint(5, 35), GPoint(45, 40)); } void across_x_layer_update_callback(L...
(&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.dest_bitmap, TEST_NAMED_PBI_FILE("draw_line_inside_origin_layer"))); layer_set_update_proc(&layer, &white_layer_update_callback); la...
164 uint8_t *buffer = (uint8_t *) kernel_malloc(header.value_length); if (UNLIKELY(header.value_length && !buffer)) { PBL_LOG(LOG_LEVEL_ERROR, "OOM for GATT notification"); return; } const uint16_t next_value_length = gatt_client_subscriptions_consume_notification(&header.charac...
{ // [MT] Kick reconnection for BT Classic when BLE comes up. // If BLE is able to reconnect, chances are BT Classic is able too, so try // immediately instead of waiting for reconnect.c's timer to fire. bt_driver_reconnect_try_now(false /*ignore_paused*/); }
/* * 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 (install_id == INSTALL_ID_INVALID) { // String initialized on the heap to reduce stack usage char *parent_id_string = kernel_malloc_check(UUID_STRING_BUFFER_LENGTH); uuid_to_string(&parent_id, parent_id_string); PBL_LOG(LOG_LEVEL_ERROR, "Pin insert for a pin with no app installe...
// Bump the app's priority by telling the cache we're using it if (app_cache_entry_exists(install_id)) { app_cache_app_launched(install_id); goto done; } // System apps don't need to be fetched / are always installed if (app_install_id_from_system(install_id)) { goto done; } ...
2) == 0); } static bool prv_find_name(ListNode *node, void *data) { PFSFileListEntry *entry = (PFSFileListEntry *)node; return (strcmp(entry->name, (char *)data) == 0); } void test_pfs__file_list(void) { pfs_format(true); pfs_init(false); // Create some files int fd; fd = pfs_open("a_test_0", OP_FLAG_W...
pfs_close(fd)
; fd = pfs_open("b_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10); cl_assert(fd >= 0); pfs_close(fd); fd = pfs_open("b_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10); cl_assert(fd >= 0); pfs_close(fd); // Should have 4 entries in pfs cl_assert_equal_b(prv_file_exists("a_test_0"), true); cl_assert_equal...
Header header = { .common.id = UUID_INVALID }; bool found = prv_find_next_notification(&header, prv_uuid_equal_func, (void *)id, fd); prv_file_close(fd); return found; } static bool prv_get_notification(TimelineItem *notification, SerializedTimelineItemHeader* header, int fd) { notification->allocated_b...
(LOG_LEVEL_ERROR, "Error writing status to notification header %d", result)
; } // Seek to the end of the header pfs_seek(fd, ((int)sizeof(*header) - (int)offsetof(CommonTimelineItemHeader, status) - sizeof(header->common.status)), FSeekCur); } bool notification_storage_get_status(const Uuid *id, uint8_t *status) { int fd = prv_file_open(OP_FLAG_READ); bool rv = false; if (...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
cl_assert(NULL != g_gbitmap_spalding_data_row_infos)
; // make sure unit-test fixture is ok #ifdef PLATFORM_TINTIN cl_assert(!process_manager_compiled_with_legacy2_sdk()); bmp = gbitmap_create_blank(s10, GBitmapFormat1Bit); cl_assert(NULL != bmp); cl_assert(NULL == bmp->data_row_infos); bmp = gbitmap_create_blank(s10, GBitmapFormat8Bit); cl_assert(NULL == ...
/* * 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_create_card_and_render(&health_data)
; cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); } void test_health_activity_summary_card__render_current_behind_typical1(void) { HealthData health_data = { .step_data = 170, .step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(LOG_LEVEL_DEBUG, (uint8_t *)&info->local_encryption_info, sizeof(info->local_encryption_info))
; prompt_send_response(" Remote Encryption Info: "); PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG, (uint8_t *)&info->remote_encryption_info, sizeof(info->remote_encryption_info)); prompt_send_response(" SMIdentityResolvingKey: "); PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG, ...
ime_ns); PBL_ASSERT(timingr != I2C_TIMINGR_INVALID_VALUE, "Could not calculate TIMINGR values!"); hal->i2c->TIMINGR = timingr; // I2C only used as a master; disable slave address acknowledgement hal->i2c->OAR1 = 0; hal->i2c->OAR2 = 0; // Enable i2c Peripheral; clear any configured interrupt bits; use anal...
if ((i2c->ISR & I2C_ISR_TXIS) != 0) { i2c->TXDR = transfer->register_address; }
assert(size == sizeof(Dictionary) + sizeof(Tuple) + 1); size = dict_calc_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,...
cl_assert(tuple->length == sizeof(SOME_DATA))
; cl_assert(memcmp(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); // ...
gatt_connection_id = TEST_GATT_CONNECTION_ID; return device; } static void prv_assert_no_event(void) { PebbleEvent event = fake_event_get_last(); cl_assert_equal_i(event.type, PEBBLE_NULL_EVENT); } static void prv_assert_subscription_event(BLECharacteristic characteristic, ...
(TEST_GATT_CONNECTION_ID)
; // Simulate discovery of random 128-bit service: fake_gatt_put_discovery_indication_random_128bit_uuid_service(TEST_GATT_CONNECTION_ID); fake_gatt_put_discovery_complete_event(GATT_SERVICE_DISCOVERY_STATUS_SUCCESS, TEST_GATT_CONNECTION_ID); } static BLECharacteristic pr...
t should have been put on the queue: cl_assert_equal_i(fake_event_get_count(), 1); // Assert 2 events can be read out: prv_assert_notification_event(characteristic, value, sizeof(value), true /* kernel */, true /* app */); prv_assert_notification_event(characteristic, value, siz...
(characteristic, value, 1 /* one byte */, false /* kernel */, true /* app */)
/* * 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...
(SLOT_OF_LAST_LAUNCHED_APP)
ttr, SmartstrapAttributeStateIdle); if (attr->request_type == SmartstrapRequestTypeWrite) { // the data we got was the ACK of the write, so change the event type and don't block writes event.smartstrap.type = SmartstrapDataSentEvent; } else { // prevent writing to the attribute until the app h...
{ // At this point, the app is closing so there's no point in freeing the buffers, and doing so // will crash the watch if the app had crashed (and the heap has already been cleaned up). prv_queue_deferred_delete(attr, false /* !do_free */); }
mutex_unlock(s_attr_list_lock); } DEFINE_SYSCALL(void, sys_smartstrap_attribute_get_info, SmartstrapAttribute *app_attr, uint16_t *service_id, uint16_t *attribute_id, size_t *length) { mutex_lock(s_attr_list_lock); SmartstrapAttributeInternal *attr = prv_find_by_buffer((uint8_t *)app_attr); mut...
ed 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 "applib/app_logging.h" #include "applib/app_smartstrap.h" #include "applib/app_smartstrap_private.h" ...
app_state_get_smartstrap_state()
; state->handlers = (SmartstrapHandlers) {0}; if (!prv_should_subscribe()) { prv_state_deinit(); } #endif } void app_smartstrap_set_timeout(uint16_t timeout_ms) { #if USE_SMARTSTRAP SmartstrapConnectionState *state = app_state_get_smartstrap_state(); state->timeout_ms = timeout_ms; #endif } SmartstrapAt...
"👍", "👎", "👌", "💩", "🎉", "🍺", }; ActionMenuLevel *root_level = action_menu_level_create(ARRAY_LENGTH(thin_values)); action_menu_level_set_display_mode(root_level, ActionMenuLevelDisplayModeThin); for (size_t i = 0; i < ARRAY_LENGTH(thin_values); i++) { ...
action_menu_level_add_action(voice_level, "This won't be seen", prv_noop_action_callback, NULL)
; action_menu_level_add_child(root_level, voice_level, "I will text back"); ActionMenuLevel *template_level = action_menu_level_create(1); action_menu_level_add_action(template_level, "This won't be seen", prv_noop_action_callback, ...
youtNodeHorizontalConfig *config) { const int capacity = config->container.num_nodes + config->container.extra_capacity; GTextNodeHorizontal *horizontal_node = graphics_text_node_create_horizontal(capacity); if (horizontal_node) { if (config->horizontal_alignment) { horizontal_node->horizontal_alignment...
{ GTextNode *node = &layout_create_headings_paragraphs_node(layout, config)->container.node; if (node) { prv_set_text_node_extent(node, (LayoutNodeExtentConfig *)config); } return node; }
#define METRICS_PER_PAGE 2 typedef struct { const char *name; const char *value; AppResourceInfo *icon_info; KinoLayer *icon_layer; int index; } MetricContext; static GTextNode *prv_metric_constructor( const LayoutLayer *layout, const LayoutNodeConstructorConfig *config) { MetricContext *context = c...
// Write fifth time const char* written_hw_version5 = "3456789"; command_hwver_write(written_hw_version5); hw_version = mfg_get_hw_version(); cl_assert_equal_s(written_hw_version5, hw_version); #endif // BOARD_SILK || BOARD_CALCULUS } void test_mfg_serials__serial_number_console(void) { const char* seria...
(fourth_sn)
, &index); sn = mfg_get_serial_number(); cl_assert_equal_i(r, MfgSerialsResultSuccess); cl_assert_equal_s(sn, fourth_sn); cl_assert_equal_i(index, 5); // SERIAL4 lives at index 5 // Fifth time: const char *fifth_sn = "7ujn8ikm9olm"; r = mfg_write_serial_number(fifth_sn, strlen(fifth_sn), &index); sn = ...
{ dbgserial_putstr("FPGA configuration failed. Is this a bigboard?"); // Don't waste time trying to get the FPGA unstuck if it's not configured. // It's just going to waste time and frustrate bigboard users. return; }
dbgserial_print("FPGA version: "); dbgserial_print_hex(prv_read_version()); dbgserial_putstr(""); // enable the power rails display_power_enable(); #ifdef TEST_FPGA_RESET_COMMAND #define ASSERT_BUSY_IS(state) \ dbgserial_putstr(GPIO_ReadInputDataBit(DISP_GPIO, DISP_PIN_BUSY) == state? \ ...
0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 147}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d, 0, 146}, { 0, 0x4d,...
{ 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 149}, { 0, 0x75, 0, 148}, { 0, 0x75, 0, 149}, // 1905: Local time: 07:00:00 AM { 0, 0x64, 2466, 160}, { 0, 0x54, 0, 162}, { 0, 0x54, 0...
{ 0, 0x43, 104, 152}, { 0, 0x43, 141, 140}, { 0, 0x43, 234, 146}, { 0, 0x43, 101, 141}, { 0, 0x53, 426, 157}, { 0, 0x54, 783, 149}, { 0, 0x43, 925, 184}, { 0, 0x75, 533, 178}, { 0, 0x75, 204, 177}, { 0, 0x86, 69, 167}, { 0, 0x74, 923, 181}, // 1965: Local time: 08:00:00 ...
/* * 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...
(t1, t2, sizeof(GTransform))
== 0; } ////////////////////////////////////// /// Modifying Transforms ////////////////////////////////////// // Note that t_new can be set to either of t1 or t2 safely to do in place muliplication // Note this operation is not commutative. The operation is as follows t_new = t1 * t2 void gtransform_concat(GTransfor...
d, 0, 0x0}, { 0, 0x3d, 0, 0x0}, { 0, 0x3d, 0, 0x0}, // 915: Local time: 05:59:00 AM { 0, 0x3d, 0, 0x0}, { 0, 0x3d, 0, 0x0}, { 0, 0x3d, 0, 0x0}, { 0, 0x3d, 0, 0x0}, { 0, 0x3e, 1036, 0x0}, { 0, 0x11, 11, 0x0}, { 0, 0x11, 0, 0x0}, { 0, 0x11, 0, 0x0}, { 0, 0x11, 0, 0x0}, ...
{ 0, 0x7b, 618, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { 0, 0x7c, 0, 0x0}, { ...
// 1095: Local time: 08:59:00 AM { 0, 0x5f, 0, 0x0}, { 0, 0x85, 7004, 0x0}, { 0, 0x3a, 3996, 0x0}, { 0, 0x4c, 1963, 0x0}, { 0, 0x5f, 608, 0x0}, { 0, 0x5e, 343, 0x0}, { 0, 0x5e, 10, 0x0}, { 0, 0x5e, 143, 0x0}, { 0, 0x5e, 506, 0x0}, { 0, 0x64, 2843, 0x0}, { 0, 0x55, 0, 0x0...
lor.argb, GColorBlue.argb); #else cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlack.argb); #endif color.a = 2; graphics_context_set_stroke_color(&context, color); #if PBL_COLOR cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorBlue.argb); #else cl_assert_equal_i(context.draw_sta...
graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10))
ule_count; void launcher_task_add_callback(CallbackEventCallback callback, void *data) { ++s_kernel_main_schedule_count; system_task_add_callback(callback, data); } // Fakes /////////////////////////////////////////////////////////// #include "../../fakes/fake_pbl_malloc.h" #include "../../fakes/fake_system_task....
{ receiver[i] = g_default_kernel_receiver_implementation.prepare( session[i], &s_endpoints[i], strlen(data[i])); cl_assert(receiver[i] != NULL); for (int j = 0; j < strlen(data[i]); j++) { g_default_kernel_receiver_implementation.write( receiver[i], (uint8_t *)&data[i][j], 1); } ...
// Unschedule after 2 iterations if (num_loops == 2) { DPRINTF("%"PRIu64": Unscheduling now\n", prv_now_ms()); animation_unschedule(h); stopped_at_r = layer.frame; unschedule_time = prv_now_ms(); } } // Make sure the frame stopped at the state it was in when we unscheduled ...
GRect(0, 0, 100, 200)
; // x, y, width, height to_r = GRect(1000, 2000, 100, 200); // x, y, width, height prop_h = property_animation_create_layer_frame(&layer, &from_r, &to_r); Animation *h = property_animation_get_animation(prop_h); void *context = &layer; animation_set_handlers(h, handlers, context); animation_set_duratio...
/* * 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...
pcTaskGetTaskName(task_handle)
; } // NOTE: The logging support calls toupper() this character if the task is currently running privileged, so // these identifiers should be all lower case and case-insensitive. char pebble_task_get_char(PebbleTask task) { switch (task) { case PebbleTask_KernelMain: return 'm'; case PebbleTask_KernelBack...
ed_cb(void *data) { if (!s_stop_mode_monitor.data_seen_this_interval) { // The accessory connector didn't have any data since the last time this callback fired. ++s_stop_mode_monitor.intervals_without_data; if (s_stop_mode_monitor.intervals_without_data >= s_stop_mode_monitor.max_intervals_withou...
{ s_send_semaphore = xSemaphoreCreateBinary(); xSemaphoreGive(s_send_semaphore); s_blocked_lock = mutex_create_recursive(); prv_initialize_hardware(); accessory_set_power(false); accessory_enable_input(); }
void accessory_block(void) { prv_lock(); accessory_send_stream_stop(); uart_deinit(ACCESSORY_UART); } void accessory_unblock(void) { // We want to restore the previous baudrate, but clear s_baudrate in order to force a complete // re-init of the peripheral. prv_set_baudrate(s_baudrate, true /* force_upda...
/* * 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 ((addr & ~SECTOR_ADDR_MASK) == 0 && addr + SECTOR_SIZE_BYTES <= s_erase_state.end_addr) { s_erase_state.next_erase_addr += SECTOR_SIZE_BYTES; flash_erase_sector(addr, prv_async_erase_done_cb, NULL); } else { // Fall back to a subsector erase s_erase_state.next_erase_addr += SUBSECTOR_SIZE_BYT...
} void flash_erase_optimal_range( uint32_t min_start, uint32_t max_start, uint32_t min_end, uint32_t max_end, FlashOperationCompleteCb on_complete, void *context) { PBL_ASSERTN(((min_start & (~SUBSECTOR_ADDR_MASK)) == 0) && ((max_end & (~SUBSECTOR_ADDR_MASK)) == 0) && (min_start ...
} else { dialog_push(dialog, prv_get_window_stack(data)); } cleanup: prv_cleanup_action_result(data, succeeded); } static bool prv_set_dialog_message(ActionResultData *data, TimelineResourceId timeline_res_id, const char *message, bool success) { const size_t message_buf...
{ ChainingWindowCBData *data = context; timeline_item_destroy(data->item); event_service_free_claimed_buffer(data->event_ref); applib_free(data); }
static void prv_invoke_chaining_action(Window *chaining_window, TimelineItemAction *action, void *context) { ChainingWindowCBData *cb_data = context; ActionResultData *data = applib_zalloc(sizeof(ActionResultData)); if (!data) { return; } data->chaining_data.acti...
/* * 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...
ceil_log_two(oversampling_ratio)
; num_bits *= (sinc_order == DFSDM_SincOrder_Sinc4) ? 4 : 3; uint32_t right_shift = MAX(num_bits - 24, 0); RCC_ClocksTypeDef clocks; RCC_GetClocksFreq(&clocks); uint32_t prescaler = clocks.PCLK2_Frequency / this->pdm_frequency; // Disable the device before changing the config DFSDM_Cmd(DISABLE); DFSDM...
NULL as well: prv_unlink_job(job); // Call the unscheduled callback: if (job->unscheduled_callback) { job->unscheduled_callback(job, true /* completed */, job->unscheduled_callback_data); } BLE_LOG_DEBUG("Unscheduled advertising completed job: %s", prv_string...
if (is_same_job && !force_refresh && s_is_advertising) { // No change in job to give air time, keep going. return; }
if (s_current) { // Clean up old job: if (!next) { // No more jobs. Stop timer: prv_timer_stop(); } if (s_is_advertising) { // Controller needs to stop advertising before we can start a new job: PBL_LOG(GAP_LE_ADVERT_LOG_LEVEL, "Disable last Ad job"); bt_driver_advert...
1, &platform_bits_1); cl_assert(id_1 != BT_BONDING_ID_INVALID); // It should be the active gateway ret = bt_persistent_storage_get_active_gateway(&id_out, &type_out); cl_assert(ret); cl_assert_equal_i(id_out, id_1); cl_assert_equal_i(type_out, BtPersistBondingTypeBTClassic); ret = bt_persistent_storage_...
bt_persistent_storage_is_unfaithful()
; cl_assert(ret); // Add a pairing, still unfaithful BTDeviceAddress addr_1 = {{0x11, 0x12, 0x13, 0x14, 0x15, 0x16}}; SM128BitKey link_key_1 = {{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}}; char name_1[BT_DEVICE_NAME_BUFFER_SIZ...
t1BitPalette: case GBitmapFormat2BitPalette: case GBitmapFormat4BitPalette: return true; case GBitmapFormat8BitCircular: return BITMAP_FORMAT_IS_CIRCULAR_FULL_SCREEN(size, format); #endif default: return false; } } static bool prv_is_palettized_format(GBitmapFormat format) { retur...
if (!bitmap) { return NULL; }
st_name = "8bitTrns", .expected_test_image_bitmap_format = GBitmapFormat8Bit, .bitmap_create_func = prv_create_bitmap_from_png_file, .need_to_destroy_bitmap = true, }, #endif }; #define COMPOSITE_TEST_IMAGE_SIZE_WIDTH (100) #define COMPOSITE_TEST_OFFSET_X (COMPOSITE_TEST_IMAGE_SIZE_WIDTH / 2) #define CO...
(GPoint(-25, 0))
; cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); } void test_graphics_draw_bitmap__origin_layer_across_y(void) { prv_origin_layer_test(GPoint(0, 40)); cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)); } void test_graphics_draw_bitmap__origin_layer_across_ny(void) { prv_origin_layer_te...
conds: for (int i = 0; i < 9; ++i) { regular_timer_fire_seconds(1); assert_ad_data("A"); cl_assert_equal_i(s_unscheduled_cb_count, 0); regular_timer_fire_seconds(1); assert_ad_data("B"); cl_assert_equal_i(s_unscheduled_cb_count, 0); } // Unschedule job "B", air job "A" regular_timer_fir...
(ad, &advert_term, sizeof(advert_term)/sizeof(GAPLEAdvertisingJobTerm), unscheduled_callback, s_unscheduled_cb_data, 0)
; cl_assert_equal_p(job, NULL); // Forever silent term: advert_term.min_interval_slots = GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS; advert_term.max_interval_slots = GAPLE_ADVERTISING_SILENCE_INTERVAL_SLOTS; advert_term.duration_secs = GAPLE_ADVERTISING_DURATION_INFINITE; job = gap_le_advert_schedule(ad, &ad...
s_no_buffer_count, s_dropped_char_count); } flash_prf_set_protection(true); accessory_use_dma(false); accessory_manager_set_state(AccessoryInputStateMfg); new_timer_delete(s_timeout_timer); PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accessory imaging"); } static void prv_timeout_timer_cb(void *context) { sys...
{ PBL_LOG(LOG_LEVEL_ERROR, "Invalid length (%"PRIu32")", length); return; }
const FlashGeometryRequest *request = payload; FlashGeometryResponse response = { .region = request->region }; if (request->region == REGION_PRF) { // assume we're about to write to this region, so unlock it flash_prf_set_protection(false); response.address = FLASH_REGION_SAFE_FIRMWARE_BEGIN;...
ft_margin = box.origin.x; prv_draw_icon(ctx, config->icon, &box, is_legacy2); } box = *bounds; if (icon_align == GAlignRight) { left_margin = horizontal_margin; box.size.w -= config->icon->bounds.size.w; } else { left_margin = !config->icon ? horizontal_margin : config->icon_form_fit ? ...
(config, is_selected)
; if (render_subtitle) { subtitle_text_frame_height = fonts_get_font_height(subtitle_font); } const int subtitle_text_cap_offset = (config->subtitle) ? fonts_get_font_cap_offset(subtitle_font) : 0; const GAlign icon_align = (GAlign)config->icon_align; const bool render_icon = ((config->icon != NULL...
critical -> good */ typedef enum { PowerStateGood, PowerStateLowPower, PowerStateCritical, PowerStateStandby } PowerStateID; extern PowerStateID s_power_state; void test_battery_monitor__transitions(void) { int good_mv = battery_curve_lookup_voltage_by_percent(100, false); int low_mv = battery_curve_lookup...
periodic_timer_trigger(5)
; cl_assert_equal_i(battery_get_charge_state().charge_percent, 50); // Should be stable by now // Shouldn't update percent (actually, shouldn't even send events.) PBL_LOG(LOG_LEVEL_DEBUG, "Shouldn't be any updates"); PBL_LOG(LOG_LEVEL_DEBUG, "▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼"); fake_battery_set_millivolts(high_mv)...
process_state/app_state/app_state.h" #include "system/logging.h" #include <limits.h> struct AppState { Window window; ScrollLayer scroll_layer; TextLayer text; }; static GFont s_system_font; static GFont s_fonts[8]; static int s_font_selection = 0; static const char* ALL_CODEPOINTS = " !\"#$%&'()*+,-./01234567...
fonts_get_system_font(FONT_KEY_GOTHIC_18)
t(r, &(TouchEvent) { .type = TouchEvent_Liftoff }); cl_assert_equal_i(last_touch_event.type, TouchEvent_Liftoff); cl_assert_equal_b(updated, true); cl_assert_equal_i(rec_event, RecognizerEvent_Cancelled); // Should not pass touch events to recognizers that are not active cl_assert_passert(recognizer_handle_t...
test_recognizer_create(&s_test_impl_data, NULL)
bottom_shading); #if !defined(RECOVERY_FW) && SCREEN_COLOR_DEPTH_BITS == 8 // Replace the clip box with a clip box that will render the item in the right place with the // right size, without menu layer's selection clipping. Menu layer will responsible for cleaning // up the changes made to this clip box. ...
prv_get_menu_layer_row(aml, new_selected_index)
; menu_layer_set_selected_index(&aml->menu_layer, MenuIndex(0, menu_layer_index), MenuRowAlignCenter, animated); } static void prv_scroll_handler(ClickRecognizerRef recognizer, void *context) { ActionMenuLayer *aml = context; const bool up = (click_recognizer_get_button_id(recogni...
_equal_i(elapsed_ms, -1 * (delay_spawn + delay_b)); // 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_stopped_handler_calls, a), 0); cl_assert_equal_i(prv_count_handler_entries(&s_...
prv_advance_to_ms_with_timers(start_ms + duration_a - 1)
; cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1); 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_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0)...
date_proc(&canvas, &canvas_layer_update_callback); layer_init(&layer, &GRect(40, 40, 80, 40)); layer_add_child(&canvas, &layer); // Corner cases test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &draw_text_single_line_ellipsis_clip_across_nx_zero_y_offset); layer_render_tree(&canvas, &c...
(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_y_second_line.${BIT_DEPTH_NAME}.pbi")
); test_graphics_context_reset(&ctx, fb); layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_nx); layer_render_tree(&canvas, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_nx.${BIT_DEPTH_NAME}.pbi")); test_graphics_context_reset(&ctx, fb);...
_select_single_click_handler(ClickRecognizerRef recognizer, void *data) { NotificationWindowData *window_data = data; TimelineItem *item = prv_get_current_notification(window_data); if (!prv_should_provide_action_menu_for_item(window_data, item)) { return; } LayoutLayer *layout = swap_layer_get_current_...
gbitmap_deinit(&data->dnd_icon)
; layer_deinit(&data->dnd_icon_layer); window_deinit(window); i18n_free_all(data); s_in_use = false; } ////////////////////// // Callback Handlers ////////////////////// static void prv_layout_did_appear_handler(SwapLayer *swap_layer, LayoutLayer *layout, int8_t rel...
/* * 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...
{ sector_end -= SECTOR_SIZE_BYTES; }
rt_text), "%F %r", local_tm); char time_end_text[64]; local_tm = localtime(&utc_end); strftime(time_end_text, sizeof(time_end_text), "%F %r", local_tm); if (num_minutes > 0) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Got %d minutes: %s to %s", num_minutes, time_start_text, time_end_text); }...
(data->debug_card.dialog_text, name, sizeof(data->debug_card.dialog_text))
; time_t day_start = time_start_of_today(); time_t now = time(NULL); HealthServiceAccessibilityMask accessible; accessible = health_service_metric_averaged_accessible( metric, day_start, now, HealthServiceTimeScopeDailyWeekdayOrWeekend); if (!(accessible & HealthServiceAccessibilityMaskAvailable)) { ...
/* * 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 ((__get_PRIMASK() & 0x1) == 0) { __disable_irq(); s_interrupts_disabled_by_heap = true; } }
static void prv_heap_unlock(void *ctx) { if (s_interrupts_disabled_by_heap) { __enable_irq(); s_interrupts_disabled_by_heap = false; } } void kernel_heap_init(void) { const bool fuzz_on_free = true; extern uint8_t __heap_start; uint8_t *heap_start = &__heap_start; uint8_t *heap_end = heap_start ...
nt_copy_service_refs_matching_uuid(&device, service_refs, num_services, &bp_service->uuid); cl_assert_equal_i(num_found_services, num_services); // Test that the UUI...
(service_refs_out[0])
; cl_assert(uuid_equal(&uuid1, &thermo_service->uuid) || uuid_equal(&uuid1, &random_128bit_service->uuid)); cl_assert(uuid_equal(&uuid2, &thermo_service->uuid) || uuid_equal(&uuid2, &random_128bit_service->uuid)); }
tus_t prv_serialize_glance(const AppGlance *glance, SerializedAppGlanceHeader **serialized_glance_out, size_t *serialized_glance_size_out) { if (!glance || (glance->num_slices > APP_GLANCE_DB_MAX_SLICES_PER_GLANCE) || !serialized_glance_o...
const AppGlanceSliceInternal *current_slice = &glance->slices[slice_index]; SliceSerializationAttributeListData *current_attr_list_data = &attr_lists[slice_index]; AttributeList *attr_list = &current_attr_list_data->attr_list; const size_t attr_list_size = current_attr_list_data->attr_list_size; /...
// Destroy the attributes of each of the attribute lists in attr_lists for (unsigned int i = 0; i < glance->num_slices; i++) { attribute_list_destroy_list(&attr_lists[i].attr_list); } kernel_free(attr_lists); return rv; } ////////////////////////////////// // Serialized Slice Validation ////////////////...
176, -1000}, { -168, -176, -984}, { -168, -176, -976}, { -152, -192, -984}, { -160, -192, -984}, { -168, -184, -992}, { -160, -176, -984}, { -160, -176, -984}, { -160, -176, -992}, { -152, -184, -992}, { -152, -184, -992}, { -160, -184, -984}, { -152, -160, -1000}, { ...
{ -152, -168, -984}, { -152, -160, -992}, { -152, -152, -992}, { -160, -160, -1000}, { -152, -168, -992}, { -160, -176, -984}, { -152, -160, -1000}, { -152, -168, -984}, { -152, -168, -984}, { -160, -160, -1000}, { -160, -168, -992}, { -152, -176, -984}, { -152, -168,...
{ -144, -144, -1016}, { -152, -160, -976}, { -160, -176, -992}, { -168, -152, -968}, { -168, -168, -984}, { -160, -176, -1000}, { -144, -144, -1016}, { -128, -176, -992}, // 39 seconds { -136, -136, -992}, { -144, -152, -1080}, { -96, -224, -976}, { -152, -184, -944}...
ionPrivate *)state->scheduled_head; if (animation == NULL) { return; } const uint32_t now = prv_get_ms_since_system_start(); const int32_t delta_ms = serial_distance32(now, animation->abs_start_time_ms); const uint32_t interval_ms = MAX(delta_ms, 0) + rate_control_delay_ms; // The animation service wil...
PBL_ASSERTN(animation->implementation != NULL)
emoryToPeripheral, .data_size = DMARequestDataSize_Byte, }; DMARequest * const SHARP_SPI_TX_DMA = &SHARP_SPI_TX_DMA_REQUEST; static DMARequestState s_accessory_uart_dma_request_state; static DMARequest ACCESSORY_UART_RX_DMA_REQUEST = { .state = &s_accessory_uart_dma_request_state, .stream = &DMA2_STREAM1_DEVICE,...
(USART1, uart_irq_handler, DBG_UART)
t.x += 2; units_text_node->node.offset.y = units_offset_y; } const int offset_y = PBL_IF_RECT_ELSE(101, 109); graphics_text_node_draw(&container->node, ctx, &GRect(0, offset_y, base_layer->bounds.size.w, fonts_get_font_height(data->bpm_font)), NULL, NULL); graphics_text_node_destroy(&co...
layer_get_data(base_layer)
; app_timer_cancel(data->pulsing_heart_timer); gdraw_command_sequence_destroy(data->pulsing_heart); i18n_free_all(base_layer); layer_destroy(base_layer); } GColor health_hr_summary_card_get_bg_color(Layer *layer) { return CARD_BACKGROUND_COLOR; } bool health_hr_summary_show_select_indicator(Layer *layer) { ...
(bool on) { } void accel_manager_exit_low_power_mode(void) { } // Return true if we are "idle", defined as seeing no movement in the last hour. bool accel_is_idle(void) { // It was idle recently, see if it's still idle. Note we avoid reading the accel hardware // again here to keep this call as lightweight as pos...
{ mutex_lock_recursive(s_accel_manager_mutex); bool rv = accel_run_selftest(); mutex_unlock_recursive(s_accel_manager_mutex); return rv; }
#if !defined(PLATFORM_SILK) // Note: This selftest is only used for MFG today. When we start to build out a // gyro API, we will need to come up with a more generic way to handle locking // for a gyro only part vs gyro + accel part extern bool gyro_run_selftest(void); bool gyro_manager_run_selftest(void) { mutex_lo...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ const uint16_t overdraw = 2; graphics_context_set_fill_color(ctx, ring_color); graphics_fill_radial(ctx, grect_inset(DISP_FRAME, GEdgeInsets(-overdraw)), GOvalScaleModeFitCircle, thickness + overdraw, 0, TRIG_MAX_ANGLE); }
// piecewise interpolator between 0 and to for the first half of ANIMATION_NORMALIZED_MAX // and between -to and 0 for the second half static int16_t prv_interpolate_two_ways_int16(AnimationProgress normalized_progress, int32_t discontinuity_progress, int16_t to) { if (...
/* * 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_draw_watch_hand_rounded(ctx, hand, center)
; break; } } static GPointPrecise prv_get_clock_center_point(ClockLocation location, const GRect *bounds) { GPoint imprecise_center_point = {0}; switch (location) { case CLOCK_LOCATION_TOP: imprecise_center_point = (GPoint) { .x = bounds->size.w / 2, .y = bounds->size.h / 4, ...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(AttributeIdNameAway + 1 == AttributeIdNameHome, "Sports layout requires that all Home attributes are directly after Away")
; _Static_assert(AttributeIdRecordAway + 1 == AttributeIdRecordHome, "Sports layout requires that all Home attributes are directly after Away"); _Static_assert(AttributeIdScoreAway + 1 == AttributeIdScoreHome, "Sports layout requires that all Home attributes are directly after Away"); #if...
TextDynamicContext) { .layout = layout, .config = *config, }; text_node->user_data = context; // graphics_text_node_create_text_dynamic() sets text_node->text.text to text_node->buffer, // but since we are using the start of that buffer for our TextDynamicContext we must override // text...
(attributes, AttributeIdParagraphs)
; const size_t num_headings = string_list_count(headings); if (num_headings == 0) { return NULL; } const LayoutNodeTextConfig s_heading_config = { .extent.node.type = LayoutNodeType_Text, .font_key = prv_get_font_key_for_size(config->heading_style_font, config->size), }; const LayoutNodeTextCon...
/* * 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 circular_buffer_copy_offset(buffer, 0, data_out, length_to_copy); }
uint16_t circular_buffer_copy_offset(const CircularBuffer* buffer, uint16_t start_offset, uint8_t *data_out, uint16_t length_to_copy) { if (buffer->data_length <= start_offset) { return 0; } const uint16_t read_index = (buffer->read_index + start_offset) % buffer->buffer...
/* * 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...
services_set_runlevel(RunLevel_Normal)
; } s_prev_low_power_active = s_low_power_active; } static void prv_low_power_toggle_timer_callback(void* data) { launcher_task_add_callback(prv_low_power_launcher_task_callback, data); } static void prv_low_power_transition(bool active) { s_low_power_active = active; if (s_toggle_timer == TIMER_INVALID_ID...
ced(&storage->file, key, key_len); } mutex_unlock(storage->mutex); return rv; } int timeline_item_storage_get_len(TimelineItemStorage *storage, const uint8_t *key, int key_len) { mutex_lock(storage->mutex); status_t rv = settings_file_get_len(&storage->file, key, key_len); mutex_unlock(storage->mute...
{ mutex_lock(storage->mutex); status_t rv = settings_file_rewrite(&storage->file, prv_flush_rewrite_cb, NULL); mutex_unlock(storage->mutex); return rv; }
.token = token, .result = result, }; comm_session_send_data(session, BLOB_DB_ENDPOINT_ID, (uint8_t*)&response, sizeof(response), COMM_SESSION_DEFAULT_TIMEOUT); } static BlobDBResponse prv_interpret_db_ret_val(status_t ret_val) { switch (ret_val) { case S_SUCCESS: return...
prv_read_ptr(iter, data + length, &key_bytes, key_size)
; // If we read too many bytes or key_size is 0 or didn't read all the bytes if (!iter || (iter != (data + length))) { prv_send_response(session, token, BLOB_DB_INVALID_DATA); return; } // perform action on database and return result status_t ret = blob_db_delete(db_id, key_bytes, key_size); prv_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...
list_prepend(&s_head->node, &e->node)
; return 0; } int HCI_LE_Remove_Device_From_White_List(unsigned int BluetoothStackID, Byte_t Address_Type, BD_ADDR_t Address, Byte_t *StatusResult) { const WhitelistEntry model = { .Addres...
f void (*InitSliceFromAttributeListFunc)(const AttributeList *attr_list, AppGlanceSliceInternal *slice_out); //! Callback for adding the type-specific fields from a slice to the provided attribute list. //! You can assume that the slice and attribute list pointers are val...
{ if (!serialized_glance || !cb) { return false; } SerializedAppGlanceSliceHeader *current_slice = (SerializedAppGlanceSliceHeader *)serialized_glance->data; size_t glance_size_processed = sizeof(SerializedAppGlanceHeader); // Note that we'll stop iterating after reading the max supported number ...
///////////////////////////////////////// // Serialized Slice Validation Helpers ///////////////////////////////////////// static bool prv_is_slice_type_valid(uint8_t type) { return (type < AppGlanceSliceTypeCount); } //! Returns true if the provided AttributeList is valid for the specified AppGlanceSliceType, //...
false, ALARM_KIND_EVERYDAY, s_every_day_schedule); id = alarm_create(&(AlarmInfo) { .hour = 6, .minute = 14, .kind = ALARM_KIND_EVERYDAY }); prv_assert_alarm_config(id, 6, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); } void test_alarm__alarm_create_recurring_weekends(void) { AlarmId id; id = alarm_c...
alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY })
; prv_assert_alarm_config(id1, 3, 14, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); alarm_set_time(id1, 5, 6); prv_assert_alarm_config(id1, 5, 6, false, ALARM_KIND_EVERYDAY, s_every_day_schedule); id2 = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_WEEKDAYS }); prv_assert_alarm...
/* * 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...
(structured_glance)
hat line will also be interpreted as data we can // read. This means there's a bit of overhead for sending data as we have to also make sure // we don't accidentally read it back. If you're going to be sending a large amount of data, // calling accessory_disable_input before will give you a nice speed boost as we...
(&BOARD_CONFIG_ACCESSORY.power_en, on)
; } bool accessory_is_present(void) { accessory_set_power(true); gpio_input_init_pull_up_down(&BOARD_CONFIG_ACCESSORY.int_gpio, GPIO_PuPd_DOWN); // budget for a capacitance up to ~1uF and a resistance of 10kOhm psleep(10); bool result = (gpio_input_read(&BOARD_CONFIG_ACCESSORY.int_gpio) == SET); gpio_input...
(ctx, text, data->typical_font, rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL)
; } static bool prv_has_sleep_data(HealthData *health_data) { // daily weekly stats doesn't include the first index so we check that separately return health_data_current_sleep_get(health_data) || health_data_sleep_get_monthly_average(health_data) > 0; } static void prv_base_layer_update_proc(Layer *base...
/* * 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 RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER); }
/* * 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...
mfg_info_get_model(model)
; if (!strcmp(model, "1002")) { // SilkHR return true; } return false; #endif } #endif #if MFG_INFO_RECORDS_TEST_RESULTS void mfg_info_write_test_result(MfgTest test, bool pass) { MfgData data = prv_fetch_struct(); data.test_results[test] = pass; prv_update_struct(&data); } bool mfg_info_get_test_resu...
_x, icon_y)); const int name_x = drawing_rect.origin.x + PBL_IF_RECT_ELSE(0, (rl_margin / 2)); const int name_y = PBL_IF_RECT_ELSE(107, 109); GRect name_rect = GRect(name_x, name_y, drawing_rect.size.w, 32); graphics_context_set_text_color(ctx, TEXT_COLOR); graphics_draw_text(ctx, name, font, name_rect, ove...
gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_START)
; summary_window->action_bar_more = gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_MORE); action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, summary_window->action_bar_start); action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, summary_window->action_bar_more); workout_summary_update_activi...
QUADSPI_CCR_IMODE | \ QUADSPI_CCR_ADMODE | \ QUADSPI_CCR_ADSIZE | \ QUADSPI_CCR_ABMODE | \ QUADSPI_CCR_ABSIZE | \ QUADSPI_CCR_DCYC | \ ...
if (last_address_aligned < start_address_aligned) { dma_size = 0; leading_bytes = length; trailing_bytes = 0; }
prv_set_num_data_bytes(length); prv_config_indirect_read(dev, instruction, start_addr, dummy_cycles, is_ddr); if (leading_bytes > 0) { prv_read_bytes(buffer, leading_bytes); } if (dma_size > 0) { // Do 4 bytes at a time for DMA QSPI_SetFIFOThreshold(QSPI_DMA_READ_WORD_SIZE); QSPI_DMACmd(...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(LOG_LEVEL_ERROR, "DMA Compositing never completed.")
; // TODO: This should never be hit, but do we want to queue up a new render // event so that there is no visible breakage in low-fps situations? dma_request_stop(COMPOSITOR_DMA); } stop_mode_enable(InhibitorCompositor); } #endif // CAPABILITY_COMPOSITOR_USES_DMA && !TARGET_QEMU && !UNITTEST
} else { /// Step count less than 1000 snprintf(data->steps_buffer, sizeof(data->steps_buffer), i18n_get("%d", data), hundreds); } layer_mark_dirty(&data->base_layer); } static void prv_update_current_steps(KickstartData *data) { data->current_steps = health_service_sum_today(HealthMetricSt...
(&data->shoe_green_small, RESOURCE_ID_STRIDE_SHOE_GREEN_SMALL)
; #endif // PBL_RECT data->steps_font = fonts_get_system_font(FONT_KEY_AGENCY_FB_36_NUMBERS_AM_PM); data->time_font = fonts_get_system_font(FONT_KEY_AGENCY_FB_60_NUMBERS_AM_PM); data->am_pm_font = fonts_get_system_font(FONT_KEY_AGENCY_FB_60_THIN_NUMBERS_AM_PM); #else #error "Undefined screen size" #endif // ROBER...
values_buf_size, int32_t avg_hr, int32_t *hr_zone_time_s) { const size_t hr_buf_size = 8; char hr_str[hr_buf_size]; if (avg_hr) { snprintf(hr_str, hr_buf_size, "%"PRIi32"", avg_hr); string_list_add_string(headings, headings_buf_size, i18n_get...
if (session->type == ActivitySessionType_Walk) { type = ActivityInsightType_ActivitySessionWalk; icon = TIMELINE_RESOURCE_ACTIVITY; prv_add_metric_duration_info(headings, headings_buf_size, values, values_buf_size, session); prv_add_avg_pace_metric_info(headings, headings_buf_size, values, values_buf_s...
const NotificationConfig config = { .notif_time = notif_time, .insight_type = type, .icon_id = icon, .body = body, .headings = headings, .values = values, .open_app = { .enabled = true, .health_card_type = HealthCardType_Activity, }, }; analytics_event_health_insigh...
stub_pebble_tasks_set_current(PebbleTask_KernelMain); window_stack_push(modal_stack, window2, true); cl_assert_equal_i(window_stack_count(modal_stack), 1); cl_assert_equal_i(window2->on_screen, true); cl_assert_equal_p(s_last_click_configured_window, window1); // Switch to modal happens via the compositor ...
(dump[1].name, "Window2")
; cl_assert_equal_p(dump[2].addr, window1); cl_assert_equal_s(dump[2].name, "Window1"); kernel_free(dump); } void test_window_stack__pop_all_modals(void) { Window *windows[NumModalPriorities]; WindowStack *window_stacks[NumModalPriorities]; for (ModalPriority idx = ModalPriorityMin; idx < NumModalPrioriti...
mentation implementation = { .base = { .update = (AnimationUpdateImplementation) property_animation_update_gpoint, }, .accessors = { .setter = { .grect = (const GRectSetter) prv_scroll_layer_set_content_offset_internal, }, .getter = { .grect = (const GRectGetter) scroll_layer_g...
(scroll_layer)
); } } void scroll_layer_set_click_config_onto_window(ScrollLayer *scroll_layer, struct Window *window) { window_set_click_config_provider_with_context(window, (ClickConfigProvider) scroll_layer_click_config_provider, scroll_layer); } void scroll_layer_set_callbacks(ScrollLayer *scroll_layer, ScrollLayerCallbacks...
---------------------------------------------------------------------- Animation *animation_sequence_init_from_array(Animation *parent, Animation **animation_array, uint32_t array_len) { PBL_ASSERTN(!animation_private_using_legacy_2(NULL)); return prv_complex_init(paren...
{ AnimationLegacy2Scheduler *legacy_state = (AnimationLegacy2Scheduler *)state; prv_dump_legacy_animations(legacy_state->head, buffer, buffer_size); }
else { prv_dump_animations(state->scheduled_head, true, buffer, buffer_size); prv_dump_animations(state->unscheduled_head, false, buffer, buffer_size); } portEXIT_CRITICAL(); } // ------------------------------------------------------------------------------------------- void animation_private_pause(void...
ic void prv_screen_on(void) { prv_start_command(CMD_DISPLAY_ON); prv_end_command(); } static void prv_screen_off(void) { prv_start_command(CMD_DISPLAY_OFF); prv_end_command(); } void prv_draw_scene(uint8_t scene) { prv_start_command(CMD_DRAW_SCENE); prv_send_command_arg(scene); prv_end_command(); } void...
{ prv_wait_busy(); prv_draw_scene(SCENE_SPLASH); // Don't turn the screen on until the boot-splash is fully drawn. prv_wait_busy(); prv_screen_on(); }
void display_firmware_update_progress( uint32_t numerator, uint32_t denominator) { static uint8_t last_bar_fill = UINT8_MAX; // Scale progress to the number of pixels in the progress bar, // rounding half upwards. uint8_t bar_fill = ((numerator * UPDATE_PROGRESS_MAX) + ((denominator+1)/2)) / denomin...
TO_TRIG(90 + 45)
,GCornerBottomRight}, .full_quadrants = GCornersLeft, .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(45),GCornerTopRight} })); // Pair of quadrants cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(0 - 360), TO_TRIG(180 - 360)), ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConf...
nimation_get_context(a)); animation_set_duration(a, duration_a); prv_clear_handler_histories(); uint64_t start_ms = prv_now_ms(); animation_schedule(a); // Seek to just after the end of the second A prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS); #endif } // ----------...
(prv_count_handler_entries(&s_stopped_handler_calls, seq), 0)
; cl_assert(prv_last_handler_entry(&s_stopped_handler_calls, a)->fire_order < prv_last_handler_entry(&s_started_handler_calls, b)->fire_order); // Finish the sequence prv_advance_to_ms_with_timers(prv_now_ms() + leftover_seq + 2 * MIN_FRAME_INTERVAL_MS); cl_assert_equal_i(prv_count_handler_entries...
ges_values_weekend; bool sys_activity_get_step_averages(uint16_t day_of_week, ActivityMetricAverages *averages) { cl_assert(averages); if (day_of_week == Sunday || day_of_week == Saturday) { s_sys_activity_get_step_averages_values_weekend.in.day_of_week = day_of_week; memcpy(averages, &s_sys_activity_get_s...
(s_metric_overrides, 0, sizeof(s_metric_overrides))
; s_prv_activity_cb__call_count = 0; s_prv_activity_cb__false_at_call_no = UINT32_MAX; s_sys_activity_get_minute_history_values = (sys_activity_get_minute_history_values) { // as all these values need to be configured in the test, we assert per default .out[0].asserts = true, }; s_activity_prefs_hea...
ps are very low (QA or a brand new pebble user), bump the value // to a slightly more reasonable number. // This fixes an integer rounding problem when the value is very small (PBL-43717) const int min_daily_steps_avg = 100; data->daily_steps_avg = MAX(data->daily_steps_avg, min_daily_steps_avg); // increase...
(&data->shoe_blue)
node); } else { // Changed and is now included: if (node == NULL) { add_app_with_install_id(&entry, source); } } prv_alert_data_source_changed(source); } static void prv_app_icon_name_updated_callback(const AppInstallId install_id, void *data) { AppMenuDataSource *data_source = data; prv_s...
(source, node)
; } static AppMenuNode * prv_find_node_with_install_id(const AppInstallId install_id, const AppMenuDataSource * const source) { AppMenuNode *node = source->list; while (node != NULL) { if (node->install_id == install_id) { return node; } else { nod...
752, 248}, { -424, 744, 256}, { -432, 744, 248}, { -432, 744, 248}, { -424, 736, 256}, { -432, 744, 256}, { -432, 752, 248}, { -432, 744, 248}, { -432, 744, 248}, { -440, 744, 256}, { -432, 752, 248}, { -432, 744, 248}, { -424, 752, 248}, { -440, 744, 248}, { -432...
{ -440, 736, 248}, { -440, 736, 248}, { -472, 760, 152}, { -312, 680, 328}, { -504, 808, 256}, { -416, 704, 232}, { -456, 736, 232}, { -464, 744, 256}, { -424, 736, 264}, { -424, 752, 240}, { -440, 744, 248}, { -432, 736, 248}, { -448, 736, 256}, { -440, 736, 256}...
ations under the License. */ #include "voice_endpoint.h" #include "kernel/pbl_malloc.h" #include "services/common/comm_session/session.h" #include "services/normal/audio_endpoint.h" #include "services/normal/voice/voice.h" #include "system/logging.h" #include "system/passert.h" #include "util/generic_attribute.h" #i...
generic_attribute_find_attribute(&msg->attr_list, VEAttributeIdTimestamp, attr_list_size)
; if (timestamp_attr && timestamp_attr->length == sizeof(uint32_t)) { uint32_t *timestamp_ptr = (uint32_t*)timestamp_attr->data; timestamp = *timestamp_ptr; } GenericAttribute *reminder_attr = generic_attribute_find_attribute(&msg->attr_list, VEAttributeIdReminder, attr_list_size); if (!reminder...
al_grect(GRect(5, 4, 2, 2), grect_centered_internal(&p2, GSize(2, 2))); // Repeat for a positive offset center point with 0.5 fractions GPointPrecise p3 = GPointPreciseFromGPoint(GPoint(5, 5)); p3.x.raw_value += FIXED_S16_3_HALF.raw_value; p3.y.raw_value += FIXED_S16_3_HALF.raw_value; // GRectZero + standar...
cl_assert_gpoint_precise(center, 2.5, 2.5)
; cl_assert_fixedS16_3(radius, 2.5); r = GRect(0, 0, 10, 10); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center, 4.5, 4.5); cl_assert_fixedS16_3(radius, 4.5); r = GRect(1, 1, 9, 9); grect_polar_calc_values(&r, mode, &center, &radius); cl_assert_gpoint_precise(center,...
12h: if (with_fulltime) { time_fmt = i18n_noop("%b %e, %l:%M %p"); } else { time_fmt = i18n_noop("%B %e"); } break; case FullStyleLower24h: case FullStyleCapital24h: if (with_fulltime) { time_fmt = i18n_noop("%b %e, %R"); } else {...
{ return prv_format_time(buffer, buf_size, i18n_noop("%d"), timestamp); }
static size_t prv_clock_get_month_named_date(char *buffer, size_t buffer_size, time_t timestamp, bool abbrev) { const char *format = abbrev ? i18n_noop("%b ") : i18n_noop("%B "); const size_t month_size = prv_format_time(buffer, buffer_size, format, timestamp); char ...
{ 1048, -448, -24}, { 1008, -440, -72}, { 968, -568, -152}, { 648, -536, 80}, { 1320, -360, 48}, { 1528, -280, 8}, { 1632, -256, 136}, { 1392, 0, 136}, { 1144, 56, 104}, { 1112, 32, 80}, { 1296, -40, 104}, { 1640, -8, 168}, { 1856, 320, 264}, { 1680, 768, 136}, ...
// 21 seconds { 1568, -192, 128}, { 1432, -120, 112}, { 1320, -184, 144}, { 1176, -240, 168}, { 1032, -296, 72}, { 960, -360, 24}, { 960, -336, -80}, { 1136, -552, -40}, { 632, -456, 64}, { 1120, -304, -96}, { 1368, -256, -80}, { 1696, -184, -104}, { 1560, -120, -...
{ 1728, 320, 408}, { 1704, 1232, 224}, { 1280, 392, 104}, { 1248, 312, 56}, { 1720, -48, 144}, { 1936, -312, 320}, { 1960, -264, 120}, { 1688, -264, 136}, { 1440, -216, 152}, // 24 seconds { 1272, -224, 88}, { 1216, -304, 104}, { 968, -624, 48}, { 896, -696, 8}, ...
{ PBL_ASSERT_TASK(PebbleTask_KernelBackground); bool did_send = false; smartstrap_state_lock(); const SmartstrapProfileInfo *info; FOREACH_PROFILE_INFO(info) { if (info->control && info->control()) { did_send = true; break; } } smartstrap_state_unlock(); return did_send; }
unsigned int smartstrap_profiles_get_max_services(void) { unsigned int max = 0; const SmartstrapProfileInfo *info; FOREACH_PROFILE_INFO(info) { max += info->max_services; } return max; }
0) prv_adjust_value_boundaries(values, ARRAY_LENGTH(values), &range); cl_assert_equal_i(values[0], 1000 / 5); cl_assert_equal_i(values[1], 1000); cl_assert_equal_i(values[2], 1000 / 10); // ensure we look at seconds_total_last_day values[0] = 1000; values[2] = 1000; range.seconds_total_last_day = SECON...
cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskNotAvailable)
; // normal value is available accessible = health_service_metric_accessible(HealthMetricStepCount, now - 10, now); cl_assert_equal_i(accessible, HealthServiceAccessibilityMaskAvailable); // values that partly are in unsupported range are available accessible = health_service_metric_accessible(HealthMetricS...
rkout_info(&steps, &duration_s, &distance_m, &bpm, &hr_zone)); cl_assert_equal_i(bpm, 180); cl_assert_equal_i(hr_zone, 3); cl_assert_equal_i(duration_s, 10 * SECONDS_PER_MINUTE + 10); cl_assert(workout_service_stop_workout()); cl_assert(!workout_service_ge...
(bpm, 100)
; cl_assert(workout_service_pause_workout(true)); // Get some new data but out stats shouldn't change (except HR) prv_inc_time(10); prv_inc_steps_and_put_event(10); prv_put_bpm_event(110, HRMQuality_Good); cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m, ...
/* * 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...
(&test_struct, field_to_access, 1234)
; cl_assert_equal_i(result, test_struct.field_to_access); const int *ptr_result = NULL_SAFE_FIELD_ACCESS(&test_struct, ptr_field_to_access, NULL); cl_assert_equal_p(ptr_result, test_struct.ptr_field_to_access); }