XWidgetSoft Forum
https://www.bbs.xwidget.com/

Edit script
https://www.bbs.xwidget.com/viewtopic.php?f=8&t=5426
Page 1 of 1

Author:  Jimking [ January 23rd, 2015, 3:47 am ]
Post subject:  Edit script

I would like to create a similar widget like this:
http://jimking.deviantart.com/art/Proce ... -378444183

The fact is that for this widget I used a single .png image for the rotation and this script.

Code:
var cs = 0;

function cpucore1OnUpdate(Sender)
{
  cs = cpucore1.get("%Percent");
  if(cs==0)
  {
    pnganimate1.play = false;
    pnganimate1.rotateAngle = 0;
  }
  else  if(cs<=30)
  {
    pnganimate1.RotateAngleStep = Math.round(cs/2);
    pnganimate1.Play = true;
  }
  else
  {
//    print("Max = 17 !");
    pnganimate1.RotateAngleStep = 17;
    pnganimate1.Play = true;
  }
}


Now I'll use a multiple serial png images (0-7). How the script should be edited to work properly...?

Author:  meme [ January 29th, 2015, 11:29 am ]
Post subject:  Re: Edit script

Please send me the widget, what you have so far, so I can see.

Author:  Jimking [ January 30th, 2015, 1:35 am ]
Post subject:  Re: Edit script

meme wrote:
Please send me the widget, what you have so far, so I can see.

Here is the widget meme:
Thanks! :)
(the script is from the other widget)

Download and try this one to see what I mean, and how the new widget should work
http://jimking.deviantart.com/art/Proce ... -378444183

Attachments:
cpu_cooler_resources.xwp [422.5 KiB]
Downloaded 315 times

Author:  meme [ January 30th, 2015, 2:40 am ]
Post subject:  Re: Edit script

Replace existing code with this, adjust the 100 value to alter the speed range.
Possibly set a minimum speed after the else rather than have the fan stop ?

Code:
var cs = 0;

function cpucore1OnUpdate(Sender)
{
    cs = cpucore1.get("%Percent");
    if(cs>0)
   {
    pnganimate1.Interval = Math.round(100/cs);       //interval range 10~99999ms
    pnganimate1.Play = true;
   }
   else
    pnganimate1.Play = false;
}

Author:  Jimking [ January 30th, 2015, 3:05 am ]
Post subject:  Re: Edit script

Quote:
Possibly set a minimum speed after the else rather than have the fan stop ?

Yes! Is exactly what I was thinking about it. If you notice on the other widget, the fan doesn't stop even on low cpu usage (0%) and the fan movement is more fluid..
So if you can do it to this one, it will be the ideal! :)

Author:  meme [ January 30th, 2015, 12:35 pm ]
Post subject:  Re: Edit script

Try this, again you can adjust the minimum speed value, ms = 100
Are you going to display the cpu% in the blue box at the front ?

Quote:
var cs = 0; // cpu speed %
var ms = 100; // minimum fan speed value

function cpucore1OnUpdate(Sender)
{
cs = cpucore1.get("%Percent");
if(cs>0)
pnganimate1.Interval = Math.round(ms/cs); // interval = 10~99999ms
else
pnganimate1.Interval = ms
}

Author:  Jimking [ January 30th, 2015, 12:55 pm ]
Post subject:  Re: Edit script

Thanks for the script mate! I will try it as soon as possible..
About the cpu percentage I don't know. Maybe I will add a right click option to show /hide it.
What do you think?

Author:  meme [ January 30th, 2015, 1:23 pm ]
Post subject:  Re: Edit script

I think it looks OK

Attachments:
cpu.png
cpu.png [ 72.37 KiB | Viewed 9037 times ]

Author:  Jimking [ January 31st, 2015, 12:29 am ]
Post subject:  Re: Edit script

I think so...! ;)
Thanks again meme
Quote:
Try this, again you can adjust the minimum speed value, ms = 100

@meme, I tried your second scipt but the fan doesn't move at all... :?
The first script worked..

Author:  meme [ January 31st, 2015, 12:43 am ]
Post subject:  Re: Edit script

Quote:
@meme, I tried your second scipt but the fan doesn't move at all... :?

Strange... here is the widget with code, try this.

Attachments:
cpu_cooler_resources.xwp [422.6 KiB]
Downloaded 278 times

Author:  Jimking [ January 31st, 2015, 1:08 am ]
Post subject:  Re: Edit script

meme wrote:
Strange... here is the widget with code, try this.

Strange because this one works fine!
Thanks :D

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/