Sorry to bother with maybe a stupid question, but I cannot get sceDisplaySetBrightness to work. :(
I updated my toolchain and now the display_kernel.h defines the two functions sceDisplaySetBrightness and sceDisplayGetBrightness.
What I understood:
1.Program must be kernel mode
2.sceDisplayGetBrightness(&curBrightness, NULL); reads current brightness
3.sceDisplaySetBrightness(brightness, 0); sets the display brightness.
4.In the makefile there must be LIBS += -lpspdisplay_driver
I wrote a little test program. It compiles with no warnings but it crashes.
I commented the lines (found here in onother thread)
Code: Select all
void sceDisplay_driver_9E3C6DC6(int a0,int a1);//a0 0-100,a1 = 0/1 (set to 0)
#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_31C4BAA8(int *a0,int *a1);
#define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
Can someone please help me?
Here's my code:
Code: Select all
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <psppower.h>
#include <pspdisplay_kernel.h>
PSP_MODULE_INFO("Brightness Test ", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main() {
scePowerSetClockFrequency(222, 222, 111);
pspDebugScreenInit();
SetupCallbacks();
pspDebugScreenSetTextColor(0xffffff);
pspDebugScreenSetBackColor(0x000000);
pspDebugScreenInit();
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("Brightness test");
int curBrightness = 0;
SceCtrlData pad;
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
sceDisplayGetBrightness(&curBrightness, NULL);
//curBrightness = 60;
pspDebugScreenSetXY(0, 23);
pspDebugScreenPrintf("Press L or R to change brightness");
pspDebugScreenSetXY(0, 24);
pspDebugScreenPrintf("Press TRIANGLE to exit");
while(1) {
pspDebugScreenSetXY(0, 15);
pspDebugScreenPrintf("Current brightness: %3.3i", curBrightness);
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_LTRIGGER) {
if (curBrightness > 0){
curBrightness--;
sceDisplaySetBrightness(curBrightness, 0);
sceKernelDelayThread(100000);
}
}else if(pad.Buttons & PSP_CTRL_RTRIGGER) {
if (curBrightness < 100){
curBrightness++;
sceDisplaySetBrightness(curBrightness, 0);
sceKernelDelayThread(100000);
}
}else if(pad.Buttons & PSP_CTRL_TRIANGLE) {
break;
}
}
sceKernelExitGame();
return(0);
}
Many thanks
P.S. Sorry for my english. :)
Ciaooo
Sakya