forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pspLed library

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
phobox



Joined: 24 Mar 2008
Posts: 140

PostPosted: Tue Jun 16, 2009 4:59 am    Post subject: pspLed library Reply with quote

I decided to reverse the simple led.prx module.

Since the current sdk doesn't have prototypes for that library, i prepared the header file.
I would have made a patch but i don't know how to insert a new library... i think that the whole makefile has to be changes, so... i don't know.

here is the header http://www.megaupload.com/?d=8VDYUYIJ

I want also to say that in this topic
http://forums.ps2dev.org/viewtopic.php?t=9485
the param structure is defined as a 4 int elements structure, but is is five elements structure and the first element may be an array of four chars, i have to investigate it.

the main function, sceLedSetMode has the second arg called mode. modes available are 4 (0, 1, 2, 3) but i discovered how to use mode 2 (modes 0 and 1 were already known), but i'm working on mode 3 (called in the other thread DELAY).

mode 3 use is difficult to find out because it's not used in any of sce modules!.. (afaik)

hope to have been useful!
bye
_________________
Ciao! from Italy
Back to top
View user's profile Send private message
shepherd



Joined: 02 Sep 2008
Posts: 2

PostPosted: Wed Sep 02, 2009 12:29 am    Post subject: Nice Reply with quote

I cann't open the header. Could you paste it again? Please
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Wed Sep 02, 2009 1:49 am    Post subject: Reply with quote

I can downlaod it so you can do it too.

Code:
/*
 * PSP Software Development Kit - http://www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * pspled.h - Prototypes for the sceLed_driver library.
 *
 * Copyright (c) 2009 Phobox
 */

#ifndef __LED_H
#define __LED_H

#ifdef __cplusplus
extern "C" {
#endif

#define SCE_LED_MS      0
#define SCE_LED_WLAN    1

#define SCE_LED_MODE_OFF        0
#define SCE_LED_MODE_ON         1
#define SCE_LED_MODE_BLINK      2
#define SCE_LED_MODE_UNK        3

typedef struct{
    /** Unknown, used only in SCE_LED_MODE_UNK */
   int param_unk0;
   /** Used in SCE_LED_MODE_BLINK. The time for the led to stay ON during the blink */
   int onTime;
   /** Used in SCE_LED_MODE_BLINK. The time for the led to stay OFF during the blink */
   int offTime;
   /** Used in SCE_LED_MODE_BLINK. The time the blink has to last. After this time the led is set in the status specified in statusAfterBlink. Set -1 for an inifite time */
   int blinkTime;
   /** Used in SCE_LED_MODE_BLINK. The status (1 = on, 0 = off) of the led after the blink */
    int statusAfterBlink;
} SceLedParam;


/**
 * Sets the mode of a led.
 * @param led - the led id.
 * @param mode - one of SCE_LED_MODE_*
 * @param param - used only with modes 2 and 3
 *
 * @ return 0 on success
 *          0x80000102 if "led" argument was not correct (< 0 or >= 2)
 *          0x80000107 if "mode" argument was not correct
 */
int sceLedSetMode(int led, int mode, SceLedParam *param);

/**
 * Turns off both leds and saves their state.
 * The state can be restored using sceLedResume
 */
void sceLedSuspend();

/**
 * Resumes the status of leds as it was before sceLedSuspend was called
 */
void sceLedResume();

/**
 * Inits the sceLed library
 * This is the same as calling module_start, so it is called when the module is started
 */
void sceLedInit();

/**
 * Terms the sceLed library
 * This is the same as calling module_reboot_before, so is called when there is a kernel reset
 */
void sceLedEnd();


#ifdef __cplusplus
}
#endif

#endif

_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 391

PostPosted: Fri May 06, 2011 10:06 pm    Post subject: Reply with quote

Some time ago I've updated this little library I've made with Phobox, just because I've used it in one of my projects, nothing have changed very much but there's no reference in the pspsdk so...
The sceLed library is used by the firmware to show Memory Stick and Wlan activity so if you want to enable\disable a led is better to use the
syscon function...

First the pspled header that is nearly equal...
Code:

/*
 * File:   pspled.h
 * Author: ne0h
 *
 * Created on 25 giugno 2009, 21.56
 */

#ifndef PSPLED_H
#define   PSPLED_H

typedef enum{
    SCE_LED_MODE_OFF = 0,   // Led mode off
    SCE_LED_MODE_ON,        // Led mode on
    SCE_LED_MODE_BLINK,     // Led blinking
    SCE_LED_MODE_UNK        // Unk mode
}SceLedMode;

typedef enum{
    SCE_LED_MS = 0,       // Memory Stick Access
    SCE_LED_WLAN = 1      // Wlan Status
}SceLeds;

typedef struct{
    u8  unk0;               // Unknow... Used only in SCE_LED_MODE_UNK
    u32 OnStateTime;        // On state blinks num
    u32 OffStateTime;       // Off state blinks num
    s32 BlinkStateTime;     // Single blink time
    u32 AfterBlinkMode;     // Reverse ON and OFF power state
} SceLedParams;

/**
 * Sets a led mode
 *
 *
 * @param led   - One of SceLeds
 * @param mode  - One of SceLedMode
 * @param params - Pointer to a SceLedParams struct
 * (can be NULL only if SCE_LED_MODE_OFF and SCE_LED_MODE_ON are chosen)
 *
 * @returns < 0 on error ( 0x80000102 // Invalid led, 0x80000107 // Invalid mode )
 */
int sceLedSetMode(SceLeds led, SceLedMode mode, SceLedParams* params);

#endif   /* PSPLED_H */


And then a bit updated syscon header
Code:

typedef enum{
    SCESYSCON_LEDMODE_OFF = 0,   // Led mode off
    SCESYSCON_LEDMODE_ON         // Led mode on
}SceSysconLedMode;

typedef enum{
    SCESYSCON_LED_MS = 0,       // Memory Stick Access
    SCESYSCON_LED_WLAN = 1,     // Wlan Status
    SCESYSCON_LED_POWER = 2,    // Green Power Led
    SCESYSCON_LED_CHARGE = 3    // Orange Power Led (DO NOT WORKS?)
}SceSysconLeds;

/**
 * Control an LED
 *
 * @param Led - The led to toggle
 * @param Mode - Whether to turn on or off
 */
int sceSysconCtrlLED(SceSysconLeds Led, SceSysconLedMode Mode);

_________________
Get Xplora!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group