Prequel
primitive recursive driven programming


Blinkp

(This example requires web workers.)

Blinkp is an unofficial Prequel simulator of Pimoroni's Blinkt! — a Raspberry Pi add-on with 8 RGB LEDs.
Create and run simple animations while honing your Prequel skills.

Shuffle Clear

Run Pause Stop

0
0
0
← calls
← instructions
← memory (max use: 0)


Prequel program

Edit Save Debug

Module: EXIT

BLINKP.SHOW_AND_EXIT()

Input:

BLINKP.NUM_PIXELS
 Total number of pixels.
 -> 8
 This value is constant.
BLINKP.ELAPSED_TIME
 Total number of seconds elapsed since the beginning of program execution.
CALL.ARGS
 Holds the list of arguments passed with CALL.
 -> [arg1, ..., argN]

Procedures:

BLINKP.GET_PIXEL(&r, &g, &b, &brightness?, index)
 Get RGB values and brightness of the pixel at index.
 The brightness return variable is optional.
 -> r: integer between 0 and 255
 -> g: integer between 0 and 255
 -> b: integer between 0 and 255
 -> brightness: number between 0.0 and 1.0
 -> index: integer between 0 and BLINKP.NUM_PIXELS-1
 Alternative syntax: r, g, b, brightness? = BLINKP.GET_PIXEL(index)
BLINKP.SET_PIXEL(index, r, g, b, brightness?)
 Set pixel at index with RGB values r g b and the specified brightness.
 The brightness argument is optional; if not used, it keeps the previous value.
 -> index: integer between 0 and BLINKP.NUM_PIXELS-1
 -> r: integer between 0 and 255
 -> g: integer between 0 and 255
 -> b: integer between 0 and 255
 -> brightness: number between 0.0 and 1.0
 Changes take effect after the next call to
  BLINKP.SHOW_AND_WAIT or BLINKP.SHOW_AND_EXIT.
BLINKP.CLEAR()
 Shorthand for BLINKP.SET_ALL(0, 0, 0).
BLINKP.SET_ALL(r, g, b, brightness?)
 Equivalent to calling BLINKP.SET_PIXEL for all pixels:
  BLINKP.SET_PIXEL(0, r, g, b, brightness?)
  BLINKP.SET_PIXEL(1, r, g, b, brightness?)
  ...
  BLINKP.SET_PIXEL(BLINKP.NUM_PIXELS-1, r, g, b, brightness?)
BLINKP.SET_BRIGHTNESS(brightness)
 Set the brightness value of all pixels to brightness.
 -> brightness: number between 0.0 and 1.0
 Changes take effect after the next call to
  BLINKP.SHOW_AND_WAIT or BLINKP.SHOW_AND_EXIT.
BLINKP.SHOW_AND_WAIT(seconds)
 Commit changes to the display and wait the specified seconds
  before continuing execution by restarting the program counter.
BLINKP.SHOW_AND_EXIT()
 Commit changes to the display and halt the program.
BLINKP.RGB_TO_YIQ(&y, &i, &q, r, g, b)
BLINKP.YIQ_TO_RGB(&r, &g, &b, y, i, q)
BLINKP.RGB_TO_HLS(&h, &l, &s, r, g, b)
BLINKP.HLS_TO_RGB(&r, &g, &b, h, l, s)
BLINKP.RGB_TO_HSV(&h, &s, &v, r, g, b)
BLINKP.HSV_TO_RGB(&r, &g, &b, h, s, v)
 Convert values between different color spaces.
 Alternative syntax: x, y, z = BLINKP.ABC_TO_XYZ(a, b, c)
CALL(&retvar1, ..., &retvarM, @modname, arg1, ..., argN)
 Start executing module modname, copying N arguments and expecting M return values.
 -> retvar: name of variable to hold the corresponding return value retval
 -> modname: name of module to start executing
 -> arg: value to be copied to the list CALL.ARGS
 Alternative syntax: retvar1, ..., retvarM = CALL(@modname, arg1, ..., argN)
 Note that recursive module calls are not allowed.
RETURN(retval1, ..., retvalM)
 Return M values from the current module.
 Resume execution at the next instruction of the corresponding CALL.
 -> retval: value to be copied to the corresponding variable retvar

Additional examples can be found on GitHub.