Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Toybox.Graphics;
- import Toybox.WatchUi;
- import Toybox.Timer;
- import Toybox.System;
- class TestTimersView extends WatchUi.View {
- var timer1, timer2;
- function initialize() {
- View.initialize();
- timer1 = new Timer.Timer();
- timer2 = new Timer.Timer();
- timer1.start(method(:onTimer1Expiry), 50, false);
- timer2.start(method(:onTimer2Expiry), 5000, true);
- }
- function onLayout(dc as Dc) as Void {
- setLayout(Rez.Layouts.MainLayout(dc));
- }
- function onUpdate(dc as Dc) as Void {
- System.println("onUpdate: " + System.getTimer());
- View.onUpdate(dc);
- }
- var i = 0;
- function onTimer1Expiry() as Void {
- System.println("timer 1: " + System.getTimer());
- i++;
- if (i % 10 == 0) {
- WatchUi.requestUpdate();
- }
- timer1.start(method(:onTimer1Expiry), 50, false);
- }
- static function onTimer2Expiry() as Void {
- System.println("timer 2: " + System.getTimer());
- }
- }
Add Comment
Please, Sign In to add comment