Input
Prefer joy.*? and knob.* for Machine sketches. Use raw GPIO only when you
are deliberately working below the workshop-friendly input layer.
Joystick
joy.up?: (input) () -> Bool
Behavior: True while the joystick is held up.
when joy.up?: [ set player.y to player.y - 1 ]
joy.down?: (input) () -> Bool
Behavior: True while the joystick is held down.
when joy.down?: [ set player.y to player.y + 1 ]
joy.left?: (input) () -> Bool
Behavior: True while the joystick is held left.
when joy.left?: [ set player.x to player.x - 1 ]
joy.right?: (input) () -> Bool
Behavior: True while the joystick is held right.
when joy.right?: [ set player.x to player.x + 1 ]
joy.click?: (input) () -> Bool
Behavior: True while the joystick is pressed.
when joy.click?: [ grid.clear: ]
Knobs
knob.left: (input) () -> Int
Behavior: Left knob as an easy-to-scale percentage-style value from 0 to
100.
knob.left:
knob.right: (input) () -> Int
Behavior: Right knob as an easy-to-scale percentage-style value from 0 to
100.
knob.right:
knob.left.raw: (input raw) () -> Int
Behavior: Raw ADC reading for the left knob.
knob.left.raw:
knob.right.raw: (input raw) () -> Int
Behavior: Raw ADC reading for the right knob.
knob.right.raw:
Raw Button Pattern
gpio.input: (GPIO) (pin) -> nil
Behavior: Configure a pin for input.
gpio.input: BUTTON_2
gpio.read: (GPIO) (pin) -> Int
Behavior: Read the current pin level.
gpio.read: BUTTON_2
If you need a semantic helper, define one at the Frothy layer:
button.two? is fn [
gpio.input: BUTTON_2;
(gpio.read: BUTTON_2) == 0
]
BUTTON_1 and A0 share the same raw GPIO on the mounted workshop board, so
prefer joy.*? and knob.* for first-time input work.