The start of a Nanoleaf library and a save problem

I’ve started working on a simple library for people like myself who have DIY Nanoleaf installations that will let you write patterns that operate at the per-panel level of granularity. So far it just has functions for turning a panel on, off, or toggle current stat, and one to check if a given pixel should be on or not. I’m still thinking of what things would be useful to add, and ways to do per-panel effects/animations. In the code below it’s toggling a random panel every 500ms. The video doesn’t quite match, when I shot it I was still trying to figure out how the timing works, after reviewing all the comments in the intro to PB programming pattern I figured it out.
One issue I am having though is I can’t save. The preview generator doesn’t seem to be coping with my code, it’s stuck saying Generating with no progress, and when I mouse over the Save Changes button I get a red slash circle.

var numPanels = 12 // Set to the total number of panels in your set
var perPanel = 12 // How many LEDs per panel
var activePanels = array(numPanels)

function activatePanel(panel) {
activePanels[panel] = 1

function deactivatePanel(panel) {
activePanels[panel] = 0

function togglePanel(panel) {
activePanels[panel] = abs(1 - activePanels[panel])

function isLit(index) {
return activePanels[trunc(index/perPanel)]

elapsedMs = 0
export function beforeRender(delta) {
t1 = time(.1)
elapsedMs += delta
if (elapsedMs > 500) {
elapsedMs = 0

export function render(index) {
h = t1 + index/pixelCount
s = 1
v = isLit(index)
hsv(h, s, v)


5 posts were split to a new topic: Drops off wifi / can’t connect