Author Topic: Mb-applet-powerctrl  (Read 32900 times)

ecc_hy

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Mb-applet-powerctrl
« on: June 15, 2007, 01:26:56 pm »
Changelog:

2007-07-15
Bump to 0.0.2
add "overclocktimeout" to powerctrl.cfg
   
2007-07-02
clean the paint code
add paint config to powerctrl.cfg

2007-06-30
dpms_set() back to "xset", give up DPMSGetTimeouts()
new function: dpms_read(), read dpms status from "xset q"
add "Attention:" to powerctrl.cfg
speedstep over unstable freq

2007-06-29:
Big fixed
Display better.
Add powerctrl.cfg, you can modify almost everthing in it.

2007-06-23

Make the three bars wider, which would make them much more visible, and look better.

Change and test ok for screensaver and suspend options. It really confuse me. Now the function is:
1. Screensaver and suspend options is opened when startup, read lightnpower config at first, but not set dpms really.
2. If you disable or enable those options, read lightnpower config, and set dpms.
3. When power changed, read lightnpower config, change backlight.
4. If mb-applet-battery runnging, powerctrl would not set dpms.
5. If mb-applet-battery not runnging, powerctrl would set dpms. Keep disable if you disabled before, Otherwiase, set dpms according lightnpower config.

Add config of usage AC higher and usage battery higher. This should satisfy meanie's idea: when on battery power, it will only underclock and not overclock, while on the other hand, if its on AC power, it can automatically overclock.

Function list:
Blanker/suspend control, no support XMMS key control
CPU/Mem monitor, battery monitor, CPU clock monitor
Low battery warn
Set CPU Clock manually and very fast, replace cpuoverclock.py.
Set backlight manually and very fast, replace lightnpower.py.
Auto speedstep according CPU usage.

Source is not cleaned, if you want to compile:
make clean
make distclean
./configure
make

No debug infor:
delete line:
#define DEBUG

Install binary mb_applet_powerctrl_0.0.1.tar.gz:
tar zvfx mb_applet_powerctrl_0.0.1.tar.gz
and copy the files according to the directory

After install:
click and hold on applet for 2 seconds
select "add" -> "power control"

You may run mb-applet-powerctrl in terminal when you getting problem.
« Last Edit: July 15, 2007, 07:25:18 am by ecc_hy »
SL-C1000, Roku wifi, pdaxii13v2/Debian dual booting

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mb-applet-powerctrl
« Reply #1 on: June 21, 2007, 10:04:54 am »
looks really useful, I will try it tonight. What is the memory use like, I try to use few mb-applets to save memory.

anyone tried this yet?

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mb-applet-powerctrl
« Reply #2 on: June 21, 2007, 05:24:20 pm »
unfortunately it crashes on loading, any ideas?
Code: [Select]
$ mb-applet-powerctrl
mbmenu: no _MB_THEME set on root window
Segmentation fault

ecc_hy

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Mb-applet-powerctrl
« Reply #3 on: June 22, 2007, 09:48:02 am »
I have not test in C3200 and icewm yet.

This program develop in PDAXROM 1.1 beta3 on C1000. It support other zaurus, but may need more test. For other zaurus, you may tell me some information as below when you get problem:
product identify -> /proc/deviceinfo/product
cpu clock -> /proc/cccr_change and /proc/zaurus/VCORE
backlight -> /proc/driver/fl/corgi-bl

It can not support kernel 2.6 now.
But new release will come soon.

As you mind. the powerctlr really does:
1. Save display screen. It merged battery, cpu usage, mem usage, and cpu clock display.
2. Optimize the display program, display changed pixel of tray icon only.
3. Change the backlight and cpu clock by simple click tray icon, it is very fast.
4. Speedstep CPU Clock according to CPU usage, when usage greater than 80%, set clock higher; when usage less than 20%. set clock lower.
SL-C1000, Roku wifi, pdaxii13v2/Debian dual booting

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #4 on: June 22, 2007, 09:58:12 am »
Quote
I have not test in C3200 and icewm yet.

This program develop in PDAXROM 1.1 beta3 on C1000. It support other zaurus, but may need more test. For other zaurus, you may tell me some information as below when you get problem:
product identify -> /proc/deviceinfo/product
cpu clock -> /proc/cccr_change and /proc/zaurus/VCORE
backlight -> /proc/driver/fl/corgi-bl

It can not support kernel 2.6 now.
But new release will come soon.

As you mind. the powerctlr really does:
1. Save display screen. It merged battery, cpu usage, mem usage, and cpu clock display.
2. Optimize the display program, display changed pixel of tray icon only.
3. Change the backlight and cpu clock by simple click tray icon, it is very fast.
4. Speedstep CPU Clock according to CPU usage, when usage greater than 80%, set clock higher; when usage less than 20%. set clock lower.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163541\"][{POST_SNAPBACK}][/a][/div]

