03-07-2023 10:29 - edited 03-07-2023 10:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-07-2023 10:29 - edited 03-07-2023 10:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Sense and Versa 3 devises.
I am trying to randomly update the background on my watchface everyday at midnight. If the display is on at midnight everything works fine, but if the display is off, which I would assume it would be, in most cases, the background does not update. I have tried to implement the display.poke() to force the display on so it will update but it does not seem to do anything, at least not in the simulator. I have not installed it on an actual device to test yet. Any help? Here is the code in use. It is the } else { statement at the end that does not seem to work. It does not log the console or anything almost like because the screen is off it does not initiate the script.
Answered! Go to the Best Answer.

Accepted Solutions
03-07-2023 11:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-07-2023 11:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Unless there's some context I'm not seeing, that code will run once when the clockface starts, and not again.
There are a few solutions. Presumably you have an ontick event listener function somewhere (eg, to update the displayed time). That listener will be executed whenever the display comes on, and every second or minute while it remains on. You could test the date in that function and update the background if a change is detected. Note that you won't want to base that test on the time.
An alternative would be to use setTimeout() to arrange for a function to be called after a period of time that you calculate. You could make this happen at midnight even if the display is off, and it wouldn't involve testing the date in every ontick(). But it would involve some maths!
Gondwana Software
03-07-2023 11:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-07-2023 11:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Unless there's some context I'm not seeing, that code will run once when the clockface starts, and not again.
There are a few solutions. Presumably you have an ontick event listener function somewhere (eg, to update the displayed time). That listener will be executed whenever the display comes on, and every second or minute while it remains on. You could test the date in that function and update the background if a change is detected. Note that you won't want to base that test on the time.
An alternative would be to use setTimeout() to arrange for a function to be called after a period of time that you calculate. You could make this happen at midnight even if the display is off, and it wouldn't involve testing the date in every ontick(). But it would involve some maths!
Gondwana Software
03-07-2023 13:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-07-2023 13:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes, I have the clock.ontick running in the index.js. The schedule.update is where the above code comes from. Would I build the setTimeout() in the clock.ontick or in the schedule.js?

03-07-2023 13:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-07-2023 13:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
I'd probably call schedule.update() at startup, and then configure a setTimeout() in there to call it again after the required interval. That way, you wouldn't need to call it at all from within your ontick handler, which is good for efficiency.
Gondwana Software
03-21-2023 11:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-21-2023 11:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
display.poke() is still not working but I ended up using the setInterval method to call the schedule every 15 minutes but to only run if (hours == 0 && (mins <= 15)). That is working like a charm. Thanks for the poke in the right direction. Pun intended.
