I don't like SimpleDataField, and I want create "DataField" code, that have more than 6 DataFields in one Screen,but I don't understand how to I do ,may be you can tell me .Thanks.
another question:
In SimpleDataField,how can I use DC ?
these code ,the function onUpdate(dc) is not using , why ?
using Toybox.WatchUi as Ui;
using Toybox.Application as App;
using Toybox.System as Sys;
using Toybox.Time as Time;
using Toybox.Activity as Act;
using Toybox.Graphics as Gfx;
class DataField extends Ui.SimpleDataField
{
var counter;
function initialize() {
label = "My Label";
counter = 0;
}
function onUpdate(dc)
{
dc.setColor( Gfx.COLOR_BLACK, Gfx.COLOR_BLACK );
dc.clear();
dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );
System.println("DC is here");
}
//! Handle the update event
function compute(info)
{
var value_picked = null;
//Cycle between Heart Rate (int), Distance (float), and elapsedTime (Duration)
if( counter == 0 )
{
if( info.currentHeartRate != null )
{
value_picked = info.currentHeartRate;
}
}
if( counter == 1 )
{
if( info.elapsedDistance != null )
{
value_picked = info.elapsedDistance * 0.000621371; //Meters to Miles
}
}
if( counter == 2 )
{
if( info.elapsedTime != null )
{
//elapsedTime is in ms.
var options = { :seconds => (info.elapsedTime / 1000) };
value_picked = Time.Gregorian.duration( options );
}
}
counter += 1;
if( counter > 2 )
{
counter = 0;
}
return value_picked;
}
}
//! main is the primary start point for a Monkeybrains application
class SimpleDataField extends App.AppBase
{
function onStart()
{
return false;
}
function getInitialView()
{
return [new DataField()];
}
function onStop()
{
return false;
}
}