Jump to content

Binary Clock


Achilles
 Share

Recommended Posts

This has turned out well - great job! It got me thinking about doing one myself, because I like binary clocks a little different style - hours are represented by a single binary column, minutes by their own (single) binary column, and seconds likewise, also a little easier to glance at and 'decode' to the time...here's the result (forgive the extreme basic-ness of this script...took about 8 minutes to write):

#Include <GUIConstants.au3>
$BinClock=GUICreate("BinClock",100,200,-1,-1,-1,$WS_EX_TOOLWINDOW)
Global $HoursLED[5]
$HoursLED[0]=GUICtrlCreateLabel("1",10,160,20,20,$SS_SUNKEN+$SS_CENTER)
$HoursLED[1]=GUICtrlCreateLabel("2",10,130,20,20,$SS_SUNKEN+$SS_CENTER)
$HoursLED[2]=GUICtrlCreateLabel("4",10,100,20,20,$SS_SUNKEN+$SS_CENTER)
$HoursLED[3]=GUICtrlCreateLabel("8",10,70,20,20,$SS_SUNKEN+$SS_CENTER)
$HoursLED[4]=GUICtrlCreateLabel("16",10,40,20,20,$SS_SUNKEN+$SS_CENTER)
;1,2,4,8,16,32
Global $MinutesLED[6]
$MinutesLED[0]=GUICtrlCreateLabel("1",40,160,20,20,$SS_SUNKEN+$SS_CENTER)
$MinutesLED[1]=GUICtrlCreateLabel("2",40,130,20,20,$SS_SUNKEN+$SS_CENTER)
$MinutesLED[2]=GUICtrlCreateLabel("4",40,100,20,20,$SS_SUNKEN+$SS_CENTER)
$MinutesLED[3]=GUICtrlCreateLabel("8",40,70,20,20,$SS_SUNKEN+$SS_CENTER)
$MinutesLED[4]=GUICtrlCreateLabel("16",40,40,20,20,$SS_SUNKEN+$SS_CENTER)
$MinutesLED[5]=GUICtrlCreateLabel("32",40,10,20,20,$SS_SUNKEN+$SS_CENTER)
Global $SecondsLED[6]
$SecondsLED[0]=GUICtrlCreateLabel("1",70,160,20,20,$SS_SUNKEN+$SS_CENTER)
$SecondsLED[1]=GUICtrlCreateLabel("2",70,130,20,20,$SS_SUNKEN+$SS_CENTER)
$SecondsLED[2]=GUICtrlCreateLabel("4",70,100,20,20,$SS_SUNKEN+$SS_CENTER)
$SecondsLED[3]=GUICtrlCreateLabel("8",70,70,20,20,$SS_SUNKEN+$SS_CENTER)
$SecondsLED[4]=GUICtrlCreateLabel("16",70,40,20,20,$SS_SUNKEN+$SS_CENTER)
$SecondsLED[5]=GUICtrlCreateLabel("32",70,10,20,20,$SS_SUNKEN+$SS_CENTER)
Global $HoursLabel=GUICtrlCreateLabel(@HOUR,10,185,20,15,$SS_CENTER)
Global $MinutesLabel=GUICtrlCreateLabel(@MIN,40,185,20,15,$SS_CENTER)
Global $SecondsLabel=GUICtrlCreateLabel(@SEC,70,185,20,15,$SS_CENTER)
GUICtrlCreateLabel(":",32,185,5,15,$SS_CENTER)
GUICtrlCreateLabel(":",62,185,5,15,$SS_CENTER)

SetClock()
GUISetState()
AdlibEnable("SetClock",1000)
Do
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func SetClock()
    $i=1
    For $n=0 To 4
        If BitAND(@HOUR,$i) Then
            GUICtrlSetBkColor($HoursLED[$n],0x77FF77)
        Else
            GUICtrlSetBkColor($HoursLED[$n],0x444444)
        EndIf
        GUICtrlSetData($HoursLabel,@HOUR)
        $i*=2
    Next
    $i=1
    For $n=0 To 5
        If BitAND(@MIN,$i) Then
            GUICtrlSetBkColor($MinutesLED[$n],0x77FF77)
        Else
            GUICtrlSetBkColor($MinutesLED[$n],0x444444)
        EndIf
        GUICtrlSetData($MinutesLabel,@MIN)
        $i*=2
    Next
    $i=1
    For $n=0 To 5
        If BitAND(@SEC,$i) Then
            GUICtrlSetBkColor($SecondsLED[$n],0x77FF77)
        Else
            GUICtrlSetBkColor($SecondsLED[$n],0x444444)
        EndIf
        GUICtrlSetData($SecondsLabel,@SEC)
        $i*=2
    Next
EndFunc
Note this flickers every few seconds because I don't have it check if a box shouldn't change state...it just resets every box every second. Wouldn't be hard to add, but...I didn't! :)
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

This has turned out well - great job! It got me thinking about doing one myself, because I like binary clocks a little different style - hours are represented by a single binary column, minutes by their own (single) binary column, and seconds likewise, also a little easier to glance at and 'decode' to the time...here's the result (forgive the extreme basic-ness of this script...took about 8 minutes to write):

;Code...

Note this flickers every few seconds because I don't have it check if a box shouldn't change state...it just resets every box every second. Wouldn't be hard to add, but...I didn't! :)

Hey, I like this new style, however I think it takes longer to read in general then a normal binary clock.

One thing, you might want to make this on GuiEventMode so that it exits automatically and not after one second...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...