We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am trying to reduce the CPU used by a Processing application to nil. I use the G4P library to build a gui to setup a configuration on an Arduino board (I have also a program on the Arduino Board, the program drives servos. The goal is to change the min and max allowed positions using the gui). I used a trick I found on this forum : I call noLoop at the end of draw(). I setup 4 mouse handlers (Moved, Dragged, Pressed and Released) to call loop(). In the future I would like to remove mouseMoved. Most of the behavior is ok but 2 problems remain :
1 - G4P widget are not refreshed the first time : draw executes but the widgets are not displayed. Is there a way to force G4P to redraw the view ? 2 - G4P sliders seems to intercept the mousePressed and mouseReleased event. When I click in a slider (in the grayed area), the drawing is not refreshed until I move the mouse, so mousePressed is not called.
Thanks !
Answers
Is there a way to force G4P to redraw the view ?
No
The G4P library requires Processing to loop to refresh the controls.
https://processing.org/reference/noLoop_.html
P.S.: The warning: "If using noLoop() in setup(), it should be the last line inside the block." there is 100% FALSE!
More correct approach is redraw(), which makes draw() be called once:
https://processing.org/reference/redraw_.html