For the big evaluation routine we currently have this giving about 15hz
Code:
'----------------------- Also creating a newled data array to be displayed on next generation -------------
FOR counter = 0 TO 1023
population = 0 :topedge = 0 :botedge = 0 :lefedge = 0 :rigedge = 0
'Grid Edge Detection
IF counter < 32 THEN botedge = 1
IF counter > 991 THEN topedge = 1
'*******************************************************************************
TempCount = Counter & 31
If TempCount = 0 THEN
lefedge = 1
ENDIF
IF TempCount = 31 THEN
rigedge = 1
ENDIF
'*******************************************************************************
'Grid Evaluation
CntPlus33 = Counter + 33
CntPlus32 = Counter + 32
CntPlus31 = Counter + 31
CntPlus1 = Counter +1
CntMinus33 = Counter - 33
CntMinus32 = Counter - 32
CntMinus31 = Counter - 31
CntMinus1 = Counter - 1
IF led[CntMinus1] > 0 THEN
IF counter > 0 THEN
Colour[population] = led[CntMinus1]
population = population + 1
ENDIF
ENDIF
IF led[CntPlus1] > 0 THEN
IF counter < 1023 THEN
Colour[population] = led[CntPlus1]
population = population + 1
ENDIF
ENDIF
IF botedge = 0 THEN
IF led [CntMinus31] > 0 THEN
Colour[population] = led[CntMinus31]
population = population + 1
ENDIF
IF led [CntMinus32] > 0 THEN
Colour[population] = led[CntMinus32]
population = population + 1
ENDIF
IF rigedge = 0 then
if led [CntMinus33] > 0 THEN
Colour[population] = led[CntMinus33]
population = population + 1
endif
ENDIF
ENDIF
IF topedge = 0 THEN
IF led [CntPlus31] > 0 THEN
Colour[population] = led[CntPlus31]
population = population + 1
ENDIF
IF led [CntPlus32] > 0 THEN
Colour[population] = led[CntPlus32]
population = population + 1
ENDIF
IF rigedge = 0 then
if led [CntPlus33] > 0 THEN
Colour[population] = led[CntPlus33]
population = population + 1
endif
ENDIF
ENDIF
lednew[counter] = led[counter]
IF led[counter] = 0 THEN
IF population = 3 THEN
if Colour[0] = Colour[1] then
lednew[counter] = Colour[0]
elseif Colour[0] = Colour[2] then
lednew[counter] = Colour[0]
elseif Colour[1] = Colour[2] then
lednew[counter] = Colour[1]
endif
ENDIF
else
IF population > 3 OR population < 2 THEN
lednew[counter] = 0
ENDIF
ENDIF
NEXT counter
Bookmarks