Please, help for sceDisplaySetBrightness

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

Moderators: cheriff, TyRaNiD

Post Reply
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Please, help for sceDisplaySetBrightness

Post by sakya »

Hi! :)

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
because in display_kernel.h now there are sceDisplayGetBrightness and sceDisplaySetBrightness.

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&#40;"Brightness Test ", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125;

int main&#40;&#41; &#123;
		  scePowerSetClockFrequency&#40;222, 222, 111&#41;;

          pspDebugScreenInit&#40;&#41;;
          SetupCallbacks&#40;&#41;;

		  pspDebugScreenSetTextColor&#40;0xffffff&#41;;
		  pspDebugScreenSetBackColor&#40;0x000000&#41;;
		  pspDebugScreenInit&#40;&#41;;
		  pspDebugScreenSetXY&#40;0, 0&#41;;
		  pspDebugScreenPrintf&#40;"Brightness test"&#41;;

		  int curBrightness = 0;
		  SceCtrlData pad;
		  sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

		  sceDisplayGetBrightness&#40;&curBrightness, NULL&#41;;
		  //curBrightness = 60;

		  pspDebugScreenSetXY&#40;0, 23&#41;;
		  pspDebugScreenPrintf&#40;"Press L or R to change brightness"&#41;;
		  pspDebugScreenSetXY&#40;0, 24&#41;;
		  pspDebugScreenPrintf&#40;"Press TRIANGLE to exit"&#41;;

		  while&#40;1&#41; &#123;
			pspDebugScreenSetXY&#40;0, 15&#41;;
			pspDebugScreenPrintf&#40;"Current brightness&#58; %3.3i", curBrightness&#41;;				

			sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
			if&#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41; &#123;
				if &#40;curBrightness > 0&#41;&#123;
					curBrightness--;
					sceDisplaySetBrightness&#40;curBrightness, 0&#41;;
					sceKernelDelayThread&#40;100000&#41;;
				&#125;
			&#125;else if&#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41; &#123;
				if &#40;curBrightness < 100&#41;&#123;
					curBrightness++;
					sceDisplaySetBrightness&#40;curBrightness, 0&#41;;
					sceKernelDelayThread&#40;100000&#41;;
				&#125;
			&#125;else if&#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41; &#123;
				break;
			&#125;
		  &#125;
		  sceKernelExitGame&#40;&#41;;
		  return&#40;0&#41;;
&#125;
What I'm doing wrong?
Many thanks

P.S. Sorry for my english. :)

Ciaooo
Sakya
zhangaihe
Posts: 4
Joined: Wed Jul 04, 2007 8:44 pm

Remove all pspsceDebug* function

Post by zhangaihe »

error is calling pspsceDebug* function,Remove all.
sorry my english,i am from china
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Re: Remove all pspsceDebug* function

Post by sakya »

Hi! :)
zhangaihe wrote:error is calling pspsceDebug* function,Remove all.
sorry my english,i am from china
I'll try, many thanks for your reply. :)
You're saying I can use the brightness functions only in a graphic application, and not in a "plain debug" app?

Ciaoooo
Sakya
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Code: Select all

void sceDisplay_driver_9E3C6DC6&#40;int a0,int a1&#41;;//a0 0-100,a1 = 0/1 &#40;set to 0&#41;
#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_31C4BAA8&#40;int *a0,int *a1&#41;;
#define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
Do you have -lpspdisplay_driver in your makefile on the LIBS line?

It works for me in a debug screen app.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
Art wrote:

Code: Select all

void sceDisplay_driver_9E3C6DC6&#40;int a0,int a1&#41;;//a0 0-100,a1 = 0/1 &#40;set to 0&#41;
#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_31C4BAA8&#40;int *a0,int *a1&#41;;
#define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
Do you have -lpspdisplay_driver in your makefile on the LIBS line?

It works for me in a debug screen app.
Yes, I have this LIB:

Code: Select all

LIBS = -lpsppower -lpspdisplay_driver
I tried the lines above, but with the new sdk (I updated it some days ago) the program won't copile.
In pspdisplay_kernel.h there are defined directly sceDisplayGetBrightness and sceDisplaySetBrightness, I think before there were sceDisplay_driver_9E3C6DC6 and sceDisplay_driver_31C4BAA8.

So I included pspdisplay_kernel.h...

This way the program compiles, but crashes as soon as sceDisplayGetBrightness is executed.
I don't know what to check! ;)

Ciaooo
Sakya
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Brightness program template: http://www.megaupload.com/?d=06AL4W64
Art.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
Art wrote:Brightness program template: http://www.megaupload.com/?d=06AL4W64
Art.
Wow, many thanks.
This way I can undestand if the problem is my program or my toolchain. :)

Ciaooo
Sakya
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

possibly.... I haven't upgraded mine in over a year I've been doing this.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
Art wrote:possibly.... I haven't upgraded mine in over a year I've been doing this.
Tested: works! :)
I'll check my program and your code.
Many thanks for your help. :)

EDIT: Modified my makefile and just added -lpspgu

Code: Select all

LIBS = -lpspgu -lpspdisplay_driver -lpsppower
Now works! :)
Many thanks again.

Ciaooo
Sakya
Post Reply