# BIG_TIME.py
#
# A large digit, digital clock DEMO.
# $VER: BIG_TIME.py_Version_1.00.00_(C)2013_B.Walker_G0LCU.
# This is issued as GPL2.
#
# This alters the Terminal/CLI colours on some systems but
# it is very simple to return back to the original state.
#
# Although designed to work on all Versions of Python from Version
# 1.4.0 this code also works on *NIX style platforms and developed
# on a Macbook Pro 13 inch circa August 2012...
#
# Final cleanup using MEmacs in the AMIGA platform...
# Enjoy finding simple solutions to often very difficult problems.

import os
import sys
import time

# Set up all _variables_ as is required.
# Force global values to suit Python 1.4.0 for the Classic AMIGAs.
global DATE
global TIME
global count
global vert
global horiz
global p
global bg
global fg

DATE="$VER: BIG_TIME.py_Version_1.00.00_(C)2013_B.Walker_G0LCU."
TIME=""
count=0
vert=1
horiz=1
p="(C)2013, B.Walker, G0LCU."
bg="\x1B[0;31;40m"
fg="\x1B[0;31;41m"

# A generic clear screen function.
# Designed around the Classic AMIGA but works fine for the
# platforms below...
def clrscn():
	print("\x1B[0;31;40m")
	for count in range(0, 64, 1):
		print(" ")
	print("\x1B[1;1f")

# This function reads the date and stores the time in "TIME".
# This works from Python 1.4.0 to 3.3.2 on Classic AMIGAs,
# E-UAE, WinUAE, Mac OSX and Linux/UNIX flavours...
# Python 1.4.0 makes life difficult, but hey, what fun getting
# it working eh! ;o)
def clock():
	global DATE
	global TIME
	global count
	TIME=""
	# The line below is needed like this for Python Version
	# 1.4.0 to Python 2.0.1...
	DATE=time.ctime(time.time())
	# Extract the TIME from the 24 character DATE string.
	# This string has not changed since Version 1.4.0...
	# This is Python version independent.
	for count in range(11, 16, 1):
		TIME=TIME+DATE[count]

# This is the plot routine for the big characters,
def plot():
	global vert
	global horiz
	global p
	p="\x1B["+str(vert)+";"+str(horiz)+"f"
	vert=vert+1

# *********************************************************
# These are the eleven BIG characters.
def zero():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"  "+fg+"  "+bg+" ")
	plot()
	print(p+fg+" "+bg+" "+fg+" "+bg+" "+fg+" "+bg+" ")
	plot()
	print(p+fg+"  "+bg+"  "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def one():
	global p
	global bg
	global fg
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"  "+fg+"  "+bg+"  ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"  "+fg+"   "+bg+" ")
def two():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+"     "+bg+" ")
def three():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def four():
	global p
	global bg
	global fg
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"  "+fg+"  "+bg+"  ")
	plot()
	print(p+bg+" "+fg+" "+bg+" "+fg+" "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"  "+fg+" "+bg+"  ")
	plot()
	print(p+fg+"     "+bg+" ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
def five():
	global p
	global bg
	global fg
	plot()
	print(p+fg+"     "+bg+" ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def six():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+"    "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def seven():
	global p
	global bg
	global fg
	plot()
	print(p+fg+"     "+bg+" ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+bg+"   "+fg+" "+bg+"  ")
	plot()
	print(p+bg+"  "+fg+" "+bg+"   ")
	plot()
	print(p+bg+" "+fg+" "+bg+"    ")
	plot()
	print(p+fg+" "+bg+"     ")
	plot()
	print(p+fg+" "+bg+"     ")
def eight():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def nine():
	global p
	global bg
	global fg
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+fg+" "+bg+"   "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"    "+bg+" ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+bg+"    "+fg+" "+bg+" ")
	plot()
	print(p+bg+" "+fg+"   "+bg+"  ")
def colon():
	global p
	global bg
	global fg
	plot()
	print(p+bg+"      ")
	plot()
	print(p+bg+"      ")
	plot()
	print(p+bg+"  "+fg+" "+bg+"   ")
	plot()
	print(p+bg+"      ")
	plot()
	print(p+bg+"  "+fg+" "+bg+"   ")
	plot()
	print(p+bg+"      ")
	plot()
	print(p+bg+"      ")
# End of the character set.
# *********************************************************

# Print all of these characters first just to display them.
# This will last for 5 seconds only...
# Done longhand purely for fun...
# The generic clear screen function.
clrscn()
horiz=10
vert=9
zero()
horiz=16
vert=9
one()
horiz=22
vert=9
two()
horiz=28
vert=9
three()
horiz=34
vert=9
four()
horiz=40
vert=9
five()
horiz=46
vert=9
six()
horiz=52
vert=9
seven()
horiz=58
vert=9
eight()
horiz=64
vert=9
nine()
horiz=70
vert=9
colon()
# "time.sleep(x)" does not work on the AMIGA platform so a work-around...
if sys.platform=="amiga":
	os.system("C:Wait 5")
# This is for the other platforms
if sys.platform!="amiga":
	time.sleep(5)
# The generic clear screen.
clrscn()
# This is the main loop
while 1:
	# Extract the time from the DATE string.
	clock()
	# Use the TIME string and plot the large characters accordingly!
	print("\x1B[0;31;40m\x1B[2;30fThe time is "+TIME+"..."+bg+" ")
	for count in range(0, 5, 1):
		horiz=(25+(6*count))
		vert=9
		if TIME[count]=="0":
			zero()
		if TIME[count]=="1":
			one()
		if TIME[count]=="2":
			two()
		if TIME[count]=="3":
			three()
		if TIME[count]=="4":
			four()
		if TIME[count]=="5":
			five()
		if TIME[count]=="6":
			six()
		if TIME[count]=="7":
			seven()
		if TIME[count]=="8":
			eight()
		if TIME[count]=="9":
			nine()
		if TIME[count]==":":
			colon()
	# As before "time.sleep(x)" does not work on Classic AMIGAs.
	if sys.platform=="amiga":
		os.system("C:Wait 1")
	# For the other platforms.
	if sys.platform!="amiga":
		time.sleep(1)
# End of BIG_TIME.py DEMO...