Jump to content

Fibonacci Clock


Melba23
 Share

Recommended Posts

  • Moderators

The Fibonacci clock lets you know the time by changing colours and requiring you do some adding up.

The Fibonacci sequence is the sequence beginning 1, 1 and where each number is the sum of the previous two. Its first five digits are: 1, 1, 2, 3, 5.  These numbers are all you need to express all the numbers from 1 to 12.

1 = 1
1+1 = 2
...
1 + 1 + 2 + 3 + 5 = 12

which means that it is possible to use them to describe the twelve positions on a clock, and therefore tell the time in 5 minute intervals.

Philippe Chrétien of Montreal Canada made such a clock with squares of side length 1, 1, 2, 3, and 5 (the numbers in the Fibonacci sequence) arranged into a "golden rectangle".  The squares lit up in red tell you the hour, and in green give you the minutes (in multiples of five). A square lit up in blue meant it is to be added for both hour and minute. Transparent squares are ignored.

The first example below decodes as follows:

Hours, red 5, red 1 and blue 3 = 5 + 1 + 3 = 9 hours
Minutes: green 2 and blue 3 = 2 + 3 = 5.  5 x 5 = 25 minutes.
So, the time is 9.25.

Clock.thumb.png.924dbde0f35f38d71cb1ad28

And here is a little script to show how you can create a Fibonacci clock of your own - by default it shows the current time (which you can reset at any time using the "Reset" button) or you can test it by entering a time in the combos:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>

$iMargin_X = 10
$iMargin_Y = 10
$iMargin_Inter = 5
$iSize = 50
$iButton_Level = ($iSize * 5) + $iMargin_Inter + 20

$hGUI = GUICreate("Fibonacci Clock", ($iSize * 8) + ($iMargin_X * 2), $iButton_Level + 100)
GUISetBkColor(0xC4C4C4)

$cBack = GUICtrlCreateLabel("", $iMargin_X - $iMargin_Inter, $iMargin_Y - $iMargin_Inter, _
        ($iSize * 8) + ($iMargin_Inter * 2), ($iSize * 5) + $iMargin_Inter)
GUICtrlSetBkColor($cBack, 0x000000)

$cLabel_1A = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 2), $iMargin_Y, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter)
$cLabel_1B = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 2), $iMargin_Y + $iSize, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter)
$cLabel_2 = GUICtrlCreateLabel("", $iMargin_X, $iMargin_Y, ($iSize * 2) - $iMargin_Inter, ($iSize * 2) - $iMargin_Inter)
$cLabel_3 = GUICtrlCreateLabel("", $iMargin_X, $iMargin_Y + ($iSize * 2), ($iSize * 3) - $iMargin_Inter, ($iSize * 3) - $iMargin_Inter)
$cLabel_5 = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 3), $iMargin_Y, $iSize * 5, ($iSize * 5) - $iMargin_Inter)

$cUserSet = GUICtrlCreateButton("Set User Time", $iMargin_X, $iButton_Level, 100, 30)
$cUserHour = GUICtrlCreateCombo("", $iMargin_X + 120, $iButton_Level, 40, 20)
GUICtrlSetData($cUserHour, "00|01|02|03|04|05|06|07|08|09|10|11|12")
$cUserMin = GUICtrlCreateCombo("", $iMargin_X + 160, $iButton_Level, 40, 20)
GUICtrlSetData($cUserMin, "00|05|10|15|20|25|30|35|40|45|50|55")
$cReset = GUICtrlCreateButton("Reset Current Time", $iMargin_X, $iButton_Level + 50, 120, 30)

