B4R Question Call C Function

Hypnos

Active Member
Licensed User
Longtime User
I have some inline C code in my BR4 project:

B4X:
void drawRect(B4R::Object* o)
{
   B4R::B4RAdafruitGFX* bgfx = (B4R::B4RAdafruitGFX*)o->data.PointerField;
   bgfx->gfx->drawRect(b4r_main::_cx, b4r_main::_cy, b4r_main::_cw, b4r_main::_ch, b4r_main::_ccolor);
}


my question is: how can I call the drawRect function within the inline C ?

can I use : drawRect();

Maybe it's a simple question, but for me, I got headache eveytime when I handle inline C ..... Thanks!
 

Hypnos

Active Member
Licensed User
Longtime User
B4X:
RunNative("drawRect",null)
Since you have not to pass parameters use null as second parameters in RunNative.
Thanks tigrot!
but maybe my question is not clear, I understand the RunNative command, but for some reason I have to call it inside the inline C code, mean that I need the c syntax to call the drawRect function.

Hope that you understand what I mean. (It’s a bit difficult for me to write in English....)

Thanks!

Example:
B4X:
B4R:
RunNative ("drawAll",Null)

Inline C Code:
void drawRect(B4R::Object* o)
{
   B4R::B4RAdafruitGFX* bgfx = (B4R::B4RAdafruitGFX*)o->data.PointerField;
   bgfx->gfx->drawRect(b4r_main::_cx, b4r_main::_cy, b4r_main::_cw, b4r_main::_ch, b4r_main::_ccolor);
}

void drawAll(B4R::Object* o)
{
drawRect (null);  ??? <-- I need to correct syntax
drawCircle(null);  ???
drawLine(null);  ???
}
 
Last edited:
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
Try:
B4X:
b4r_main::_drawRect(o);

Why do you need it?

Thank you Erel!

My case:

- I find a code in C can extract the pixel information from a 12x12 Chinese Font file
- I have to pass those info to GFX and use the drawPixel / drawRect command to plot the character to the LCD screen

I think it should have some better / direct method for the solution, but it's more easy for me to use the "Call" function.
(as I can't read/write C code, it's the most easy way for me...)

Here is the result:

 
Last edited:
Upvote 0
Top