Jump to content



Photo
- - - - -

Getkeywait doesnt work correctly on fx-9860GII

fx-9860GII SDK

  • Please log in to reply
2 replies to this topic

#1 danbot

danbot

    Newbie

  • Members
  • Pip
  • 1 posts
  • Gender:Male

  • Calculators:
    fx-9860Gii
    fx-911ES plus

Posted 26 January 2017 - 06:58 PM

So i've finally gotten around to learning to make add-ins for my fx-9860gii and i'm having a little bit of trouble getting the functionality I want.

 

What I'm trying to do is write a function that will repeat constantly, but once the menu key is pressed the main menu opens up. my first thought was..

unsigned int key;
while(1)
{
    GetKey(&key);

    if(key!=KEY_CTRL_MENU)
    {
        //loop code
    }
} 

but then I found that this won't work because the GetKey() command halts the program and so it doesn't continue the loop unless a key is pressed.

eventually I came across the BKey_GetKeyWait() and the documentation says that it has the functionality I'm looking for. If I was to write..

unsigned int kcode1,kcode2;
short unused;

while(1)
{
    Bkey_GetKeyWait(&kcode1, &kcode2, KEYWAIT_HALTOFF_TIMEROFF, 0, 0, &unused);

//loop code
}

Then since I'm using  KEYWAIT_HALTOFF_TIMEROFF the program wont halt anymore and will continuously run the loop code. Whats more, since the fifth input is 0 the documentation says that the function will open up the menu rather than return the keycode when the menu button is pressed.

 

This isn't the case however, the calculator runs the loop and doesn't go to the main menu when the button is pressed.

does anyone know how to get the functionality I want or can at least tell me what I'm doing wrong?

 



#2 f16falcona46

f16falcona46

    Newbie

  • Members
  • Pip
  • 1 posts

  • Calculators:
    FX-9750GII, flashed with FX-9860GII OS

Posted 19 September 2018 - 12:52 PM

Looks like a bug to me. My sketchy solution is:

if (IsKeyDown(KEY_CTRL_MENU)) {
	GetKey(&key);
}

which is non-blocking, but has the disadvantage that if the menu is canceled, then the program is still stuck waiting at GetKey.

Unfortunately even GetKeyWait(KEYWAIT_HALTON_TIMERON, 0, 1, &key) does not work because it breaks Auto Power Down.


Edited by f16falcona46, 19 September 2018 - 12:54 PM.


#3 GodOfCows

GodOfCows

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts
  • Gender:Male

  • Calculators:
    fx-9860gii, fx-9750gii, TI-92, TI-89, TI-83 Plus

Posted 19 September 2018 - 03:21 PM

(This is a really old post, I don't even know if this guy is even active)

 

I don't know a specific solution, but the function SetTimer() could help.

 

This is the function I use for my add-ins (I'm not advance)

You can look at how it works with an add-in that I made (https://community.ca...7788-tron-game/)

 

Or you can look at this simple code I made (I can't check for errors right now, but it gives you the basic idea)

#include "stdio.h" //sprintf needed

void test()
{
static a = 0;
char string[30];
a++;
Bdisp_AllClr_DDVRAM();
sprintf(&string,"%d",a);

PrintXY(0,0,string,0);

}

int main()
{
int key;

while (1)
{
SetTimer(1,500,test); //this function interupts whatever is currently going on and executes test function
GetKey(&key);
}

return 0;
}


Edited by GodOfCows, 19 September 2018 - 03:23 PM.






Also tagged with one or more of these keywords: fx-9860GII, SDK

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users