diff options
Diffstat (limited to 'examples/joystick.scm')
-rw-r--r-- | examples/joystick.scm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/joystick.scm b/examples/joystick.scm new file mode 100644 index 0000000..6a618de --- /dev/null +++ b/examples/joystick.scm @@ -0,0 +1,14 @@ +(define x-max 128) +(define y-max 32) + +(define (clamp x a b) + (cond ((> x b) b) ((< x a) a) (else x))) + +(let loop ((x (/ x-max 2)) (y (/ y-max 2)) (r 3)) + (c12832-cls) + (c12832-fillcircle x y r 1) + (mbed-wait-ms 50) + (loop + (clamp (cond ((joystick-active? 2) (- x 1)) ((joystick-active? 3) (+ x 1)) (else x)) 0 x-max) + (clamp (cond ((joystick-active? 0) (- y 1)) ((joystick-active? 1) (+ y 1)) (else y)) 0 y-max) + (if (joystick-active? 4) 10 3))) |