hello, i'm doing a gui to reads some sensors from arduino, and i need a gui block for each sensor.
that works but is not OOP at all...
the blocks are equal and so i can wrap them in a class.
like this one:
- public class Sensor {
- private ControlP5 gui;
- private App parent; // App extends PApplet
- public Sensor(int id, App parent, ControlP5 gui) {
- this.id = id;
- this.gui = gui;
- this.parent = parent;
- gui.addNumberbox("min_in"+id);
- }
- public void set_min_in(float n) {
- // bla bla
- }
- }
And in my App class (that extends PApplet) i have:
- public void min_in_0(float n) {sensors[0].set_min_in(n);}
- public void min_in_1(float n) {sensors[1].set_min_in(n);}
- public void min_in_2(float n) {sensors[2].set_min_in(n);}
- public void min_in_3(float n) {sensors[3].set_min_in(n);}
(and a little bit ugly..)
i want something that as i click on the NumberBox of the sensor n.0 the callback call a function of the Sensor class instantiated in sensors[0] is called...
i tried to play a little bit with "class Sensor implements CallbackListener" but i haven't find an easy and direct way to do that and.. what else?
i've thought to make this with java reflection but i think it is a little bit
intricate for a similar project (it is only a gui for debug sensors and route messages from arduino to somewhere)..
i've began to write this little project in processing.org just because it has to be small and easy/fast to write and processing.org is a great tool for fast prototype..
some hints?
1