Jump to content

Binary Clock


no4ndth3n
 Share

Recommended Posts

Just wanted to post my latest project to get some feedback...I threw it together last night so the code is a little bit messy. I am still having a little bit of trouble with the GUI flickering, but have controlled it for the most part.

EDIT: Guess I should explain how to read the clock...the two columns on the farthest right are the seconds...starting from the bottom, middle two columns are minutes...left columns are hours

So in the screenshot, the time would be 3:21:32

Essentially it looks like this...

0 0 0 0 0 0

0 0 0 0 0 0

0 1 1 0 1 1

0 1 0 1 1 0

-----------------

Column 1 = 00 --> 0

Column 2 = 0011 --> 3

Column 3 = 010 --> 2

Column 4 = 0001 --> 1

Column 5 = 011 --> 3

Column 6 = 0010 --> 2

What this program has:

1. Draggable GUI

2. Always on top setting

3. 4 different LED colors

4. 12/24 hour time formats

5. Tooltip that displays actual time when hovering over GUI

Attached are the exe and source code. I grabbed a couple snippets of code from the database for dragging as well as forming the GUI and rouding the corners.

#cs
BINARY CLOCK v1.0 
Created by Eric Ito
#ce

#include <GuiConstants.au3>
#include "GuiHyperLink.au3"
#include "Events.au3"
#NoTrayIcon

Opt("GUIOnEventMode", 1); Sets script to execute certain programs when events occur
Opt("TrayMenuMode",1); Exit/Pause will not be shown on tray icon
Opt("TrayOnEventMode",1); Sets script to execute commands on tray events

; Defaults for GUI Window position
$X = -1
$Y = -1

; Check for an INI file, and set the x and y values if present
If FileExists(@ScriptDir & "\config.ini") Then
    $X = IniRead("config.ini","Settings","x","-1")
    $Y = IniRead("config.ini","Settings","y","-1")
EndIf

