本文整理汇总了C++中APP_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ APP_LOG函数的具体用法?C++ APP_LOG怎么用?C++ APP_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了APP_LOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inbox_received_callback
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
// Store incoming information
static char icon_buffer[8];
static char temperature_buffer[8];
static int temperature;
// Read tuples for data
Tuple *weather_units_tuple = dict_find(iterator, MESSAGE_KEY_UNITS);
Tuple *weather_on_tuple = dict_find(iterator, MESSAGE_KEY_WEATHER_ON);
Tuple *weather_safemode_tuple = dict_find(iterator, MESSAGE_KEY_WEATHER_SAFEMODE);
Tuple *temp_tuple = dict_find(iterator, MESSAGE_KEY_TEMPERATURE);
Tuple *icon_tuple = dict_find(iterator, MESSAGE_KEY_ICON);
Tuple *background_color_tuple = dict_find(iterator, MESSAGE_KEY_BACKGROUND_COLOR);
Tuple *background_on_tuple = dict_find(iterator, MESSAGE_KEY_BACKGROUND_ON);
// If we get weather option
if ( weather_on_tuple ) {
// Set weather flag
weather_on_conf = (bool)weather_on_tuple->value->int16;
persist_write_bool(MESSAGE_KEY_WEATHER_ON, weather_on_conf);
}
if ( weather_safemode_tuple ) {
weather_safemode_conf = (bool)weather_safemode_tuple->value->int16;
persist_write_bool(MESSAGE_KEY_WEATHER_SAFEMODE, weather_safemode_conf);
}
if ( weather_units_tuple ) {
weather_units_conf = (bool)weather_units_tuple->value->int16;
persist_write_bool(MESSAGE_KEY_UNITS, weather_units_conf);
}
// If all data is available, use it
if ( temp_tuple && icon_tuple ) {
// Assemble strings for temp and icon
temperature = (float)temp_tuple->value->int32;
if ( weather_units_conf ) {
snprintf(temperature_buffer, sizeof(temperature_buffer), "%d F", temperature);
} else {
snprintf(temperature_buffer, sizeof(temperature_buffer), "%d C", temperature);
}
snprintf(icon_buffer, sizeof(icon_buffer), "%s", icon_tuple->value->cstring);
// Set temp and icon to text layers
text_layer_set_text(s_weather_layer, icon_buffer);
text_layer_set_text(s_weathertext_layer, temperature_buffer);
}
// If weather disabled, clear weather layers
if ( !weather_on_conf ) {
text_layer_set_text(s_weather_layer, "");
text_layer_set_text(s_weathertext_layer, "");
}
// If background color and enabled
if ( background_color_tuple && background_on_tuple ) {
// Set background on/off
background_on_conf = (bool)background_on_tuple->value->int16;
persist_write_bool(MESSAGE_KEY_BACKGROUND_ON, background_on_conf);
// Set background color if enabled, otherwise we load the default one - red
background_color = background_on_conf ? (int)background_color_tuple->value->int32 : 0xFF0000;
persist_write_int(MESSAGE_KEY_BACKGROUND_COLOR, background_color);
// Redraw
if ( s_canvas_layer ) {
layer_mark_dirty(s_canvas_layer);
}
}
APP_LOG(APP_LOG_LEVEL_DEBUG, "weather_units_conf %d", weather_units_conf);
APP_LOG(APP_LOG_LEVEL_DEBUG, "weather_on_conf %d", weather_on_conf);
APP_LOG(APP_LOG_LEVEL_DEBUG, "background_on_conf %d", background_on_conf);
APP_LOG(APP_LOG_LEVEL_DEBUG, "background_color %d", background_color);
}
示例2: DEBUG_CODE
DEBUG_CODE(void print_value(char* value, uint16_t value_length) { \
char* v = calloc(value_length + 1, sizeof(char)); \
snprintf(v, value_length + 1, "%s", value); \
APP_LOG(APP_LOG_LEVEL_INFO, " Found value [%d] %s ", value_length, v); \
free(v); \
});
示例3: inbox_dropped_cb
/*
* Handle dropped messages from the AppMessage API.
*/
static void inbox_dropped_cb(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Message dropped.");
}
示例4: select_click_handler
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "SELECT" );
send_message();
data.queried = true;
}
示例5: down_click_handler
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "DOWN" );
}
示例6: in_dropped_handler
static void in_dropped_handler(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Incoming AppMessage from Pebble dropped, %d", reason);
}
示例7: vibrate_hourly_pattern
static void vibrate_hourly_pattern() {
// values
uint32_t VIBRATE_SEGMENTS[48];
u_short MAX_SEGMENTS = 48;
// get hour from local time
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
// create pattern for vibration
int hours = tick_time->tm_hour;
// adjust for non-24-hour time
if(clock_is_24h_style() != true && hours > 12) {
hours = hours - 12;
}
// need pattern count
int pattern_count = hours * 2;
int long_pulses = 0;
// do math to abbreviate pulses
if(ABBREVIATE_PULSES && hours > 5) {
long_pulses = hours / 5;
pattern_count = pattern_count - (long_pulses * 2 * 5) + 1; // eats 10 "spaces" or
}
// chop off remainder (last space is always silent/pause otherwise)
pattern_count = pattern_count - 1;
int vibrate_segment_count = pattern_count; // store value
// fill array with pattern
for(int i = 0; i < MAX_SEGMENTS; i += 2) {
if(pattern_count > 0) {
if(long_pulses > 0) {
long_pulses--;
VIBRATE_SEGMENTS[i] = VIBRATE_LONG_PULSE_MS; // longer pulse for abbreviation
} else {
VIBRATE_SEGMENTS[i] = VIBRATE_PULSE_MS; // pulse each hour
}
if(MAX_SEGMENTS > (i + 1)) {
VIBRATE_SEGMENTS[i + 1] = VIBRATE_PAUSE_MS; // followed by a pause
}
pattern_count-=2; // subtract two because two pattern blocks
} else {
VIBRATE_SEGMENTS[i] = 0;
if(MAX_SEGMENTS > (i + 1)) {
VIBRATE_SEGMENTS[i + 1] = 0;
}
}
}
// enqueue
APP_LOG(APP_LOG_LEVEL_DEBUG, "Enqueueing %d segments for hours %d", vibrate_segment_count, hours);
// enqueue pattern
VibePattern pat = {
.durations = VIBRATE_SEGMENTS,
.num_segments = vibrate_segment_count,
};
vibes_enqueue_custom_pattern(pat);
}
示例8: action_menu_callback
static void action_menu_callback(ActionMenu *action_menu, const ActionMenuItem *action, void *context) {
ValveCmdCode i = (ValveCmdCode)action_menu_item_get_action_data(action);
APP_LOG(APP_LOG_LEVEL_INFO, "Action menu triggered: %d", i);
sendCmdRequest(selectedValve->guid, i);
}
示例9: window_load
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
battery_layer = layer_create(GRect(0, 0, 144, 30));
outline_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LECO_16));
bluetooth_connection_service_subscribe(bluetooth_handler);
upper_text_layer = text_layer_create(GRect(0, 36, 144, 44));
text_layer_set_font(upper_text_layer, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS));
text_layer_set_text_alignment(upper_text_layer, GTextAlignmentCenter);
text_layer_set_background_color(upper_text_layer, GColorClear);
outline_layer = text_layer_create(GRect(0, 36, 144, 168));
text_layer_set_font(outline_layer, outline_font);
text_layer_set_text_alignment(outline_layer, GTextAlignmentCenter);
text_layer_set_text_color(outline_layer, GColorWhite);
text_layer_set_background_color(outline_layer, GColorClear);
lower_text_layer = text_layer_create(GRect(0, 84, 144, 100));
text_layer_set_font(lower_text_layer, fonts_get_system_font(FONT_KEY_LECO_28_LIGHT_NUMBERS));
text_layer_set_text_alignment(lower_text_layer, GTextAlignmentCenter);
text_layer_set_background_color(lower_text_layer, GColorClear);
text_layer_set_text(lower_text_layer, "");
weekday_text = text_layer_create(GRect(0,144,144,25));
text_layer_set_text_alignment(weekday_text, GTextAlignmentCenter);
text_layer_set_background_color(weekday_text, GColorClear);
text_layer_set_text_color(weekday_text, GColorWhite);
text_layer_set_font(weekday_text, outline_font);
battery_text = text_layer_create(GRect(0,0,144,25));
text_layer_set_text_alignment(battery_text, GTextAlignmentCenter);
text_layer_set_background_color(battery_text, GColorClear);
text_layer_set_text_color(battery_text, GColorWhite);
text_layer_set_font(battery_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
layer_add_child(window_layer, battery_layer);
layer_add_child(window_layer, text_layer_get_layer(lower_text_layer));
layer_add_child(window_layer, text_layer_get_layer(upper_text_layer));
layer_add_child(window_layer, text_layer_get_layer(outline_layer));
layer_add_child(battery_layer, text_layer_get_layer(battery_text));
layer_add_child(window_layer, text_layer_get_layer(weekday_text));
if (persist_read_int(KEY_TOP_COLOR)) {
int top_color = persist_read_int(KEY_TOP_COLOR);
set_background_and_text_color(top_color);
}
if (persist_read_int(KEY_BOTTOM_COLOR)) {
int bottom_color = persist_read_int(KEY_BOTTOM_COLOR);
set_layer1_color_and_text(bottom_color);
}
if (persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT)) {
twenty_four_hour_format = persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT);
}
if (persist_read_int(KEY_TOP_TEXT_COLOR)) {
int top_text_color = persist_read_int(KEY_TOP_TEXT_COLOR);
set_top_text_color(top_text_color);
}
if(persist_read_int(KEY_BOTTOM_TEXT_COLOR)) {
int bottom_text_color = persist_read_int(KEY_BOTTOM_TEXT_COLOR);
set_bottom_text_color(bottom_text_color);
}
if(persist_exists(KEY_BLUETOOTH_VIBRATION)){
bluetooth_vibration = persist_read_int(KEY_BLUETOOTH_VIBRATION);
APP_LOG(APP_LOG_LEVEL_INFO,"Bluetooth read");
}
if(persist_exists(KEY_SHOW_BATTERY)){
show_battery = persist_read_int(KEY_SHOW_BATTERY);
}
if(persist_exists(KEY_SHOW_WEEKDAY)){
show_weekday = persist_read_int(KEY_SHOW_WEEKDAY);
APP_LOG(APP_LOG_LEVEL_INFO,"Weekday read");
}
if(persist_exists(KEY_DATE_FORMAT)){
change_date_format = persist_read_int(KEY_DATE_FORMAT);
APP_LOG(APP_LOG_LEVEL_INFO,"Date format read");
}
if(persist_read_int(KEY_WEEKDAY_COLOR)) {
int weekday_color = persist_read_int(KEY_WEEKDAY_COLOR);
set_weekday_color(weekday_color);
}
//.........这里部分代码省略.........
示例10: generate_world
static void generate_world() {
srand(time(NULL));
#ifdef BENCHMARK
uint16_t start = time_ms(NULL, NULL);
#endif
// Bottom level grass
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_GRASS);
}
}
// Seed sand
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
if(rand() % 100 > SAND_SEED_BIAS) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_SAND);
}
}
}
// Clump sand
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
if(rand() % 100 > SAND_CLUMP_BIAS
&& is_near_color(GPoint(x, y), 0, COLOR_SAND)) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_SAND);
}
}
}
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
if(near_this_many_of_color(GPoint(x, y), 0, COLOR_SAND, SAND_NEIGHBOURS)) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_SAND);
}
}
}
// Water in sand areas
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
if(near_this_many_of_color(GPoint(x, y), 0, COLOR_SAND, WATER_NEIGHBOURS)) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_WATER);
}
}
}
// Clump water
for(int y = 0; y < GRID_HEIGHT; y++) {
for(int x = 0; x < GRID_WIDTH; x++) {
if(rand() % 100 > WATER_CLUMP_BIAS
&& is_near_color(GPoint(x, y), 0, COLOR_WATER)) {
block_set_color(s_block_array[vec2i(Vec3(x, y, 0))], COLOR_WATER);
}
}
}
// Castle walls
int x = 2;
int y = 6;
for(y = 6; y < 10; y++) {
for(int z = 0; z < 6; z++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, z))], COLOR_STONE);
}
}
y = 11;
for(x = 2; x < 6; x++) {
for(int z = 0; z < 6; z++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, z))], COLOR_STONE);
}
}
y = 6;
for(x = 2; x < 6; x++) {
for(int z = 0; z < 6; z++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, z))], COLOR_STONE);
}
}
x = 6;
for(y = 6; y < 10; y++) {
for(int z = 0; z < 6; z++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, z))], COLOR_STONE);
}
}
int z = 6;
for(y = 6; y < 10; y++) {
for(x = 2; x < 7; x++) {
block_set_color(s_block_array[vec2i(Vec3(x, y, z))], COLOR_STONE);
}
}
#ifdef BENCHMARK
uint16_t finish = time_ms(NULL, NULL);
APP_LOG(APP_LOG_LEVEL_INFO, "Generation time: %d ms", (int)finish - start);
#endif
}
示例11: bt_client_btcm_cb
static void bt_client_btcm_cb(VMUINT evt, void * param, void * user_data)
{
APP_LOG("[BTC]bt_client_btcm_cb, evt = %d, client_status = %d", evt, g_clientContext.client_status);
switch (evt)
{
case VM_SRV_BT_CM_EVENT_ACTIVATE:
{
// waiting for power on to process
if (g_clientContext.client_status == BT_CLIENT_POWERING_ON)
{
VMINT ret = bt_client_init_spp();
if(ret<0)
{
*(g_clientContext.waiting_result_p) = false;
g_clientContext.waiting_result_p = NULL;
if(bt_client_end_spp())
{
g_clientContext.ptr->post_signal();
}
}
else
{
*(g_clientContext.waiting_result_p) = true;
g_clientContext.waiting_result_p = NULL;
g_clientContext.ptr->post_signal();
}
}
else if (g_clientContext.client_status == BT_CLIENT_ENDING)
{
VMINT ret = vm_btcm_switch_off();
if(VM_SRV_BT_CM_RESULT_SUCCESS == ret)
{
g_clientContext.client_status = BT_CLIENT_POWERING_OFF;
}
else
{
if(g_clientContext.btcm_hdl >= 0)
{
vm_btcm_exit(g_clientContext.btcm_hdl);
g_clientContext.btcm_hdl = -1;
}
g_clientContext.client_status = BT_CLIENT_IDLE;
//LTask.post_signal();
g_clientContext.ptr->post_signal();
}
}
break;
}
case VM_SRV_BT_CM_EVENT_DEACTIVATE:
{
if (g_clientContext.client_status == BT_CLIENT_BEGINING)
{
VMINT ret = vm_btcm_switch_on();
if(VM_SRV_BT_CM_RESULT_SUCCESS == ret)
{
//wait for callback to process
g_clientContext.client_status = BT_CLIENT_POWERING_ON;
}
else
{
*(g_clientContext.waiting_result_p) = false;
g_clientContext.waiting_result_p = NULL;
if(bt_client_end_spp())
{
//LTask.post_signal();
g_clientContext.ptr->post_signal();
}
}
}
else if(g_clientContext.client_status == BT_CLIENT_POWERING_OFF)
{
if(g_clientContext.btcm_hdl >= 0)
{
vm_btcm_exit(g_clientContext.btcm_hdl);
g_clientContext.btcm_hdl = -1;
}
g_clientContext.client_status = BT_CLIENT_IDLE;
//LTask.post_signal();
g_clientContext.ptr->post_signal();
//.........这里部分代码省略.........
示例12: calcSun
float calcSun(int year, int month, int day, float latitude, float longitude, int sunset, float zenith)
{
int N1 = my_floor(275 * month / 9);
int N2 = my_floor((month + 9) / 12);
int N3 = (1 + my_floor((year - 4 * my_floor(year / 4) + 2) / 3));
int N = N1 - (N2 * N3) + day - 30;
float lngHour = longitude / 15;
float t;
if (!sunset)
{
//if rising time is desired:
t = N + ((6 - lngHour) / 24);
}
else
{
//if setting time is desired:
t = N + ((18 - lngHour) / 24);
}
float M = (0.9856 * t) - 3.289;
//calculate the Sun's true longitude
//L = M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) + 282.634
float L = M + (1.916 * my_sin((M_PI/180.0f) * M)) + (0.020 * my_sin((M_PI/180.0f) * 2 * M)) + 282.634;
if (L<0) L+=360.0f;
if (L>360) L-=360.0f;
//5a. calculate the Sun's right ascension
//RA = atan(0.91764 * tan(L))
float RA = (180.0f/M_PI) * my_atan(0.91764 * my_tan((M_PI/180.0f) * L));
if (RA<0) RA+=360;
if (RA>360) RA-=360;
//5b. right ascension value needs to be in the same quadrant as L
float Lquadrant = (my_floor( L/90)) * 90;
float RAquadrant = (my_floor(RA/90)) * 90;
RA = RA + (Lquadrant - RAquadrant);
//5c. right ascension value needs to be converted into hours
RA = RA / 15;
//6. calculate the Sun's declination
float sinDec = 0.39782 * my_sin((M_PI/180.0f) * L);
float cosDec = my_cos(my_asin(sinDec));
//7a. calculate the Sun's local hour angle
//cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude))
float cosH = (my_cos((M_PI/180.0f) * zenith) - (sinDec * my_sin((M_PI/180.0f) * latitude))) / (cosDec * my_cos((M_PI/180.0f) * latitude));
if (cosH > 1) {
return 0;
}
else if (cosH < -1)
{
return 0;
}
//7b. finish calculating H and convert into hours
float H;
if (!sunset)
{
//if rising time is desired:
H = 360 - (180.0f/M_PI) * my_acos(cosH);
}
else
{
//if setting time is desired:
H = (180.0f/M_PI) * my_acos(cosH);
}
H = H / 15;
//8. calculate local mean time of rising/setting
float T = H + RA - (0.06571 * t) - 6.622;
//9. adjust back to UTC
float UT = T - lngHour;
if (UT<0) {UT+=24;}
if (UT>24) {UT-=24;}
time_t now = time(NULL);
struct tm *tick_time = localtime(&now);
struct tm *gm_time = gmtime(&now);
int timezoneoffset = 60 * (60 * (24 * (tick_time->tm_wday - gm_time->tm_wday) + tick_time->tm_hour - gm_time->tm_hour) + tick_time->tm_min - gm_time->tm_min);
// Correct for transitions at the end of the week.
int SECONDS_IN_WEEK=604800;
if (timezoneoffset > SECONDS_IN_WEEK/2) timezoneoffset -= SECONDS_IN_WEEK;
if (timezoneoffset < -SECONDS_IN_WEEK/2) timezoneoffset += SECONDS_IN_WEEK;
timezoneoffset /= 3600;
APP_LOG(APP_LOG_LEVEL_DEBUG, "timezone offset %d", timezoneoffset);
APP_LOG(APP_LOG_LEVEL_DEBUG, "other timezone offset %d", (tick_time-gm_time));
// return UT+(tick_time-gm_time);
return UT;
}
示例13: out_failed_handler
// Called when PebbleKitJS does not acknowledge receipt of a message
static void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "**WATCH**: PebbleKit does not acknowledge receipt of message. Error: %d",reason);
}
示例14: in_dropped_handler
// Called when an incoming message from PebbleKitJS is dropped
static void in_dropped_handler(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "**WATCH**: An incoming message from PebbleKitJS is dropped. Error: %d",reason);
}
示例15: out_failed_handler
static void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "out_failed_handler: App Error Message : %d",reason);
}