Jump to content

"LED" Clock


RAMzor
 Share

Recommended Posts

Hi!

This is my first code posted here. It's few bugy and not ended (sorry) because was written in 1 hour jast for fun - but work!

Feel free to change and use my code B)

;                    www
;                   (o o)
;=================ooO=(_)=Ooo====================
;              Igal 10.11.2005
;================================================

#include <GuiConstants.au3>

$gWidth = 213
$gHeight = 210
GuiCreate("LED Watch", $gWidth, $gHeight,(@DesktopWidth-$gWidth)/2, (@DesktopHeight-$gHeight)/2 );, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetBkColor(0x4B63A5)
;~ GUICtrlSetColor(-1, 0x384DB8) Dark gray 65708B

$Ref_1 = GuiCtrlCreateLabel("", 100, 170, 10, 10)
$Ref_2 = GuiCtrlCreateLabel("", 170, 100, 10, 10)
$Ref_3 = GuiCtrlCreateLabel("", 100, 28, 10, 10)
$Ref_4 = GuiCtrlCreateLabel("", 30, 100, 10, 10)
$Bell = GuiCtrlCreateLabel("A", 70, 70, 20, 20)
GUICtrlSetFont( $Bell, 9, 400, 0, "MS Outlook" )
$Clock = GuiCtrlCreateLabel("00:00", 53, 83, 100, 50)
GUICtrlSetFont( $Clock, 30, 950, 0, "Times New Roman" )

Dim $Label[62], $Loop, $PntPos[62][2]
$OffsetX = 100
$OffsetY = 100
$Radius = 80
$NoOfPoints = 60
$pi = 3.14159265358979
$Angle = -($pi/2)
;~ $Center = GuiCtrlCreateLabel("", $OffsetX, $OffsetY, 10, 10)

; Circle points calculation
For $i = 1 To $NoOfPoints
    $t = $i * (2*$pi) / $NoOfPoints
    $PntPos[$i][0] = $Radius * Cos( $t + $Angle ); X axy
    $PntPos[$i][1] = $Radius * Sin( $t + $Angle ); Y axy
Next

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        $Test = GuiCtrlCreateLabel("", $PntPos[@SEC + 1][0] + $OffsetX, $PntPos[@SEC + 1][1] + $OffsetY, 5, 10)
;~      GUICtrlSetFont( -1, 15, 400, 0, "Times New Roman" ); Bold points
        If @SEC = 59 Then $Loop = NOT $Loop
        If $Loop = 1 Then 
            GUICtrlSetColor ( $Test, 0x4B63A5 ); "Transparent"
        Else
            GUICtrlSetColor ( $Test, 0xEEC716 ); Blue
        EndIf
        GUICtrlSetData ( $Clock, @HOUR & ":" & @MIN )
        
        Sleep(200)
        
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

eventually you'll exceed the limit of controls by creating labels for each step, instead create the labels first then just change the color

;                    www
;                   (o o)
;=================ooO=(_)=Ooo====================
;              Igal 10.11.2005
;================================================

#include <GuiConstants.au3>

$gWidth = 213
$gHeight = 210
GUICreate("LED Watch", $gWidth, $gHeight, (@DesktopWidth - $gWidth) / 2, (@DesktopHeight - $gHeight) / 2);, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetBkColor(0x0000ff)
;~ GUICtrlSetColor(-1, 0x384DB8) Dark gray 65708B

$Ref_1 = GUICtrlCreateLabel("•", 100, 170, 10, 10)
$Ref_2 = GUICtrlCreateLabel("•", 170, 100, 10, 10)
$Ref_3 = GUICtrlCreateLabel("•", 100, 28, 10, 10)
$Ref_4 = GUICtrlCreateLabel("•", 30, 100, 10, 10)
$Bell = GUICtrlCreateLabel("A", 70, 70, 20, 20)
GUICtrlSetFont($Bell, 9, 400, 0, "MS Outlook")
$Clock = GUICtrlCreateLabel("00:00", 53, 83, 100, 50)
GUICtrlSetFont($Clock, 30, 950, 0, "Times New Roman")

Dim $Label[62], $Loop, $PntPos[62][2]
$OffsetX = 100
$OffsetY = 100
$Radius = 80
$NoOfPoints = 60
$pi = 3.14159265358979
$Angle = - ($pi / 2)
;~ $Center = GuiCtrlCreateLabel("•", $OffsetX, $OffsetY, 10, 10)

; Circle points calculation
For $i = 1 To $NoOfPoints
    $t = $i * (2 * $pi) / $NoOfPoints
    $PntPos[$i][0] = $Radius * Cos($t + $Angle); X axy
    $PntPos[$i][1] = $Radius * Sin($t + $Angle); Y axy
Next
Dim $sec_lbls[60]
$sec_color = 0x000000
For $x = 0 To 59
    $sec_lbls[$x] = GUICtrlCreateLabel("•", $PntPos[$x + 1][0] + $OffsetX, $PntPos[$x + 1][1] + $OffsetY, 5, 10)
    GUICtrlSetColor($sec_lbls[$x], $sec_color)
Next

GUISetState()
$sec_color = 0xffffff
$hold_sec = @SEC
$hold_hour = -1
$hold_min = -1
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If @SEC <> $hold_sec Then
                $hold_sec = @SEC
                If $hold_hour <> @HOUR Or $hold_min <> @MIN Then
                    GUICtrlSetData($Clock, @HOUR & ":" & @MIN)
                    $hold_hour = @HOUR
                    $hold_min = @MIN
                EndIf
                If @SEC = 0 Then
                    GUICtrlSetColor($sec_lbls[59], 0x000000)
                Else
                    GUICtrlSetColor($sec_lbls[@SEC - 1], 0x000000)
                EndIf
                GUICtrlSetColor($sec_lbls[@SEC], $sec_color)
            EndIf
    EndSelect
WEnd
Exit
Edited by gafrost

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

It looks like it rapidly creates new label controls as a 'second hand'. I'm afraid to run this, I only have 2 gigabytes of ram B) Maybe drawing pixels would consume less memory.... Yep, memory usage goes up like crazy, pixels are cheaper but I don't know how to make them stick (they get painted over and disappear).

Link to comment
Share on other sites

It looks like it rapidly creates new label controls as a 'second hand'. I'm afraid to run this, I only have 2 gigabytes of ram :o Maybe drawing pixels would consume less memory.... Yep, memory usage goes up like crazy, pixels are cheaper but I don't know how to make them stick (they get painted over and disappear).

Don't worry about memory - it's crash far before due Autoit controls limit B)

Nice looking app anyway.

Link to comment
Share on other sites

Don't worry about memory - it's crash far before due Autoit controls limit B)

Nice looking app anyway.

shouldn't crash now, forgot to put the condition in.

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

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