GUICtrlCreateLabel("Hours:" & @CRLF & @CRLF & "Mins:" & @CRLF & @CRLF & "Both:", 250, $iButton_Level, 150, 80)
GUICtrlCreateLabel("", 300, $iButton_Level, 50, 20)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlCreateLabel("", 300, $iButton_Level + 25, 50, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlCreateLabel("", 300, $iButton_Level + 50, 50, 20)
GUICtrlSetBkColor(-1, 0x0000FF)

GUISetState()

_Reset()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cReset
            _Reset()
        Case $cUserSet
            $iHour = GUICtrlRead($cUserHour)
            $iMin = GUICtrlRead($cUserMin) / 5
            _Set_Clock($iHour, $iMin)
    EndSwitch

WEnd

Func _Reset()

    $sDTG = _NowCalc()
    $iHour = StringRegExpReplace($sDTG, "^.*\s(\d\d):.*", "$1")
    $iHour = (($iHour > 12) ? ($iHour - 12) : ($iHour))
    $iMin = Int(StringRegExpReplace($sDTG, "^.*:(\d\d):.*", "$1") / 5)

    _Set_Clock($iHour, $iMin)

EndFunc   ;==>_Reset

Func _Set_Clock($iH, $iM)

    $iH = Number($iH)
    $iM = Number($iM)

    ;ConsoleWrite("Entry: " & $iH & " - " & $iM & @CRLF)

    GUICtrlSetBkColor($cLabel_1A, 0xC4C4C4)
    GUICtrlSetBkColor($cLabel_1B, 0xC4C4C4)
    GUICtrlSetBkColor($cLabel_2, 0xC4C4C4)
    GUICtrlSetBkColor($cLabel_3, 0xC4C4C4)
    GUICtrlSetBkColor($cLabel_5, 0xC4C4C4)

    $iState_1A = 0
    $iState_1B = 0
    $iState_2 = 0
    $iState_3 = 0
    $iState_5 = 0

    While $iH
        ;ConsoleWrite($iH & @CRLF)
        Switch $iH
            Case 5 To 12
                ;;ConsoleWrite("5-12" & @CRLF)
                If Not $iState_5 Then
                    ;;ConsoleWrite("- 5" & @CRLF)
                    $iH -= 5
                    GUICtrlSetBkColor($cLabel_5, 0XFF0000)
                    $iState_5 = 1
                Else
                    ContinueCase
                EndIf
            Case 3 To 12
                ;;ConsoleWrite("3-12" & @CRLF)
                If Not $iState_3 Then
                    ;;ConsoleWrite("- 3" & @CRLF)
                    $iH -= 3
                    GUICtrlSetBkColor($cLabel_3, 0XFF0000)
                    $iState_3 = 1
                Else
                    ContinueCase
                EndIf
            Case 2 To 12
                ;;ConsoleWrite("2-12" & @CRLF)
                If Not $iState_2 Then
                    ;;ConsoleWrite("- 2" & @CRLF)
                    $iH -= 2
                    GUICtrlSetBkColor($cLabel_2, 0XFF0000)
                    $iState_2 = 1
                Else
                    ContinueCase
                EndIf
            Case Else
                ;;ConsoleWrite("Else" & @CRLF)
                If $iState_1A Then
                    ;;ConsoleWrite("- 1B" & @CRLF)
                    $iH -= 1
                    GUICtrlSetBkColor($cLabel_1B, 0XFF0000)
                    $iState_1B = 1
                Else
                    ;;ConsoleWrite("- 1A" & @CRLF)
                    $iH -= 1
                    GUICtrlSetBkColor($cLabel_1A, 0XFF0000)
                    $iState_1A = 1
                EndIf
        EndSwitch
    WEnd

    While $iM

        Switch $iM
            Case 5 To 12
                $bContinueCase = False
                ;ConsoleWrite("5-12" & @CRLF)
                Switch $iState_5
                    Case 0
                        ;ConsoleWrite("-5:G" & @CRLF)
                        $iM -= 5
                        GUICtrlSetBkColor($cLabel_5, 0X00FF00)
                        $iState_5 = 2
                    Case 1
                        ;ConsoleWrite("-5:B" & @CRLF)
                        $iM -= 5
                        GUICtrlSetBkColor($cLabel_5, 0X0000FF)
                        $iState_5 = 2
                    Case 2
                        $bContinueCase = True
                EndSwitch

                If $bContinueCase Then ContinueCase
            Case 3 To 12
                ;ConsoleWrite("3-12" & @CRLF)
                $bContinueCase = False
                Switch $iState_3
                    Case 0
                        ;ConsoleWrite("-3:G" & @CRLF)
                        $iM -= 3
                        GUICtrlSetBkColor($cLabel_3, 0X00FF00)
                        $iState_3 = 2
                    Case 1
                        ;ConsoleWrite("-3:B" & @CRLF)
                        $iM -= 3
                        GUICtrlSetBkColor($cLabel_3, 0X0000FF)
                        $iState_3 = 2
                    Case 2
                        $bContinueCase = True
                EndSwitch
                If $bContinueCase Then ContinueCase
            Case 2 To 12
                ;ConsoleWrite("2-12" & @CRLF)
                $bContinueCase = False
                Switch $iState_2
                    Case 0
                        ;ConsoleWrite("-2:G" & @CRLF)
                        $iM -= 2
                        GUICtrlSetBkColor($cLabel_2, 0X00FF00)
                        $iState_2 = 2
                    Case 1
                        ;ConsoleWrite("-2:B" & @CRLF)
                        $iM -= 2
                        GUICtrlSetBkColor($cLabel_2, 0X0000FF)
                        $iState_2 = 2
                    Case 2
                        $bContinueCase = True
                EndSwitch
                If $bContinueCase Then ContinueCase
            Case Else
                Switch $iState_1A
                    Case 2
                        $iM -= 1
                        If $iState_1B Then
                            ;ConsoleWrite("-1B:B" & @CRLF)
                            GUICtrlSetBkColor($cLabel_1B, 0X0000FF)
                        Else
                            ;ConsoleWrite("-1B:G" & @CRLF)
                            GUICtrlSetBkColor($cLabel_1B, 0X00FF00)
                        EndIf
                    Case 1
                        ;ConsoleWrite("-1A:B" & @CRLF)
                        $iM -= 1
                        If $iState_1B = 0 Then
                            GUICtrlSetBkColor($cLabel_1B, 0x00FF00)
                            $iState_1B = 1
                        Else
                            GUICtrlSetBkColor($cLabel_1A, 0x0000FF)
                            $iState_1A = 2
                        EndIf
                    Case Else
                        ;ConsoleWrite("-1A:G" & @CRLF)
                        $iM -= 1
                        GUICtrlSetBkColor($cLabel_1A, 0x00FF00)
                        $iState_1A = 1
                EndSwitch
        EndSwitch

    WEnd

EndFunc   ;==>_Set_Clock

If anyone can produce shorter internal code to colour the labels, please do post it - I found that quite a difficult problem to crack and I am certain I do not have an optimal solution.

M23

P.S. The original clock:

 

Edited by Melba23
Added tag by request

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

When setting to 00 / 00 and pushing "Set User Time" it "goes crazy". Upper smallest square becomes red and the below square is flickering in red / grey!

CPU increases to 100% on one core. Probably an endless loop.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

UEZ,

Sorry about that - string/number type mismatch. I have forced the correct datatype in the new code above and it works now (for me at least).

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

There is still an issue. When I change the time and push "Set User Time" (a bunch of times) then the CPU increase to 100% on one core again.

I assume there is no exit in one of the While/Wend loops within _Set_Clock() function on some specific values.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

UEZ,

Why is it always you who has problems with my UDFs?

I cannot reproduce that behaviour when I press the "Set User Time" button repeatedly - it just runs and re-draws the clock (correctly). Can you give me a repeatable selection and button press sequence so I can investigate further.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Sorry, my bad aura. :>

I did random selection, so I cannot give you an exact reproduction. It just happend several times when I stressed your code.

 

Try this: set it to 00 50 and press the "Set User Time" buttom.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Rather go to bed at this time: no bug! :naughty:

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Moderators

UEZ,

Got it - I told you the code was not optimal.

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

All,

And fixed. ContinueCase does NOT do what I rather stupidly expected it to do when it is used inside another, internal Switch structure to the one I wanted to continue. See first post for new code.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Seems to work now. :thumbsup: (not my bad aura)

I'm trying to create a 3D matrix to get rid of the loops within the _Set_Clock function.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

UEZ,

Great. And my apologies for blaming you - when it was my poor coding that was at fault.

I am looking forward to seeing your version. I did think of using a matrix at one point, but it all got too complicated far too quickly. Although seeing how complicated the loops became it might have been the wrong choice!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Is there a need for both 00 and 12 in the hour combo (as it seems to hold fine without)?  and i uglied it up so the combos match the current time on start:

and your 1s are backwards from the example (clock.png - 5:45): not that i suppose it would matter which 1 is the 'first' 1

GUICtrlSetData($cUserHour, "01|02|03|04|05|06|07|08|09|10|11|12" , @Hour)
$cUserMin = GUICtrlCreateCombo("", $iMargin_X + 160, $iButton_Level, 40, 20)
If @Min <= 2 OR @Min > 57 Then $Min = "00"
If @Min > 2 AND @Min <= 7 Then $Min = "05"
If @Min > 7 AND @Min <= 12 Then $Min = "10"
If @Min > 12 AND @Min <= 17 Then $Min = "15"
If @Min > 17 AND @Min <= 22 Then $Min = "20"
If @Min > 22 AND @Min <= 27 Then $Min = "25"
If @Min > 27 AND @Min <= 32 Then $Min = "30"
If @Min > 32 AND @Min <= 37 Then $Min = "35"
If @Min > 37 AND @Min <= 42 Then $Min = "40"
If @Min > 42 AND @Min <= 47 Then $Min = "45"
If @Min > 47 AND @Min <= 52 Then $Min = "50"
If @Min > 52 AND @Min <= 57 Then $Min = "55"
GUICtrlSetData($cUserMin, "00|05|10|15|20|25|30|35|40|45|50|55" , $Min)

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

boththose,

Is there a need for both 00 and 12 in the hour combo

At the moment setting 00 means that no squares are coloured while they are all coloured for 12. As there is no AM/PM selection, I thought I might make at least that distinction.

As the clock is now working for my good friend UEZ, could I also make clear that I have no interest in developing the code further. So please post your own version in this thread if you want to further develop the concept.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

All,

OK, I lied - a little update in the first post as I find this a strangely fascinating way of telling the time

Any thoughts out there on how to measure the passing of each minute rather than the current changes on each 5 minute block? Nothing I have thought of so far seems to fit in with the desired Fibonacci zeitgeist.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Well, currently I'm stuck at how to split any number from 2 to 12 to number of Fibonacci sequence.

Examples:

11 = 5 + 3 + 2 + 1

6 = 5 + 1 and not 3 + 2 + 1

7 = 5 + 2 and not 5 + 1 + 1

12 = 5 + 3 + 2 + 1 + 1

etc.

Afterwards it is easy to create the 3D array (matrix) which reflects any possible time.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This feature also steps up the game.

To add to the challenge, the combinations are picked randomly from all the different ways a number can be displayed. There are, for example, 16 different ways to display 6:30 and you never know which one the clock will use!

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

UEZ,

I decided to use the fewest possible squares - so 6  would always be represented as 5 + 1 and never 3 + 2 + 1.

boththose,

My poor old brain has enough trouble reading the clock using the algorithm I chose - no way do I want to go anywhere near a random choice display!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Can you check this version whether it works properly?

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>

$iMargin_X = 10
$iMargin_Y = 10
$iMargin_Inter = 5
$iSize = 50
$iButton_Level = ($iSize * 5) + $iMargin_Inter + 20
$bUserSet = False
$iPrevMin = -1
$hGUI = GUICreate("Fibonacci Clock - " & @HOUR & ":" & @MIN & ":" & @SEC, ($iSize * 8) + ($iMargin_X * 2), $iButton_Level + 100)
GUISetBkColor(0xC4C4C4)

$cBack = GUICtrlCreateLabel("", $iMargin_X - $iMargin_Inter, $iMargin_Y - $iMargin_Inter, _
        ($iSize * 8) + ($iMargin_Inter * 2), ($iSize * 5) + $iMargin_Inter)
GUICtrlSetBkColor($cBack, 0x000000)

$cLabel_1A = GUICtrlCreateLabel("1", $iMargin_X + ($iSize * 2), $iMargin_Y, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter)
$cLabel_1B = GUICtrlCreateLabel("1", $iMargin_X + ($iSize * 2), $iMargin_Y + $iSize, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter)
$cLabel_2 = GUICtrlCreateLabel("2", $iMargin_X, $iMargin_Y, ($iSize * 2) - $iMargin_Inter, ($iSize * 2) - $iMargin_Inter)
$cLabel_3 = GUICtrlCreateLabel("3", $iMargin_X, $iMargin_Y + ($iSize * 2), ($iSize * 3) - $iMargin_Inter, ($iSize * 3) - $iMargin_Inter)
$cLabel_5 = GUICtrlCreateLabel("5", $iMargin_X + ($iSize * 3), $iMargin_Y, $iSize * 5, ($iSize * 5) - $iMargin_Inter)

$cUserSet = GUICtrlCreateButton("Set User Time", $iMargin_X, $iButton_Level, 100, 30)
$cUserHour = GUICtrlCreateCombo("", $iMargin_X + 120, $iButton_Level, 40, 20)
GUICtrlSetData($cUserHour, "00|01|02|03|04|05|06|07|08|09|10|11|12")
$cUserMin = GUICtrlCreateCombo("", $iMargin_X + 160, $iButton_Level, 40, 20)
GUICtrlSetData($cUserMin, "00|05|10|15|20|25|30|35|40|45|50|55")
$cReset = GUICtrlCreateButton("Reset Current Time", $iMargin_X, $iButton_Level + 50, 120, 30)

GUICtrlCreateLabel("Hours:" & @CRLF & @CRLF & "Mins:" & @CRLF & @CRLF & "Both:", 250, $iButton_Level, 150, 80)
GUICtrlCreateLabel("", 300, $iButton_Level, 50, 20)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlCreateLabel("", 300, $iButton_Level + 25, 50, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlCreateLabel("", 300, $iButton_Level + 50, 50, 20)
GUICtrlSetBkColor(-1, 0x0000FF)

Global $i, $aFibMatrix[13][12][5], $fTimer = TimerInit()
For $iHr = 0 To 12
    For $iMin = 0 To 11
        $aHr = FibSplit($iHr)
        $aMin = FibSplit($iMin)
        For $i = 0 To 4
            $aFibMatrix[$iHr][$iMin][$i] = 0xC4C4C4
            If $aHr[$i] = $aMin[$i] Then
                If $aHr[$i] Then $aFibMatrix[$iHr][$iMin][$i] = 0x0000FF
            Else
                If $aHr[$i] Then $aFibMatrix[$iHr][$iMin][$i] = 0xFF0000
                If $aMin[$i] Then $aFibMatrix[$iHr][$iMin][$i] = 0x00FF00
            EndIf
        Next
    Next
Next
ConsoleWrite(TimerDiff($fTimer) & @CRLF)
GUISetState()

_Reset()

AdlibRegister("Clock")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            AdlibUnRegister("Clock")
            Exit
        Case $cReset
            $bUserSet = False
            _Reset()
        Case $cUserSet
            $iHour = GUICtrlRead($cUserHour)
            $iMin = Floor(GUICtrlRead($cUserMin) / 5)
            _Set_Clock($iHour, $iMin)
            $bUserSet = True
    EndSwitch

WEnd

Func Clock()
    WinSetTitle($hGUI, "", "Fibonacci Clock - " & @HOUR & ":" & @MIN & ":" & @SEC)
    If Not $bUserSet Then
        If $iPrevMin <> Int(@MIN / 5) Then
            $iPrevMin = Int(@MIN / 5)
            ConsoleWrite("Clock updated at " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
            _Reset()
        EndIf
    EndIf
EndFunc

Func _Reset()

    $sDTG = _NowCalc()
    $iHour = StringRegExpReplace($sDTG, "^.*\s(\d\d):.*", "$1")
    $iHour = (($iHour > 12) ? ($iHour - 12) : ($iHour))
    $iMin = Int(StringRegExpReplace($sDTG, "^.*:(\d\d):.*", "$1") / 5)

    _Set_Clock($iHour, $iMin)

EndFunc   ;==>_Reset

Func _Set_Clock($iH, $iM)

;~  ConsoleWrite("Entry: " & $iH & " - " & $iM & @CRLF)

    GUICtrlSetBkColor($cLabel_1A, $aFibMatrix[$iH][$iM][0])
    GUICtrlSetBkColor($cLabel_1B, $aFibMatrix[$iH][$iM][1])
    GUICtrlSetBkColor($cLabel_2, $aFibMatrix[$iH][$iM][2])
    GUICtrlSetBkColor($cLabel_3, $aFibMatrix[$iH][$iM][3])
    GUICtrlSetBkColor($cLabel_5, $aFibMatrix[$iH][$iM][4])

EndFunc   ;==>_Set_Clock

Func FibSplit($iNumber)
    Local $aFib[5] = [5, 3, 2, 1, 1], $i = 0
    Local $aBits[5]
    While 1
        $iNumber -= $aFib[$i]
        If $iNumber > -1 Then
            $aBits[4 - $i] = 1
        Else
            $aBits[4 - $i] = 0
            $iNumber += $aFib[$i]
        EndIf
        $i += 1
        If $i = 5 Then ExitLoop
    WEnd
    Return $aBits
EndFunc

Thanks.

 

Instead of creating a matrix it is also possible to code 0-12 into bits...

Edited by UEZ
added real time clock display + avoid updating clock every 250 ms

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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

×
×
  • Create New...