
\ A small 7 segment display example

$2010 constant LEDs
$2020 constant hexA
$2030 constant hexB
$2040 constant hexC

binary

create font
0111111 , \ 0
0000110 , \ 1
1011011 , \ 2
1001111 , \ 3
1100110 , \ 4
1101101 , \ 5
1111101 , \ 6
0000111 , \ 7
1111111 , \ 8
1101111 , \ 9
1110111 , \ A
1111100 , \ B
0111001 , \ C
1011110 , \ D
1111001 , \ E
1110001 , \ F

decimal

: nibble>seg  ( u -- x ) $F and 2* font + @ ;

: byte>seg ( u -- x ) dup 4 rshift nibble>seg 8 lshift swap nibble>seg or ;

: A.x ( u -- ) byte>seg hexA io! ;
: B.x ( u -- ) byte>seg hexB io! ;
: C.x ( u -- ) byte>seg hexC io! ;

: ascii ( -- )
  begin
    key dup A.x
        dup LEDs io!
    27 =
  until
;
