Place Value Tag Expression?

Can tag expression determines the value of each place value?

For example,
if Tens placement value is 8, then opacity 100.
if Hundreds placement value is 3, then opacity 0

GWS has no way to determine what the value is, if it is text input and not a number. You could do something like that with a “counter” app using Tizen Studio.
It it is something that GWS has a tag fuse modulo % operator. For example for step count digits (([sc]%10) * 10) +10 for units ((([sc]%100) % 10) * 10) +10 for tens and so on

Ron
Samsung Developer Program
Samsung Developer Program

1 Like

It can determine values on the places of tag value.
for the units its easy ([kcal]%10==6)*100
for tens its harder (([kcal]%100-[kcal]%10)/10==8)*100
for hundreds its alike, I guess you can continue.

1 Like

@r.liechty_SDR
Thanks Ron, modulo operator is one of those that my brain still doesn’t get it. Even though I understand what it does, but I still don’t fully understand why it works haha.

@Peter
You’re a wizard! Peter. Honestly I don’t know why it works, but it works fantastically! If you have free time, I would appreciate it if you can explain it in plain English.

Place Value Plain English Tag Expression
Units/Ones Show image if Ones is 6 ([sc]%10==6)*100
Tens Show image if Tens is 2 (([sc]%100-[sc]%10)/10==2)*100
Hundreds Show image if Hundreds is 7 (([sc]%1000-[sc]%100)/100==7)*100
Thousands Show image if Thousands is 8 (([sc]%10000-[sc]%1000)/1000==8)*100
Ten Thousands Show image if Ten Thousands is 5 (([sc]%100000-[sc]%10000)/10000==5)*100

This can be a workaround for text on curved/circular path, potentially. Downside is you would need to use 10 bitmap font images and their tag expression for each place value. For step counts that goes to ten thousands, it would use 50 of them. I wonder if that will cause lag or battery drain.

It would be 10 times easier to make a circular text workaround if we were allowed to display result of tag expressions directly in text field.
In plain english remember when you learned division of numbers before you learned decimals. There was a/b meaning how many times the whole b can be subtracted from a and how much reminds of it after that. This reminder is what [tag]%x gives, like no mater how many times you can subtract whole x from the tag, main thing is what reminds after that.
Thanks for the praise, but I feel more and more bitter, about being unworthy to be allowed to publish one or two watchfaces.

1 Like

That would be great!

Thanks for the plain English explanation. I’ll need more time to train my left brain about this.

What do you mean?

@Peter How about decimals such as tenths and hundredths ?

I tried to use these tag expression for Moved Distance in km without success.

Show image if tenths is 5
([md]%1==5)*100

Show image if hundredths is 6
([md]%0.1==6)*100

The modulus operator is the remainder of the division
Anything divided by 1 will never have a remainder.
so you have an if statement
if (0 == 5) is true then 1 x 100
but (0 == 5) is always false or zero.

so you want an if else statement
([md]%5) ? 0 : 100
This shows only when something is divisible by 5.

Does that help you?
Ron

That makes sense.

I’m trying to use this tag expression to show and hide bitmap font image. Peter’s solution works for integer. But I can’t figure out how to apply it for a float number.

For Moved Distance [md], I can’t figure out how to get [md] range in the tenths and hundredths value. I’m not even sure if [md] range returns an integer or a float number. Do you know?

Also, is [md] calculation based on GPS data or approximation from steps count?

image

At least the GWS shows tenths, I don’t know if the watch shows hundreds.
The moved distance has to be based on GPS (probably phone unless not connected) because it works for cycling not step count.

Raise the bridge instead of lowering the river.
([md]*10) for example will show tenths

This shows every half meter (([md]*10)%5) ? 0 : 100

Ron
Samsung Developer Program

1 Like

Are you sure about this? I’m pretty sure that Moved Distance works for step count. Move Speed on the other hand must use GPS tracking data.

It works for step count I walk every day and track it. If I set in my chair and move my arm back and forth the step count rises it shows me as active but the distance doesn’t change… but I don’t have GPS on for my watch.

Ron
Samsung Developer Program

1 Like

Sorry for late reply. I guess, for tenths there would be something like this:
((([md]*10)%10)>=0)*((([md]*10)%10)<1)*100 for x.0
((([md]*10)%10)>=1)*((([md]*10)%10)<2)*100 for x.1 and so on

1 Like

Thanks Peter, I’ll give it a try in the future projects.

From the values I have seen in the tag expressions, it shows some values up to 3 decimal places. Using that as the precision, this would be how I would do it (note: I included a Thousands value and a Thousandths value just so you can see the pattern further).

Let’s say the number is 1653.274

Thousands: (([md]%10000-[md]%1000)/1000)
(1653.274 - 653.274)/1000 = (1000)/1000 = 1

Hundreds: (([md]%1000-[md]%100)/100)
(653.274 - 53.274)/100 = (600)/100 = 6

Tens: (([md]%100-[md]%10)/10)
(53.274 - 3.274)/10 = (50)/10 = 5

Ones: (([md]*1000-[md]*1000%1000)/1000%10)
(1653274 - 1653274%1000)/1000%10 = (1653274-274)/1000%10 = (1653000)/1000%10 = 1653%10 = 3

Tenths: (([md]*1000%1000-[md]*1000%100)/100)
(1653274%1000 - 1653274%100)/100 = (274 - 74)/100 = (200)/100 = 2

Hundredths: (([md]*1000%100-[md]*1000%10)/10)
(1653274%100 - 1653274%10)/10 = (74 - 4)/10 = (70)/10 = 7

Thousandths: ([md]*1000%10)
1653274%10 = 4

If you know you are only working with integer values, then the Ones digit can be written as:

Ones: ([md]%10)

1 Like

Cool, thanks VizFZ! I’ll give that a try in the future projects.

1 Like