Created
June 14, 2013 20:05
-
-
Save Pharylon/5784850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CON | |
_xinfreq=5_000_000 'We are using a 5Mhz Crystal | |
_clkmode=xtal1+pll8x 'Run at 16x5 = 80mhz! | |
S2Pin = 17 | |
S3Pin = 18 | |
S4Pin = 19 | |
VAR | |
byte outArray[100] | |
byte message[4000] 'If your message is 10 characters, each character is 8x7 (56)bytes so 56*10=560 bytes. | |
byte letters[400] | |
long DisplayMode | |
long SnakePixelsX[56] | |
long SnakePixelsY[56] | |
long CurrentLength | |
long DrawStack[20] | |
long MoveStack[20] | |
long InputStack[20] | |
long GraphicsCogID | |
long CurrentDirection ' 0 is up, 1 is right, 2 is down, 3 is left. | |
long Seed | |
long FruitX | |
long FruitY | |
long FruitExists | |
long GameOver | |
long TurnQueued | |
PUB main | X | |
SetLetters | |
DisplayMode := 0 | |
cognew(Input, @InputStack) | |
repeat | |
if DisplayMode == 1 | |
clearArray(@message,3900) | |
DrawString(string("HARDIK"), @message, 30) {All letters have to be in caps} | |
repeat X from 0 to 115 {"100" This number needs to be bigger for larger messages, See below for a longer message} | |
clearArray(@outArray,80) | |
copyArray(@message,@outArray,X,1) {use "2" instead of "1" for a horizontal badge, set to 0 if badge is vertical and leds are on the bottom} | |
showArray(@outArray,10000) {The 10000 adjusts brightness and smoothness, 10000 seems to be optimal} | |
waitcnt(1500000 + cnt) | |
elseif DisplayMode == 2 | |
clearArray(@message,3900) | |
DrawString(string("I WIN"), @message, 30) {All letters have to be in caps} | |
repeat X from 0 to 115 {"100" This number needs to be bigger for larger messages, See below for a longer message} | |
clearArray(@outArray,80) | |
copyArray(@message,@outArray,X,1) {use "2" instead of "1" for a horizontal badge, set to 0 if badge is vertical and leds are on the bottom} | |
showArray(@outArray,10000) {The 10000 adjusts brightness and smoothness, 10000 seems to be optimal} | |
waitcnt(1500000 + cnt) | |
pub Input | ButtonPressed | |
ButtonPressed := 0 | |
repeat | |
if ina[S2Pin] == 0 AND ButtonPressed == 0 | |
DisplayMode := 1 | |
waitcnt(clkfreq/5 + cnt) | |
ButtonPressed := 1 | |
elseif ina[S4Pin] == 0 AND ButtonPressed == 0 | |
DisplayMode := 2 | |
waitcnt(clkfreq/5 + cnt) | |
ButtonPressed := 1 | |
elseif ina[S2Pin] == 1 AND ButtonPressed == 1 | |
ButtonPressed := 0 | |
elseif ina[S4Pin] == 1 AND ButtonPressed == 1 | |
ButtonPressed := 0 | |
{repeat | |
clearArray(@message,3900) | |
DrawString(string("HARDIK"), @message, 30) {All letters have to be in caps} | |
repeat X from 0 to 115 {"100" This number needs to be bigger for larger messages, See below for a longer message} | |
clearArray(@outArray,80) | |
copyArray(@message,@outArray,X,1) {use "2" instead of "1" for a horizontal badge, set to 0 if badge is vertical and leds are on the bottom} | |
showArray(@outArray,10000) {The 10000 adjusts brightness and smoothness, 10000 seems to be optimal} | |
waitcnt(1500000 + cnt) {This is how fast the text scrolls, 1500000 seems to be optimal} | |
clearArray(@message,3900) | |
DrawString(string("HSCLT"), @message, 30) | |
repeat X from 0 to 100 | |
clearArray(@outArray,80) | |
copyArray(@message,@outArray,X,1) | |
showArray(@outArray,10000) | |
waitcnt(1500000 + cnt) | |
} | |
PUB SetLetters | |
letters[0*6+0]:=%00000000 | |
letters[0*6+1]:=%00111100 | |
letters[0*6+2]:=%01000010 | |
letters[0*6+3]:=%01111110 | |
letters[0*6+4]:=%01000010 | |
letters[0*6+5]:=%01000010 | |
letters[0*6+6]:=%00000000 | |
letters[1*6+0]:=%00000000 | |
letters[1*6+1]:=%01111100 | |
letters[1*6+2]:=%01000010 | |
letters[1*6+3]:=%01111100 | |
letters[1*6+4]:=%01000010 | |
letters[1*6+5]:=%01111100 | |
letters[1*6+6]:=%00000000 | |
letters[2*6+0]:=%00000000 | |
letters[2*6+1]:=%00111110 | |
letters[2*6+2]:=%01000000 | |
letters[2*6+3]:=%01000000 | |
letters[2*6+4]:=%01000000 | |
letters[2*6+5]:=%00111110 | |
letters[2*6+6]:=%00000000 | |
letters[3*6+0]:=%00000000 | |
letters[3*6+1]:=%01111100 | |
letters[3*6+2]:=%01000010 | |
letters[3*6+3]:=%01000010 | |
letters[3*6+4]:=%01000010 | |
letters[3*6+5]:=%01111100 | |
letters[3*6+6]:=%00000000 | |
letters[4*6+0]:=%00000000 | |
letters[4*6+1]:=%01111110 | |
letters[4*6+2]:=%01000000 | |
letters[4*6+3]:=%01111110 | |
letters[4*6+4]:=%01000000 | |
letters[4*6+5]:=%01111110 | |
letters[4*6+6]:=%00000000 | |
letters[5*6+0]:=%00000000 | |
letters[5*6+1]:=%01111110 | |
letters[5*6+2]:=%01000000 | |
letters[5*6+3]:=%01111110 | |
letters[5*6+4]:=%01000000 | |
letters[5*6+5]:=%01000000 | |
letters[5*6+6]:=%00000000 | |
letters[6*6+0]:=%00000000 | |
letters[6*6+1]:=%00111110 | |
letters[6*6+2]:=%01000000 | |
letters[6*6+3]:=%01001110 | |
letters[6*6+4]:=%01000010 | |
letters[6*6+5]:=%00111100 | |
letters[6*6+6]:=%00000000 | |
letters[7*6+0]:=%00000000 | |
letters[7*6+1]:=%01000010 | |
letters[7*6+2]:=%01000010 | |
letters[7*6+3]:=%01111110 | |
letters[7*6+4]:=%01000010 | |
letters[7*6+5]:=%01000010 | |
letters[7*6+6]:=%00000000 | |
letters[8*6+0]:=%00000000 | |
letters[8*6+1]:=%01111110 | |
letters[8*6+2]:=%00010000 | |
letters[8*6+3]:=%00010000 | |
letters[8*6+4]:=%00010000 | |
letters[8*6+5]:=%01111110 | |
letters[8*6+6]:=%00000000 | |
letters[9*6+0]:=%00000000 | |
letters[9*6+1]:=%01111110 | |
letters[9*6+2]:=%00001000 | |
letters[9*6+3]:=%00001000 | |
letters[9*6+4]:=%01001000 | |
letters[9*6+5]:=%01110000 | |
letters[9*6+6]:=%00000000 | |
letters[10*6+0]:=%00000000 | |
letters[10*6+1]:=%01000110 | |
letters[10*6+2]:=%01011000 | |
letters[10*6+3]:=%01100000 | |
letters[10*6+4]:=%01011000 | |
letters[10*6+5]:=%01000110 | |
letters[10*6+6]:=%00000000 | |
letters[11*6+0]:=%00000000 | |
letters[11*6+1]:=%01000000 | |
letters[11*6+2]:=%01000000 | |
letters[11*6+3]:=%01000000 | |
letters[11*6+4]:=%01000000 | |
letters[11*6+5]:=%01111110 | |
letters[11*6+6]:=%00000000 | |
letters[12*6+0]:=%00000000 | |
letters[12*6+1]:=%01000010 | |
letters[12*6+2]:=%01100110 | |
letters[12*6+3]:=%01011010 | |
letters[12*6+4]:=%01000010 | |
letters[12*6+5]:=%01000010 | |
letters[12*6+6]:=%00000000 | |
letters[13*6+0]:=%00000000 | |
letters[13*6+1]:=%01000010 | |
letters[13*6+2]:=%01000010 | |
letters[13*6+3]:=%01100010 | |
letters[13*6+4]:=%01011010 | |
letters[13*6+5]:=%01000110 | |
letters[13*6+6]:=%00000000 | |
letters[14*6+0]:=%00000000 | |
letters[14*6+1]:=%00111100 | |
letters[14*6+2]:=%01000010 | |
letters[14*6+3]:=%01000010 | |
letters[14*6+4]:=%01000010 | |
letters[14*6+5]:=%00111100 | |
letters[14*6+6]:=%00000000 | |
letters[15*6+0]:=%00000000 | |
letters[15*6+1]:=%01111100 | |
letters[15*6+2]:=%01000010 | |
letters[15*6+3]:=%01111100 | |
letters[15*6+4]:=%01000000 | |
letters[15*6+5]:=%01000000 | |
letters[15*6+6]:=%00000000 | |
letters[16*6+0]:=%00000000 | |
letters[16*6+1]:=%00111100 | |
letters[16*6+2]:=%01000010 | |
letters[16*6+3]:=%01010010 | |
letters[16*6+4]:=%01100010 | |
letters[16*6+5]:=%01111100 | |
letters[16*6+6]:=%10000000 | |
letters[17*6+0]:=%00000000 | |
letters[17*6+1]:=%01111100 | |
letters[17*6+2]:=%01000010 | |
letters[17*6+3]:=%01111100 | |
letters[17*6+4]:=%01011000 | |
letters[17*6+5]:=%01000110 | |
letters[17*6+6]:=%00000000 | |
letters[18*6+0]:=%00000000 | |
letters[18*6+1]:=%00111100 | |
letters[18*6+2]:=%01000000 | |
letters[18*6+3]:=%00111100 | |
letters[18*6+4]:=%00000010 | |
letters[18*6+5]:=%01111100 | |
letters[18*6+6]:=%00000000 | |
letters[19*6+0]:=%00000000 | |
letters[19*6+1]:=%01111100 | |
letters[19*6+2]:=%00010000 | |
letters[19*6+3]:=%00010000 | |
letters[19*6+4]:=%00010000 | |
letters[19*6+5]:=%00010000 | |
letters[19*6+6]:=%00000000 | |
letters[20*6+0]:=%00000000 | |
letters[20*6+1]:=%01000010 | |
letters[20*6+2]:=%01000010 | |
letters[20*6+3]:=%01000010 | |
letters[20*6+4]:=%01000010 | |
letters[20*6+5]:=%00111100 | |
letters[20*6+6]:=%00000000 | |
letters[21*6+0]:=%00000000 | |
letters[21*6+1]:=%01000010 | |
letters[21*6+2]:=%01000010 | |
letters[21*6+3]:=%01000010 | |
letters[21*6+4]:=%00100100 | |
letters[21*6+5]:=%00011000 | |
letters[21*6+6]:=%00000000 | |
letters[22*6+0]:=%00000000 | |
letters[22*6+1]:=%01000010 | |
letters[22*6+2]:=%01000010 | |
letters[22*6+3]:=%01011010 | |
letters[22*6+4]:=%01100110 | |
letters[22*6+5]:=%01000010 | |
letters[22*6+6]:=%00000000 | |
letters[23*6+0]:=%00000000 | |
letters[23*6+1]:=%01000010 | |
letters[23*6+2]:=%00100100 | |
letters[23*6+3]:=%00011000 | |
letters[23*6+4]:=%00100100 | |
letters[23*6+5]:=%01000010 | |
letters[23*6+6]:=%00000000 | |
letters[24*6+0]:=%00000000 | |
letters[24*6+1]:=%01000010 | |
letters[24*6+2]:=%00100100 | |
letters[24*6+3]:=%00011000 | |
letters[24*6+4]:=%00011000 | |
letters[24*6+5]:=%00011000 | |
letters[24*6+6]:=%00000000 | |
letters[25*6+0]:=%00000000 | |
letters[25*6+1]:=%01111110 | |
letters[25*6+2]:=%00000100 | |
letters[25*6+3]:=%00011000 | |
letters[25*6+4]:=%00100000 | |
letters[25*6+5]:=%01111110 | |
letters[25*6+6]:=%00000000 | |
PUB DrawString(stringToSend,inArray,offset)|X | |
repeat X from 1 to StrSize(stringToSend) | |
DrawByteArray(byte[stringToSend][X-1],@byte[inArray],X*8+10+offset) | |
PUB DrawByteArray(inLetter,inArray,offset) | BY,BX | |
repeat BY from 0 to 6 | |
repeat BX from 0 to 7 | |
IF letters[(inLetter-65)*6+BY] >> BX &1==1 | |
byte[inArray][(7-BX+offset)*7+(6-BY)]:=1 | |
pub clearArray(inArray,arraySize)|x,y | |
repeat x from 0 to arraySize | |
byte[inArray][x]:=0 | |
pub showArray(inArray,cspeed)|x,y | |
repeat x from 0 to 7 | |
repeat y from 0 to 6 | |
if byte[inArray][(7-x)*7+y]==1 | |
light(y,x) | |
waitcnt(cspeed + cnt) | |
else | |
dira[20..27] := 0 | |
dira[20..27] := 0 | |
pub copyArray(inArray,oArray,offset,direction)|x,y | |
if (direction==0) | |
repeat x from 0 to 6 | |
repeat y from 0 to 6 | |
if byte[inArray][(7-x+offset)*7+y]==1 | |
byte[oArray][((7-y))*7+(6-x)]:=1 | |
if (direction==1) | |
repeat x from 0 to 6 | |
repeat y from 0 to 6 | |
if byte[inArray][(7-x+offset)*7+y]==1 | |
byte[oArray][((y))*7+(x)]:=1 | |
if (direction==2) | |
repeat x from 0 to 7 | |
repeat y from 0 to 6 | |
if byte[inArray][(7-x+offset)*7+y]==1 | |
byte[oArray][(7-(x))*7+y]:=1 | |
pub light(Y, X) | |
dira[20..27] := 0 | |
dira[X+20] := 1 | |
outa[X+20] := 0 | |
if X+20 > Y+20 | |
dira[Y+20] := 1 | |
outa[Y+20] := 1 | |
else | |
dira[Y+20 + 1] := 1 | |
outa[Y+20 + 1] := 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment