ControlP5 disable boradcasting (broad)
in
Contributed Library Questions
•
1 year ago
In controlP5range.pde there is this part:
- // disable boradcasting since setRange and setRangeValues will trigger an event
- .setBroadcast(false)
I don't understand why it's set to false, i disabled it and it doesn't harm.
Could someone explain?
all code from controlP5range.pde:
- import controlP5.*;
- ControlP5 cp5;
- int myColorBackground = color(0,0,0);
- int colorMin = 100;
- int colorMax = 100;
- Range range;
- void setup() {
- size(700,400);
- cp5 = new ControlP5(this);
- range = cp5.addRange("rangeController")
- // disable boradcasting since setRange and setRangeValues will trigger an event
- .setBroadcast(false)
- .setPosition(50,50)
- .setSize(400,40)
- .setHandleSize(20)
- .setRange(0,255)
- .setRangeValues(50,100)
- // after the initialization we turn broadcast back on again
- .setBroadcast(true)
- .setColorForeground(color(255,40))
- .setColorBackground(color(255,40))
- ;
- noStroke();
- }
- void draw() {
- background(colorMax);
- fill(colorMin);
- rect(0,0,width,height/2);
- }
- void controlEvent(ControlEvent theControlEvent) {
- if(theControlEvent.isFrom("rangeController")) {
- // min and max values are stored in an array.
- // access this array with controller().arrayValue().
- // min is at index 0, max is at index 1.
- colorMin = int(theControlEvent.getController().getArrayValue(0));
- colorMax = int(theControlEvent.getController().getArrayValue(1));
- println("range update, done.");
- }
- }
- void keyPressed() {
- switch(key) {
- case('1'):range.setLowValue(0);break;
- case('2'):range.setLowValue(100);break;
- case('3'):range.setHighValue(120);break;
- case('4'):range.setHighValue(200);break;
- case('5'):range.setRangeValues(40,60);break;
- }
- }
1