Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:flashingtext

Differences

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

Link to this comparison view

Next revision
Previous revision
tips:flashingtext [2015/01/28 19:29] – created jt3tips:flashingtext [2015/01/28 19:39] (current) – [Flashing/Alternating Text or Graphics] jt3
Line 1: Line 1:
 ====== Flashing/Alternating Text or Graphics ====== ====== Flashing/Alternating Text or Graphics ======
  
-Ever want to display flashing text?  How about a battery indicator that flashes when the battery drops below 20%?  Here's how.+Ever want to display flashing text?  How about a battery indicator that flashes when the battery drops below 20%?  Or, maybe you'd like to show weather and date in the same space?  Here's how.  All example formulas are designed for the **Opacity** field.
  
 ===== Examples ===== ===== Examples =====
Line 7: Line 7:
 ==== Flashing ==== ==== Flashing ====
  
-   {drss}%6>=3 and 100 or 0 +   {drss}%6<3 and 100 or 0
-   +
 ==== Conditional Flashing ==== ==== Conditional Flashing ====
  
-   {bl}>=20 and 100 or {drss}%6>=3 and 100 or 0+   {bl}>=20 and 100 or {drss}%6<3 and 100 or 0
  
 ==== Alternating ==== ==== Alternating ====
Line 24: Line 23:
 We're going to use a handy mathematical tool here called Modulo, which in LUA is represented by the percent sign (%).  Modulo gives you only the remainder for any division problem.  For example, 6/3=2 with no remainder, so Modulo would return 0.  5/3=1 with 2 remainder, so Modulo returns 2.   We're going to use a handy mathematical tool here called Modulo, which in LUA is represented by the percent sign (%).  Modulo gives you only the remainder for any division problem.  For example, 6/3=2 with no remainder, so Modulo would return 0.  5/3=1 with 2 remainder, so Modulo returns 2.  
  
-One second on a clock is 6 degrees of rotation (360 degrees / 60 seconds = 6 degrees/sec.).  Thus, {drss} will increase by 6 each second, but it's updated 50 times per second, so for the other 49/50 of a second, there will be a remainder.  we don't really care what the remainder is but we know it will steadily climb from 0 to something in the 5.9 range.  Using modulo, we can test for half-seconds by simply stating test "{drss}%6<3", which will result true for the first half of every second, and false for the 2nd half.  After that, we simply set opacity to 100 or 0, depending on which half second it is.  So, **{drss}%6<3 and 100 or 0** basically says to show for the first half of every second, and don't show for the second half.+One second on a clock is 6 degrees of rotation (360 degrees / 60 seconds = 6 degrees/sec.).  Thus, {drss} will increase by 6 each second, but it's updated 50 times per second, so for the other 49/50 of a second, there will be a remainder if we divide by 6.  We don't really care what the remainder is but we know it will steadily climb from 0 to something in the 5.9 range.  Using modulo, we can test for half-seconds by simply stating "{drss}%6<3", which will result true for the first half of every second, and false for the 2nd half.  After that, we simply set opacity to 100 or 0, depending on which half second it is.  So, **{drss}%6<3 and 100 or 0** basically says to show for the first half of every second, and don't show for the second half.
  
 You can add conditions to this, such as having the text flash when battery level is below 20%. In the example, the battery level display is steady until battery level falls below 20%, where it will start flashing.  This could be set the opposite way (Like a "Charge Battery Now!" sign) by simply changing that first 100 to 0. You can add conditions to this, such as having the text flash when battery level is below 20%. In the example, the battery level display is steady until battery level falls below 20%, where it will start flashing.  This could be set the opposite way (Like a "Charge Battery Now!" sign) by simply changing that first 100 to 0.
  
-Alternating text is basically this, twice.  You could choose to alternate colors, which means you probably still want to flash quickly, or you could use it to alternate displays, such as have date and weather alternate, so that both show in the same exact space.  In this case, you'd want to slow things down a bit.  Simply changing {drss} to {ds} in that same formula will slow things down so that each would display for seconds.  You alternate simply by reversing the opacity values on the objects, so that when one is 100 the other is 0 and vice versa. +Alternating text is basically this, twice.  You could choose to alternate colors, which means you probably still want to flash quickly, or you could use it to alternate displays, such as have date and weather alternate, so that both show in the same exact space.  In this case, you'd want to slow things down a bit.  Whereas {drss} takes 1 second to become divisible by 6, {ds} takes 6 seconds to get there.  So, simply changing {drss} to {ds} in that same formula will slow things down to a 3-second flash, rather than 1/2 second.  You alternate simply by reversing the opacity values on the objects, so that when one is 100 the other is 0 and vice versa. In this case, weather and date (or whatever) can each show for 3 seconds before switching to the other display.
tips/flashingtext.1422473356.txt.gz · Last modified: 2015/01/28 19:29 by jt3