symbol SCLK = 0 'Display pin 2 to PICAXE out 0
symbol SDA = 1 'Display pin 3 to PICAXE out 1
symbol DC = 2 'Display pin 4 to PICAXE out 2
symbol CS = 3 'Display pin 5 to PICAXE out 3
symbol RES = 4 'Display pin 8 to PICAXE out 4
symbol Loop1 = b0
symbol Value= b1
symbol Loop2 = b2
symbol Command = b3
symbol Counter = b4
symbol X = b5
symbol Y = b6
symbol Mask = b7
symbol Loop3 = b8
Main:
setfreq m64
gosub ClearFast
gosub Init
REM BEGIN: ***** TO DO *****
'The lines between "REM BEGIN" and "REM END" will be replaced by Input Key code to set the desired countdown time.
SetUpScreen:
gosub ClearFast
b9 = 6 'Ones, last digit.
b10 = 10
X = 45
Y = 3
gosub GotoXY
command = 0
gosub One
b11 = 6 'Tens, third digit.
b12 = 10
X = 40
Y = 3
gosub GotoXY
command = 0
gosub Ten
Colon:
X = 35
Y = 3
gosub GotoXY
command = 0
for Loop1 = 56 to 60
Read Loop1, Value
gosub WriteToLCD
next Loop1
b13 = 6 'Hundreds, second digit.
b14 = 10
X = 30
Y = 3
gosub GotoXY
command = 0
gosub Hundred
b15 = 11 'Thousands, 1st gidit.
b16 = 15
X = 25
Y = 3
gosub GotoXY
command = 0
gosub Thousand
StartScreen:
X = 14
Y=1
gosub GotoXY
Command = 0
for Loop1 = 121 to 175 ' Send "PRESS START" to screen.
read Loop1, Value
gosub WriteToLCD
next Loop1
if pinC.6 = 1 then
goto BeginCountDown 'Wait for Key Press
end if
goto StartScreen
Rem End:**********
BeginCountdown:
X = 1
Y = 1
gosub GotoXY
Command = 0
for b20 = 1 to 15
for Loop1 = 66 to 70 ' Send "" (Space) to screen to clear previous message.
read Loop1, Value '
gosub WriteToLCD '
next Loop1
next b20
X = 18
Y=1
gosub GotoXY
Command = 0
for Loop1 = 176 to 220 'Send "TIME LEFT" to screen.
read Loop1, Value
gosub WriteToLCD
next Loop1
pause 7750
if b9 = 6 then
b9 = 1
goto Tens
end if
Ones:
X = 45
Y = 3
gosub GotoXY
for b9 = 51 to 6 step -5
Command = 0
b10 = b9 + 4
gosub One
X = 45
Y = 3
gosub GotoXY
pause 7750 'Pause 1 second at 64MHz, change if running at slower speed.
next b9
Tens:
X = 40
Y = 3
gosub GotoXY
command = 0
if b11 = 6 and b9 = 1 then
goto Hundreds
end if
b11 = b11 -5
b12 = b12 - 4
gosub Ten
goto Ones
Hundreds:
X = 30
y = 3
gosub GotoXY
command = 0
if b13 = 6 and b9 = 1 then
goto Thousands
end if
if b13 > 6 then
b13 = b13 -5
b14 = b13 + 4
gosub Hundred
b11 = 31
b12 = b11 + 4
X = 40
Y = 3
gosub GotoXY
command = 0
gosub Ten
goto Ones
end if
goto Ones
Thousands:
X = 25
y=3
gosub GotoXY
command = 0
if b15 = 6 and b13 = 6 and b11 = 6 and b9 = 1 then
goto Endprog
end if
if b15 = 6 and b13 > 6 then
b13 = 51
b14 = 55
goto Hundreds
end if
if b15 > 6 and b13 = 6 and b11 = 6 and b9 = 1 then
b15 = b15 - 5
b16 = b15 + 4
gosub Thousand
X = 30
gosub GotoXY
command = 0
b13 = 51
b14 = 55
gosub Hundred
b11 = 31
b12 = b11 + 4
X = 40
gosub GotoXY
command = 0
gosub Ten
goto Ones
end if
Stop
End
Endprog: 'Send "E N D" to screen and play tune.
X = 1
Y = 1
gosub GotoXY
Command = 0
for b20 = 1 to 15
for Loop1 = 66 to 70 ' Send "" (Space) to screen to clear previous message.
read Loop1, Value '
gosub WriteToLCD '
next Loop1
next b20
X = 25
Y=1
gosub GotoXY
Command = 0
for Loop1 = 61 to 90 '
read Loop1, Value '
gosub WriteToLCD '
next Loop1
'Wombles
tune 7, 4,($27,$69,$00,$6C,$00,$69,$27,$6C,$27,$69,$00,$C4,$2C,$44,$05,$44,$02,$04,$42,$00,$02,$69,$00,$2B,$EC,$27,$69, $00,$6C,$00,$69,$27,$6C,$27,$69,$00,$C4,$2C,$44,$05,$44,$02,$04,$42,$00,$02,$69,$2B,$C0)
Stop
End
Init:
EEPROM 0,(33,197,6,19,32,12)
EEPROM 6, (0x3E, 0x51, 0x49, 0x45, 0x3E) '0
EEPROM 11, (0x00, 0x42, 0x7F, 0x40, 0x00) '1
EEPROM 16, (0x42, 0x61, 0x51, 0x49, 0x46) '2
EEPROM 21, (0x21, 0x41, 0x45, 0x4B, 0x31) '3
EEPROM 26, (0x18, 0x14, 0x12, 0x7F, 0x10) '4
EEPROM 31, (0x27, 0x45, 0x45, 0x45, 0x39) '5
EEPROM 36, (0x3C, 0x4A, 0x49, 0x49, 0x30) '6
EEPROM 41, (0x01, 0x71, 0x09, 0x05, 0x03) '7
EEPROM 46, (0x36, 0x49, 0x49, 0x49, 0x36) '8
EEPROM 51, (0x06, 0x49, 0x49, 0x29, 0x1E) '9
EEPROM 56, (0x00, 0x36, 0x36, 0x00, 0x00) ' :
EEPROM 61, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
EEPROM 66, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
EEPROM 71, (0x7F, 0x04, 0x08, 0x10, 0x7F) 'N
EEPROM 76, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
EEPROM 81, (0x7F, 0x41, 0x41, 0x22, 0x1C) 'D
EEPROM 86, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
EEPROM 121, (0x7F, 0x09, 0x09, 0x09, 0x06) 'P
EEPROM 126, (0x7F, 0x09, 0x19, 0x29, 0x46) 'R
EEPROM 131, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
EEPROM 136, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
EEPROM 141, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
EEPROM 146, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
EEPROM 151, (0x46, 0x49, 0x49, 0x49, 0x31) 'S
EEPROM 156, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
EEPROM 161, (0x7E, 0x11, 0x11, 0x11, 0x7E) 'A
EEPROM 166, (0x7F, 0x09, 0x19, 0x29, 0x46) 'R
EEPROM 171, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
EEPROM 176, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
EEPROM 181, (0x00, 0x41, 0x7F, 0x41, 0x00) 'I
EEPROM 186, (0x7F, 0x02, 0x0C, 0x02, 0x7F) 'M
EEPROM 191, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
EEPROM 196, (0x00, 0x00, 0x00, 0x00, 0x00) 'Space
EEPROM 201, (0x7F, 0x40, 0x40, 0x40, 0x40) 'L
EEPROM 206, (0x7F, 0x49, 0x49, 0x49, 0x41) 'E
EEPROM 211, (0x7F, 0x09, 0x09, 0x09, 0x01) 'F
EEPROM 216, (0x01, 0x01, 0x7F, 0x01, 0x01) 'T
low SCLK
low SDA
low DC
low CS
low RES
pause 20
low RES
pause 500
high RES
high CS
Command = 1
for Loop1 = 0 to 5 ' Was 0 to 5 ‘ start a loop
read Loop1, Value ' read value from EEPROM
gosub WriteToLCD ' transmit to serial LCD module
next Loop1
gosub GotoXY
return
WriteToLCD:
high DC 'Data mode
if Command = 0 then DataMode
low DC 'Command mode
DataMode:
low CS
for Loop2 = 1 to 8
low SCLK
Mask = Value & 128
low SDA
if Mask = 0 then Skiphigh
high SDA
Skiphigh:
high SCLK
Value = Value * 2
next Loop2
high CS
return
ClearFast:
low SDA
high DC
low CS
for Loop1=1 to 48
for Loop3= 1 to 84
low SCLK
high SCLK
next loop3
next Loop1
return
GotoXY:
Command = 1
Value = X + 128
gosub WriteToLCD
Value = Y + 64
gosub WriteToLCD
return
Thousand:
for Loop1 = b15 to b16
Read Loop1, Value
gosub WriteToLCD
next Loop1
return
Hundred:
for Loop1 = b13 to b14
Read Loop1, Value
gosub WriteToLCD
next Loop1
return
Ten:
for Loop1 = b11 to b12
Read Loop1, Value
gosub WriteToLCD
next Loop1
return
One:
for Loop1 = b9 to b10
Read Loop1, Value
gosub WriteToLCD
next Loop1
return