What does this error screen mean?

Hi,

I'm writing a data field, but am running into problems. My data field seems to run well, but sometimes I get this error screen:


What does it mean and how can I fix it?

Thanks in advance!
Lorenzo
  • With the circ buffer, it can be sped up once you have a total for all 10 elements. (lets say the total is 2500)

    when you are going to replace, say, the 3rd element, subtract it's value from the 2500 (say 35), and add the value of the replacement (say 45). You'd have the new total (2510) without adding everything up again.

    When you are building the initial 10 your total would start at 0, and as you add an element, you add it to the current total. So you never have to run down the array and add everything up. You keep a running total of what's in the array. With 10 items it might not be a big issue, but if you used 1000 samples, you'd save a boatload of processor!


    Interesting concept. I'll explore further (u can tell from this response that I have no idea how to implement this but I'll google - at least u planted the idea (some would say - u "inception")
  • Actually Nike, it's not a concept. It's a perspective, In the "add up all entries often and divide by 10" approach, its what you would do in your life if given 10 numbers to average

    The "running total" approach is if you've been programming for a while, and are handed each of the 10 numbers one at a time. and see a way you never have to add them all up to get an average. You keep a "running total" when something is added or removed, and 10 "adds" plus a divide is now jut one divide.

    And to be honest, the perspectives can really impact how fast things happen in a program Imagine if it was 1000 elements and not 10...

    Both appraches work, it's just there is a difference in the time it takes to do the same thing
  • hmm.. you can tell english is not my native tongue.
    When I said concept - I meant approach or idea or whatever is the correct term.
    I didn't think of it and I didnt know such an approach / idea etc was there already.

    but I undersrtand that you're saying and the concept of how to do it, but alas, i dont (already) know how to do it (yet)

    :-p

    Thanks for the idea. Will be something to think / compare . (if not for the 10s pace but the 30s pace perhaps)
  • I have a bit of time today, and will try to show an example later!

    Ok, here is a sample. It's simple, and what it does is to use a timer to add data very few seconds, with the value added being a random number between 0 and 100. The array of 10 values is initialized to all zeros, and "addValue()" is where everything is done.

    using Toybox.WatchUi as Ui;
    using Toybox.Math as Math;
    using Toybox.Graphics as Gfx;
    using Toybox.System as Sys;

    class easyAvgView extends Ui.View {

    var timer;
    //the values to be averaged
    var values=[0,0,0,0,0,0,0,0,0,0];
    var valuesMax=10; //10 values
    var valuesUsed=0; //how many of valuesMax are used
    var valuesNext=0; //where to but next value;
    var valuesTotal=0; //running total of values
    var valuesAvg=0; //current avg of values

    function initialize() {
    timer = new Timer.Timer();
    //have time run to provide values
    timer.start( method(:onTimer), 1000*10, true );
    }

    function onTimer() {
    //randowm number between 0 and 100
    var num = Math.rand()%100;
    addValue(num);
    }


    //! Update the view
    function onUpdate(dc) {
    dc.setColor(Gfx.COLOR_BLACK,Gfx.COLOR_BLACK);
    dc.clear();

    dc.setColor(Gfx.COLOR_WHITE,Gfx.COLOR_TRANSPARENT);
    dc.drawText(dc.getWidth()/2,10,Gfx.FONT_LARGE,"avg="+valuesAvg.format("%.2f")+"\nwith "+valuesUsed+" values",Gfx.TEXT_JUSTIFY_CENTER);

    }

    function addValue(num) {
    //
    //update the running total
    // this is how you avoid adding everything up for an average
    //
    //subtract value being replaced and add in new value
    valuesTotal=valuesTotal-values[valuesNext]+num;

    //store new one
    values[valuesNext]=num;

    //
    // manage the circural buffer
    //
    //inc index for next location
    valuesNext++;

    //circle back to beginning if needed
    if(valuesNext==valuesMax) {
    valuesNext=0;
    }

    //
    // values used will max out at 10 in this example, but will be less
    // than that as the values are first being populated
    //
    if(valuesUsed<valuesMax) {
    //was less than max
    valuesUsed++;
    }

    valuesAvg=(valuesTotal*1.0)/valuesUsed;

    Sys.println("used="+valuesUsed.format("%2d")+" next="+valuesNext.format("%2d")+" added="+num.format("%3d")+" total="+valuesTotal.format("%4d")+" avg="+valuesAvg.format("%.2f"));

    //
    // just so it's shown in the simulator
    //
    Ui.requestUpdate();
    }

    }