Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chinese #244

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions wordclock_config/wordclock_config.reference.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ animation_fps = 25
# * Maps the port for web-access to 8080
developer_mode = False

# Set to X seconds to test all the times in X seconds per step, from 00:00 onwards
# E.g. 5 seconds will take like 12 minutes total testing one time round the clock
# 0 seconds will disable this mode
developer_mode_step_seconds = 0

# Additionally available after parsing by the wordclock-software:
# base_path = "/path/to/wordclock.py"
# e.g.: base_path = "/home/pi/rpi_wordclock"
Expand Down Expand Up @@ -305,3 +310,15 @@ swedish=["KLOCKANTÄRK",
"FEMSFLORSEX",
"SJUÅTTAINIO",
"TIOELVATOLV"]
chinese=["现在十一两三四五六七",
"八九点一三刻半两三四",
"五十零五OXIÀN爱",
"ZÀI心SHÍSĀN",
"YĪÈRLIÙJIÛ",
"WǓSÌQĪBĀ高兴",
"DIǍN佳SĀNYĪ",
"WǓBÀNKÈRSÌ",
"SHÍLÍNG练WǓ"]



18 changes: 16 additions & 2 deletions wordclock_plugins/time_default/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def __init__(self, config):
self.pretty_name = "The time"
self.description = "The minimum, you should expect from a wordclock."

if config.getint('wordclock', 'developer_mode_step_seconds') > 0:
self.step_seconds = config.getint('wordclock', 'developer_mode_step_seconds')
self.step_count = 0

self.animation = ''.join(config.get('plugin_' + self.name, 'animation'))

animations = ["fadeOutIn", "typewriter", "none"]
Expand Down Expand Up @@ -171,7 +175,7 @@ def run(self, wcd, wci):
print("Date and time not set")

# Check, if a minute has passed (to render the new time)
if prev_min < now.minute:
if prev_min < now.minute or self.step_seconds > 0:
sleepActive = \
self.sleep_begin <= now.time() < self.sleep_end or \
self.sleep_end < self.sleep_begin <= now.time() <= datetime.time(23, 59, 59) or \
Expand Down Expand Up @@ -216,7 +220,17 @@ def run(self, wcd, wci):
self.color_selection(wcd, wci)

def show_time(self, wcd, wci, animation=None, animation_speed=25):
now = datetime.datetime.now()
now = datetime.datetime.now()

if self.step_seconds > 0: # simulator test
if self.step_count == 0: #initialize time tracker
self.step_currtime = now
self.step_count = 1 # start first cycle
if now > self.step_currtime + datetime.timedelta(seconds=self.step_seconds * self.step_count):
self.step_count = self.step_count + 1

now = now.replace(hour=0,minute=0, second=0, microsecond=0) + datetime.timedelta(minutes=5 * (self.step_count - 1))

# Set background color
wcd.setColorToAll(self.bg_color, includeMinutes=True)
# Returns indices, which represent the current time, when being illuminated
Expand Down
93 changes: 93 additions & 0 deletions wordclock_plugins/time_default/time_chinese.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

class time_chinese:
"""
This class returns a given time as a range of LED-indices.
Illuminating these LEDs represents the current time on a chinese WCA 10x10 (last 2 lines are fully dummy)

It shows the time both in Chinese characters as in how to pronounce them,
and additionally has a bonus sentence and some bonus words in Chinese characters:
* Beautiful - 佳 pronounced as Jiā
* Love - 爱 pronounced as Ài
* Heart - 心 pronounced as Xīn
* Practice/experience - 练 pronounced as Liàn
* Happy - 高兴 pronounced as Gāoxìng

I have used this explanation https://improvemandarin.com/tell-time-in-chinese/
In general: It is <hours> o'clock <minutes> / 1 or 3 quarters past / half past
So no term for Minutes (not needed in non-formal chinese) and no X minutes before...
On last thing: when using 5 minutes past, an extra "Ling" must be used for "zero-five".


range(0,2) + range(12,13) + range(21,28) + range(63,67):
It is ... o'clock: 现在 ... 点 and XIÀNZÀI ... DIǍN

十两 SHÍ ÈR Twelve range(2,3) + range()
一 YĪ One range(51,54)
两 ÈR Two range(55,59)
三 SÃN Three range(62,66)
四 SÌ Four range(66,70)
五 WǓ Five range(70,74)
六 LIÙ Six range(74,77)
七 QĪ Seven range(77,82)
八 BÃ Eight range(88,92)
九 JIÛ Nine range(83,88)
十 SHÍ Ten range(91,95)
十一 SHÍ YĪ Eleven range(96,99)
十两 SHÍ ÈR Twelve range(99,105)

零五 LÍNG WǓ Five past
十 SHÍ Ten past
一刻 YĪ KÈ One quarter past
两十 ÈR SHÍ Twenty past
两十五 ÈR SHÍ WǓ Twenty five past
半 BÀN Half past
三十五 SÃN SHÍ WǓ Thirty five past
四 SÌ SHÍ Fourty past
三刻 SÃN KÈ Three quarters past
五十 WǓ SHÍ Fifty past
五十五 WǓ SHÍ WǓ Fifty five past


self.full_hour= n/a
"""

