저는 페블 시계 얼굴을 만들기 시작했고, 타이머를 카운트 다운하기를 원했습니다. 그 시간에 몇 시간을 남겨두고 12 초에 다시 시작할지 계산할 수 있습니다. 매일.페블 지능형 시계 코딩에 새로운 도움이 되십시오. 시간을 숫자로 변환하려고 시도합니다.
문제는 현재의 시간에서 24 시간을 뺀 다음 시계 (H : M과 같은 시간과 분 포함)에 표시하면 수학을 올바르게 표시하는 방법을 찾을 수 없다는 것입니다.
// Time functions
static void update_time() {
// Get a tm structure
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
double munistime;
// Create a long-lived buffer
static char buffer[] = "00:00:00";
// Write the current hours and minutes into the buffer
if(clock_is_24h_style() == true) {
// Use 24 hour format
strftime(buffer, sizeof("00:00:00"), "%H:%M:%S", tick_time);
munistime = 24.0 - 19.0;
} else {
// Use 12 hour format
strftime(buffer, sizeof("00:00:00"), "%I:%M:%S", tick_time);
}
// Display this time on the TextLayer
text_layer_set_text(s_time_layer, buffer);
}
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
update_time();
}
// Set the count from the start of the day
Static void update_countdown() {
}
// Window Functions
static void main_window_load(Window *window) {
// Create time TextLayer
s_time_layer = text_layer_create(GRect(0, 130, 150,50));
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:00");
// Improve the layout to be more like a watchface
text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
// Creates A count Timer Layer
s_countdown_layer = text_layer_create(GRect(0, 40, 150, 50));
text_layer_set_background_color(s_countdown_layer, GColorBlack);
text_layer_set_text_color(s_countdown_layer, GColorWhite);
text_layer_set_text(s_countdown_layer, "00:00:00");
text_layer_set_text_alignment(s_countdown_layer, GTextAlignmentCenter);
text_layer_set_font(s_countdown_layer,fonts_get_system_font(FONT_KEY_GOTHIC_28));
// Add it as a child layer to the Window's root layer
layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
layer_add_child(window_get_root_layer(window),text_layer_get_layer(s_countdown_layer));
update_time();
}
정말 질문하지 않았습니다. 문제는 정확히 무엇입니까? – Chris
24에서 현재 시간을 빼고 조약돌 화면에서 % h : % m : % s의 형식으로 표시하는 방법은 무엇입니까? –