BinClock

Post your working scripts, libraries and tools for AHK v1.1 and older
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

BinClock

12 Mar 2015, 21:24

A short script for creating and displaying a small binary clock. This is rewritten from my original binary clock.

Image

Original forum post: http://www.autohotkey.com/board/topic/8 ... ary-clock/

Code:
Last edited by geek on 23 Mar 2015, 19:32, edited 1 time in total.
User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Re: BinClock

12 Mar 2015, 21:26

Neat :)
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

13 Mar 2015, 02:57

Very nice!!!

Please, what are the ASCII codes that have you used to define On and Off? When I copy your code I get

Code: Select all

On := "?"
Off := "?"
Blank := " "
Thanks in advance.
Everything is possible!
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: BinClock

13 Mar 2015, 03:12

@empardopo
You can use my tool for something like this ;)
TextConverter

Image

Code: Select all

● = Chr(9679)
○ = Chr(9675)
@GeekDude
Nice little tool :)
suggestions for improvement: Use Chr(n) for better compatibility (like above) and chooseable colors
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

13 Mar 2015, 03:37

jNizM wrote:@empardopo
You can use my tool for something like this ;)
TextConverter

Image

Code: Select all

● = Chr(9679)
○ = Chr(9675)
@GeekDude
Nice little tool :)
suggestions for improvement: Use Chr(n) for better compatibility (like above) and chooseable colors
Thanks! I want to do a recopilation of my favourite scripts!! And this script, it will be in this recopilation.
Everything OK.

Thanks.
Attachments
binclock.png
Everything is possible!
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: BinClock

13 Mar 2015, 05:13

Thanks and your welcome ;)
If I got some more time, I will rewrite the code
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
boiler
Posts: 16960
Joined: 21 Dec 2014, 02:44

Re: BinClock

13 Mar 2015, 13:08

Cool. Could I suggest an option to have the clock display each grouping as a single binary number instead of each digit?

For example, 59 minutes would display the binary representation of 59 rather than binary 5 and binary 9. Because the current way isn't truly binary if it's showing the tens digit from the decimal system separate from the ones digit.
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: BinClock

13 Mar 2015, 13:12

I suppose, but I wonder how it should be formatted. 2 columns of 6 (up to 63, minutes and seconds) and one column of 5 (up to 31, hours)?
User avatar
boiler
Posts: 16960
Joined: 21 Dec 2014, 02:44

Re: BinClock

13 Mar 2015, 15:41

That seems reasonable to me.
User avatar
joedf
Posts: 8959
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: BinClock

13 Mar 2015, 16:59

neat-o, geekdude! :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

16 Mar 2015, 02:30

Perhaps, it can be interesting to be able see the time in digital format and program an alarm.
Greetings.
Everything is possible!
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

17 Mar 2015, 13:23

Anyone has tested it in W8? It doesn't work for me.
Greetings.
Everything is possible!
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: BinClock

17 Mar 2015, 13:43

I can't say I know what is going wrong for you, but it works fine in my Windows 10 VM

Image

It would be much more helpful if you could explain just what isn't working. E.g. does the window open, but the dots just aren't there?
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

17 Mar 2015, 14:00

GeekDude wrote:I can't say I know what is going wrong for you, but it works fine in my Windows 10 VM

Image

It would be much more helpful if you could explain just what isn't working. E.g. does the window open, but the dots just aren't there?
I think this is my problem

Code: Select all

On := Chr(9679)
Off := Chr(9675)
I can not write the ● character.
Everything is possible!
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: BinClock

17 Mar 2015, 15:01

Does it not display at all, or does it display as broken ANSI? Does it display correctly when using Chr()?
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

18 Mar 2015, 02:04

GeekDude wrote:Does it not display at all, or does it display as broken ANSI? Does it display correctly when using Chr()?
The program works fine in W7 64 bits.
Debuggin on it I get this (debug.png).

However,debugging in W8 I get that the value of On and Off variable are a blank space or an unprintable value. I'm not sure.

I can see nothing on the screen when I run binclock in w8.

Thanks.
Attachments
Debug.png
Debug.png (5.67 KiB) Viewed 7325 times
Everything is possible!
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

20 Mar 2015, 03:08

I don't know the reason but It works fine now. Perhaps, I modified something.
I've made some modifications (digital time, alarm, ect).

If GeekDude wants I publish the modified code here.
Greetings.
Attachments
BinClock.png
BinClock.png (997 Bytes) Viewed 7292 times
Everything is possible!
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: BinClock

20 Mar 2015, 08:03

File encoding change perhaps? You can post your derivative work, I don't see any reason not to
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: BinClock

23 Mar 2015, 02:23

GeekDude wrote:File encoding change perhaps? You can post your derivative work, I don't see any reason not to
OK, Thanks.

My version is here.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance,Force
#NotrayIcon

ficheroIni = %A_WorkingDir%\BinClock.ini

if !(FileExist(ficheroIni)){
	MsgBox, 262192, Warning, The BinClock ini file doesn't exist. The program will create one automatically.
	CrearIniFile(ficheroIni)
	ExitApp
}

global SizeFont,ClockX,ClockY,AlarmClock,OnCharacter,OffCharacter,ColorFont,ColorClock,ClockSizeFont,TimeToShowClock,ColorWindowAlarm
ReadFromIni(ficheroIni)

;~ On := Chr(9679)
;~ Off := Chr(9675)

On := Chr(OnCharacter)
Off := Chr(OffCharacter)
Blank := " "
;SizeFont := 13

