Black screen on app launch

Hi Devs !

I've been working on this for hours and can't figure out a way out ...

I'm developping an app (improved watchface with some webrequests). All is fine on the sim, grab of info and display are working just fine but once the app is installed and run on the watch, I only get black screen. No IQ! nor other debug info.

App is made of the app istelf, a background service (to trigger the webrequest every 10 mn), a view and the webrequest part.

Any help would be very much appreciated.

Ced 

  • class CedWatchFaceView extends WatchUi.View {

    function initialize() {

    View.initialize();

    }

    // Load your resources here
    function onLayout(dc as Dc) as Void {

    //setLayout(Rez.Layouts.View(dc));

    }


    // Called when this View is brought to the foreground. Restore
    // the state of this View and prepare it to be shown. This includes
    // loading resources into memory.

    function onShow() as Void {

    }

    function onUpdate(dc) as Void {

    View.onUpdate(dc);
    dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
    dc.drawLine(0, 95, 416, 95);
    dc.drawLine(0, 96, 416, 96);
    dc.drawLine(0, 173, 416, 173);
    dc.drawLine(0, 174, 416, 174);

    garmin = WatchUi.loadResource(Rez.Fonts.garmin);

    dc.drawText(250, 100, garmin, "⌂", Graphics.TEXT_JUSTIFY_CENTER);
    dc.drawText(155, 100, garmin, "╠", Graphics.TEXT_JUSTIFY_CENTER);
    dc.drawText(300, 100, garmin, "╚", Graphics.TEXT_JUSTIFY_CENTER);
    dc.drawText(200, 140, Graphics.FONT_XTINY, Application.Storage.getValue("myDatatext"), Graphics.TEXT_JUSTIFY_CENTER);

    //fetch date, time, system stats, activities, weather, userprofile
    //var clockDate = Time.Gregorian;

    var clockTime = System.getClockTime();

    //time
    var hourtimeString = Lang.format("$1$", [clockTime.hour.format("%02d")]) + ":";
    var minutetimeString = Lang.format("$1$", [clockTime.min.format("%02d")]);
    dc.drawText(168, 160, Graphics.FONT_NUMBER_MEDIUM, hourtimeString, Graphics.TEXT_JUSTIFY_CENTER);
    dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);
    dc.drawText(263, 160, Graphics.FONT_NUMBER_MEDIUM, minutetimeString, Graphics.TEXT_JUSTIFY_CENTER);

    //date
    //var monthDateString = Lang.format("$1$", [clockDate.month.format("%02d")]);
    dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
    var today = Gregorian.info(Time.now(), Time.FORMAT_MEDIUM);
    var dateString = Lang.format("$1$ $2$", [today.day, today.month]);
    dc.drawText(210, 250, Graphics.FONT_SMALL, dateString, Graphics.TEXT_JUSTIFY_CENTER);


    // Call the parent onUpdate function to redraw the layout
    //View.onUpdate(dc);
    }


    function onHide() as Void {
    }

    // The user has just looked at their watch. Timers and animations may be started here.
    function onExitSleep() as Void {
    $.webrqst();
    }

    // Terminate any active timers and prepare for slow updates.
    function onEnterSleep() as Void {

    }

    }

  • i've checked indents and they should be ok ...as for line numbers I've got no solution ...

  • Ok, to start, as you're not using layouts, you don't need the View.onUpdate().

    Then you set the color to COLOR_WHITE, COLOR_TRANSPARENT, and draw some lines.  If the background is already WHITE, you won't see the lines

    Do something like

    dc.setColor(Graphics.COLOR_BLACK,Graphics.COLOR_BLACK);

    dc.clear();

    before the setColor you have

    In onEnterSleep() and onExitSleep(), you want to use a flag to indicate if you are in low power or not. (onEnterSleep() indicates you are in low power, where what you can do on a AMOLED device is very limited).  In the sim, you can toggle this with Settings>Low Power Mode. On as real device, these calls happen based on something like a gesture or a tap, and the device only drops out of low power for 10 seconds or so.  Most of the time you'll be in low power.

    Comment out your onUpdate() and try this.  You should see a white "Hello" at 100,100


    function onUpdate(dc) {
        dc.setColor(Graphics.COLOR_BLACK,Graphic.COLOR_BLACK);
        dc.clear();
        dc.setColor(Graphics.COLOR_WHITE,Graphics.COLOR_TRANSPARENT);
        dc.drawText(100,100,Graphics.FONT_SMALL,"Hello",Graphics.TEXT_JUSTIFY_CENTER);
    }

  • OK achieved this ! thanks ! Playing with the onEnterSleep(); now ...

  • Settings>Low Power Mode is greyed out ... 

  • So it'a not a watch face but a device app? No onEnterSleep or onExitSleep in a device app, and you must trigger your own screen updates with WatchUi,requestUpdate calls, often with a timer.

  • ha ok starting to figure that out ... I tried to build a watchface with webrequest but ended up with a "toybox.communications not available for watchfaces" ... therefore I headed to an app instead ... Do you have by any chance an example of timer that will trigger WatchUi.Update calls ? At the utmost, I'd like to have a refresh each and every time I look at the watch (could be within 5 mn up to 2 hours ...)

  • You can do makeWebRequest calls in the background service of a watch face.

    With a timer, I usually create/start them in the view's initialize.

    		var timer= new Timer.Timer();
    		timer.start( method(:onTimer), 1000, true );

    With a callback like this:

    function onTimer() {WatchUI.requestUpdate();}

    (add type checking stuff if needed)

    The timer will fire once a second and onUpdate() will be called.

  • Ho sounds great ... Test it right now ! Thanks for your help

  • I'm still struggling with the Communications permission when moving from app to watch face ... the webrequest is after a (:background) tag. Isn't it sufficient enough ? What do you mean by "in the bg service of a watch face" ???