Acknowledged
CIQQA-3115

bug: System.getSystemStats().battery is Number instead of Float

According to the docs: Toybox.System.Stats.battery as Float, but on real fr965 it is a Number or at least it's value is always a Number (without decimal).

function initialize() {
    session = ActivityRecording.createSession({
	 	:name => "test",
	 	:sport => Activity.Sport.SPORT_RUNNING,
	 	:subSport => Activity.SubSport.SUB_SPORT_TREADMILL
	});
    batteryPercentageField = session.createField("battery", 11, FitContributor.DATA_TYPE_FLOAT, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "%" });
}

function compute() as Void {
    batteryPercentageField.setData(System.getSystemStats().battery);
}

Parents
  • I created a simple data field with the following compute function:

    function compute(info as Activity.Info) as Numeric or Duration or String or Null {
        var battery = System.getSystemStats().battery;
        return "" + (battery instanceof Float) + " " + battery.toString();
    }

    The output in the sim (fr955) is:

    true 50.000000

    The output on a real fr955 (with latest beta firmware) is:

    true 94.000000

    So it looks to me like:

    - both the sim and the real device return a literal Float (the sim allows you to set the fractional part to non-zero, in Settings > Battery Status)

    - even though the device returns a Float, the fractional part is *probably* always zero. (If I ever observe a battery level with a non-zero fractional part, I'll post back)

Comment
  • I created a simple data field with the following compute function:

    function compute(info as Activity.Info) as Numeric or Duration or String or Null {
        var battery = System.getSystemStats().battery;
        return "" + (battery instanceof Float) + " " + battery.toString();
    }

    The output in the sim (fr955) is:

    true 50.000000

    The output on a real fr955 (with latest beta firmware) is:

    true 94.000000

    So it looks to me like:

    - both the sim and the real device return a literal Float (the sim allows you to set the fractional part to non-zero, in Settings > Battery Status)

    - even though the device returns a Float, the fractional part is *probably* always zero. (If I ever observe a battery level with a non-zero fractional part, I'll post back)

Children
No Data