Here is my first test with the leds:
https://youtu.be/_1POJM5hCWk
Its not a 4k monitor, I did not have enough leds
Mikko
P.S. I really would like to have the simple TCP/IP send/recieve string commands in AGK.
Also I'm missing the AppGameKit player in Pi.
-------------------------------------------------------------------
// Project: MK-LEDS
// Created: 2016-05-08 Mikko Ketonen
// set window properties
SetWindowTitle( "MK-LEDS" )
SetWindowSize( 640, 480, 0 )
// set display properties
SetVirtualResolution( 640, 480)
SetOrientationAllowed( 1, 1, 1, 1 )
global display as integer [6,6]
global outputpin as integer [1,25] // virtual gpios 1-25
global GPO as integer [1,25]
GPO[1]=[0,2,3,4,14,15,17,18,27,22,23,24,10,9,11,8,7,5,6,12,13,19,16,26,20,21] // real gpios
batx=3:baty=5
ex=random(1,5)
ey=0
hurry#=1
for f=1 to 25 // set the initial output pin values
outputPin[1,f] = OpenToWrite( "gpio:"+str(GPO[1,f]) )
WriteByte( outputPin[1,f], 0)
next f
do
inc ey:
if ey>5
ey=0: ex=random(1,5):hurry#=hurry#-0.01
endif
while Timer()<hurry#
if GetRawKeyState(37) then left=1 // check for left key
if GetRawKeyState(39) then right=1 // check for right key
if GetRawKeyState(27) then stop() // check for escape key and exit
endwhile
if left and batx>1 then dec batx
if right=1 and batx<5 then inc batx
left=0
right=0
For x=1 to 5
for y=1 to 5
if x=batx and y=baty or x=ex and y=ey
display[x,y]=1
else
display[x,y]=0
endif
If batx=ex and baty=ey
For x=1 to 5
for y=1 to 5
display[x,y]=1
next
next
ey=0: ex=random(1,5)
endif
next
next
leds()
Sync()
ResetTimer()
loop
function leds()
count=0
ox=270:oy=190
for x=1 to 5
Dx=x*20
for y=1 to 5
inc count
Dy=y*20
if display[x,y]=1
drawbox(ox+Dx,oy+Dy,ox+Dx+10,oy+Dy+10,255,255,255,255,0)
WriteByte( outputPin[1,count], 1 ) // set the pin value
endif
if display[x,y]=0
drawbox(ox+Dx,oy+Dy,ox+Dx+10,oy+Dy+10,55,55,55,55,0)
WriteByte( outputPin[1,count], 0) // set the pin value
endif
next y
next x
endfunction
function stop()
for f=1 to 25
CloseFile( outputPin[1,f] )
next f
end
endfunction
mikko_ketonen( )hotmail.com