![]() |
2010-04-08
, 20:47
|
Posts: 2 |
Thanked: 0 times |
Joined on Apr 2010
|
#1
|
![]() |
2010-04-09
, 02:55
|
Posts: 336 |
Thanked: 610 times |
Joined on Apr 2008
@ France
|
#2
|
#!/bin/python VERBOSE_MODE = True # Set to False for no information. import time class BinaryClock: t = time.time() localtime = time.localtime(t) def display(self, verbose = False): hour = str(self.localtime[3]) minute = str(self.localtime[4]) second = str(self.localtime[5]) hms = (hour, minute, second) for line in reversed(range(4)): if verbose: timeline = "%s " % (1 << line) else: timeline = "" for tt in hms: if len(tt) == 1: tt = "0" + tt for i in range(2): if self.bit_at_p(int(tt[i]), line) == 1: timeline += "*" else: timeline += " " timeline += " " print timeline if verbose: print " %s%s : %s%s : %s%s" % (hour[0], hour[1], minute[0], minute[1], second[0], second[1]) def bit_at_p(self, N, p): dis = 1 << p x = N & dis return int(x > 0) bc = BinaryClock() bc.display(VERBOSE_MODE)
** * * * * * ** *
8 * 4 ** 2 * 1 * ** ** 12 : 55 : 19
The Following User Says Thank You to CrashandDie For This Useful Post: | ||
![]() |
2010-04-13
, 01:47
|
Posts: 336 |
Thanked: 610 times |
Joined on Apr 2008
@ France
|
#3
|
#!/bin/python VERBOSE_MODE = True # Set to False for no information. import time class BinaryClock: localtime = time.localtime(time.time()) def display(self, verbose = False): hms = (self.pad_zero(self.localtime[3]), self.pad_zero(self.localtime[4]), self.pad_zero(self.localtime[5])) for line in reversed(range(4)): if verbose: timeline = "%s " % (1 << line) else: timeline = "" for tt in hms: for i in range(2): if self.bit_at_p(int(tt[i]), line) == 1: timeline += "*" else: timeline += " " timeline += " " print timeline if verbose: print " %s%s : %s%s : %s%s" % (hms[0][0], hms[0][1], hms[1][0], hms[1][1], hms[2][0], hms[2][1]) def bit_at_p(self, N, p): dis = 1 << p x = N & dis return int(x > 0) def update(self): self.localtime = time.localtime(time.time()) def pad_zero(self, tt): tt = str(tt) if len(tt) == 1: return "0" + tt else: return tt bc = BinaryClock() while True: print "\n" * 24 bc.display(VERBOSE_MODE) time.sleep(1) bc.update()
![]() |
2010-04-13
, 09:36
|
Posts: 2 |
Thanked: 0 times |
Joined on Apr 2010
|
#4
|
![]() |
2010-04-13
, 11:35
|
Posts: 336 |
Thanked: 610 times |
Joined on Apr 2008
@ France
|
#5
|