charging attribute accesible since SDK 3.0.0 acording to docs but I get in SDK 2.4.9

Hi,

I can read in SDK docs that charging attribute, from System.getSystemStats(), is ready since SDK 3.0.0 (https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/System/Stats.html#charging-instance_method), but I have a FR 735XT with 2.4.9 SDK version and I have wrote a widget that can access this attribute.

The widget is this: https://apps.garmin.com/us-EN/apps/47f0e3cc-16ad-41c2-b0cc-bb34efec9e6c

Could I know what's the minimum SDK version when charging attribute can be accessed?

Many thanks,
  • Use what's stated in the API documentation (3.0.0) if you want to know all devices that support it. There are times that things might be there in earlier versions of FW (as it appears "changing" is on the 735). What you can do is use "has" to see if it's available on the device. "has" is expensive, so I do my "has" checks for things at startup then set a boolean, and the just check the boolean.
  • Use what's stated in the API documentation (3.0.0) if you want to know all devices that support it. There are times that things might be there in earlier versions of FW (as it appears "changing" is on the 735). What you can do is use "has" to see if it's available on the device. "has" is expensive, so I do my "has" checks for things at startup then set a boolean, and the just check the boolean.


    Thanks. Yes, I always use "has" to ensure something is available.

    I use "has" when I need, and It should be inside compute() function, every iteration. So I'll rewrite my code to do it inside initialize() and get a lighter app, many thanks for this.
  • "has" has to look at a dictionary to see if something is there, so it's not a simple thing. That's why I do that in initialize. Its' the same with things like reading the object store and settings. Read those at startup, or in the case of settings, onSettingChanged, so it doesn't have to keep getting things based on a key, or re-reading things that haven't changed. Every little bit helps when you're looking at performance! :)
  • The version listed in the documentation is the version that the feature should be integrated by. Depending on the type of feature, it could get enabled earlier than advertised. But, as Jim suggests, you should follow what the documentation says.