create a clock in a scene

466 views
Skip to first unread message

Richard Wallace

unread,
Feb 2, 2015, 6:06:06 PM2/2/15
to tas...@googlegroups.com
Is it possible to create a clock in a scene, that updates (obviously!)
The way I can think is to have a wait of 60 seconds in a task?
But would this drain battery?

Jay M

unread,
Feb 2, 2015, 6:09:33 PM2/2/15
to tas...@googlegroups.com

This was asked before ages ago, try a search of the group might find some half decent info in the thread.


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Richard Wallace

unread,
Feb 3, 2015, 4:38:19 AM2/3/15
to tas...@googlegroups.com
Ive searched and found only answers from years ago, that werent a great solution.
Has anyone come up with a better solution.
 
@Pent...i read that you were going to look at changing %TIME into a dynamic variable? Any progress
 
 
 

On Monday, 2 February 2015 23:09:33 UTC, Jay M wrote:

This was asked before ages ago, try a search of the group might find some half decent info in the thread.


On Mon, 2 Feb 2015 23:06 Richard Wallace <richiew...@googlemail.com> wrote:
Is it possible to create a clock in a scene, that updates (obviously!)
The way I can think is to have a wait of 60 seconds in a task?
But would this drain battery?

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.

Richard Wallace

unread,
Feb 4, 2015, 11:18:36 AM2/4/15
to tas...@googlegroups.com
bump
Any ideas / sugestions?

Marta Hintz

unread,
Feb 4, 2015, 2:10:40 PM2/4/15
to tas...@googlegroups.com
If you look in the online help file in Tasker with Time you will see that it is already a variable (at least in the profile when selecting Time).  is that what you are meaning? You just need to click on the wavy arrows.  
online help file is opened up when you select the 3 dots in the top right menu.  Usually something is written there pertinent to the screen or action you have selected.  

Marta

Richard Blackmore

unread,
Feb 4, 2015, 5:19:27 PM2/4/15
to tas...@googlegroups.com
Use a webview in a scene with a JavaScript clock .. Loads of source code on the web copy and paste

Richard Wallace

unread,
Feb 5, 2015, 8:10:21 AM2/5/15
to tas...@googlegroups.com
yes i know time is a variable!
i am looking for a way to display a clock in a scene, i,e. have it update!
Otherwise it will stay at the time the scene is opened and not change every minute!

Jeremy Harris

unread,
Feb 5, 2015, 4:49:28 PM2/5/15
to tas...@googlegroups.com
Richard Blackmore probably has the most efficient approach to this.

How often are you trying to update the scene, minutes or seconds?

Richard Wallace

unread,
Feb 5, 2015, 5:03:24 PM2/5/15
to tas...@googlegroups.com
Just looking to update every minute.
I've found a basic JavaScript that'll do it.
Whatnim struggling with now is to apply styles to it?
Anyone abkento help?
Just looking to change size, font and font colour really. Oh and position.

Jeremy Harris

unread,
Feb 5, 2015, 5:19:49 PM2/5/15
to tas...@googlegroups.com
You could probably style it with regular html if you go down the Web View path, and embed the JavaScript.

Richard Wallace

unread,
Feb 5, 2015, 5:53:15 PM2/5/15
to tas...@googlegroups.com
Could you guide me here Jeremy, I'm at a loss?!

Jeremy Harris

unread,
Feb 5, 2015, 7:34:12 PM2/5/15
to tas...@googlegroups.com

I would love to really help you, and return the favor for what I've soaked up from reading some of your posts. I'm not an expert on html or Javascript, but i gave myself a crash course recently while working on a project...so I hesitate because I don't want to steer you wrong.

Here's a link to a source that i found very helpful and a good example of what I think you're trying to do:

http://www.w3schools.com/js/default.asp

http://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_style

<!DOCTYPE html>
<html>
<body>

<h1>What Can JavaScript Do?</h1>

<p id="demo">JavaScript can change the style of an HTML element.</p>

