Newbe - Silly Questions

Please Don't Laugh,

I have been playing with the Eclipse connect plugin to practice writing the code for different Data Fields, and I now have 6 different simple.mc data field files that I would like to display at once on my own layout.

Here are the stupid questions:

Do datafields need to be in their own .mc file?

I have a concept of during the get initial view - The user points the watch in a particular compass direction to store the direction once somewhere when onSelect happens..... to then be used in one of the data field calculations later on.

a.How can I store it for use for the remainder of the session from the getinitialview page

b.How do I give Data Field access to the object / variable /  whatever it is for the Data Field calculation ....... or are they both accessed from a view?

  • Each DF is actually it's own .prg file, with it's own manifest ID (a compiled piece of code).  To build a prg, it can be one or more .mc files, and depending on how you want to do things, each DF could have it's own ,mc file(s), or using shared file(s) between different DF's.

    The easiest way to start is each DF has it's own .mc file(s) and in eclipse is a separate project - so you'd have projects called df1, df2, etc for example.

    As far as the onSelect() thing, input delegates can only be used on some non-wearable devices (edge bike computers with touch screens) and then, only onTap() is available.

    Do you have a CIQ device?  if so, you might want to sideload a prg file for a DF and see how that works.  See the new developer FAQ wiki and programmer's guil;d to learn about sideloading.

  • What Jim said.  But in addition, on most wearable devices (watches) you can only use 2 data fields at a time.  On some Edge devices you can use up to 10.

    You can always use "onLap" to trigger your event code, but there will also be an actual lap recorded in the activity file.

  • Ok - First thanks for taking the time to respond. There is very little tutorials on this availble

    Conceptially is 1 DF, displaying 1 thing.... Ie it could be UTC Time, or elapsed time or distance to next waypoiint? is that 3 seperate DFs? I believe my watch supports up to 6.

    What is the purpose of the DF ?  To return a number ?

    Or can this be done in other places like View also ?

    Could I somehow output several different numbers using one DF?

    Like Time / Dist / Speed etc?

    I'm generally trying to use activity.info to refresh values on  screen once a second

  • Im also not sure in eclipse, how to I run 2 projects at one.... or do you link to the other project to get values in another project?

  • In eclipse, you an only run one DF at a time.  It sounds like you've only looked at simple data fields, where in compute() a value is returned to display.  There are also complex data fields, where they do their own drawing, and you can display a number of different things at the same time, so a single DF could display UTC, elapsed time, etc, at once.

    As far as changing, an approach I read about just the other day, is to do a change based on moving between data screens, so for example, if your data field is on screen 1, you move to screen 2, and back to screen 1 in a short amount of time, what's displayed in your data field could change.  Gar better that using the lap button and messing up the .fit file.

  • I see, are there any examples of a complex datafield in the SDK example pack that you can recomend?

    I used the simple one as a guide, which I copied to try and make an output, but nothing in the example pack is labelled complex.

    My understanding is that the code is run in seguence from the app.mc, which then starts the initial views delegate etc...

    once  a view is called in.... If there is functions inside that view and another view is called in does the functions in the initial view stop?

    If someone has any time, looking at this code, would it work? ( ignoring the { } I had to manually put spacing in there on this forum)

    using Toybox.WatchUi;
    using Toybox.System;

    class AngleOffSimpleDataField extends WatchUi.SimpleDataField {

    function initialize() {
    SimpleDataField.initialize();
    label = "Angle Off";
    }
    function compute() {

    var AO = "----";

     if(info.track != null) {
      if(info.bearing != null) {
       if(info.track >= info.bearing) {
        if(toDegrees(info.track - info.bearing) > 180) {
          var AO = 360 - toDegrees(info.track) + toDegrees(info.bearing) + "R";
          }
        if(toDegrees(info.track - info.bearing) <= 180) {
           var AO = toDegrees(info.track - info.bearing) + "L";
          }
         }
       if(info.track < info.bearing) {
         if(toDegrees(info.bearing - info.track) > 180) {
            var AO = 360 - toDegrees(info.bearing) + toDegrees(info.track) + "L";
            }
         if(toDegrees(info.bearing - info.track) <= 180) {
             var AO = toDegrees(info.bearing - info.track) + "R";
            }
         }
       }
      }
    return AO;
     }
    }

  • Thanks Jim, i'm starting to understand, when you say a single data field can display several things at once. Can you control the formatting of all the stuff to be drawn in that data field ( move the separate values around the screen ) and make it full screen with different fonts etc....

    I'm thinking that might be the better way to go, as I only really want to look at one screen when doing the activity.

    Can I add a png or bitmap to be the background, to help visually separate the values for the user?

    Lastly - to see if I'm anywhere near on the right track for conceptually how to do this, this is what I would like the app to do.

    1. On startup  display an arrow up on face, and store compass heading for use in data field calculations on a button push ( with  user facing the watch into the desired direction ), and then display second instruction screen, to save a second number value ( user input 0-60 ) on a push of button. Then show menu

    2. Set which mode ( from 2 options ) to operate the watch in ( I am guessing each mode will then display a similar but separate dataField ) 

            Basic Mode  - Show Data Screen A info, Initiate Timer and Record FIT data ( plus 1 custom field ) on push of start / stop button. with option to discard activity or save when stop is pushed

           Advanced Mode - Select between A and B Type

                Type A - Opens a Course menu, to select from a list of pre-saved Lat/Long courses from CIQ.

                    Then Loads the course, and pressing start initiates similar screen to basic mode and recording

                Type B - Allows user to store two or 3 waypoints and create a course by clicking button when at the waypoint

                    Then provides similar functional data to basic mode

    In summary - advanced mode is using waypoint data to modify the Data Field Display slightly. The Data Field will always display something in the field, it will just change what it is if there is waypoint data available.

    Regarding the Activity recording..... is the option of what to record  done separately to the datafield? But I could tell it to record one of the created fields in the data field? 

    __________________________________________________________________________________

     Lastly I understand that all FIT recordings are stuck in CIQ with time along the bottom and the data on the side.

    Is there a way in connect IQ to graph some custom thing  both on the bottom and the side

    If not - Is there a way to control and record over a single FIT time data field, so that for example I only ever write data from time = 0 seconds to time = 359, and can overwrite the custom value that is stored against the seconds. Then zoom in in connect IQ to see the values required over a semi custom X axis? 

    Or simpler but not as effective......... Store an array that continually updates a list of has Max values array from 0 - 359, and the FIT data looks at the corresponding array value per second , looping... ie   Time =1 second, data = array index [1], Time = 2, data = array index[2]...

    Time = 360, array = 0, time = 361 array = 1.....

    By the end of the activity I would have a 360 second time period I could zoom into to get the info 

  • You can't see button presses in a data field as you propose. 

    In Eclipse, do a File>New>Connect IQ Project, and set the app type to be a Data field. and when asked "simple" or "complex", select complex