porting labview to LEDP10 | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
porting labview to LEDP10
December 16, 2018
5:35 am
Avatar
shklo
Member
Members
Forum Posts: 6
Member Since:
December 16, 2018
sp_UserOfflineSmall Offline

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.

December 18, 2018
12:34 am
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

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);

December 18, 2018
1:33 pm
Avatar
shklo
Member
Members
Forum Posts: 6
Member Since:
December 16, 2018
sp_UserOfflineSmall Offline

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

December 18, 2018
4:30 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

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);

December 19, 2018
10:45 am
Avatar
shklo
Member
Members
Forum Posts: 6
Member Since:
December 16, 2018
sp_UserOfflineSmall Offline

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.

December 19, 2018
4:14 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

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.

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
7
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356