本文整理汇总了Python中decoder.Decoder.visualize方法的典型用法代码示例。如果您正苦于以下问题:Python Decoder.visualize方法的具体用法?Python Decoder.visualize怎么用?Python Decoder.visualize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类decoder.Decoder
的用法示例。
在下文中一共展示了Decoder.visualize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Citrocan
# 需要导入模块: from decoder import Decoder [as 别名]
# 或者: from decoder.Decoder import visualize [as 别名]
class Citrocan(App):
dec = None
update = False
stop_ev = threading.Event()
d_time = StringProperty()
d_date = StringProperty()
d_temp = StringProperty()
d_vol = StringProperty()
d_band = StringProperty()
d_name = StringProperty()
d_info = StringProperty()
d_title = StringProperty()
d_memch = StringProperty()
d_dx = StringProperty()
d_rds = StringProperty()
d_rds_ok = BooleanProperty()
d_ta = StringProperty()
d_ta_ok = BooleanProperty()
d_pty = StringProperty()
d_pty_ok = BooleanProperty()
d_ptyname = StringProperty()
d_rdtxt_rnd = StringProperty()
d_reg = StringProperty()
d_loud = StringProperty()
d_icon = StringProperty("icon")
d_volbar = NumericProperty()
d_alert = StringProperty()
d_debug = StringProperty()
def build(self):
Window.size = (1024, 520)
self.dec = Decoder(self.prop_set)
Clock.schedule_interval(self.update_time, .5)
Clock.schedule_interval(self.visualize, .4)
thr = threading.Thread(target=self.get_candata)
thr.setDaemon(True)
thr.start()
def update_time(self, *_):
self.d_time = time.strftime("%H %M" if ':' in self.d_time else "%H:%M")
self.d_date = time.strftime("%a %d/%m/%Y")
def visualize(self, *_):
if self.dec and self.update:
self.update = False
self.dec.visualize()
def prop_set(self, var, val):
if self.__getattribute__("d_" + var) != val:
self.__setattr__("d_" + var, val)
def file_receiver(self, on_recv, fname):
old_tm = .0
sp = open(fname, "r")
for ln in sp:
if self.stop_ev.is_set():
break
buf = ln.strip()
# print("got:", buf)
if len(buf):
tm, _, b = buf.partition(' ')
if old_tm:
time.sleep(float(tm) - old_tm)
old_tm = float(tm)
if b[0] in ('R', 'S'):
on_recv(b)
sp.close()
print("EOF, stop playing.")
def serial_receiver(self, on_recv):
sp = None
while not self.stop_ev.is_set():
if not sp:
buf = []
ready = False
try:
sp = serial.Serial(port=Port, baudrate=460800, timeout=1)
except (ValueError, serial.SerialException) as e:
print("can't open serial:", e)
if self.dec.connected:
self.dec.connected = False
self.update = True
if sp and not ready:
try:
sp.write("i0\r\n".encode())
except serial.SerialTimeoutException as e:
print("can't write to serial:", e)
time.sleep(1)
if sp:
while not self.stop_ev.is_set():
try:
r = sp.read(1)
except serial.SerialException:
sp.close()
sp = None
r = None
if not r:
#.........这里部分代码省略.........