LED demo using IO Board and mainboard LEDs

I finished up the 1.5 mainboard and the IO card. Everything seems to be working fine, except for the timer initialization, which I’m still sorting out.

Meanwhile, here are some words that I wrote to exercise the LEDs.

Warning: lots of blinking LEDs if you are sensitive to that.

Enjoy!

\ type **leds** again to remove all of these (and everything defined later)
marker **leds**

\ select a led based on power of two
\ this way you can do 7 led instead of 128, etc.
: led ( u -- ) 1 swap lshift ;

\ helps me remember that c! is required
: led! ( u port -- ) c! ;

\ Given porta or portb and maximum number of leds to light do a scanner style display
\ Max on porta is 8 and max on portb is 4

\ Invoke as portX max_led scanner
\ porta 8 scanner or portb 4 scanner, for example 
: scanner ( addr u -- ) 0 do dup i led swap led! 30000 delay loop 10000 delay 0 swap led! ;

\ Scan from porta to portb n times; limit on stack
: repeater ( n -- ) 0 do porta 8 scanner portb 4 scanner loop ;

\ Alternate bottom four leds and top four leds on porta
: flashera 0 do 15 porta led! 10000 delay 240 porta led! 10000 delay loop 0 porta led! ;

\ Alternate bottom 2 and top two leds on portb
: flasherb 0 do 3 portb led! 10000 delay 12 portb led! 10000 delay loop 0 portb led! ;

\ create character arrays with useful porta led values
create leds 24 c, 36 c, 66 c, 129 c,
create leds_bigger 24 c, 36 c, 66 c, 129 c, 129 c, 66 c, 36 c, 24 c,

: burst 4 0 do leds i + c@ porta led! 10000 delay loop 10000 delay 0 porta led! ;
: burst_bigger 8 0 do leds_bigger i + c@ porta led! 10000 delay loop 10000 delay 0 porta led! ;

: burst_demo 0 do burst loop ;
: burst_bigger_demo 0 do burst_bigger loop ;

\ this will provide a demo of the leds
: led_demo burst_bigger 2 repeater 5 flashera 5 flasherb 10 burst_demo 2 repeater 3 burst_bigger_demo ;



1 Like