Switching on/off the LEDs? How?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
melado
Posts: 7
Joined: Mon Sep 18, 2006 8:12 am

Switching on/off the LEDs? How?

Post by melado »

Is it possible to switch on/off the PSP LEDs (wifi, power, MS) via software? I've read that last version of IR Shell can do this, but I don't know how it's done.

Thanks.
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

First, use the search, 2nd read the headers...

Code: Select all

int sceSysconCtrlLED(int SceLED, int state);
-Aura
melado
Posts: 7
Joined: Mon Sep 18, 2006 8:12 am

Post by melado »

Hi! Thank you very much for your reply.

I did use the search but I couldn't find anything useful searching "led" or "leds". And if I search sceSysconCtrlLED, I find a thread, but it doesn't talk about that function.

I found the file with that function, but it says "only SCE_LED_POWER". Is this right? Isn't any way to control the other 2 LEDs?

Thanks again.
Nekuz0r
Posts: 3
Joined: Mon Apr 02, 2007 11:13 am

Post by Nekuz0r »

i suggest you to test other value by your self ;)
like 0, 2, 3 .... ;)
M.Jackson
Posts: 85
Joined: Mon Sep 10, 2007 6:37 pm
Contact:

Post by M.Jackson »

Nekuz0r wrote:i suggest you to test other value by your self ;)
like 0, 2, 3 .... ;)
If I remember correctly, none of those values can control the LEDs except the one for power. However, I did find some code from the IPL SDK that does work in controlling the other two LEDs:

#define REG32(a) *(volatile unsigned long *)(a)

// Turn on both LEDs at the same time
REG32( 0xbe240008 ) = 0xC0; /* GPIO SET */
// Turn off both LEDs
REG32(0xbe24000c) = 0xC0; /* GPIO CLEAR */

// Turn on the LED for memory stick
REG32( 0xbe240008 ) = 0x40;
// Turn off the LED for memory stick
REG32( 0xbe24000c ) = 0x40;

Hope it helps.
SilverSpring
Posts: 110
Joined: Tue Feb 27, 2007 9:43 pm
Contact:

Post by SilverSpring »

Unless you plan to bypass the kernel completely dont use the IPL sdk to do it. It can produce unwanted side effects.

Use the sceLed lib instead (only controls ms/wlan leds).

Code: Select all

// led (0-ms, 1-wlan)
// mode (on/off, and some others)
// param controls a bunch of other things like blinking, the rate it blinks, how long to blink for, etc.
int sceLedSetMode(int led, int mode, SceLedParam *param);
Im sure someone will post a proper sample on how to use, *cough*adrahil*cough*.
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

For the Power LED you should use Syscon call, but for WLAN/MS leds, you can use this:

Code: Select all

typedef struct{
  int oncnt;
  int offcnt;
  int endcnt;
  int endstat;
}SceLedParam;

#define LED_MODE_OFF 0
#define LED_MODE_ON 1
#define LED_MODE_TIMED 2
#define LED_MODE_DELAY 3

#define LED_TYPE_MS 0
#define LED_TYPE_WLAN 1

int sceLedSetMode(int led, int mode, SceLedParam* param);
Just link in the led.prx exports and off you go :) (Forget about modes 2 and 3, as 0 and 1 are enough)
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

adrahil wrote:
Just link in the led.prx exports and off you go :) (Forget about modes 2 and 3, as 0 and 1 are enough)
as im a N00B do you mean like

Code: Select all

LoadStartModule("flash0:/kd/led.prx");
or

Code: Select all

SceUID mod;

	mod = LoadStartModule("flash0:/kd/led.prx");
	if &#40;mod < 0&#41;
	&#123;
		ErrorExit&#40;6000, "Error %08X loading/starting led.prx\n", mod&#41;;
	&#125;

and i found this code somewere and im not sure if it would help?

Code: Select all

#include <pspkernel.h>

//==============================
//Definitions for the LED function. For now, only
// the power LED is functioning....
#define POWER_LED 1

#define STATE_ON 1
#define STATE_OFF 0

extern int sceSysconCtrlLED&#40;int LedID,int state&#41;;
//==============================
&#91;...&#93;
while&#40;1&#41;&#123;
    sceSysconCtrlLED&#40;POWER_LED, STATE_ON&#41;;
    sceKernelDelayThreadCB&#40;100000&#41;;
    sceSysconCtrlLED&#40;POWER_LED, STATE_OFF&#41;;
    sceKernelDelayThreadCB&#40;100000&#41;;
&#125;
&#91;...&#93;
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

It's good to see this finaly out, thanks.

Potential for controlling other devices through relays is really here with this
if you wanted to open a PSP to tap the LED ports.

I hope there is nothing naughty about doing it this way?
I don't notice any bad side effects.

Code: Select all

int sceSysconCtrlLED&#40;int SceLED, int state&#41;;

		sceSysconCtrlLED&#40;1,0&#41;;		// turn off LEDs
		sceSysconCtrlLED&#40;0,0&#41;;
		sceSysconCtrlLED&#40;2,0&#41;;
		sceSysconCtrlLED&#40;3,0&#41;;
Cheers, Art.
If not actually, then potentially.
CodeKiller
Posts: 1
Joined: Thu Jul 31, 2008 12:31 am

Post by CodeKiller »

Is it possible to "take over" the leds? I mean to use the leds for own madess >:-) while using standard syscalls, that normally use the leds.
In specific: i wan't to use the wlan led, but also plan to use ad-hoc wlan (which is normally also blink the led) but i think they will interfere.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You want to hook the LED functions so that you can call the original vectors, but everyone else gets your hook function.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Is there a way to turn off only *one* of the Power LEDs? There are actually 2 green LEDs for the Power.
Post Reply