i would like a small text widget to show the phone "on time"
please help
time since boot widget - how to do that?
Moderator: Martin
Re: time since boot widget - how to do that?
Hi,
You can either use the function getUptimeMillis() in a script to get the milliseconds since boot, not counting time spent in deep sleep or you can use getElapsedRealtimeMillis() to get the overall millis since boot, including time spent in sleep.
You could use a script like this in a text element of a widget to show the duration in a more human readable format:
{getDurationString(getUptimeMillis())}
..or like this to strip off the seconds and milliseconds of the duration:
{getDurationString(getUptimeMillis()/60000*60000)}
You can also use function setWidgetElementProperty to update a text element of a widget from within a script. This could be useful when you want to show the duration in a custom format.
Regards,
Martin
You can either use the function getUptimeMillis() in a script to get the milliseconds since boot, not counting time spent in deep sleep or you can use getElapsedRealtimeMillis() to get the overall millis since boot, including time spent in sleep.
You could use a script like this in a text element of a widget to show the duration in a more human readable format:
{getDurationString(getUptimeMillis())}
..or like this to strip off the seconds and milliseconds of the duration:
{getDurationString(getUptimeMillis()/60000*60000)}
You can also use function setWidgetElementProperty to update a text element of a widget from within a script. This could be useful when you want to show the duration in a custom format.
Regards,
Martin
Re: time since boot widget - how to do that?
beautiful
is there a list of commands we can use in widgets somewhere?

Re: time since boot widget - how to do that?
You can use all functions documented in action Script (scroll down a bit to section Functions, also check out section String Inline Expressions).
However I would recommend to only use very simple inline scripts directly in a text element since it can become unreadable quite fast when nested function calls are involved. When you want to make more complex calculations I would recommend to move the function to a flow and to call setWidgetElementProperty to update the text on the widget. This method is also way more powerful since you can change every property of an element like color, size and position and not just the text.
The widget tutorial lists some ideas in the Tips section at the end of the tutorial.
However I would recommend to only use very simple inline scripts directly in a text element since it can become unreadable quite fast when nested function calls are involved. When you want to make more complex calculations I would recommend to move the function to a flow and to call setWidgetElementProperty to update the text on the widget. This method is also way more powerful since you can change every property of an element like color, size and position and not just the text.
The widget tutorial lists some ideas in the Tips section at the end of the tutorial.
Re: time since boot widget - how to do that?
Looks great! Would you like to share the flows and the widget?orenmi wrote:beautiful![]()
Re: time since boot widget - how to do that?
widget attached.