Object data-type
in
Programming Questions
•
1 year ago
Hi everyone
I am using a custom library for some hardware prototypes and am running into an issue which I cant resolve.
One of the functions provided by the library is
getDULData(); which returns
Object[] as data-type. What I am expecting is an array of integers. However using int() gives me an error, as the int() function does not except the Object datatype.
The library comes with an example, which sadly confuses me even more, and throws an error.
it initiates the veriable "res" like this:
- Integer[] res=null;
and within draw then assigns the Object[] to it
- res=dul.getDULData();
When I run the code it says cannot convert Object[] to Integer[]
*
- Here is the complete code
- import processing.serial.*;
- import dulRadio.*;
- import processing.opengl.*;
- import de.looksgood.ani.*;
- DULRadio dul;
- Integer[] res=null;
- PGraphics pg;
- String[] texts=new String[14];
- void setup() {
- frameRate(25);
- size(screen.width, screen.height);
- pg=createGraphics(screen.width, screen.height,OPENGL);
- //Replace "COM79" with the COM port you inserted the USB stick into
- dul=new DULRadio(this, "COM79", 115200, 13);
- Ani.init(this);
- }
- void draw() {
- pg.beginDraw();
- pg.background(255);
- res=dul.getDULData();
- if (res!=null && res.length==4) {
- float m=map(res[1], -255, 255, 0.5, 1.5);
- float m2=map(res[2], -255, 255, 0.5, 1.5);
- float m3=map(res[3], -255, 255, 0.5, 1.5);
- pg.translate(width/2, height/2);
- pg.pushMatrix();
- pg.rotateZ(PI*m);
- pg.rotateX(PI*m2);
- pg.rotateY(PI*m3);
- pg.box(100);
- pg.popMatrix();
- }
- pg.endDraw();
- }
More infos to what this is about can be found here:
http://www.digitalurbanliving.dk/news/news/dul-radio.php
Its actually pretty cool :-)
*
If anyone could give me some tip on how to sort out my data-issues, I would be really grateful
Thanks
p.
1