Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:batterymeters

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
Next revisionBoth sides next revision
tips:batterymeters [2015/01/21 19:20] – [Rotation] jt3tips:batterymeters [2015/01/21 20:53] – [Rotation] jt3
Line 12: Line 12:
 (Segment Between – Opacity in range 100%, Opacity Out of range 0%) (Segment Between – Opacity in range 100%, Opacity Out of range 0%)
  
-   Start:  180+(9*(math.floor(({bl}/5})+0.5)))  (100% @ 0ᵒ to 0% @ 180ᵒ – diminishing Counterclockwise)+   Start:  180+(9*(math.floor(({bl}/5)+0.5)))  (100% @ 0ᵒ to 0% @ 180ᵒ – diminishing Counterclockwise)
    End:  360    End:  360
  
Line 33: Line 33:
  
 Segmented meters are used when you want an “LED” effect, where you light up equal segments such that an entire segment lights at once.  This is very common for battery meters and makes a cool effect.  In almost every other case, you’ll use smooth meter calculations for battery meters. Segmented meters are used when you want an “LED” effect, where you light up equal segments such that an entire segment lights at once.  This is very common for battery meters and makes a cool effect.  In almost every other case, you’ll use smooth meter calculations for battery meters.
 +
 +{{:tips:rotation1.png?200|Single Rotation}} {{:tips:rotation2.png?200|Double Rotation}} {{:tips:segmented1.png?200|Segmented}}
  
 ===== Explanation of Examples ===== ===== Explanation of Examples =====
 ==== Rotation ==== ==== Rotation ====
-So let’s explain those examples.  The first set uses rotation.  This assumes that you’re using a watch hand as a battery meter.  However, you can use circle shaders too.  The only difference is that instead of using the Rotation field, you’ll use the Circle Shader’s Start and End fields.  ONE of those fields will have the formula, and the other will have the start or end point as appropriate (similar to the segmented examples, which we’ll cover in a bit).+{{ :tips:rotation1.png?200|}}So let’s explain those examples.  The first set uses rotation.  This assumes that you’re using a watch hand as a battery meter.  However, you can use circle shaders too.  The only difference is that instead of using the Rotation field, you’ll use the Circle Shader’s Start and End fields.  ONE of those fields will have the formula, and the other will have the start or end point as appropriate (similar to the segmented examples, which we’ll cover in a bit).
  
 The first example is a simple meter, working as a clock hand.  100% at 12:00, moving counterclockwise, and ending up back at 12:00.  There are 100 possible values for battery percentage, and we need to move 360ᵒ.  360/100 is 3.6, so we multiply battery level by 3.6. The first example is a simple meter, working as a clock hand.  100% at 12:00, moving counterclockwise, and ending up back at 12:00.  There are 100 possible values for battery percentage, and we need to move 360ᵒ.  360/100 is 3.6, so we multiply battery level by 3.6.
  
-3.6*{bl}+   3.6*{bl}
  
 The next couple examples assume more of a “watch battery on one side, phone battery on the other” approach.  Still, 100% is at 12:00.  We simply move 0% to the bottom.  Now each meter is half the circle.  The examples both show the watch battery {bl}, so you’d simply change the one you want as the phone meter to {pbl}. The next couple examples assume more of a “watch battery on one side, phone battery on the other” approach.  Still, 100% is at 12:00.  We simply move 0% to the bottom.  Now each meter is half the circle.  The examples both show the watch battery {bl}, so you’d simply change the one you want as the phone meter to {pbl}.
  
-The first example of the set is the left side.  We’re basically just cutting the first example in half, so the rotation is the same, but we need to start at 180ᵒ, instead of 0ᵒ, and the meter only has to move half as far.  So, we reduce the multiplier down to 1.8, and we add the start point at the end.  Thus, 3.6*{bl} becomes **(1.8*{bl})+180**.+{{:tips:lefthand.png?200 |Left Hand}}The first example of the set is the left side.  We’re basically just cutting the first example in half, so the rotation is the same, but we need to start at 180ᵒ, instead of 0ᵒ, and the meter only has to move half as far.  So, we reduce the multiplier down to 1.8, and we add the start point at the end.  Thus, 3.6*{bl} becomes...
  
