We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am working hard on an LED sequencer and have gotten it working they way I want with an altered Matrix class and re-compiled controlP5, but it isnt a great way to distribute the project, so I want to understand how to instead extend the Matrix class and add the features I need. I have looked at the example for extending classes with controlP5 but it is only for a generic controller, not for a controlInterface like Matrix. I have done this:
class ColorMatrix extends Matrix<ColorMatrix> {
int[][] _myCellColor;
ColorMatrix(ControlP5 cp5, String theName) {
super(cp5, theName);
for (int x = 0; x < _myCellX; x++) {
for (int y = 0; y < _myCellY; y++) {
_myCellColor[x][y] = 0;
}
}
}
//some additional new methods and method overrides
}
and then called it like this:
new ColorMatrix(cp5, "LED_sequence")
.setPosition(50, 400)
.setSize(800, 290)
.setGrid(SEQUENCE_LENGTH, NUMBER_OF_LED)
.setGap(2, 2)
.setInterval(200)
.setMode(ControlP5.MULTIPLES)
.setColorBackground(color(1,0, .1))
.setBackground(color(1,0, .3))
;
But the compiler returns "The function setPosition(int, int) does not exist." which I assumes means my inheritence is not happening correctly. Appreciate any help!
Answers
If setPosition() is a ControlP5's method, you can only invoke it if somehow your custom
class
inherited it from Matrix! :-SSHi, you can extend a Matrix as shown in the example below.