Hi,
I am new at this!!!
I am trying to use Timer object in a WatchUi.WatchFace view, but I getting a runtime error in the line "timer1.start( method(:xcallback1), 5000, true );".
Details bellow.
Here is my source code of my view:
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.Timer as Timer;
var timer1;
class WatchFace1View extends Ui.WatchFace {
function xcallback1()
{
var x = 1;
//Ui.requestUpdate();
}
//! Load your resources here
function onLayout(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() {
var timer1 = new Timer.Timer();
timer1.start( method(:xcallback1), 5000, true );
}
//! Update the view
function onUpdate(dc) {
dc.setColor( Gfx.COLOR_BLACK, Gfx.COLOR_BLACK );
dc.clear();
dc.setColor( Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT );
dc.drawText( 0, 0, Gfx.FONT_NUMBER_THAI_HOT, "Test", Gfx.TEXT_JUSTIFY_LEFT );
}
//! Called when this View is removed from the screen. Save the
//! state of this View here. This includes freeing resources from
//! memory.
function onHide() {
timer1.stop();
}
//! The user has just looked at their watch. Timers and animations may be started here.
function onExitSleep() {
}
//! Terminate any active timers and prepare for slow updates.
function onEnterSleep() {
}
}
Here is the console output when runs
Found Transport: tcp
Connecting...
Connecting to device...
Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0
Copying file.... 3% complete
Copying file.... 6% complete
Copying file.... 10% complete
Copying file.... 13% complete
Copying file.... 17% complete
Copying file.... 20% complete
Copying file.... 23% complete
Copying file.... 27% complete
Copying file.... 30% complete
Copying file.... 34% complete
Copying file.... 37% complete
Copying file.... 41% complete
Copying file.... 44% complete
Copying file.... 47% complete
Copying file.... 51% complete
Copying file.... 54% complete
Copying file.... 58% complete
Copying file.... 61% complete
Copying file.... 65% complete
Copying file.... 68% complete
Copying file.... 71% complete
Copying file.... 75% complete
Copying file.... 78% complete
Copying file.... 82% complete
Copying file.... 85% complete
Copying file.... 89% complete
Copying file.... 92% complete
Copying file.... 95% complete
Copying file.... 99% complete
Copying file.... 100% complete
File pushed successfully
Connection Finished
Closing shell and port
Found Transport: tcp
Connecting...
Connecting to device...
Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0
Failed invoking <symbol>
Permission Required
in onShow (C:\_pjnr\Eclipse\workspace\WatchFace1\source\WatchFace1View.mc:24)
in onShow (C:\_pjnr\Eclipse\workspace\WatchFace1\source\WatchFace1View.mc:24)
Permission Required
Tried several variantions without luck.
Does anyone knows what this is about?
Best regards,
Paulo Reis