-The second of the set needs to rotate in the other direction, so we take the INVERSE of battery percentage.  In other words, instead of measuring how far from empty (92%), we ask how far from full (8%).  We do that by subtracting battery level from 100.  Then, it’s identical to the first example, except we again only travel half as far, so we use half the multiplier.  **1.8*(100-{bl})**+   (1.8*{bl})+180 
 + 
 +{{ :tips:righthand.png?200|Right Hand}}The second of the set needs to rotate in the other direction, so we take the INVERSE of battery percentage.  In other words, instead of measuring how far from empty (92%), we ask how far from full (8%).  We do that by subtracting battery level from 100.  Then, it’s identical to the first example, except we again only travel half as far, so we use half the multiplier. 
 + 
 +   1.8*(100-{bl})
  
 ==== Circle Shaders (Segments) ==== ==== Circle Shaders (Segments) ====
Line 55: Line 61:
 For these examples, we’re going to duplicate the “watch on one side/battery on the other” approach, where 100% is at 12:00 and 0% is at 6:00.  We’re also going to assume that EACH side has 20 equal segments (LEDs) to be lit. For these examples, we’re going to duplicate the “watch on one side/battery on the other” approach, where 100% is at 12:00 and 0% is at 6:00.  We’re also going to assume that EACH side has 20 equal segments (LEDs) to be lit.
  
-On the left side, the formula is %%180+(9*(math.floor(({bl}/5})+0.5))).%%  The 180 is, again, the starting point.  We have 180ᵒ to travel, with 20 equal segments.  180/20=9, so we get 9 degrees per segment.  Also, we have 100 units to measure in those 20 segments.  100/20=5, so we end up with 5% of battery per segment.  Math.floor means to drop any remainder in the division problem, so that we don’t have to deal with the other 1-4% of battery levels, and we ROUND to the nearest 5% by adding 0.5 to the number before we drop that remainder.  So, the formula is really:  %%start point + (degrees per segment * (math.floor(({bl} / percent per segment)+0.5).%%  Fill everything in, and it becomes **%%180+(9*(math.floor(({bl}/5})+0.5)))%%**.+On the left side, the formula is %%180+(9*(math.floor(({bl}/5)+0.5))).%%  The 180 is, again, the starting point.  We have 180ᵒ to travel, with 20 equal segments.  180/20=9, so we get 9 degrees per segment.  Also, we have 100 units to measure in those 20 segments.  100/20=5, so we end up with 5% of battery per segment.  Math.floor means to drop any remainder in the division problem, so that we don’t have to deal with the other 1-4% of battery levels, and we ROUND to the nearest 5% by adding 0.5 to the number before we drop that remainder.  So, the formula is really:  %%start point + (degrees per segment * (math.floor(({bl} / percent per segment)+0.5))).%%  Fill everything in, and it becomes... 
 + 
 +   180+(9*(math.floor(({bl}/5)+0.5))) 
 + 
 +For the right side we’re moving the other way, so we end at 180ᵒ and subtract the rest, where we’d added before.  Otherwise, it’s the same formula.  Notice though, that earlier, we used the START field of the shader,  but here, the END field will be used.
  
-For the right side we’re moving the other way, so we end at 180ᵒ and subtract the rest, where we’d added before.  Otherwise, it’s the same formula.  Notice though, that earlier, we used the START field of the shader,  but here, the END field will be used. **%%180-(9*(math.floor(({bl}/5)+0.5)))%%**+   180-(9*(math.floor(({bl}/5)+0.5)))
  
tips/batterymeters.txt · Last modified: 2015/01/22 05:01 by jt3