Jump to content



Photo
- - - - -

Endless Loop


  • Please log in to reply
10 replies to this topic

#1 paul_brassington

paul_brassington

    Newbie

  • Members
  • Pip
  • 25 posts

  • Calculators:
    fx-9860g II SD

Posted 03 March 2013 - 05:11 PM

Hi All,

First my thanks to all who helped me get started and I'm pleased to show my first bit of code that puts 5 blocks at the bottom just above the F1 to F5 keys.

#include "fxlib.h"
#include "dispbios.h"

int AddIn_main(int isAppli, unsigned short OptionNum) {

Bdisp_AllClr_DDVRAM();
Bdisp_AreaReverseVRAM(5, 57, 20, 63); // F1
PrintMini(11,58,(unsigned char*)"1",MINI_REV);
Bdisp_AreaReverseVRAM(26, 57, 41, 63); // F2
PrintMini(32,58,(unsigned char*)"2",MINI_REV);
Bdisp_AreaReverseVRAM(47, 57, 62, 63); // F3
PrintMini(53,58,(unsigned char*)"3",MINI_REV);
Bdisp_AreaReverseVRAM(68, 57, 83, 63); // F4
PrintMini(74,58,(unsigned char*)"4",MINI_REV);
Bdisp_AreaReverseVRAM(89, 57, 104, 63); // F5
PrintMini(95,58,(unsigned char*)"5",MINI_REV);
Bdisp_PutDisp_DD();
Sleep(15000);

}

#pragma section _BR_Size
unsigned long BR_Size;
#pragma section


#pragma section _TOP

int InitializeSystem(int isAppli, unsigned short OptionNum)
{
		return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}

#pragma section

What I want to do is to put this into an endless loop unless the Menu key is pressed, because at present it just shows for 15 seconds and then finishes.

Please point me to where I can find the best solution, I'm sure it has been solved many times but I have tried a few ways without success. I have read the SDK libraries and the solution may be waiting for a key or a timer but I'd like to know the preferred way before I start seriously.

Warm Regards

Paul Brassington

#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 03 March 2013 - 05:26 PM

I am not sure how this works with fx9860 SDK, but with the PRIZM, you would put a blocking Getkey in your while loop, which would handle the menu key. Maybe that helps...

#3 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 03 March 2013 - 05:57 PM

You should do it this way:
unsigned int key;
while(1)
{
...your drawing...
GetKey(&key);
}

Then the loop is performed, the program waits for a key.
Next the loop starts again.
(If Menu was pressed, the calc shows the main menu).

Is that what you want?

#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 03 March 2013 - 06:19 PM

...

GetKey(&key);
}

Then the loop is performed, the program waits for a key.
Next the loop starts again.
(If Menu was pressed, the calc shows the main menu).

Is that what you want?


Yes, that's the blocking getkey i was talking about... it will stop the program until a key is pressed on the prizm, don't know about the 9860.

#5 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 03 March 2013 - 06:25 PM

Ok, so I missunderstood you.

Use this instead: http://www.casiopeia....php?f=2&t=1483
(see IsKeyDown)

#6 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 03 March 2013 - 07:32 PM

Ok, so I missunderstood you.

Use this instead: http://www.casiopeia....php?f=2&t=1483
(see IsKeyDown)


No, I don't think you did, maybe i phrased my last post wrong...

What I meant was does the Getkey command in 9860SDK stop the program like it does on the PRIZM?

#7 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 04 March 2013 - 05:57 AM

Yes, it does. IsKeyDown doesn't.

#8 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 04 March 2013 - 03:09 PM

Yes, it does. IsKeyDown doesn't.


IsKeyDown is compatible with the power graphic 2 calcs?

#9 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 04 March 2013 - 04:42 PM

No, but the link I posted points to A compatible replacement.

#10 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 04 March 2013 - 04:50 PM

Oh ok. What we do with the PRIZM is this (pardon my C coding skills):

while(1) {
   if (GetkeyPRGM()==keyMenu) {
	  Getkey();
   }
}

GetkeyPRGM is non blocking, but it doesn't handle the MENU key. So we check with GetkeyPRGM whether or not menu was pressed, and then we let the blocking Getkey take care of exiting to the main menu.

#11 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 04 March 2013 - 06:20 PM

That's a great idea. IsKeyDown is like GetKeyPRGM / PRGM_GetKey.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users