global showTime,TimeS
showTime := 0
TimeS := ""

Inicio:
Gui, Color, Black
Gui, font, s%SizeFont% c%ColorFont%, Courier New
Gui, Add, Text, vDisplay, % MakeDisplay(On, Off, Blank)
Gui, font, s%ClockSizeFont% c%ColorClock%, Courier New
;Gui, Add, Text, x22 y+0 vMhoraActual +Center, -00:00:00
Gui, Add, Text, x1 y+0 w120 vMhoraActual +Center, %TimeS%
Gui, +ToolWindow +E0x40000 +AlwaysOnTop -Caption ;added -Caption
Gui, Color, 000111 ;added
Gui, Show,x%ClockX% y%ClockY%, BinClock ;added x and y coords
WinSet, Transcolor, 000111, BinClock ;added
SetTimer, UpdateDisplay, 1000
return
 
!F1::
SizeFont++
Gui,Destroy
Gosub, Inicio
;Reload
return

!F2::
SizeFont--
Gui,Destroy
Gosub, Inicio
return

!F3::
if (showTime==0){
	showTime=1
	if (TimeToShowClock != 0){
		SetTimer, UpdateShowTimeTo0, %TimeToShowClock%
	}
}else if (showTime==1){
	showTime=0
}
;ValorTime()
return

UpdateDisplay:
GuiControl, Text, Display, % MakeDisplay(On, Off, Blank)
;GuiControl,, MhoraActual, %A_Hour%:%A_Min%:%A_Sec%
ValorTime()
GuiControl,, MhoraActual, %TimeS%
;alarm = 16:00:00
HoraActual = %A_Hour%:%A_Min%:%A_Sec%
if (CheckAlarmaClock(HoraActual,alarmClock)){
	PantallaColor()
}
return

UpdateShowTimeTo0:
showTime=0
SetTimer, UpdateShowTimeTo0, Off
return

!Esc::
GuiClose:
ExitApp
return

CheckAlarmaClock(ActualTime,Alarm){
    if(ActualTime == Alarm){
        resultado = 1
    }else{
        resultado = 0
    }
    return resultado
}


ValorTime()
{
	if (showTime==0){
		TimeS := ""
	}else if (showTime==1){
		TimeS =	%A_Hour%:%A_Min%:%A_Sec%  a%AlarmClock%
	}
}

MakeDisplay(On, Off, Blank, Stamp="")
{
FormatTime, T, %Stamp%, HH:mm:ss
T := StrSplit(T), LedMask := 0xFE0FE0FC
Loop, 4
{
y := A_Index, Out .= "`n"
Loop, 8
Out .= !(LedMask & 1<<A_Index*4+y-5) ? Blank : (T[A_Index] & 1<<4-y) ? On : Off
}
return SubStr(Out, 2)
} 

PantallaColor()
{
	Loop
	{
		Gui,2: Color, %ColorWindowAlarm%
		Gui,2: +ToolWindow -Caption   ; +ToolWindow prevents taskbar button. -Caption removes borders and stuff.
		Gui,2: Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%
		Sleep, 250  ; This is the duration of the black screen
		Gui,2: Hide
		Sleep 2000
	}
}

CrearIniFile(ficheroIni){
	tempo := "16:00:00"
	IniWrite,9679, %ficheroIni%,option,OnCharacter
	IniWrite,9675, %ficheroIni%,option,OffCharacter
	IniWrite,13, %ficheroIni%,option,SizeFont
	IniWrite,0x0000ff, %ficheroIni%,option,ColorFont
	IniWrite,600, %ficheroIni%,option,ClockX
	IniWrite,600, %ficheroIni%,option,ClockY
	IniWrite,8, %ficheroIni%,option,ClockSizeFont
	IniWrite,0xff0000, %ficheroIni%,option,ColorClock
	IniWrite,4000, %ficheroIni%,option,TimeToShowClock
	IniWrite,%tempo%, %ficheroIni%,option,AlarmClock
	IniWrite,0xff0000, %ficheroIni%,option,ColorWindowAlarm
}

ReadFromIni(ficheroIni){
	if (FileExist(ficheroIni)){		
		IniRead, OnCharacter, %ficheroIni%,option,OnCharacter
		IniRead, OffCharacter, %ficheroIni%,option,OffCharacter
		IniRead, SizeFont, %ficheroIni%,option,SizeFont
		IniRead, ColorFont, %ficheroIni%,option,ColorFont
		IniRead, ClockX, %ficheroIni%,option,ClockX
		IniRead, ClockY, %ficheroIni%,option,ClockY
		IniRead, ClockSizeFont, %ficheroIni%,option,ClockSizeFont
		IniRead, ColorClock, %ficheroIni%,option,ColorClock
		IniRead, TimeToShowClock, %ficheroIni%,option,TimeToShowClock
		IniRead, AlarmClock, %ficheroIni%,option,AlarmClock
		IniRead, ColorWindowAlarm, %ficheroIni%,option,ColorWindowAlarm
	}
}
My BinClock works using an ini file called binclock.ini

Code: Select all

[option]
OnCharacter=9679
OffCharacter=9675
SizeFont=13
ColorFont=0x0000ff
ClockX=1740
ClockY=940
ClockSizeFont=7
ColorClock=0x0000ff
TimeToShowClock=4000
AlarmClock=16:00:00
ColorWindowAlarm=0xff0000
Greetings.
Everything is possible!

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 137 guests