我正在制作一个 Pebble 表盘,以在适当的 Linux 终端调用下显示数据和时间,以获取这些时间。
我有一个很好的大部分静态副本工作,但我正在尝试向脸部添加打字动画。
为此,我使用 AppTimer 200 毫秒,并在每次调用时再输入一个字母。
但是现在我遇到了一个问题,即使我可以获得动画命令,我也无法让大的时间和日期文本消失(并在命令完成输入后重新出现)。
这里是一些相关的代码,其余的在 GitHub https://github.com/vidia/Pebble-Shell/tree/type
我认为发生的事情是文本的设置覆盖了颜色的设置并使文本再次出现。但我不完全确定。如果需要,请随时自行安装。
static char hourmin[] = "~$date +%I:%M";
static char timecmd[] = " ";
static char monthday[] = "~$date +%h\\ %d";
static char datecmd[] = " ";
...
static void handleMinuteTick(...)
{
text_layer_set_text_color(time_layer, GColorClear);//the time text
text_layer_set_text_color(date_layer, GColorClear);//the date text
text_layer_set_text_color(dprompt_layer, GColorClear);//the date prompt
text_layer_set_text_color(prompt_layer, GColorClear);//the final, empty prompt
...
//set text of time_layer to the current time
//register a timer
}
static void animateTimePrompt()
{
static unsigned int i = 2;
static int TYPE_TIME = 200;
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 97, "i: %d", i);
strncpy(timecmd, hourmin, i++);
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 60, "timecmd: \"%s\"", timecmd);
text_layer_set_text(text_layer, timecmd);
if( i > strlen(hourmin))
{
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 97, "Typed word!!: %d", i);
i = 2;
text_layer_set_text_color(time_layer, GColorWhite);
text_layer_set_text_color(dprompt_layer, GColorWhite);
//app_timer_cancel(timer);
timer = app_timer_register(TYPE_TIME, animateDatePrompt, 0);
}
else
timer = app_timer_register(TYPE_TIME, animateTimePrompt, 0);
}
static void animateDatePrompt()
{
static int i = 2;
static int TYPE_TIME = 200;
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 97, "i: %d", i);
strncpy(datecmd, monthday, i++);
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 60, "datacmd: \"%s\"", datecmd);
text_layer_set_text(dprompt_layer, datecmd);
if((unsigned int) i > strlen(monthday))
{
app_log(APP_LOG_LEVEL_DEBUG, "unix-time.c", 97, "Typed word!!: %d", i);
i = 2;
text_layer_set_text_color(date_layer, GColorWhite);
text_layer_set_text_color(prompt_layer, GColorWhite);
//timer = app_timer_register(TYPE_TIME, animateDatePrompt, 0);
//app_timer_cancel(timer);
}
else
timer = app_timer_register(TYPE_TIME, animateDatePrompt, 0);
}
...
void handleSecondTick(...)
{
//set text of prompt_layer for the blinking cursor.
}