'------------------------------------------------------------------
'sequens.bas johnf john.fisher@tauntonschool.co.uk 26/10/2001
'Used to create sequences of coloured lights via parallel port
'The screen mimics the mains-powered bulbs allowing off-line testing
'Try it for discos, party lights, Halloween, Guy Fawkes- or to impress!
'PS Makes a great traffic light simulator too. Two sets for the crossing roads.
'In UK we have a different sequence to that in the US! (NO filter-on-red)
'Que aproveche! Muchas gracias, Carl, por Liberty BASIC. Sobresaliente!
'Assumes this port is on &H378 (the usual address)
'Gave me a chance to revise the color command, * read/ dat/ restore
'By using data commands it is very easy to plan a sequence
'-------------------------------------------------------------------
nomainwin
WindowWidth = 480
WindowHeight = 280
UpperLeftX = 32
UpperLeftY = 32
graphicbox #window.box1, 20, 20, 440, 80
textbox #window.t, 020, 120, 440, 40
textbox #window.t2, 020, 170, 440, 30
textbox #window.t3, 020, 210, 440, 30
open "Parallel Port driver" for graphics_nsb as #window
print #window, "setfocus";
print #window, "trapclose [out_of_here]";
print #window, "fill lightgray";
print #window.t, "!font ariel_bold 24"
print #window.t, " Parallel port pattern driver"
print #window.t2, "!font ariel 12"
print #window.t2, " Sequence and timing set in data statements. Port at &H378";
print #window.t2, "!font ariel 12"
print #window.t3, " Now plug in the full power lights! jhf 28/10/2001"
print #window.box1, "goto 400 10"
print #window.box1, "down"
print #window.box1, "fill black"
finished =0
pace =4
while finished <>1
scan
read op$, duration
if op$ ="end" then
finished =1
end if
if op$ ="repeat" then
restore
print #window.box1, "flush"
end if
op =binStringToDecimal( op$)
out hexdec( "&H378"), op
now =time$("milliseconds")
while time$("milliseconds") -now <>"-" then
j =j +2^(8 -i)
print #window.box1, "backcolor 255 "; str$(255 *i/8); " "; str$( 255 -255 *i/8)
print #window.box1, "goto "; str$( -30 +50 *i); " 10"
print #window.box1, "boxfilled "; str$( -30 +40 +50 *i); " 60"
else
print #window.box1, "backcolor darkblue"
print #window.box1, "goto "; str$( -30 +50 *i); " 10"
print #window.box1, "boxfilled "; str$( -30 +40 +50 *i); " 60"
end if
next i
binStringToDecimal =j
end function
' running light
data "-------*", 0300
data "------*-", 0300
data "-----*--", 0300
data "----*---", 0300
data "---*----", 0300
data "--*-----", 0300
data "-*------", 0300
data "*-------", 0300
data "--------", 1000
' alternate
data "*-*-*-*-", 0400
data "-*-*-*-*", 0400
data "*-*-*-*-", 0400
data "-*-*-*-*", 0400
data "*-*-*-*-", 0400
data "-*-*-*-*", 0400
data "*-*-*-*-", 0400
data "-*-*-*-*", 0400
data "--------", 1000
' different alternator
data "----****", 0400
data "****----", 0400
data "-----***", 0400
data "***-----", 0400
data "------**", 0400
data "**------", 0400
data "-------*", 0400
data "*-------", 0400
data "--------", 1000
' build & decay
data "*-------", 0200
data "**------", 0200
data "***-----", 0200
data "****----", 0200
data "*****---", 0200
data "******--", 0200
data "*******-", 0200
data "********", 1000
data "-*******", 0200
data "--******", 0200
data "---*****", 0200
data "----****", 0200
data "-----***", 0200
data "------**", 0200
data "-------*", 0200
data "--------", 2000
data "repeat", 0
data "end", 0