SimpleDataField: not possible to return and display String-Value in Simulator

At the moment I try to use SimpleDataField to return and display a pace value.

class ExactCurrentPace extends Ui.SimpleDataField and method compute(info).

It's possible to return a Integer or Float and simulate the output in the simulator (920xt, square watch).
But it's not possible to return a String-Value (<min>:<sec> e.g. "5:32"). Or the value is returned and
not displayed in the Simulator. To display the Label works fine, but when i return a String the rest of the screen is black.

In the Monkey C documentation i found the following description for SimpleDataField:
"The compute method should return a value to be displayed. Allowed types are Number, Float, Long, Double, and String."

Any ideas?

Coding:

using Toybox.WatchUi as Ui;
using Toybox.Application as App;
using Toybox.System as Sys;
using Toybox.Time as Time;

class ExactCurrentPace extends Ui.SimpleDataField
{

//! Constructor
function initialize()
{
label = "Pace value";
}

//! Handle the update event
function compute(info)
{

return 0.00; // works fine, label and value are displayed in simulator
// return "test" // doesn't work, label is displayed, String not
}
}

//! main is the primary start point for a Monkeybrains application
class SimpleDataField extends App.AppBase
{
function onStart()
{
return false;
}

function getInitialView()
{
return [new ExactCurrentPace()];
}

function onStop()
{
return false;
}
}
  • Former Member
    Former Member over 10 years ago
    This bug in the simulator has already been reported. The forum search is a good starting point if you get a problem.
  • Former Member
    Former Member over 10 years ago
    The String display is not functional in the current version of the ConnectIQ simulator (0.2.4).

    For displaying pace values, I recommend returning a duration value, which is the built in type for displaying a time value (XX:XX) in a simple data field. The simple data field sample in the SDK has an example of this.
  • Brian,

    According to the documentation, a duration value cannot be returned from compute(). The example is clearly returning a Duration.

    What types are actually supported?
  • Former Member
    Former Member over 10 years ago
    Well, you are correct... Duration is the only type that was missed in the documentation. I'll try to make sure it gets added.
  • The String display is not functional in the current version of the ConnectIQ simulator (0.2.4).


    +1 for getting this fixed asap.
    I was looking at creating a SimpleDataField that display the current location as a grid reference displayed as a string, and without this support in the simulator testing is all but impossible.
  • Former Member
    Former Member over 10 years ago
    +1 for getting this fixed asap.
    I was looking at creating a SimpleDataField that display the current location as a grid reference displayed as a string, and without this support in the simulator testing is all but impossible.


    When the app store goes live, I wonder how many OS grid reference apps we'll see?! I've already written one, for starters :)
  • Did you create an app? What features have you implemented?
    I was just planning on creating a simple DataField for it.
    Are you planning on open sourcing it? Care to share a GitLab repo?
  • I was looking at creating a SimpleDataField that display the current location as a grid reference displayed as a string, and without this support in the simulator testing is all but impossible.


    It is not impossible. As mentioned above, you can (temporarily) implement a regular DataField with an onUpdate() method to render the text as you see fit. When this bug is fixed, you just change the name of the class that you extend and rip out the unnecessary code. Another option that is much simpler would be to use Sys.println(...) to display your grid reference information every time a new value is computed.
  • Former Member
    Former Member over 10 years ago
    Did you create an app? What features have you implemented?
    I was just planning on creating a simple DataField for it.
    Are you planning on open sourcing it? Care to share a GitLab repo?


    I've written 2 apps for gridrefs - a simple DataField app, and a Widget with some additional features. Don't think something so small & simple really needs a git project? It should just work.