Register

Casio Basic to SDK

Discuss issues related to the fx-9860G Software Development Kit
Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Fri May 11, 2012 1:54 pm

Start to experiment, f. i. implement the dot and the minus, which you will need.
Perhaps you read "fx-9860G Libraries.pdf" and try some of the other library functions.
It is very important to understand the code, before we proceed.
Try to get some C/C++-documentation, if you don't have it already.

I am off for about two hours now.
I'll be back!

Member
Posts: 48
Joined: Mon Apr 23, 2012 3:58 am
Location: Chennai,India
Calculators: Casio fx-9750GII, Casio fx-9860G Slim, Casio fx-9860GII

Postby nagarajan » Fri May 11, 2012 2:08 pm

Definitely I'll give it a try.
Is this the only way to get user input?

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Fri May 11, 2012 3:42 pm

nagarajan wrote:Is this the only way to get user input?

No. F. i. you already saw this: http://www.casiocalc.org/?showtopic=6781
(Though I do not know if the VRAM-address-problem of revolution has been fixed).
There are some syscalls, which could be used.
Perhaps there are some other libraries available. Scan the forums (planet casio (french), omnimaga, cemetech).

But if you are new to C/C++, I recommend to do some basic exercises at any rate.
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Sat May 12, 2012 8:23 am

About graphics functions, you can use MonochromeLib by Pierrotll, which provides lots of useful functions.

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Sat May 12, 2012 7:57 pm

nagarajan wrote:Is this the only way to get user input?

I dropped a syscall-based line-editor-snippet here
http://www.casiopeia.net/forum/viewtopic.php?f=20&t=1377
I'll be back!

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Postby aapman55 » Sun May 13, 2012 6:32 pm

read ths post and thought well lets try it. But already got confused in the example code if opening an new project.
Code: Select all
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;

    Bdisp_AllClr_DDVRAM();

    locate(1,4);
    Print((unsigned char*)"This application is");
    locate(1,5);
    Print((unsigned char*)" sample Add-In.");

    while(1){
        GetKey(&key);
    }

    return 1;
}


what does unsigned int key do?
what is undigned char?
Code: Select all
 while(1){
        GetKey(&key);
    }

is this just an infinite loop where it keeps asking for keyinput?

what does return 1 do?

and what part should i delete to input your example codes and which part must i leave untouched?

sorry for these stupid questions, im just beginning and have really no idea.

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Sun May 13, 2012 9:37 pm

Code: Select all
unsigned int key;

this declares the variable "key" of the type "unsigned int".
"unsigned int"-variables cover the range 0..4294967295 (four bytes).
"unsigned char"-variables cover the range 0..255 (one byte).

In C/C++ the compiler must know how much RAM-space a variable needs.
A declaration is necessary to inform the compiler accordingly.

Code: Select all
while(1){
        GetKey(&key);
    }

You are right. Normally "key" will be processed in some way.
In this example the infinite loop only serves the purpose to wait for the MENU-key or Shift-Ac/on.

Addins normally never quit. When idling, they wait for MENU or Shift-Ac/on, usually inside of GetKey.

"return 1" is never reached. But do not omit it.

The first trial code you can place inside of Addin_main, t. i. between the first "{" and "return 1".
I'll be back!

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Postby aapman55 » Thu May 17, 2012 9:05 am

I have a few questions.

If i now want to exit the program then i use return 0, but then the program cant be reaccessed again without switching to another menu first. So what i want to know if there is a function that does exactly the same as the menu key in a infinite loop.

I want to have a random number generator, ive found the function rand() on cprogramming.com. But when i want to print the random number to the screen it doesnt display anything. My display function might be wrong, but thus i cant check if the rand() is working or not. Here is the code that i used:
Code: Select all
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    int randomnr;
Start:
    Bdisp_AllClr_DDVRAM();
   randomnr=rand();
locate(1,1);
    PrintC( &randomnr );

    while(1){
        GetKey(&key);
if (key==KEY_CTRL_EXE) break;
    }
goto Start;
    return 1;
}



I also want to do something with arrays. Is it possible to fill the whole array with a certain number? Is it possible to take the sum of all numbers in an array? and the product of an array?

hope you can help me.

aap

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Thu May 17, 2012 9:33 am

aapman55 wrote:If i now want to exit the program then i use return 0, but then the program cant be reaccessed again without switching to another menu first. So what i want to know if there is a function that does exactly the same as the menu key in a infinite loop.

If you have to exit your addin_main instead of staying in an infinite GetKey-loop, you can enable the restart with APP_EnableRestart()...
http://www.casiopeia.net/forum/viewtopic.php?f=21&t=1368
This works with fx-9860G/GII-types (not with GII-2-types).
I'll be back!

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Postby SimonLothar » Thu May 17, 2012 10:01 am

aapman55 wrote:I want to have a random number generator


Print or PrintC work with pointers to strings or chars, resp..
If you want to display a number, you have to convert it to an (unsigned char)-array beforhand.
This can be done by itoa. I don't remember in which header-file itoa is located. I normally use the syscall.

Additionally I added the rand-function source code. Maybe you are interested.
Drop it if you do not need it any more.

I'd rather avoid the use of "goto". I'd implement loops instead.

Code: Select all
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
typedef int(*sc_iv)(void);
typedef void(*sc_viuc)( int, unsigned char* );
const unsigned int sc003B[] = { SCA, SCB, SCE, 0x003B };
#define RTC_GetTicks (*(sc_iv)sc003B)
const unsigned int sc0541[] = { SCA, SCB, SCE, 0x0541 };
#define itoa (*(sc_viuc)sc0541)


//
static unsigned int lastrandom=0x12345678;
unsigned int rand( int seed = 0 ){
    if (seed) lastrandom=seed;
    lastrandom = ( 0x41C64E6D*lastrandom ) + 0x3039;
    return ( lastrandom >> 16 );
}

int AddIn_main(int isAppli, unsigned short OptionNum)
{
  unsigned int key;
  int randomnr;
  unsigned char s[21];

// initialize the random generator (seed)
  rand( RTC_GetTicks() );   

  while ( 1 ){
    randomnr=rand();
    itoa( randomnr, s );

    locate(1,1);
    Print( s );

    GetKey( &key );
  }

  return 1;
}


I'll be back!

PreviousNext

Return to Casio fx-9860 SDK

Who is online

Users browsing this forum: No registered users and 18 guests