def __init__(self):
self.prefix = list(range(0,2)) + list(range(12,13)) + list(range(25,29)) + list(range(30,33)) + list(range(60,64))
self.hours= [\
list(range(2,3)) + list(range(4,5)) + list(range(34,37)) + list(range(42,44)), \
list(range(3,4)) + list(range(40,42)), \
list(range(4,5)) + list(range(42,44)), \
list(range(5,6)) + list(range(37,40)), \
list(range(6,7)) + list(range(52,54)), \
list(range(7,8)) + list(range(50,52)), \
list(range(8,9)) + list(range(44,48)), \
list(range(9,10)) + list(range(54,56)), \
list(range(10,11)) + list(range(56,58)), \
list(range(11,12)) + list(range(47,50)), \
list(range(2,3)) + list(range(34,37)), \
list(range(2,3)) + list(range(3,4)) + list(range(34,37)) + list(range(40,42)), \
list(range(2,3)) + list(range(4,5)) + list(range(34,37)) + list(range(42,44))]
self.minutes=[[], \
list(range(22,23)) + list(range(23,24)) + list(range(83,87)) + list(range(88,90)), \
list(range(21,22)) + list(range(80,83)), \
list(range(13,14)) + list(range(15,16)) + list(range(68,70)) + list(range(75,77)), \
list(range(17,18)) + list(range(21,22)) + list(range(76,78)) + list(range(80,83)), \
list(range(17,18)) + list(range(21,22)) + list(range(23,24)) + list(range(76,78)) + list(range(80,83)) + list(range(88,90)), \
list(range(16,17)) + list(range(72,75)), \
list(range(14,15)) + list(range(21,22)) + list(range(23,24)) + list(range(65,68)) + list(range(80,83)) + list(range(88,90)), \
list(range(19,20)) + list(range(21,22)) + list(range(78,80)) + list(range(80,83)), \
list(range(14,15)) + list(range(15,16)) + list(range(65,68)) + list(range(75,77)), \
list(range(70,72)) + list(range(21,22)) + list(range(70,72)) + list(range(80,83)), \
list(range(70,72)) + list(range(21,22)) + list(range(23,24)) + list(range(70,72)) + list(range(80,83)) + list(range(88,90))]
self.full_hour= []

def get_time(self, time, purist):
hour=time.hour%12 #+(1 if time.minute//5 > 3 else 0)
minute=time.minute//5
# Assemble indices
return \
(self.prefix if not purist else []) + \
self.minutes[int(minute)] + \
self.hours[hour] + \
self.full_hour

85 changes: 85 additions & 0 deletions wordclock_plugins/time_default/time_hindi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

class time_hindi:
"""
This class returns a given time as a range of LED-indices.
Illuminating these LEDs represents the current time on a dutch WCA 11x10

range(0,3) + range(4,6): HET IS

range(7,11) + range(40,44): VIJF OVER
range(11,15) + range(40,44): TIEN OVER
range(28,33) + range(40,44): KWART OVER
range(11,15) + range(18,22) + range(33,37): TIEN VOOR HALF
range(7,11) + range(18,22) + range(33,37): VIJF VOOR HALF
range(33,37): HALF
range(7,11) + range(22,26) + range(33,37): VIJF OVER HALF
range(11,15) + range(22,26) + range(33,37): TIEN OVER HALF
range(28,33) + range(44,48): KWART VOOR
range(11,15) + range(44,48): TIEN VOOR
range(7,11) + range(44,48): VIJF VOOR

range(99,105): TWAALF
range(51,54): EEN
range(55,59): TWEE
range(62,66): DRIE
range(66,70): VIER
range(70,74): VIJF
range(74,77): ZES
range(77,82): ZEVEN
range(88,92): ACHT
range(83,88): NEGEN
range(91,95): TIEN
range(96,99): ELF
range(99,105): TWAALF

self.full_hour= range(107,110)
"""

