[sharing] Knowing if a device is visible
Mattijs Kneppers
Sep 18 2023 | 9:17 am
Sometimes when a device has a CPU-intensive UI, it is useful to know whether the device is visible at all. If not, drawing can be turned off. Here is a script that does that.
"use strict"; /* Outputs a bang when it becomes visible. Only passes on incoming bangs when visible. Note that to be visible for a device in presentation mode, this object must be included in presentation. */ mgraphics.init() function paint() { outlet(0, "bang") } function bang() { mgraphics.redraw() }
Here is an example of usage in a device.