B4R Question How can i convert a Arduino Libary to B4R

pucki

Active Member
Licensed User
I have a library that runs perfectly under the Aurdino IDE.

How can I convert it so that it is available under the B4R IDE and can be integrated and used.

If possible, please provide precise instructions, as I am still unable to cope with the internal things of B4R.

Many Thanks

greeting

Pucki

* text translated from German into English with google *
 

candide

Active Member
Licensed User
to check memory leak at several steps of program, please to add :
Log("memory=", AvailableRAM)
Log("stack :",StackBufferUsage)

also, try to extend stack buffer:
#StackBufferSize: 1000 (example)
 
Upvote 0

pucki

Active Member
Licensed User
What I do not understand is that there is no user here who has so far read a 16-key keyboard with a PCF-8574. After all, this keyboard is available for $ 1.50 from 1000 sellers.

Here is a link to one of the keyboards.


The Layout is a 4 x 4 Matrix.

I connected the rows to pin 0 - 3 and the columns to pin 4-7 of the PCF-8574.

The program runs fine, but then it crashes.

Maybe Erel will write a library for such parts one day.

I can not C thats why i use b4x ;) and this is the first big problem I have with B4x. And I even write software for the Android system.

greeting

Pucki
 
Upvote 0

candide

Active Member
Licensed User
after a look at both wrappers, i don't see error, it is basic wrapper and it should work properly...

i saw one thing on original MyKeypad_I2C.h but i don't know if it crash the program

on this file found on the web we have :
B4X:
class MyKeypad_I2C
{
  public:
    MyKeypad_I2C(byte);
    void setKeyCode(byte, byte);
    void clearAllKeyCodes(void);
    bool isReady(void);
    byte receiveKey(int8_t);
    void checkKey(void);
    void printKeyCodes(void);
and we need :
B4X:
class MyKeypad_I2C
{
  public:
    MyKeypad_I2C(byte i2cAdd);
    void setKeyCode(byte code, byte index);
    void clearAllKeyCodes(void);
    bool isReady(void);
    byte receiveKey(int8_t anzahl);
    void checkKey(void);
    void printKeyCodes(void);
i suppose it is OK for you because i suppose compilation should block

after you have to check witch library have an issue.
First you should write a small project with a loop and a lot of actions using all functions of library MyPCF8574
write a work, several word
write a but and several bits
and after read all bytes with check of content
and read all bit changed and check of content.
and multiple actions to use all functions.
and add several checks of memory+ stack in your loop to check this status.

and you will see if it is running without crash. it is a way to see if issue is due to this library.

good luck
 
Upvote 0

pucki

Active Member
Licensed User
Thats the full Projekt inc. Library. The Library is in the correct pfad.

I don't know where the problem is.

greeting

Pucki
 

Attachments

  • Aufnahme-Steuerung.zip
    5.9 KB · Views: 216
Upvote 0

candide

Active Member
Licensed User
in your project, you are using a timer to launch keyboard reading every seconds, but what append when we have no answer of keyboard in one second or if this answer is late ?
in first, for debugging we can add traces and we can use a loop DO - LOOP because this loop don't launch a second loop until the first is finished.

this test can be done with file attached
=> please to try B4R project attached and we will see if you have crash (no timer, only a loop DO-LOOP) and some traces to check timing
=> if no crash, you can add LCD and check again
 

Attachments

  • keyboard.zip
    1.1 KB · Views: 195
Last edited:
Upvote 0
Top