Prequel
primitive recursive driven programming
(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.
←0
←0
←0
← calls
← instructions
← memory (max use: 0)
BLINKP.SHOW_AND_EXIT()
BLINKP.NUM_PIXELSTotal number of pixels.-> 8This value is constant.BLINKP.ELAPSED_TIMETotal number of seconds elapsed since the beginning of program execution.CALL.ARGSHolds the list of arguments passed with CALL.-> [arg1, ..., argN]
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-1Alternative 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.0Changes take effect after the next call toBLINKP.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.0Changes take effect after the next call toBLINKP.SHOW_AND_WAIT or BLINKP.SHOW_AND_EXIT.BLINKP.SHOW_AND_WAIT(seconds)Commit changes to the display and wait the specified secondsbefore 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.ARGSAlternative 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