; Create GUI
$my_gui = GUICreate("Binary Clock", 147, 90, $X, $Y, $WS_POPUP,$WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

; Round off the GUI
_GuiRoundCorners($my_gui, 10, 10, 20, 20)

$pic = GUICtrlCreatePic(@ScriptDir & "\Bin\clock_large.bmp",-1,-1,167,110)

; Context Menu layout...tabbed for easy viewing
$CONTEXT_MENU           = GUICtrlCreateContextMenu($pic)
    $SETTINGS           = GUICtrlCreateMenu("Settings",$CONTEXT_MENU)
        $COLOR_MENU     = GUICtrlCreateMenu("LED Color",$SETTINGS)
            $RED        = GUICtrlCreateMenuitem("Red",$COLOR_MENU)
            $BLUE       = GUICtrlCreateMenuitem("Blue",$COLOR_MENU)
            $GREEN      = GUICtrlCreateMenuitem("Green",$COLOR_MENU)
            $AMBER      = GUICtrlCreateMenuitem("Amber",$COLOR_MENU)
        $TIME_FORMAT    = guictrlcreatemenu("Time Format",$SETTINGS)
            $24_HOUR    = GUICtrlCreateMenuitem("24 Hour",$TIME_FORMAT)
            $12_HOUR    = GUICtrlCreateMenuitem("12 Hour",$TIME_FORMAT)
    $ON_TOP             = GUICtrlCreateMenuitem("Always on Top",$CONTEXT_MENU)
                          GUICtrlCreateMenuitem("",$CONTEXT_MENU)
    $ABOUT              = GUICtrlCreateMenuitem("About",$CONTEXT_MENU)
                  GUICtrlCreateMenuitem("",$pic)
$EXIT           = GUICtrlCreateMenuitem("Exit",$pic)

; Again check settings from INI file if exists, otherwise use defaults
If FileExists(@ScriptDir & "\config.ini") Then
    $LED_COLOR = IniRead(@ScriptDir & "\config.ini","Settings","LED Color","blue")
    If $LED_COLOR = "red" Then
        GUICtrlSetState($RED,$GUI_CHECKED)
    ElseIf $LED_COLOR = "blue" Then
        GUICtrlSetState($BLUE,$GUI_CHECKED)
    ElseIf $LED_COLOR = "green" Then
        GUICtrlSetState($GREEN,$GUI_CHECKED)
    Else
        GUICtrlSetState($AMBER,$GUI_CHECKED)
    EndIf

    If IniRead(@ScriptDir & "\config.ini","Settings","Time Format","24 Hour") = "24 Hour" Then
        GUICtrlSetState($24_HOUR,$GUI_CHECKED)
    Else
        GUICtrlSetState($12_HOUR,$GUI_CHECKED)
    EndIf
    
    If IniRead(@ScriptDir & "\config.ini","Settings","On Top","1") = "1" Then
        GUICtrlSetState($ON_TOP,$GUI_CHECKED)
    Else
        GUICtrlSetState($ON_TOP,$GUI_UNCHECKED)
    EndIf
Else
    $LED_COLOR = "red"

    GUICtrlSetState($RED,$GUI_CHECKED)
    GUICtrlSetState($24_HOUR,$GUI_CHECKED)
    GUICtrlSetState($ON_TOP,$GUI_CHECKED)
EndIf


; Initialize LEDs, used 21 to keep from using LED[0]
Global $LED[21]
Global $POWER = "off"

; Column 1
$LED[1] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",23,49,16,16)
$LED[2] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",23,65,16,16)

; Column 2
$LED[3] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",40,17,16,16)
$LED[4] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",40,33,16,16)
$LED[5] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",40,49,16,16)
$LED[6] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",40,65,16,16)

; Column 3
$LED[7] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",61,33,16,16)
$LED[8] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",61,49,16,16)
$LED[9] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",61,65,16,16)

; Column 4
$LED[10] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",78,17,16,16)
$LED[11] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",78,33,16,16)
$LED[12] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",78,49,16,16)
$LED[13] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",78,65,16,16)

; Column 5
$LED[14] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",99,33,16,16)
$LED[15] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",99,49,16,16)
$LED[16] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",99,65,16,16)

; Column 6
$LED[17] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",116,17,16,16)
$LED[18] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",116,33,16,16)
$LED[19] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",116,49,16,16)
$LED[20] = GUICtrlCreatePic(@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp",116,65,16,16)


; Events for the GUI and Controls
GUISetOnEvent($GUI_EVENT_CLOSE,"quit")
GUICtrlSetOnEvent($pic,"drag")
GUICtrlSetOnEvent($EXIT,"quit")
GUICtrlSetOnEvent($12_HOUR,"_Format_Time")
GUICtrlSetOnEvent($24_HOUR,"_Format_Time")
GUICtrlSetOnEvent($RED,"_toRed")
GUICtrlSetOnEvent($BLUE,"_toBlue")
GUICtrlSetOnEvent($GREEN,"_toGreen")
GUICtrlSetOnEvent($AMBER,"_toAmber")
GUICtrlSetOnEvent($ON_TOP,"onTop")
GUICtrlSetOnEvent($ABOUT,"aboutme")

; Initializa hours, minutes, seconds
Global  $hours      = ""
Global  $minutes    = ""
Global  $seconds    = ""

GUISetState()

While 1
    
; Check to see if the seconds have changed
    If @SEC <> $seconds Then 
        updateSec( @SEC )
        $seconds = @SEC
    EndIf
    
; check to see if the minutes have changed
    If @MIN <> $minutes Then
        updateMin( @MIN )
        $minutes = @MIN
    EndIf
    
; check to see if the hours have changed
    If @HOUR <> $hours Then
        $hours = @HOUR
        updateHours( @HOUR )
    EndIf   
    
; This is for the tool tip when hovering over the gui
    If $hours > 12 Then
        Local $h = $hours-12
        Local $flag = "pm"
    Else
        Local $h = $hours
        If $h = 12 Then
            Local $flag = "pm"
        Else    
            Local $flag = "am"
        EndIf
        
    EndIf
    Local $m = $minutes
    Local $s = $seconds
    
    
    GUICtrlSetTip($pic,$h & ":" & $m & ":" & $s & " " & $flag)

    Sleep(100)
;_ReduceMemory( )
WEnd

; Display About Me
Func aboutme( )
    Opt("GUIOnEventMode", 0)
    
    GUISetState(@SW_DISABLE,$my_gui)
    Opt("WinTitleMatchMode", 4)
    Opt("MustDeclareVars", 1)
    Local $aboutGUI = GUICreate("Binary Clock 1.0",300,100,-1,-1,-1,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    
    Local $hl_ctrl[1]
    Local $Links = "mailto:eito@cs.ucr.edu"
    Local $Link_On = "Email me"

    $hl_ctrl[0] = _GuiCtrlHyperLinkCreate ($aboutGUI,'Hope you enjoy my binary clock. Feel free to Email me your comments, questions, or criticisms.', $Links, $Link_On,10, 10, 280, 50)
    Local $label = GUICtrlCreateLabel("Created by Eric Ito (c) September 2006",55,80)
     
    GUISetState( )
    GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
    While 1
        Local $msg = GUIGetMsg($aboutGUI)
        Select 
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                GUISetState(@SW_ENABLE,$my_gui)
                Opt("WinTitleMatchMode", 0)
                Opt("MustDeclareVars", 0)
                Opt("GUIOnEventMode", 1)
                ExitLoop
        EndSelect
    
    
        
    WEnd
    

    Opt("GUIOnEventMode", 1)
EndFunc


Func _ReduceMemory($i_PID = -1)
    
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

Func updateHours( $h )
    
    If GUICtrlRead($24_HOUR) = 65 Then
; Do nothing
    Else
        If $h > 12 Then
            $h = $h - 12
        EndIf
        
    EndIf
    
    Local $tens = Floor(Int($h/10))
    Local $ones = Mod($h,10)
    
    If $tens = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[1],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[2],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 1 Then
        GUICtrlSetImage($LED[1],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[2],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $tens = 2 Then
        GUICtrlSetImage($LED[1],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[2],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    EndIf
    
    If $ones = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 1 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 2 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 3 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 4 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 5 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 6 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 7 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 8 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 9 Then
        GUICtrlSetImage($LED[3],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[4],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[5],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[6],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    EndIf
    
    
    
    
EndFunc

Func updateMin( $m )
    Local $tens = Floor(Int($m/10))
    Local $ones = Mod($m,10)
    
    If $tens = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 1 Then
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $tens = 2 Then
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 3 Then
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $tens = 4 Then
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 5 Then
        GUICtrlSetImage($LED[7],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[8],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[9],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    
    EndIf
    
    If $ones = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 1 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 2 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 3 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 4 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 5 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 6 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 7 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 8 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 9 Then
        GUICtrlSetImage($LED[10],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[11],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[12],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[13],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    EndIf
    
    
    
    
EndFunc


Func updateSec( $s )
    Local $tens = Floor(Int($s/10))
    Local $ones = Mod($s,10)
    
    If $tens = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 1 Then
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $tens = 2 Then
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 3 Then
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $tens = 4 Then
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $tens = 5 Then
        GUICtrlSetImage($LED[14],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[15],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[16],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    
    EndIf
    
    If $ones = 0 Then
; ALL bubbles empty
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 1 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 2 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 3 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 4 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 5 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 6 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 7 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    ElseIf $ones = 8 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
    ElseIf $ones = 9 Then
        GUICtrlSetImage($LED[17],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
        GUICtrlSetImage($LED[18],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[19],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $POWER & ".bmp")
        GUICtrlSetImage($LED[20],@ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & "on" & ".bmp")
    EndIf
    
    
    
    
EndFunc





Func balloon( )
    If $hours > 12 Then
        Local $h = $hours-12
        Local $flag = "pm"
    Else
        Local $h = $hours
        If $h = 12 Then
            Local $flag = "pm"
        Else    
            Local $flag = "am"
        EndIf
        
    EndIf
    Local $m = $minutes
    Local $s = $seconds
    TrayTip("Current Time",$h & ":" & $m & ":" & $s & " " & $flag,2)
    

EndFunc


Func onTop( )
        
        If GUICtrlRead($ON_TOP) = 65 Then
            GUICtrlSetState($ON_TOP,$GUI_UNCHECKED)
;   GUICtrlSetStyle($my_gui,$WS_POPUP,$WS_EX_TOOLWINDOW)
            WinSetOnTop("Binary Clock","",0)
        Else
            GUICtrlSetState($ON_TOP,$GUI_CHECKED)
;   GUICtrlSetStyle($my_gui,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
            WinSetOnTop("Binary Clock","",1)
        EndIf
        
EndFunc


Func _toRed( )
    ChangeColor( "Red" )
EndFunc

Func _toBlue( )
    ChangeColor( "Blue" )
    $hours = ""
    $minutes = ""
    $seconds = ""
EndFunc

Func _toGreen( )
    ChangeColor( "Green" )
    $hours = ""
    $minutes = ""
    $seconds = ""
EndFunc

Func _toAmber( )
    ChangeColor( "Amber" )
    $hours = ""
    $minutes = ""
    $seconds = ""
EndFunc

Func ChangeColor( $color )

    If $color = "Red" Then
        GUICtrlSetState($RED,$GUI_CHECKED)
        GUICtrlSetState($BLUE,$GUI_UNCHECKED)
        GUICtrlSetState($GREEN,$GUI_UNCHECKED)
        GUICtrlSetState($AMBER,$GUI_UNCHECKED)
        $LED_COLOR = "red"
;_updateClock("red")
    ElseIf $color = "Blue" Then
        GUICtrlSetState($RED,$GUI_UNCHECKED)
        GUICtrlSetState($BLUE,$GUI_CHECKED)
        GUICtrlSetState($GREEN,$GUI_UNCHECKED)
        GUICtrlSetState($AMBER,$GUI_UNCHECKED)
        $LED_COLOR = "blue"
;_updateClock("blue")
    ElseIf $color = "Green" Then
        GUICtrlSetState($RED,$GUI_UNCHECKED)
        GUICtrlSetState($BLUE,$GUI_UNCHECKED)
        GUICtrlSetState($GREEN,$GUI_CHECKED)
        GUICtrlSetState($AMBER,$GUI_UNCHECKED)
        $LED_COLOR = "green"
;_updateClock("green")
    Else
        GUICtrlSetState($RED,$GUI_UNCHECKED)
        GUICtrlSetState($BLUE,$GUI_UNCHECKED)
        GUICtrlSetState($GREEN,$GUI_UNCHECKED)
        GUICtrlSetState($AMBER,$GUI_CHECKED)
        $LED_COLOR = "amber"
;_updateClock("amber")
    EndIf
    
    $hours = ""
    $minutes = ""
    $seconds = ""

EndFunc



Func _Format_Time( )
    
    if GUICtrlRead($24_HOUR) = 65 Then
; uncheck, check 12
        GUICtrlSetState($24_HOUR,$GUI_UNCHECKED)
        GUICtrlSetState($12_HOUR,$GUI_CHECKED)
    Else
        GUICtrlSetState($12_HOUR,$GUI_UNCHECKED)
        GUICtrlSetState($24_HOUR,$GUI_CHECKED)
    EndIf
    
    $hours = ""
    $minutes = ""
    $seconds = ""
    
EndFunc


Func quit( )

    FileDelete(@ScriptDir & "\config.ini")
    
; Save Time Format
    If GUICtrlRead($24_HOUR) = 65 Then
        IniWrite("config.ini","Settings","Time Format","24 Hour")
    Else
        IniWrite("config.ini","Settings","Time Format","12 Hour")
    EndIf
    
; Save Color
    If GUICtrlRead($RED) = 65 Then
        IniWrite("config.ini","Settings","LED Color","red")
    ElseIf GUICtrlRead($BLUE) = 65 Then
        IniWrite("config.ini","Settings","LED Color","blue")
    ElseIf GUICtrlRead($GREEN) = 65 Then
        IniWrite("config.ini","Settings","LED Color","green")
    Else
        IniWrite("config.ini","Settings","LED Color","amber")
    EndIf
    
; Always on top?
    If GUICtrlRead($ON_TOP) = 65 Then
        IniWrite("config.ini","Settings","On Top","1")
    Else
        IniWrite("config.ini","Settings","On Top","0")
    EndIf
    
    Local $array = WinGetPos("Binary Clock")
    
    IniWrite("config.ini","Settings","x",$array[0])
    IniWrite("config.ini","Settings","y",$array[1])
    
    Exit
EndFunc

Func drag( )
    _Drag($my_gui)
EndFunc


 
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
     Dim $pos, $ret, $ret2
     $pos = WinGetPos($h_win)
     $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
     If $ret[0]Then
          $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
          If $ret2[0]Then
               Return 1
          Else
               Return 0
          EndIf
     Else
          Return 0
     EndIf
 EndFunc;==>_GuiRoundCorners 
 
 Func _Drag($h_gui)
   DllCall("user32.dll", "int", "ReleaseCapture")
   DllCall("user32.dll", "int", "SendMessage", "hWnd", $h_gui, "int", 0xA1, "int", 2, "int", 0)
EndFunc;==>_Drag

Please let me hear your criticisms, comments, concerns. I also attached a quick screen shot to give you a basic idea...it is actually a little more rounded than it looks in the screenshot.

Thank you

BinaryClock.zip

Edited by no4ndth3n
Link to comment
Share on other sites

where can I download GuiHyperLink.au3?

2¢

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Just wanted to say Welcome and nice for 1st script posted to the forum, suggestion tho could reduce the code a bit, i just worked a the updates real quick

Func updateHours($h)
    
    If GUICtrlRead($24_HOUR) = 65 Then
        ; Do nothing
    Else
        If $h > 12 Then
            $h = $h - 12
        EndIf
        
    EndIf
    
    Local $tens = Floor(Int($h / 10))
    Local $ones = Mod($h, 10)
    
    If $tens = 0 Then
        ; ALL bubbles empty
        _SetColumn1($POWER, $POWER)
    ElseIf $tens = 1 Then
        _SetColumn1($POWER, "on")
    ElseIf $tens = 2 Then
        _SetColumn1("on", $POWER)
    EndIf
    
    If $ones = 0 Then
        ; ALL bubbles empty
        _SetColumn2($POWER, $POWER, $POWER, $POWER)
    ElseIf $ones = 1 Then
        _SetColumn2($POWER, $POWER, $POWER, "on")
    ElseIf $ones = 2 Then
        _SetColumn2($POWER, $POWER, "on", $POWER)
    ElseIf $ones = 3 Then
        _SetColumn2($POWER, $POWER, "on", "on")
    ElseIf $ones = 4 Then
        _SetColumn2($POWER, "on", $POWER, $POWER)
    ElseIf $ones = 5 Then
        _SetColumn2($POWER, "on", $POWER, "on")
    ElseIf $ones = 6 Then
        _SetColumn2($POWER, "on", "on", $POWER)
    ElseIf $ones = 7 Then
        _SetColumn2($POWER, "on", "on", "on")
    ElseIf $ones = 8 Then
        _SetColumn2("on", $POWER, $POWER, $POWER)
    ElseIf $ones = 9 Then
        _SetColumn2("on", $POWER, $POWER, "on")
    EndIf
EndFunc   ;==>updateHours

Func updateMin($m)
    Local $tens = Floor(Int($m / 10))
    Local $ones = Mod($m, 10)
    
    If $tens = 0 Then
        ; ALL bubbles empty
        _SetColumn3($POWER, $POWER, $POWER)
    ElseIf $tens = 1 Then
        _SetColumn3($POWER, $POWER, "on")
    ElseIf $tens = 2 Then
        _SetColumn3($POWER, "on", $POWER)
    ElseIf $tens = 3 Then
        _SetColumn3($POWER, "on", "on")
    ElseIf $tens = 4 Then
        _SetColumn3("on", $POWER, $POWER)
    ElseIf $tens = 5 Then
        _SetColumn3("on", $POWER, "on")
    EndIf
    
    If $ones = 0 Then
        ; ALL bubbles empty
        _SetColumn4($POWER, $POWER, $POWER, $POWER)
    ElseIf $ones = 1 Then
        _SetColumn4($POWER, $POWER, $POWER, "on")
    ElseIf $ones = 2 Then
        _SetColumn4($POWER, $POWER, "on", $POWER)
    ElseIf $ones = 3 Then
        _SetColumn4($POWER, $POWER, "on", "on")
    ElseIf $ones = 4 Then
        _SetColumn4($POWER, "on", $POWER, $POWER)
    ElseIf $ones = 5 Then
        _SetColumn4($POWER, "on", $POWER, "on")
    ElseIf $ones = 6 Then
        _SetColumn4($POWER, "on", "on", $POWER)
    ElseIf $ones = 7 Then
        _SetColumn4($POWER, "on", "on", "on")
    ElseIf $ones = 8 Then
        _SetColumn4("on", $POWER, $POWER, $POWER)
    ElseIf $ones = 9 Then
        _SetColumn4("on", $POWER, $POWER, "on")
    EndIf
EndFunc   ;==>updateMin

Func updateSec($s)
    Local $tens = Floor(Int($s / 10))
    Local $ones = Mod($s, 10)
    
    If $tens = 0 Then
        ; ALL bubbles empty
        _SetColumn5($POWER, $POWER, $POWER)
    ElseIf $tens = 1 Then
        _SetColumn5($POWER, $POWER, "on")
    ElseIf $tens = 2 Then
        _SetColumn5($POWER, "on", $POWER)
    ElseIf $tens = 3 Then
        _SetColumn5($POWER, "on", "on")
    ElseIf $tens = 4 Then
        _SetColumn5("on", $POWER, $POWER)
    ElseIf $tens = 5 Then
        _SetColumn5("on", $POWER, "on")
    EndIf
    
    If $ones = 0 Then
        ; ALL bubbles empty
        _SetColumn6($POWER, $POWER, $POWER, $POWER)
    ElseIf $ones = 1 Then
        _SetColumn6($POWER, $POWER, $POWER, "on")
    ElseIf $ones = 2 Then
        _SetColumn6($POWER, $POWER, "on", $POWER)
    ElseIf $ones = 3 Then
        _SetColumn6($POWER, $POWER, "on", "on")
    ElseIf $ones = 4 Then
        _SetColumn6($POWER, "on", $POWER, $POWER)
    ElseIf $ones = 5 Then
        _SetColumn6($POWER, "on", $POWER, "on")
    ElseIf $ones = 6 Then
        _SetColumn6($POWER, "on", "on", $POWER)
    ElseIf $ones = 7 Then
        _SetColumn6($POWER, "on", "on", "on")
    ElseIf $ones = 8 Then
        _SetColumn6("on", $POWER, $POWER, $POWER)
    ElseIf $ones = 9 Then
        _SetColumn6("on", $POWER, $POWER, "on")
    EndIf
EndFunc   ;==>updateSec

Func _SetColumn1($s1, $s2)
    GUICtrlSetImage($LED[1], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s1 & ".bmp")
    GUICtrlSetImage($LED[2], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s2 & ".bmp")
EndFunc   ;==>_SetColumn1

Func _SetColumn2($s3, $s4, $s5, $s6)
    GUICtrlSetImage($LED[3], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s3 & ".bmp")
    GUICtrlSetImage($LED[4], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s4 & ".bmp")
    GUICtrlSetImage($LED[5], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s5 & ".bmp")
    GUICtrlSetImage($LED[6], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s6 & ".bmp")
EndFunc   ;==>_SetColumn2

Func _SetColumn3($s7, $s8, $s9)
    GUICtrlSetImage($LED[7], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s7 & ".bmp")
    GUICtrlSetImage($LED[8], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s8 & ".bmp")
    GUICtrlSetImage($LED[9], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s9 & ".bmp")
EndFunc   ;==>_SetColumn3

Func _SetColumn4($s10, $s11, $s12, $s13)
    GUICtrlSetImage($LED[10], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s10 & ".bmp")
    GUICtrlSetImage($LED[11], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s11 & ".bmp")
    GUICtrlSetImage($LED[12], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s12 & ".bmp")
    GUICtrlSetImage($LED[13], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s13 & ".bmp")
EndFunc   ;==>_SetColumn4

Func _SetColumn5($s14, $s15, $s16)
    GUICtrlSetImage($LED[14], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s14 & ".bmp")
    GUICtrlSetImage($LED[15], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s15 & ".bmp")
    GUICtrlSetImage($LED[16], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s16 & ".bmp")
EndFunc   ;==>_SetColumn5

Func _SetColumn6($s17, $s18, $s19, $s20)
    GUICtrlSetImage($LED[17], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s17 & ".bmp")
    GUICtrlSetImage($LED[18], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s18 & ".bmp")
    GUICtrlSetImage($LED[19], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s19 & ".bmp")
    GUICtrlSetImage($LED[20], @ScriptDir & "\Bin\" & $LED_COLOR & "_led_" & $s20 & ".bmp")
EndFunc   ;==>_SetColumn6

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hey thanks for the responses guys.. Although this is the first script I have posted, I have been tinkering with AutoIt for a little while now..mostly scripts to use at my work... gafrost I have not had time to try your reduced code...did you notice am improvement in performance at all? Any suggestions on reducing some of the flicker?

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...