Froth, and this site, are pre-alpha. This site is largely OSAI-generated documentation from the Froth repo.

This tutorial uses the Froth Machine input layer: joystick booleans and knob percent values.

Read The Inputs Directly

At the prompt:

joy.up?:
joy.down?:
joy.left?:
joy.right?:
joy.click?:
knob.left:
knob.right:

Each joy.*? word returns a boolean. The knob helpers return a value on the 0..100 scale.

Map A Knob To A Pixel

Define one scaling helper:

to scale with percent, max [
  percent * max / 100
]

Use the left knob as an x coordinate:

input.frame is fn [
  here x is scale: (knob.left:), (grid.width - 1);
  grid.clear:;
  grid.set: x, 3, true;
  grid.show:
]

Run a short loop:

repeat 100 [
  input.frame:;
  ms: 30
]

Turn the knob while the loop runs. The pixel should move across the display.

Add Joystick Movement

Store a cursor position:

cursor.x is 5
cursor.y is 3

Update it from the joystick:

cursor.step is fn [
  when joy.left?: [ set cursor.x to wrap: cursor.x - 1, grid.width ];
  when joy.right?: [ set cursor.x to wrap: cursor.x + 1, grid.width ];
  when joy.up?: [ set cursor.y to wrap: cursor.y - 1, grid.height ];
  when joy.down?: [ set cursor.y to wrap: cursor.y + 1, grid.height ]
]

Draw it:

cursor.frame is fn [
  cursor.step:;
  grid.clear:;
  grid.set: cursor.x, cursor.y, true;
  grid.show:
]

Run:

repeat 200 [
  cursor.frame:;
  ms: 35
]

That is the basic input pattern for small sketches: read a boolean or percent, update a few top-level values, draw the current state.