Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:tickertext

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:tickertext [2015/05/27 05:28] jt3tips:tickertext [2015/05/27 13:55] (current) jt3
Line 58: Line 58:
 The first method is the "on millisecond" method.  This uses the "On_Millisecond" function in the main script.  The main advantage to this method is that it's smoother, and the loop is seamless.  That means that the beginning and end of the looped text can be visible at the same time.  So, when the loop ends, it doesn't need to completely scroll out of sight before the next loop starts.  However, this kind of loop is *constantly* running, so it's harder on your battery, and it tends to bog down the processor, even when the text isn't currently being displayed.  It also tends to require more code than the standard function method, and the timing is a bit more reliant on the speed of your watch, so it's a bit harder to ensure a universal scrolling speed.  Thus, the scrolling speed on your phone will tend to be *much* faster than on your watch, so be sure to test on both. The first method is the "on millisecond" method.  This uses the "On_Millisecond" function in the main script.  The main advantage to this method is that it's smoother, and the loop is seamless.  That means that the beginning and end of the looped text can be visible at the same time.  So, when the loop ends, it doesn't need to completely scroll out of sight before the next loop starts.  However, this kind of loop is *constantly* running, so it's harder on your battery, and it tends to bog down the processor, even when the text isn't currently being displayed.  It also tends to require more code than the standard function method, and the timing is a bit more reliant on the speed of your watch, so it's a bit harder to ensure a universal scrolling speed.  Thus, the scrolling speed on your phone will tend to be *much* faster than on your watch, so be sure to test on both.
  
-We start by defining some constants, such as the number of characters that will be shown at once (window_length), the speed (var_slowdown), and a separator string.  In the example, we use a series of spaces as the separator (between loops), but one advantage of this method is that you can use visible characters, such as dashes, underscores, or periods, as a separator as well.+We start by defining some constants, such as the number of characters that will be shown at once (window_length), the scroll speed (var_slowdown), and a separator string.  In the example, we use a series of spaces as the separator (between loops), but one advantage of this method is that you can use visible characters, such as dashes, underscores, or periods, as a separator as well.
  
 Once we actually enter the function, we essentially move the visible part of the string along, limiting the visible portion to the window size. So, if we've determined the window size to be 15 characters, we'll show the 1st to 15th character, then the 2nd to 16th, 3rd to 17th, 4th to 18th, etc.  If we run out of characters we simply use the "separator" string as a buffer, before starting over with the 1st character.  Thus, it's perfectly acceptable to show the last 10 characters, followed by a 3-character separator, followed by the first 2 characters (to equal a 15-character window).  Also, keep in mind that the example shows a variable set in the main script as the display text, but the string could just as easily be a tag such as {wct}. Once we actually enter the function, we essentially move the visible part of the string along, limiting the visible portion to the window size. So, if we've determined the window size to be 15 characters, we'll show the 1st to 15th character, then the 2nd to 16th, 3rd to 17th, 4th to 18th, etc.  If we run out of characters we simply use the "separator" string as a buffer, before starting over with the 1st character.  Thus, it's perfectly acceptable to show the last 10 characters, followed by a 3-character separator, followed by the first 2 characters (to equal a 15-character window).  Also, keep in mind that the example shows a variable set in the main script as the display text, but the string could just as easily be a tag such as {wct}.
Line 66: Line 66:
 The second method is a lot more battery and processor friendly, and the scroll speed is measured in seconds, making it consistent across devices, but the major disadvantage is that the text must completely scroll out of sight before it can start up again, because there is a slight delay as you recall the function (which restarts the scrolling text... as each function call only scrolls the text one time). The second method is a lot more battery and processor friendly, and the scroll speed is measured in seconds, making it consistent across devices, but the major disadvantage is that the text must completely scroll out of sight before it can start up again, because there is a slight delay as you recall the function (which restarts the scrolling text... as each function call only scrolls the text one time).
  
-Here, we start by defining some initial values for certain variables (mainly to prevent "null" errors), but in the case of "tweens.scroll," we're going to "restart" it every time the value reaches the maximum value, so we need to initially set it to a value higher than it will ever be in normal use.+Here, we again start by defining some initial values for certain variables (mainly to prevent "null" errors), but in the case of "tweens.scroll," we're going to "restart" it every time the value reaches the maximum value, so we need to initially set it to a value higher than it will ever be in normal use.  Thus, it will immediately trigger our first function call by being higher than it should be.  The speed control here is var_speed, and is in seconds (as in, how many seconds it will take to fully scroll the text).
  
 The function, in this case is simply a "tween" animation, so it's easy to understand.  Essentially, we do the same thing as in the "on_millisecond" method, but we use a standard function call to determine how long the display window should be, and we must recall that function every time we want to loop.  This is best for screens that won't always be visible, such as weather screens that are called by tap action.  Thus, the scrolling only happens when necessary, saving processor and battery. The function, in this case is simply a "tween" animation, so it's easy to understand.  Essentially, we do the same thing as in the "on_millisecond" method, but we use a standard function call to determine how long the display window should be, and we must recall that function every time we want to loop.  This is best for screens that won't always be visible, such as weather screens that are called by tap action.  Thus, the scrolling only happens when necessary, saving processor and battery.
  
-The text object is a bit more complicated here, since we did very little processing in the main script.  The important thing to remember here is that the text must scroll *completely* out of sight before restarting.  We do this by padding the text with leading and trailing invisible spaces, equal to the window length.  So, if we're showing 15 characters, then we must add 15 spaces before *and* after the text string.  They must be spaces.  You can't use visible characters with this method.  Also, we must tell the function how many characters are to be displayed in the string, and finally, we must recall the function when the string is finished (and we've reached the end of the scroll).  Performing three functions in a single "text field" may make for some confusing code, but by doing all the heavy lifting yourself, your processor and battery will thank you. +The text object is a bit more complicated here, since we did very little processing in the main script.  The important thing to remember here is that the text must scroll *completely* out of sight before restarting.  We do this by padding the text with leading and trailing invisible spaces, equal to the window length.  So, if we're showing 15 characters, then we must add 15 spaces before *and* after the text string.  They must be spaces.  You can't use visible characters with this method.  Also, we must tell the function how many characters are to be displayed in the string, and finally, we must recall the function when the string is finished (and we've reached the end of the scroll).  Performing three functions in a single "text field" may make for some confusing code, but your processor and battery will thank you. 
  
 You might notice that the string length is 15, but we tell it to scroll 16 characters in the tween statement.  This is to ensure that it scrolls the last visible character completely out of sight, and ends by showing only spaces (no actual text).  So, wherever you see 16 in the example, be sure to add 1 to the number of characters you want displayed.  At the end, however, we do list the actual window length in the animation endpoint, so where you see 15 in the example, be sure to replace it with the actual number of characters to be displayed. You might notice that the string length is 15, but we tell it to scroll 16 characters in the tween statement.  This is to ensure that it scrolls the last visible character completely out of sight, and ends by showing only spaces (no actual text).  So, wherever you see 16 in the example, be sure to add 1 to the number of characters you want displayed.  At the end, however, we do list the actual window length in the animation endpoint, so where you see 15 in the example, be sure to replace it with the actual number of characters to be displayed.
tips/tickertext.txt · Last modified: 2015/05/27 13:55 by jt3