Advertising (This ad goes away for registered users. You can Login or Register)

[Tutorial] Python PSP Programming Part II

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
User avatar
Acid_Snake
Retired Mod
Posts: 3099
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

[Tutorial] Python PSP Programming Part II

Post by Acid_Snake » Sun Aug 19, 2012 10:10 am

Before we continue experimenting with psp2d let's take a look at other psp modules.


pspos:
This module provides information about the psp, and some other functions like changing cpu/bus speed:

Code: Select all

pspos.setclocks(333,166) # To set both CPU and Bus clock
pspos.setclock(333) # To set the CPU clock only
pspos.setbus(166) # To set the bus speed only
pspos.getclocks() # To get the current clock
This functions are usually useless since the python interpreter will automatically set the clock for you.
Apart from messing around with clock speed, the pspos module provides information about various aspects of the psp system:

Code: Select all

pspos.freemem() # Return amount of free memory
pspos.battery() # Returns a list containing different values about the battery
pspos.battery()[3] # Returns battery charge percentage
pspos.getnickname() # Returns the current users nickname
And last but not least, the function:

Code: Select all

pspos.getsystemparam(param)
As you can see you have to pass a parameter, there are a total of 9 parameters, depending on what information you require:

Code: Select all

PSP_SYSTEMPARAM_ID_STRING_NICKNAME     = 1
PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL   = 2
PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE  = 3
PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT     = 4
PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT     = 5
PSP_SYSTEMPARAM_ID_INT_TIMEZONE        = 6
PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS = 7
PSP_SYSTEMPARAM_ID_INT_LANGUAGE        = 8
PSP_SYSTEMPARAM_ID_INT_UNKNOWN         = 9
So if you want to retrieve the system language (PSP_SYSTEMPARAM_ID_INT_LANGUAGE), you use:

Code: Select all

pspos.getsystemparam(8)
because 8 is the ID for PSP_SYSTEMPARAM_ID_INT_LANGUAGE. Now be careful because PSP_SYSTEMPARAM_ID_INT_LANGUAGE returns another number, instead of the real language. Using that returned number you have to identify the laguage by yourself:

Code: Select all

PSP_SYSTEMPARAM_LANGUAGE_JAPANESE            = 0
PSP_SYSTEMPARAM_LANGUAGE_ENGLISH             = 1
PSP_SYSTEMPARAM_LANGUAGE_FRENCH              = 2
PSP_SYSTEMPARAM_LANGUAGE_SPANISH             = 3
PSP_SYSTEMPARAM_LANGUAGE_GERMAN              = 4
PSP_SYSTEMPARAM_LANGUAGE_ITALIAN             = 5
PSP_SYSTEMPARAM_LANGUAGE_DUTCH               = 6
PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE          = 7
PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN             = 8
PSP_SYSTEMPARAM_LANGUAGE_KOREAN              = 9
PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL = 10
PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED  = 11
so if pspos.getsystemparam(8) returns 1 you know the language is english, but if it returns 3 you know the number is spanish. Also PSP_SYSTEMPARAM_ID_STRING_NICKNAME is the same as pspos.getnickname(), as a matter of fact if you call pspos.getsystemparam(1) it will itself call pspos.getnickname().
That's basically it for this module, take a look at it since it's very easy to understand.


pspsnd:
This module provides functions about sound such as music playback and volume control.
Setting the volume:

Code: Select all

pspsnd.setMusicVolume(vol)
vol has to be a number between 0 and 255.

Code: Select all

pspsnd.setSndFxVolume(vol)
again, vol has to be a number between 0 and 255.
Play a file:

Code: Select all

music = pspsnd.Music("path_to_file")
music.start()
music.stop()
as you can see, it's pretty straightforward.


pspnet:
To be honest, I haven't used this module myself, but looking at the source code and other examples it isn't that big a deal:

Code: Select all

pspnet.connectToAPCTL(n)  # Connect to AP, n has to be a number depending on the AP (see bellow)
pspnet.disconnectAPCTL()  # Disconnect from AP
pspnet.wlanSwitchState()  # Return the wlan switch state
pspnet.wlanEtherAddr()  # Return Ethernet Address
pspnet.getAPCTLState()  # Return state of connection
pspnet.getIP()  # Return IP address
pspnet.enumConfigs()  # Enumerate the different AP configurations

Well that's basically it. On the next lesson we'll start seeing some real examples.
Previous: viewtopic.php?f=5&t=13112
Next: viewtopic.php?f=5&t=13374
Advertising

svenn
Posts: 66
Joined: Fri Dec 24, 2010 5:17 pm
Location: Belgium
Contact:

Re: [Tutorial] Python PSP Programming Part II

Post by svenn » Tue Sep 18, 2012 8:39 am

whats "setSndFxVolume" for ? and setMusicVolume ?

obv for volume settings buts what the difference between "SndFX" and "Music" ?
Advertising

User avatar
Acid_Snake
Retired Mod
Posts: 3099
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: [Tutorial] Python PSP Programming Part II

Post by Acid_Snake » Tue Sep 18, 2012 8:04 pm

good question, I have no idea cause I've never really used it. Try messing with it.

User avatar
NNNRT
Moderator
Posts: 1604
Joined: Fri Jul 27, 2012 1:32 pm
Location: Byblos
Contact:

Re: [Tutorial] Python PSP Programming Part II

Post by NNNRT » Tue Jan 08, 2013 5:45 pm

How do you add different sounds in pspsnd? Like selecting an image makes a unique sound... 8-)

Post Reply

Return to “Programming and Security”