5:35 am
December 16, 2018
I have been using "Arduino compatible" some time and are now experimenting with porting other Arduino library. I am working on poring LEDP10 for writing on a 16*32 LED board. I am able to port
" void showmsg_single_static(charmsg_[],int font)"
by putting
LedP10 myled;
myled.showmsg_single_static(%s,%s);
in the translator.
This works fine with number, however when i tried to do text, it gave me error.
1:33 pm
December 16, 2018
Steffan said
Try casting to a char* like this. The underlying String library uses .c_str() which returns a const char*.
myled.showmsg_single_static((char*)%s,%s);
Thanks for prompt reply,
A) however when I tried as suggested, still doesn't work
error message:
invalid cast from type string to type char
myled.showmsg_single_static((char*)const149,const179)
B) if i just use myled.showmsg_single_static(%s,%s), it compiled and map as follow
myled.showmsg_single_static("const149",const179)
but the display is const149, instead of what was stored inside string const149
i
10:45 am
December 16, 2018
Steffan said
Oh right, you need to dereference the c string pointer from the String datatype using .c_str(). This is discussed in the user manual.
myled.showmsg_single_static((char*)%s.c_str(), %s);
Thanks , it now works perfectly. Pls let me know which manual and where in the manual can I read more about this function. It’s in the arduino compatible menu or. The Labview manual?
I would also like to suggest using a function with both string and number in the future to demonstrate the porting process on top of the analog-shield example.
4:14 pm
March 12, 2015
In the Arduino Compatible Compiler for LabVIEW in the "Porting an Arduino Library to LabVIEW" section it talks about mapping to C code and the use of the translator and using the Arduino Code Display tool to show the output C code. Form that you need knowledge of C++ to know how to map the data properly. In this case you should be able to see that a String datatype is used and you have to cast it properly to the libraries function call. It is not feasible to generate an example for every possible use case; as you can imagine there are a lot. We leave it up to the developer and that is why we provide the Arduino Code Display Tool.
31
1 Guest(s)