it runs fine on my c3000 running icewm 1.2.26
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Mb-applet-powerctrl
« Reply #5 on: June 22, 2007, 10:22:38 am »
Great approach! Thank you!

Some ideas:
You could make the three bars wider, which would make them much more visible.
Now they are quite hard to see.

Blank screeen once did not work, and now it segfaults here.
Do you hae an ide why?

I see "Max speed" and "Max save" can both be unchecked which is probably setting the CPU speed to default behavior (i.e. don't change at all and set to 416MHz).
But I think it would be good to have an explicit third option "Default speed" so te user really knows that the applet doesn't change anything. It is not obvious instantly that the optoins canno only be "cross-checked" but also unchecked at all.

Did you use Meanie's algorithms from his banker applet hack for the blanker equivalent options?

Maybe the volume applet could also be integrated?  

daniel
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

climber

  • Full Member
  • ***
  • Posts: 189
    • View Profile
Mb-applet-powerctrl
« Reply #6 on: June 22, 2007, 10:43:13 am »
This sound very interesting!

As I'm not the linux specialist what have I to to with the "mb_applet_powerctrl_0.0.1.tar.gz?"

I extracted the file and there are a few folders like the zaurus already has. I think there's should be a command how to get these data to the right folders!?

Thanks
climber

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #7 on: June 23, 2007, 12:37:20 am »
i packaged it up.


i like the new features it adds, but since i am using icewm which already has the monitoring bits i am inclined to rather not have it show those monitors. what i intend to do is use the code from powerctrl and merge it back into my custom blanker applet (which also has the xmms stuff removed but handles the screensaver/suspend functionality a bit better).
so i intend to add the cpu and backlight settings parts to blanker applet, but i want to add some logic to the power step feature where when on battery power, it will only underclock and not overclock, while on the other hand, if its on AC power, it can automatically overclock.
« Last Edit: June 23, 2007, 01:05:17 am by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #8 on: June 23, 2007, 10:03:40 am »
there is a bug, the SL-C3200 is ignored and thus the overclocking will fail for it.
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

ecc_hy

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Mb-applet-powerctrl
« Reply #9 on: June 24, 2007, 01:26:33 am »
Quote
there is a bug, the SL-C3200 is ignored and thus the overclocking will fail for it.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163590\"][{POST_SNAPBACK}][/a][/div]

Writing the zaurus model as hard code is not good idea.

Next version, I should make a config file.
SL-C1000, Roku wifi, pdaxii13v2/Debian dual booting

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #10 on: June 24, 2007, 04:51:51 am »
ok, then you are going to change the following code to read a config instead?

(memcmp(sLine, "SL-C1000", 7) == 0 || memcmp(sLine, "SL-C3100", 7) == 0 || memcmp(sLine, "SL-C3000", 7) == 0)

Don't forget to add the SL-C3200 to that config list.

In addition, in 2.4.20 kernel, you can easily determine the model name, but in 2.6.x kernel, this info is not easily available. Instead, you can only get the dog name, ie Akita, Spitz, Borzoi, Terrier, etc.. so if you use that information instead, then the applet could also work in new pdaXrom that is using 2.6.x kernel...I have added the following into postinst:

HARDWARE=`cat /proc/cpuinfo | grep 'Hardware' | cut -d':' -f2 | cut -d' ' -f3` > /etc/hardware

because there is no /proc/deviceinfo under 2.6.x kernel

so instead of reading /proc/deviceinfo/product, I read /etc/hardware instead and instead of checking whether the model is SL-C1000, SL-C3100, etc... I check for Akita, Borzoi, etc... instead... This would make it work for all versions of pdaXrom...




Also, can you add another option so you can choose whether you want to display cpu info/memory info/battery status or the suspend/screensaver status which the original blanker is displaying?

Another nice to have feature would be an extra option to turn on/off swap...
« Last Edit: June 24, 2007, 06:46:57 am by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #11 on: June 24, 2007, 06:36:32 am »
Quote
Change and test ok for screensaver and suspend options. It really confuse me. Now the function is:
1. Screensaver and suspend options is opened when startup, read lightnpower config at first, but not set dpms really.
2. If you disable or enable those options, read lightnpower config, and set dpms.
3. When power changed, read lightnpower config, change backlight.
4. If mb-applet-battery runnging, powerctrl would not set dpms.
5. If mb-applet-battery not runnging, powerctrl would set dpms. Keep disable if you disabled before, Otherwiase, set dpms according lightnpower config.

This is what I intended for the blanker when I hacked it:

1. In the original blanker, screensaver and suspend option were always enabled by default when you start the applet (even when they really were enabled or disabled), so I changed the code to check whether those features really were enabled or disabled when the applet started and had it show the status accordingly.

2. Yep, I also found that xset didn't properly set those options so made it call xset-wrapper instead which when fiddled with the options to set things properly, ie if you have xscreensaver installed, it would also enabled/disable xscreensaver as well and not only the build in screensaver in X

3. Exactly. power.cfg has backlight settings for AC and battery mode, so set backlight according to what is set there.

4. Battery applet calls lightnpower.py to set dpms when power changes between AC/battery, so when it is running, blanker/powerctrl does not need to do anything

5. since there is no battery applet, powerctrl applet needs to change settings. maybe it should check whether blanker applet is running as well.
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #12 on: June 24, 2007, 08:08:27 am »
the speedstep feature has a problem. when i am on battery power and doing nothing it correctly steps down to a lower cpu frequency, however, when i am plugged into the AC and do a compile, i can see it steps up the cpu frequency but then it shuts down my Zaurus and I have to reset it...
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

ecc_hy

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Mb-applet-powerctrl
« Reply #13 on: June 24, 2007, 10:44:03 am »
Quote
ok, then you are going to change the following code to read a config instead?
Yes, the config file should be copy to /etc/powerctrl.cfg or ~/Choice/powerctrl.cfg. Puting the config file to HOME should avoid the problem of user right.
The /proc/cpuinfo can be used or not? Only cpu model stored in it.

Quote
Also, can you add another option so you can choose whether you want to display cpu info/memory info/battery status or the suspend/screensaver status which the original blanker is displaying?
This maybe not easy if you want to change the status bar on tray image. As you know, the all drawing work is based the icon file. If you really want to do this, drawing the whole icon's backgroud is needed.
If you just wat ignore it and leave the bar no change, it should by more easy.

Quote
1. In the original blanker, screensaver and suspend option were always enabled by default when you start the applet (even when they really were enabled or disabled), so I changed the code to check whether those features really were enabled or disabled when the applet started and had it show the status accordingly.
Do you mean check lightnpower.cfg?
Disable screen save or suspend if the value of config file is 0. Yes, I have done it.

Quote
2. Yep, I also found that xset didn't properly set those options so made it call xset-wrapper instead which when fiddled with the options to set things properly, ie if you have xscreensaver installed, it would also enabled/disable xscreensaver as well and not only the build in screensaver in X
I have copy it from your blanker, even do not know why. Now you explain it.

Quote
3. Exactly. power.cfg has backlight settings for AC and battery mode, so set backlight according to what is set there.
Yes. powerctrl read lightnpower.cfg to get the baklight config, and also read
/proc/driver/fl/corgi-bl to get current backlight value.

Quote
4. Battery applet calls lightnpower.py to set dpms when power changes between AC/battery, so when it is running, blanker/powerctrl does not need to do anything
I have copy it from your blanker, and check battery applet is running or not.

Quote
5. since there is no battery applet, powerctrl applet needs to change settings. maybe it should check whether blanker applet is running as well.
In fact, I want to replace replace battery applet and blanker applet. Any way, I shill check the blanker.

Quote
Another nice to have feature would be an extra option to turn on/off swap...
This should be easy by exec "swapon -a" and "swapoff -a". I will try.

Quote
the speedstep feature has a problem. when i am on battery power and doing nothing it correctly steps down to a lower cpu frequency, however, when i am plugged into the AC and do a compile, i can see it steps up the cpu frequency but then it shuts down my Zaurus and I have to reset it...
[div align=\"right\"][a href=\"index.php?act=findpost&pid=163638\"][{POST_SNAPBACK}][/a][/div]

I have found the "make" program may be error when overclock.
The same problem occurs one times before modify the screensaver and suspend control. It seems powerctrl always call dpms_set.

Now the new ipk and source is changed screensaver and suspend control according meanies' blanker. I have not shuts down after modified.

You may try new ipk and source.

Someone said, overclock may not safe, and suggest 7500 can not over clock for 30 minutes, and C1000 can not for one hour. Is it truth? I can design a time protect. Is it nessary?

Thanks meanie very much, I will conside those ideas carefully.
« Last Edit: June 24, 2007, 11:52:22 am by ecc_hy »
SL-C1000, Roku wifi, pdaxii13v2/Debian dual booting

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mb-applet-powerctrl
« Reply #14 on: June 24, 2007, 07:55:13 pm »
Quote
The /proc/cpuinfo can be used or not? Only cpu model stored in it.
Yes but it contains extra info which you need to strip out first and it only has dog name but no model name.

Quote
Quote
Also, can you add another option so you can choose whether you want to display cpu info/memory info/battery status or the suspend/screensaver status which the original blanker is displaying?
This maybe not easy if you want to change the status bar on tray image. As you know, the all drawing work is based the icon file. If you really want to do this, drawing the whole icon's backgroud is needed.
If you just wat ignore it and leave the bar no change, it should by more easy.
Those bars are really of no use to me, so I rather have the old icons back.

Quote
Quote
Another nice to have feature would be an extra option to turn on/off swap...
This should be easy by exec "swapon -a" and "swapoff -a". I will try.

I changed the CPU frequency for the overclocking using the values from Cacko instead and it didnt shutdown or turn into a white screen

I also rearranged the order of the popup items a bit to suit my own preferenes...
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K