XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 7th, 2025, 11:47 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: December 9th, 2013, 11:41 am 
Offline
User avatar

Joined: June 12th, 2012, 11:05 am
Posts: 257
Location: Barcelona
I could not run the remaining battery time ( ${LifeTime} )...
Any idea why this happens?
Thanks!


Top
 Profile  
 
PostPosted: December 10th, 2013, 9:15 am 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
i don't have battery to test it,
but i think you could use "%LifeTime" instead

when i use "${LifeTime}" i don't get anything
but when i use "%LifeTime" i will get 00:00
as i said i don't have battery to be sure

maybe it doesn't converted to new format yet
or there is a problem with new formatting


Top
 Profile  
 
PostPosted: December 11th, 2013, 6:28 am 
Offline
User avatar

Joined: June 12th, 2012, 11:05 am
Posts: 257
Location: Barcelona
Thanks Hamid!! Its works!!!!!


Top
 Profile  
 
PostPosted: December 17th, 2013, 5:49 am 
Offline
User avatar

Joined: June 12th, 2012, 11:05 am
Posts: 257
Location: Barcelona
When XWidget restarts,
%LifeTime change to ${LifeTime}
But seems it's work anyway. It's a bit slow to change... but... works.

Unfortunately:
1) shows the minutes not divided in hours (eg.: 157 minutes) ... (do not know how you become with code to hours and minutes ...).
2) when the power cord is plugged in (and the battery is charging) does not show the minutes of charging (shows 00:00)

Tony: batterycore should improve! thanks!


Top
 Profile  
 
PostPosted: December 20th, 2013, 8:37 am 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
Armando wrote:
When XWidget restarts,
%LifeTime change to ${LifeTime}
But seems it's work anyway. It's a bit slow to change... but... works.

try %LifeTime in code maybe it works faster;
and maybe it doesn't change to ${LifeTime} in code;

to set a core tag for the object in the code use this:
text1.Coreformat="%LifeTime"

also if you need:
to get the value of a tag from a core in the code use this:
batterycore1.get("%LifeTime")





============
Armando wrote:
1) shows the minutes not divided in hours (eg.: 157 minutes) ... (do not know how you become with code to hours and minutes ...).


you can use like this in code to make it [hour:minute]
Code:
   mp=parseInt("157minutes",10)
   h1=parseInt(mp/60,10)
   m1=parseInt(mp%60,10)
   text1.text=h1+":"+m1

you can use your own statement instead of "157minutes" in mp line:

ex: using a tag:
mp=parseInt( batterycore1.get("%LifeTime") , 10 )

or

ex: using a variable:
bm=batterycore1.get("%LifeTime")
mp=parseInt( bm , 10 )

----------------

and also if needed you should add the code to a [if] statement,
since i don't have battery i don't know when it displays in minutes.

---------------
Note:
parseInt( numString , Radix ): A function that will make its input to int
-numString: the String you want to make int
-Radix: the numeral system to be used (it can be from 2-36); use 10 for decimal system


ex: float>int:
parseInt(12.157,10) >>> 12

ex: char>int:
parseInt(123abcd,10) >>> 123

ex: float&chars>int:
parseInt(153.12abcd,10) >>> 153

==================


Top
 Profile  
 
PostPosted: December 20th, 2013, 12:09 pm 
Offline
User avatar

Joined: June 12th, 2012, 11:05 am
Posts: 257
Location: Barcelona
Great!!! it's work fine, BUT numbers appear only a second and then disappear. I can only see the numbers again reloading the widget.

I finally use this code:

mp=parseInt(batterycore1.get("%LifeTime"),10)
h1=parseInt(mp/60,10)
m1=parseInt(mp%60,10)
text1.text=h1+":"+m1

I put in the opening lines of code. (lines 1,2,3,4 of the script code area).
should have put it somewhere else? (for example in the part of "text1 on change")?
THANKS again!


Top
 Profile  
 
PostPosted: December 20th, 2013, 4:04 pm 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
Armando wrote:
Great!!! it's work fine, BUT numbers appear only a second and then disappear. I can only see the numbers again reloading the widget.

I put in the opening lines of code. (lines 1,2,3,4 of the script code area).
should have put it somewhere else? (for example in the part of "text1 on change")?
THANKS again!

yes, you should use it in a function.
lines of the code that place outside of the function will only run at startup.

this code will convert the output of %LifeTime to hour:min
so it should be placed in a function that be called after each %LifeTime update

use one of these that you have used in your code:
-you can use it in batterycore1onupdate function since it will run after each update of batterycore
or
-you can use it in text1OnChange function if you bind the %LifeTime tag to it, so on each update text1 will change and the text1OnChange function will run and convert the output

==============
remember that since the %LifeTime is not always in minutes you should also use it in a [if] statement. to prevent running it for other conditions.
if you told me that what's the other conditions it displays i can help you more;

if it displays only in 00:00 and []minutes formats
so you can use the code in an [else] after your previous [if(00:00)]:
Code:
function text1OnChange(Sender)
{
  if(text1.Text=="00:00")
  {
     text1.Text="FULL"
  }
  else
  {
     mp=parseInt(batterycore1.get("%LifeTime"),10)
     h1=parseInt(mp/60,10)
     m1=parseInt(mp%60,10)
     text1.text=h1+":"+m1
  }
}


Top
 Profile  
 
PostPosted: December 20th, 2013, 7:34 pm 
Offline
User avatar

Joined: June 12th, 2012, 11:05 am
Posts: 257
Location: Barcelona
Hamid... GREAT!!! now it's working perfect!!!
Thanks for all your help and teaching! I'm sure this will help others!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group