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 

sceKernelSuspendThread and battery information

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



Joined: 24 Mar 2008
Posts: 31

PostPosted: Mon Oct 27, 2008 6:22 am    Post subject: sceKernelSuspendThread and battery information Reply with quote

Hi everyone,
I don't understand why, when I use sceKernelSuspendThread (here in my function ~= xmbpause) I must wait a long time to see battery life time in the xmb.
But, when I don't use sceKernelSuspendThread, I can see rapidly battery life time in the xmb.
So I want to know how I can see rapidly battery life time when I use sceKernelSuspendThread :)

Here's a part of my code:
Code:

void xmbpause(SceUID thid){

   if(pauseuid >= 0)
   return;
   pauseuid = thid;
   sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_buf_now, MAX_THREAD, &thread_count_now);
   int x, y, match;
   for(x = 0; x < thread_count_now; x++){
      match = 0;
      SceUID tmp_thid = thread_buf_now[x];
      for(y = 0; y < thread_count_start; y++){
         if((tmp_thid == thread_buf_start[y]) || (tmp_thid == thid)){
            match = 1;
            break;
         }
      }
      if(match == 0)
      sceKernelSuspendThread(tmp_thid);
   }

}

//resume game
void xmbresume(SceUID thid){

   if(pauseuid != thid)
   return;
   pauseuid = -1;
   int x, y, match;
   for(x = 0; x < thread_count_now; x++){
      match = 0;
      SceUID tmp_thid = thread_buf_now[x];
      for(y = 0; y < thread_count_start; y++){
         if((tmp_thid == thread_buf_start[y]) || (tmp_thid == thid)){
            match = 1;
            break;
         }
      }
      if(match == 0)
      sceKernelResumeThread(tmp_thid);
   }

}

int main_thread(SceSize args, void *argp)
{
    unsigned int oldpad = 0;
   
    int info = 0;
    char strinfo2[64];
   
     SceCtrlData pad;
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
     
    while(1)
     {
         sceCtrlReadBufferPositive(&pad, 1);
      
         if(info) {   
        if(scePowerIsBatteryExist() > 0) {
         sprintf(strinfo2,"Hours Left (in min(~in h)) --> %d min approximately %d h", scePowerGetBatteryLifeTime(), scePowerGetBatteryLifeTime()/60);
         }
         else {
         sprintf(strinfo2,"Hours Left (in minutes(~in h)) --> ??");
         }   
       }
         
       if(pad.Buttons != oldpad) {
           if(pad.Buttons & PSP_CTRL_SQUARE) {
               if(info == 0) {
                    info = 1;
             }
                 else if(info == 1) {
                    info = 0;
                }
             }
         }
         oldpad = pad.Buttons;
      
       if(info) {
         blit_string(1,100,strinfo2,0x000000,0x111fff);   
       xmbpause(main_thread);      
       }
       else if(!info) {
       xmbresume(main_thread);
       }
      
      sceKernelDelayThread(100000);
     }
 return 0;
}


Thanks to everyone who help me

PS: I'm apologize for my bad English because I'm French :)
_________________
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
Back to top
View user's profile Send private message
pspflashsystem



Joined: 24 Mar 2008
Posts: 31

PostPosted: Tue Oct 28, 2008 5:49 am    Post subject: Reply with quote

Any idea??
_________________
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Oct 28, 2008 8:03 am    Post subject: Reply with quote

EDIT..
Maybe you should wait for blit to finish. Its probably suspending the thread before that.
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