def __init__(self):
self.prefix = list(range(107,110))
self.minutes=[[], \
list(range(74,80)) + list(range(95,100)) + list(range(100,105)), \
list(range(74,80)) + list(range(87,90)) + list(range(100,105)), \
list(range(10,14)), \
list(range(74,80)) + list(range(90,93)) + list(range(100,105)), \
list(range(74,80)) + list(range(80,85)) + list(range(100,105)), \
list(range(5,10)), \
list(range(65,72)) + list(range(80,85)) + list(range(100,105)), \
list(range(65,72)) + list(range(90,93)) + list(range(100,105)), \
list(range(0,5)), \
list(range(65,72)) + list(range(87,90)) + list(range(100,105)), \
list(range(65,72)) + list(range(95,100)) + list(range(100,105)) ]
self.hours= [list(range(50,55)), \
list(range(35,37)), \
list(range(18,20)), \
list(range(37,40)), \
list(range(46,50)), \
list(range(30,35)), \
list(range(33,36)), \
list(range(22,25)), \
list(range(23,26)), \
list(range(55,58)), \
list(range(20,23)), \
list(range(40,46)), \
list(range(50,55))]
self.full_hour= list(range(60,64))

def get_time(self, time, purist):
hour=time.hour%12+(1 if time.minute//5 > 6 else 0)
minute=time.minute//5

if (minute == 6 and hour == 1):
return (self.prefix if not purist else []) + \
list(range(26,30)) + \
self.full_hour
if (minute == 6 and hour == 2):
return (self.prefix if not purist else []) + \
list(range(14,18)) + \
self.full_hour
# Assemble indices
return \
(self.prefix if not purist else []) + \
self.minutes[int(minute)] + \
self.hours[hour] + \
(self.full_hour if (minute == 0) else [])

9 changes: 8 additions & 1 deletion wordclock_tools/wordclock_display.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import wordclock_plugins.time_default.time_swiss_german as time_swiss_german
import wordclock_plugins.time_default.time_swiss_german2 as time_swiss_german2
import wordclock_plugins.time_default.time_swedish as time_swedish
import wordclock_plugins.time_default.time_chinese as time_chinese
import wordclock_plugins.time_default.time_hindi as time_hindi
import wordclock_tools.wordclock_colors as wcc
import wordclock_tools.wordclock_screen as wordclock_screen
import colorsys
Expand Down Expand Up @@ -52,7 +54,8 @@ def __init__(self, config, wci):

if config.getboolean('wordclock', 'developer_mode'):
import wordclock_tools.wordclock_strip_wx as wcs_wx
self.strip = wcs_wx.WxStrip(wci)
self.strip = wcs_wx.WxStrip(wci, config)

else:
import wordclock_tools.wordclock_strip_neopixel as wcs_neo
self.strip = wcs_neo.wordclock_strip_neopixel(self.wcl)
Expand Down Expand Up @@ -137,6 +140,10 @@ def __init__(self, config, wci):
self.taw = time_swabian2.time_swabian2()
elif language == 'swedish':
self.taw = time_swedish.time_swedish()
elif language == 'chinese':
self.taw = time_chinese.time_chinese()
elif language == 'hindi':
self.taw = time_hindi.time_hindi()
elif language == 'swiss_german':
self.taw = time_swiss_german.time_swiss_german()
elif language == 'swiss_german2':
Expand Down
20 changes: 14 additions & 6 deletions wordclock_tools/wordclock_strip_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import threading
import os
import sys
import ast
from wordclock_interfaces import event_handler as weh
from wordclock_tools.wordclock_colors import Color

Expand Down Expand Up @@ -40,11 +41,18 @@ def updateDisplay(self):
self.Update()

class WxStrip():
def __init__(self, weh):
def __init__(self, weh, config):
self.label = "QTstrip"

chars = "ESKISTLFÜNFZEHNZWANZIGDREIVIERTELTGNACHVORJMHALBQZWÖLFPZWEINSIEBENKDREIRHFÜNFELFNEUNVIERWACHTZEHNRSBSECHSFMUHR...."

language = ''.join(config.get('wordclock_display', 'language'))
stencil_content = ast.literal_eval(config.get('language_options', language))

height = len(stencil_content)
width = len(stencil_content[0])
chars = ""
for i in range(0, height):
chars = chars + stencil_content[i]
chars = chars + "...."
self.labels = []
self.colors = []

Expand All @@ -60,7 +68,7 @@ def __init__(self, weh):
vbox = wx.BoxSizer(wx.VERTICAL)
font = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(32)
gs = wx.GridSizer(11, 11, 5, 5)
gs = wx.GridSizer(height + 1, width, 5, 5)
vbox.Add(gs, proportion=1, flag=wx.EXPAND)
for i in str(chars):
self.colors.append(Color(0, 0, 0))
Expand All @@ -73,12 +81,12 @@ def __init__(self, weh):
self.labels.append(st2)

x = x + 1;
if x == 11:
if x == width:
x = 0
y = y + 1

self.w.SetSizer(vbox)
self.w.SetSize(1024, 1024)
self.w.SetSize(900, 900)
else:
print("No Main Thread")

Expand Down