How to add battery and tempe data to datafield?

Former Member
Former Member
I'm creating a datafield to display all the info I like to see in a custom display, but would also like to be able to view the battery percent and temperature in the corners of the display.
I can see the computer(info) function is passed an Activity.Info object, which I shall be using for all my speed/time data, but it doesn't contain either battery or temperature. So in theory I shouldn't be able to, yet I have seen it working in some third party datafields, such as:

Graphic Cycling Dashboard with Power Meter, by QQSTARS
https://apps.garmin.com/en-US/apps/28cc09d4-1398-4356-a233-65c57a00d585

My EDGE, by Stanislav Bures
https://apps.garmin.com/en-US/apps/4262c271-a0b7-4e7b-abc6-b9527668b027

Charts, by Stanislav Bures
https://apps.garmin.com/en-US/apps/f93c3c35-ce80-4758-9714-bd5b6b33cc61


Any ideas please?
  • Temperature isn't available to data fields (no access to Sensors, and that's where you can get it), unless you want to do your own ANT+ calls.

    Battery, is easy though..

    In the data filed, you just need to use Sys.getSystemStats().battery
  • Former Member
    Former Member over 8 years ago
    You can get the battery percentage like so:
    var batPct = Toybox.System.getSystemStats().battery;
  • Former Member
    Former Member over 8 years ago
    6374

    You can get the battery percentage like so:
    var batPct = Toybox.System.getSystemStats().battery;


    That sounds good - I'll try it tonight! Don't suppose there's a similar trick for temperature? I do realise it may be trickier due to having to use a sensor..
  • Former Member
    Former Member over 8 years ago
    Temperature isn't available to data fields (no access to Sensors, and that's where you can get it), unless you want to do your own ANT+ calls.

    Battery, is easy though..

    In the data filed, you just need to use Sys.getSystemStats().battery


    Doh - missed this post. Thanks for the info!
    Looks like I'll just have to go without.

    I wonder how the standard temperature datafield does it..
  • I wonder how the standard temperature datafield does it..


    It's not CIQ and has access to it. Like I said, in CIQ it's in sensors, which you can't access in a DF. You can in a widget or watch-app though..
  • Former Member
    Former Member over 8 years ago
    Thanks Jim! A font of knowledge :)
  • That sounds good - I'll try it tonight! Don't suppose there's a similar trick for temperature? I do realise it may be trickier due to having to use a sensor..


    You could use the MoxyDataField sample project as a guide for adding the Tempe as a Generic Ant channel. It would require a few mods, but the principle is all there. It also shows how to save the data in the FIT file.