|
#1
|
|||
|
|||
|
unfortunaly I am not able to do that. But I think it will look great. Can somebody do this?
|
|
#2
|
|||
|
|||
|
Code:
#!/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) Sample output: Silent mode: Code:
** * * * * * ** * Code:
8 *
4 **
2 *
1 * ** **
12 : 55 : 19
Last edited by CrashandDie; 2010-04-09 at 02:57. |
| The Following User Says Thank You to CrashandDie For This Useful Post: | ||
|
#3
|
|||
|
|||
|
Updated version
Code:
#!/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() |
|
#4
|
|||
|
|||
|
Thank you very much for the Code :-). But i ment that I am not able to Programm for the N900. I made a Picture for a Binary Clock (Example).
This would be nice. Can somebody do that? Xelahu Last edited by xelahu; 2010-04-13 at 09:39. |
|
#5
|
|||
|
|||
|
Save the code to a file (binaryclock.py), and in the X-Terminal, run:
python binaryclock.py It will show the above, without the fancy graphics. I haven't done any graphical programming on the N900 lately, so wouldn't be able to make it run with a nice frontend as you shown above, but the initial idea is there. If anyone can point me to an easy tutorial on how to use Qt/Widget with python, I'd be happy to give it a shot. If anyone fancies writing a GTK frontend to it, please, join in, the more the merrier. |
![]() |
|
|