Seven-segment display clock

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
neorobin
Posts: 47
Joined: 01 May 2012 12:18

Seven-segment display clock

#1 Post by neorobin » 01 Aug 2016 20:36

Code: Select all

     -     -         -   -     - 
  | | | .   |   | .   |   | . | |
           -         -         -
  | | | .   |   | . |     | .   |
     -     -         -         -


Code: Select all

set "_c="c = !!(x-2)""
set "_b="b = !!(x-5)^&!!(x-6)""
set "_a="a = (!!(x-1) ^& !!(x-4)) ^<^< 1""
set "_d="d = (!!(x-1) ^& !!(x-4) ^& !!(x-7)) ^<^< 1""
set "_g="g = !(!x ^| !(x-1) ^| !(x-7)) ^<^< 1""
set "_f="f = (!(x^&3) ^| !!(x^&~3)) ^& !!(x-7)""
set "_e="e = ~x ^& 1 ^& !!(x-4)""
@echo off & setlocal enabledelayedexpansion & color 0a & mode 33,5
set "__=0" & set "_= "
for /l %%i in () do (
    set /a "t=!time:~-2,1!" & set /a "t ^= z, z ^= t"
    if !t! neq 0 (
        set "O=" & set "i=0"
        for %%L in ("_ a _" "f _ b" "_ g _" "e _ c" "_ d _") do (
            for %%d in (0 _ 1 _ : _ 3 _ 4 _ : _ 6 _ 7 _ : _ 9) do (
                if "%%d" geq "0" (
                    set "tm=!time: =0!" & set "x=!tm:~%%d,1!"
                    for %%_ in (%%~L) do set /a !_%%_! & set "O=!O!!%%_!"
                ) else if "!i!%%d"=="1:" (set "O=!O!.") else set "O=!O! "
            )
            set /a "i^=1"
        )
        set "O=!O:1=|!" & set "O=!O:2=-!" & cls & set "O=!O:0= !"
        <nul set /p=!O:~0,-1!
    )
)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Seven-segment display clock

#2 Post by foxidrive » 02 Aug 2016 00:51

That works well.

You may find this thread of interest as it's along the same lines.
Several versions are posted along the way by different people.

viewtopic.php?t=5028

Post Reply