-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new files * new files Co-authored-by: msk <54884351+minsangkim89@users.noreply.github.com>
- Loading branch information
1 parent
9e92ac0
commit b4ccd5b
Showing
5 changed files
with
314 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(description="IIDXSEG") | ||
parser.add_argument("host", type=str) | ||
parser.add_argument("port", type=int) | ||
parser.add_argument("password", type=str) | ||
parser.add_argument( | ||
"--width", | ||
type=int, | ||
help="Width of the window") | ||
parser.add_argument( | ||
"--height", | ||
type=int, | ||
help="Height of the window") | ||
parser.add_argument( | ||
"--borderless", | ||
action="store_true", | ||
help="Remove window border and title bar") | ||
parser.add_argument( | ||
"--x", | ||
type=int, | ||
help="Desired x-coordinate for the window position") | ||
parser.add_argument( | ||
"--y", | ||
type=int, | ||
help="Desired y-coordinate for the window position") | ||
parser.add_argument( | ||
"--font_size", | ||
type=int, | ||
default=0, | ||
help="Preferred font size for the ticker. When omitted, the ticker will fill the window") | ||
parser.add_argument( | ||
"--offset", | ||
type=int, | ||
default=0, | ||
help="Desired y-offset in pixels to shift the ticker up (negative) or down (positive)") | ||
parser.add_argument( | ||
"--clock", | ||
action="store_true", | ||
help="Show the wall clock") | ||
parser.add_argument( | ||
"--timer", | ||
action="store_true", | ||
help="Show the stop watch") | ||
parser.add_argument( | ||
"--time_font_size", | ||
type=int, | ||
default=24, | ||
help="Desired font size for the wall clock and the stop watch") | ||
args = parser.parse_args() | ||
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
|
||
DEBUG = False | ||
|
||
DEFAULT_WIDTH = 520 | ||
DEFAULT_ASPECT_RATIO = (52 / 10) | ||
|
||
if getattr(sys, 'frozen', False): | ||
CurrentPath = sys._MEIPASS | ||
else: | ||
CurrentPath = os.path.dirname(__file__) | ||
DEFAULT_FONT = os.path.join(CurrentPath, 'DSEG14Classic-Italic.ttf') | ||
|
||
CONNECTING_TEXT = "CONNECT.!.!." | ||
|
||
# colors | ||
|
||
BLACK = (0, 0, 0) | ||
GRAY = (20, 10, 10) | ||
RED = (255, 0, 0) | ||
|
||
# default colors | ||
|
||
COLOR_TEXT_ON = RED | ||
COLOR_TEXT_OFF = GRAY | ||
COLOR_BACKGROUND = BLACK | ||
|
||
# '!' is all-off character in DSEG14 font | ||
ALL_OFF_CHAR = "!" | ||
|
||
# '~' is all-on character in DSEG14 font | ||
ALL_ON_CHAR = "~" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import spiceapi | ||
import time | ||
import pygame | ||
from constants import * | ||
|
||
def spice_client(q, host, port, password): | ||
con = None | ||
reconnect = False | ||
failed_connection_attempt = 0 | ||
clock = pygame.time.Clock() | ||
while True: | ||
ticker_text = CONNECTING_TEXT | ||
if (con is None and | ||
(time.time() - failed_connection_attempt) > 10): | ||
|
||
try: | ||
print("connecting ...") | ||
con = spiceapi.Connection( | ||
host=host, | ||
port=port, | ||
password=password) | ||
|
||
except: | ||
con = None | ||
|
||
if con is None: | ||
failed_connection_attempt = time.time() | ||
|
||
if con is not None: | ||
try: | ||
ticker_text = get_ticker(con) | ||
except: | ||
reconnect = True | ||
|
||
if reconnect: | ||
try: | ||
reconnect = False | ||
con.reconnect() | ||
except: | ||
pass | ||
|
||
try: | ||
q.put(ticker_text) | ||
except: | ||
pass | ||
|
||
clock.tick(8) | ||
pass | ||
|
||
def get_ticker(con): | ||
text = spiceapi.iidx_ticker_get(con) | ||
return convert_ticker_text(text[0]) | ||
|
||
def convert_ticker_text(original_text): | ||
text = original_text | ||
|
||
if DEBUG: | ||
print_text_in_hex(original_text) | ||
|
||
# HT (horizontal tab) is sent after ! | ||
text = text.replace(chr(9), " ") | ||
text = text.replace("!", "./") | ||
|
||
# lower case m = period | ||
text = text.replace("m", "." + ALL_OFF_CHAR) | ||
text = text.replace("q", "'") | ||
text = text.replace("u", ",") | ||
|
||
# Make S look more like IIDX | ||
text = text.replace("S", "5") | ||
# [ ] are not supported | ||
text = text.replace("[", "(") | ||
text = text.replace("]", ")") | ||
text = text.replace("~", "-") | ||
|
||
# Lastly, blank space must be replaced by all-off character to keep | ||
# monospace | ||
text = text.replace(" ", ALL_OFF_CHAR) | ||
return text | ||
|
||
def print_text_in_hex(text): | ||
print(text) | ||
for c in text: | ||
print(ord(c), end=" ") | ||
|
||
print("") |
Oops, something went wrong.