<script>
function myFunction() {
    var x = document.getElementById("demo");
    x.style.fontSize = "25px";          
    x.style.color = "red";
}
</script>

<button type="button" onclick="myFunction()">Click Me!</button>

</body>
</html>

Jeremy Harris

unread,
Feb 5, 2015, 7:50:42 PM2/5/15
to tas...@googlegroups.com

Here's a description of a scene I use a Web View element to have JavaScript process a bunch of calculations for me:

Scene: Sun_and_moon
P:480x720 L:1x1

Orientation: System
Background Colour: #00FFFFFF
Action Bar Style: System
Title: Sun_and_moon
Subtitle:
Icon: null
Tab Labels:

Element: WebView1/WebView
Geometry:
P:0,0 1x1 L:1,1 1x1
Content:
Mode: URI
Source: file://%path%query
Allow Phone Access: On
Self Handle Links: Off
App Cache API: Off
DB API: Off
Events:
PageLoaded: 272

And here's an example of how I use it in a task:

A13: Variable Set [ Name:%path To:/storage/emulated/0/HuntingTimes/sun_moon.html Do Maths:Off Append:Off ]
A14: Variable Set [ Name:%query To:?Place='%city'&Lat=%lat&Long=%long&TZ=-5&TZname='EST'&Year=%year&Month=%month&Day=%day Do Maths:Off Append:Off ]
A15: Show Scene [ Name:Sun_and_moon Display As:Overlay Horizontal Position:0 Vertical Position:0 Animation:System Show Exit Button:Off Continue Task Immediately:On ]
A16: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A17: Destroy Scene [ Name:Sun_and_moon ]
A18: Return [ Value:%srise|%sset|%mnrise|%mnset|%mnphasedegstart|%mnphasepctstart|%mnphasedegend|%mnphasepctend Stop:On ]

Richard Wallace

unread,
Feb 6, 2015, 6:11:27 AM2/6/15
to tas...@googlegroups.com
Thanks Jeremy.
 
I actually figured it out.
 
I was over thinking it!
Its a simple as setting the style in a style sheet with css and then referencing that in the div container for the clock!
This is just proof of concept, so will be tidying it up a bit later to make it look all pretty!
 

<html>
<style type="text/css">

.otto {
font: bold 70px Roboto;
margin: 0;
padding: 0px;
color: #5f6062 ;
vertical-align: middle;
text-align: center;
}

.text{
font-family: "Roboto Condensed";
font-weight: 300;
font-size: 70px;
line-height: 30px;
text-align: center;
vertical-align: middle;
color: #5f6062;
padding: 10px;
}

</style>
<script type="text/javascript">
function GetClock(){
var d=new Date();
var nhour=d.getHours(),nmin=d.getMinutes();
if(nmin<=9) nmin="0"+nmin

document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+"";
}

window.onload=function(){
GetClock();
setInterval(GetClock,1000);
}
</script>

<body>
<div id="clockbox" class="text"></div>
<hr width="60%">
</body>
</html>

Jeremy Harris

unread,
Feb 6, 2015, 11:10:28 AM2/6/15
to tas...@googlegroups.com
Thanks Jeremy.

I actually figured it out.

Great!!

EW

unread,
May 29, 2015, 5:28:16 PM5/29/15
to tas...@googlegroups.com
I actually happened upon this thread and did a little research.

Using a webview element you can use source from these:
http://www.ricocheting.com/code/javascript/html-generator/date-time-clock you can use the page to generate a simple clock.  You may be able to tailor it a bit if you are adventurous. 
http://www.timeanddate.com/clocks/free.html - there are options for fancier clocks.  

In the webview, I set the mode to direct.  I did limited experimentation with the second and found that it worked better after a reboot if I checked the "self handle links" button.  I have no idea what that does or why it should work, but I just wanted to pass that on.

I don't know what the impact would be on battery life if the scene was to be displayed for any length of time.
Reply all
Reply to author
Forward
0 new messages