I am working on making a Pebble watchface to display the data and time under the appropriate Linux terminal calls to get those times.
I have a nice mostly static copy working, but I am trying to add a typing animation to the face.
To do that I use a AppTimer for 200ms and type one more letter each time it calls.
However now I am having an issue where even though I can get the commands to animate, I cannot get the large time and date texts to disappear (and reappear when the command has finished typing).
Here is some of the relevant code, the rest is on GitHub https://github.com/vidia/Pebble-Shell/tree/type
I think what it happening is that the setting of the text is overriding the setting of the color and makes the text appear again. But I am not completely sure. Feel free to install it yourself if you must.
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.
}