;
; Simple demo scripts for DESMO and the CYPHER
;
constant GPIO3    $1B087
constant GPIO3DIR $1B083

;
; Function to turn a LED on
;
function LEDON
	if #1 > 3
		print "LED must be 0-3"
		stop
	end
	w8 GPIO3 (R8 gpio3) | (1 << #1)
end

;
; Function to turn a LED off
;
function LEDOFF
	if #1 > 3
		print "LED must be 0-3"
		stop
	end
	w8 GPIO3 (R8 gpio3) & ~(1 << #1)
end

;
; Function to display moving LED bar
;
function TEST
	variable	I
	variable	J
	while i < 3
		j = 0;
		while j < 4
			ledon j
			j = j + 1
			delay 100
		end
		while j > 0
			j = j - 1
			ledoff j
			delay 100
		end
		i = i + 1
	end
end

;
; These commands are NOT recorded in a function, and will be performed
; when the file is loaded.
;
w8 GPIO3DIR f
w8 GPIO3 0
print "Cypher test scipts loaded, GPIO3 initialized."
print
print "Use LEDON <led>   to turn a LED on"
print "Use LEDOFF <led>  to turn a LED off"
print "Use TEST          to run LED demo"
print
