Firmware inclusion request to ED: script for keyboard LED illumination control


hmc

Active Member
Joined
Dec 19, 2011
Messages
787
Location
Bavaria, Germany
Hi,
should this be requested this way and done by ED or some other Pandora OS maintainer, or should I make such changes by myself using git or something?

If I should do this by myself, can anyone give some initial hints please? I am not familiar with contributing to the Pandora OS yet.

The purpose of the changes is that the keyboard LED light can be controlled by a configbutton Plugin.

I think I'll distribute the Configbutton Plugin in an installer PND, that's probably the best way, as most people won't need that Plugin?

Here is the receipe:



Create script:
sudo nano /usr/pandora/scripts/op_kbd_light.sh

fill it with:


#!/bin/sh
# Released under the GPL
# Sets keyboard light (if keyboard light hardware is installed) to given val$
# Give value for PWM brightness control as parameter $1
# Valid values: 0 (off) to 255 (full brightness)

echo $1 > /sys/class/leds/pandora\:\:keypad_bl/brightness
 



make it executable:
sudo chmod a+x /usr/pandora/scripts/op_kbd_light.sh


Add script to sudoers file:
sudo nano /etc/sudoers.d/50_openpandora

by adding line:
%wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_kbd_light.sh
 
Last edited by a moderator:
Great stuff. But I would suggest to make an installer for this as not everyone has the led light pad connected to something or has vonnected something different there. I have a rumblemotor on those pads, wich might lead to unwanted results with this script.


Including it into the firmware might not be the best thing to do.
 
Great stuff. But I would suggest to make an installer for this as not everyone has the led light pad connected to something or has vonnected something different there. I have a rumblemotor on those pads, wich might lead to unwanted results with this script.

Including it into the firmware might not be the best thing to do.
IMO, it makes sense to add this to the firmware. It's only an extra script to be able to control keypad led light brightness without requiring root permisions.
In your case you probably had to add a line to sudoers file or change some permissions to be able to control the rumble motor (without using root). This script would avoid having to do that manually.

Might as well make the script capable of controlling all of the leds. Like so:

Code:
#!/bin/sh
# Released under the GPL
# Sets the specified LED light to the given brightness
# 
# First argument selects which LED to modify.
# Valid values: bluetooth, charger, keypad_bl, power, sd1, sd2, wifi
#
# Second argument is the desired brightness value:
# Valid values: 0 (off) to 255 (full brightness)

LEDSDIR=/sys/class/leds

case $1 in
	bluetooth | charger | keypad_bl | power | sd1 | sd2 | wifi )
		if [ $2 -ge 0 -a $2 -le 255 ]; then
			echo -n $2 > $LEDSDIR/pandora\:\:$1/brightness
		else
			exit 1
		fi
		;;
	*)
		exit 1
		;;
esac
Then to set keypad led to full brightness:
Code:
/usr/pandora/scripts/op_leds.sh keypad_bl 255
The script returns with exit status of 1 if invalid value is provided or with exit status of 0 if successful (the system() function should return the exit status of the program/script that was executed).
 
Last edited by a moderator:
I have a rumblemotor on those pads, wich might lead to unwanted results with this script.
So these are pads on the mainboard which are not connected to anything on a stock pandora, and you soldered a vibration motor to the board?
 
I have a rumblemotor on those pads, wich might lead to unwanted results with this script.
So these are pads on the mainboard which are not connected to anything on a stock pandora, and you soldered a vibration motor to the board?
See here:

http://boards.openpandora.org/index.php/topic/10722-hardware-hack-pandora-rumble-edition/?hl=%2Brumble+%2Bedition


Works quite good and I play rRootage with it all the time.


I started the pnds I modified with sudo to use the rumblefeature.


I like that this one doesn't need sudo but if you start a game using rumble with leds attached, you'll get a lightshow instead of rumble.


What might also be really cool when I think about it :)
 
Last edited by a moderator:
IMO, it makes sense to add this to the firmware. It's only an extra script to be able to control keypad led light brightness without
If it isn't visible by default I would agree, otherwise I agree with mcobit as this could confuse new Pandora users.
 
IMO, it makes sense to add this to the firmware. It's only an extra script to be able to control keypad led light brightness without
If it isn't visible by default I would agree, otherwise I agree with mcobit as this could confuse new Pandora users.
I there's a bit of confusion going on here. From what I understand the proposal is to only add a script into /usr/pandora/scripts directory to allow to provide easier access to control LED brightness.

What this means is that a PND could control LED brightness without needing to make special modifications to the PND itself or to the /etc/sudoers file.

The script itself will be effectively invisible to the average user, until they install a PND which makes use of it.
 
I think I'll distribute the Configbutton Plugin in an installer PND, that's probably the best way, as most people won't need that Plugin?
I guess this line confused me - but if an installer is already there/in the making - why not let the installer also copy the script to the proper location ?
 
Yoyobuae is right. 

The script is only there in the rootfs, only visible if you look for it in the scripts directory.

It allows to easily set the LED brightness without using sudo, just using a call of the script (from a PND, from the Configbutton Plugin I wrote, or whatever).

Regarding mcobit's issue with the rumble motor: The pads on the mainboard are explicitly meant for connecting keyboard illumination, also the developer guide explains them that way. So I think it's valid to put that script inot the firmware with the explicit purpose of controlling the keyboard illumination brightness. If someone connects something else to those pads, they do it on their own "risk". ;-)

The script and its sudoers entry will not disturb any PND that uses those lines for a rumble motor, for a laser show unit or even for a nuclear weapon trigger. Just don't use the script. ;-) Or use it on purpose. You CAN use it to control the rumble motor even without sudo. Just don't expect that an LED switches on, but expect that the rumble motor begins to rumble.

About thatgui'*s suggestion (Let the configbutton Plugin installer install the script): This would require any user, who wants to control the keyboard illumination pads (be it for LEDs, for rumble motor or whatever) to install the configbutton Plugin. mcobit for instance could make good use from the script to control his rumble motor without sudo, but he won't need the confogbutton Plugin. That Plugin would disturb him, because in his Configbutton applet there would be a new entry "Swtch on keyboard light", which would then actually switch on his rumble motor. ;-)

Also, I don't like the idea of a PND to mess around with the sudoers file!

So I'd still prefer that the script and modified sudoers file becomes part of the official firmware, whereas the keyboard light configbutton plugin will be distributed as a PND.

Consider the script and sudoers modification kind of a "driver" for the keyboard illumination pads.

Original question remains:

How to proceed now? Will ED take care about that, or should I do something using git, or....?
 
Last edited by a moderator:
I'm not a fan of this because when some pnds start using this, we'll have to provide this functionality forever and it will complicate things when we want to do backward compatibility on future pandora revisions / Pandora2 / Pandora3000 / whatever that might have completely different LEDs..

But it's up to ED to make the decision.
 
Back
Top