0

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.

enter image description here

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.
}
Vidia
  • 471
  • 5
  • 17

1 Answers1

0

I think you are changing the color of the entire text layer when you just want to change the color of the prompt. I think it might be easier to just create a layer to display the prompt and then move it around as the user types.

sarfata
  • 4,625
  • 4
  • 28
  • 36
  • But I am always just changing the text color back and forth. Also what do you mean by moving it around? There is no real typing happening. – Vidia Apr 01 '14 at 18:22
  • You are changing the text color of the entire layer. Is that really what you want to do? Or do you want to change the color of just one character? – sarfata Apr 01 '14 at 21:32
  • I want to change the color of the entire text of the layer. My idea is to make it appear as clear (ie invisible) until I need to display it. I figured that would be easier than de/reattaching it from the parent. – Vidia Apr 07 '14 at 16:50
  • I provided a link above. – Vidia Apr 12 '14 at 15:08