Closed JohnySeven closed 3 years ago
To use this:
"binding": { "format": "Depth $$ m", }
to the Format field. $$
in Step 2.Right?
If you're finished with this PR, go ahead and merge it. I've looked at the code and I understand only about half of it. (Unless you WANT me to test it before you merge it - and if you do, I will.)
Do you want me to explain some bits?
Most of the "bits" I don't understand very well are about working with JSON. I know what it does, and how it works IN GENERAL, but I'm not familiar with the details - like when you use a JsonObject vs. JsonArray, and when you CreateNestedObject(), etc. But I've been looking at the data that the Watch sends to SK as a single delta (battery, uptime, and something else), trying to break that out into three separate deltas so they can be displayed in Instrument Panel. I'll dig into the JSON stuff then.
But there is one line of code in what you just added that doesn't make any sense to me:
replace.replace("$$", stringValue.c_str());
The first replace
is an instance of a String. But I don't understand the syntax of replace.replace()
.
Well the replace
is instance of string, the format text from binding object. I call replace function of string
class that will replace occurrences of "$$" from first argument with string in second argument in replace
variable that is in instance of string - man, does it even make sense? Maybe I'll rename the variable to make it more understandable.
Ah, that makes sense. I thought the two "replace" were referring to the same instance of a String, and it was some kind of String class magic.
I've managed to rename the variable replace and merging!
This update will fix issue when user is specifying color from hex. This update adds new binding property 'format' that allows user to format binding text result.
Something like:
"binding": { "format": "Depth $$ m", }
And $$ will be replaced by calculated value from SK, result will be:
Depth 4.3 m
Please test it with latest Designer - supports both of the changes. Thanks