\ Arrow up/down for debugging/test screen 708 bytes

hex chere

(*
: /\    ( y x -- )
    5 umin >r  70 umin
    dup  r@     xy" IQPH"
    dup  r@ 1+  xy" 0110"
         r> 2 + xy" 0110" ;

: \/    ( y x -- )
    5 umin >r  70 umin
    dup  r@     xy" 0110"
    dup  r@ 1+  xy" 0110"
         r> 2 + xy" GONF" ;
*)

: /\    ( y x -- )
    5 umin >r  70 umin
    dup  r@     xy" IQPH"
    dup  r@ 1+  xy" 0110"
    dup  r@ 2 + xy" 0110"
         r> 3 + xy" 0000" ;

: \/    ( y x -- )
    5 umin >r  70 umin
    dup  r@     xy" 0000"
    dup  r@ 1+  xy" 0110"
    dup  r@ 2 + xy" 0110"
         r> 3 + xy" GONF" ;

: ARROW ( flag y x -- )     \ Frward/backward arrow
    rot if  /\  else \/ then ;


\ On/Off dots for debugging/test screen

: DOT   ( flag y x -- )     \ Eight character on/off dot
    6 umin >r  70 umin
    swap if
        dup  r@    xy" Q11P"
             r> 1+ xy" O11N" exit
    then
    dup  r@     xy" 0ED0"
         r> 1+  xy" 0CB0" ;


create FLAGS 0B allot
: !flag  ( flag +n  -- ) flags + c! ;
: @flag  ( +n -- flag )  flags + c@ ;

: !BYTE     ( b a -- )  {i2write  i2out1  i2stop} ; \ Addr. dev. & sent byte
: >LEDS     ( b -- )    dup 029 c!  invert 042 !byte ;
: @BYTE     ( a -- b )  {i2read  i2in} ; \ Addr. dev. & read byte
: INPUT     ( -- +n )   040 @byte 0FF xor ;

: set-flags     ( -- )
    input  dup >leds
    dup 01 and  0 !flag
    dup 02 and  1 !flag
    dup 04 and  2 !flag
    dup 08 and  3 !flag
    dup 10 and  4 !flag
    dup 20 and  5 !flag
    dup 40 and  6 !flag
        80 and  9 !flag
    s?  dup 7 !flag  8 !flag
    10 20 bit* 0=  A !flag ;

: .TRACE        ( -- )
    00 @flag 4 0 dot     01 @flag 1E 0 dot
    02 @flag 38 0 dot    03 @flag 52 0 dot    4 @flag 6C 0 dot
    05 @flag C 3 dot     06 @flag 64 3 dot
    07 @flag 24 4 arrow  08 @flag 4C 4 arrow
    09 @flag 38 6 dot    0A @flag 6C 6 dot ;

: TESTSCREEN    ( -- )
    setup-i2c  dm 20 06A c! \ UCB0BR0   Bitrate 400 KHz with 8 MHz DCO
    setup-display  &page
    10 22 *bic  10 21 *bis  10 27 *bis
    0 1 >xy s" Mushi sensor" &&type
    0 4 >xy s"     test" &&type
    800 ms  &page
    begin
        set-flags  .trace
    key? until
    &page ;

chere swap - dm u.

shield TEST\  freeze
