[英]Problems with PBL_IF_ROUND_ELSE function
I'm trying to follow the tutorial about Watchfaces creation, but I'm stuck. 我正在尝试遵循有关Watchfaces创建的教程,但是我遇到了麻烦。 I copied the code from the wiki so there shouldn't be any error whatsoever, but I'm getting this error while compiling
我从Wiki复制了代码,因此无论如何都不会出现任何错误,但是在编译时出现了此错误
error: implicit declaration of function 'PBL_IF_ROUND_ELSE' [-Werror=implicit-function-declaration]
错误:函数'PBL_IF_ROUND_ELSE'的隐式声明[-Werror = implicit-function-declaration]
I tried to google it but I couldn't find anything useful. 我试图用谷歌搜索,但找不到任何有用的东西。 This is the code
这是代码
#include <pebble.h>
static Window *s_main_window;
static TextLayer *s_time_layer;
static void update_time() {
// Get a tm structure
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
// Write the current hours and minutes into a buffer
static char s_buffer[8];
strftime(s_buffer, sizeof(s_buffer), clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
// Display this time on the TextLayer
text_layer_set_text(s_time_layer, s_buffer);
}
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
update_time();
}
static void main_window_load(Window *window) {
// Get information about the Window
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
// Create the TextLayer with specific bounds
s_time_layer = text_layer_create(
GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50));
// Improve the layout to be more like a watchface
text_layer_set_background_color(s_time_layer, GColorClear);
text_layer_set_text_color(s_time_layer, GColorBlack);
text_layer_set_text(s_time_layer, "00:00");
text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
// Add it as a child layer to the Window's root layer
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
}
static void main_window_unload(Window *window) {
// Destroy TextLayer
text_layer_destroy(s_time_layer);
}
static void init() {
// Create main Window element and assign to pointer
s_main_window = window_create();
// Set handlers to manage the elements inside the Window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
// Show the Window on the watch, with animated=true
window_stack_push(s_main_window, true);
// Make sure the time is displayed from the start
update_time();
// Register with TickTimerService
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
}
static void deinit() {
// Destroy Window
window_destroy(s_main_window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
I'm using the CloudPebble SDK. 我正在使用CloudPebble SDK。
我知道了,PBL_IF_ROUND_ELSE仅适用于3.X SDK(我使用的是2.X)。
" PBL_IF_ROUND_ELSE(58, 52) " Only works with Pebble Time or SDK3 . “ PBL_IF_ROUND_ELSE(58,52) ”仅适用于Pebble Time或SDK3 。
You can replace " PBL_IF_ROUND_ELSE(58, 52) " with a range between 0 and 100. 0 meaning it will be at the top of the screen. 您可以将“ PBL_IF_ROUND_ELSE(58,52) ”替换为0到100之间的范围。0表示它将位于屏幕顶部。 100 means it will be at the bottom of the screen.
100表示它将位于屏幕的底部。
Replace the "PBL_IF_ROUND_ELSE(58, 52)" with a 0. That should do the trick. 将“ PBL_IF_ROUND_ELSE(58,52)”替换为0。这可以解决问题。 Im assuming you are trying to run this program on the aplite version?
我假设您正在尝试在aplite版本上运行此程序?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.