pyblock/pybitblock/clock/__init__.py
GaltRanch 8e2737251d Add enhanced block clock with 12 new features for Menu A
New clock/ package replaces the old design() polling loop with a
flicker-free ANSI cursor-positioned renderer. Features include:
countdown timer, epoch/halving progress bar, fee rate indicator,
hashrate sparkline, matrix mining animation, odometer digit transition,
heartbeat pulse, zen mode, UTC time display, fireworks on milestone
blocks, generative hash art, and configurable sound modes.

All features are toggleable via Settings → D (Clock Display Settings).

Also fixes hardcoded config paths in menuSelection(), menuSelectionLN(),
and TUI startup to use the cfg singleton instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:35:59 -03:00

44 lines
1 KiB
Python

"""Enhanced block clock for PyBLOCK.
Entry point: run_clock(mode, path, settings_clock)
"""
import time
import sys
from . import animations
from .data import ClockData
from .renderer import Layout
def run_clock(mode, path, settings_clock):
"""Main clock loop with partial screen updates.
mode: 'local', 'remote', or 'lite'
path: dict with bitcoincli, ip_port, rpcuser, rpcpass
settings_clock: dict from pyblocksettingsClock.conf
"""
data = ClockData(mode, path)
layout = Layout(settings_clock)
try:
# Initial full fetch and render
data.refresh()
layout.render_full(data)
while True:
time.sleep(2)
changed = data.poll()
if 'block_height' in changed:
layout.on_new_block(data, animations)
else:
# Update dynamic elements
layout.update_countdown(data)
layout.heartbeat(data)
except KeyboardInterrupt:
pass
finally:
layout.cleanup()