本文整理汇总了Python中clock.Clock.d_temp方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.d_temp方法的具体用法?Python Clock.d_temp怎么用?Python Clock.d_temp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clock.Clock
的用法示例。
在下文中一共展示了Clock.d_temp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: piOClock
# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import d_temp [as 别名]
class piOClock(daemon.Daemon):
def __init__(self):
path, filename = os.path.split(os.path.abspath(__file__))
pidfile = os.path.join("/var/run", "piOClock.pid")
self.logfile = os.path.join("/var/log", "piOClock.log")
logging.basicConfig(
format='%(asctime)-23s - %(levelname)-7s - %(name)s - %(message)s',
file=self.logfile)
self.log = logging.getLogger("piOClock")
self.log.setLevel(logging.INFO)
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
daemon.Daemon.__init__(self, pidfile,
stderr=self.logfile, stdout=self.logfile)
def shutdown(self, signum=0, frame=None):
self.log.info("Shutdown clock...")
self.clk.clear()
self.clk.oled.text_center("Exiting...", "blue", size=30)
self.clk.display()
self.clk.stop_all()
self.clk.oled.fillScreen(0)
os._exit(0)
def run(self):
# Wiringpi pin number, NOT RPI PIN! see here: http://wiringpi.com/pins/
# Maybe use RPi instead of wiringpi...
RESET_PIN = 15
DC_PIN = 16
led = ssd1351.SSD1351(reset_pin=RESET_PIN, dc_pin=DC_PIN, rows=96)
self.clk = Clock(led)
# handle sigterm
signal.signal(signal.SIGTERM, self.shutdown)
now = datetime.datetime.now()
led.clear()
led.log.setLevel(logging.WARNING)
hours = now.hour
minutes = now.minute
# time sync
time.sleep(1-datetime.datetime.now().microsecond/1000.0/1000.0)
REFRESH_RATE = 1
# Alarm (fixed for testing purpose)
self.clk.alarm = "" # 07:00"
try:
while True:
now = datetime.datetime.now()
resync = 0
self.clk.clear()
if self.clk.input_thread.has_input.is_set():
with self.clk.audio_thread.lock:
wheel = self.clk.input_thread.wheel
click = self.clk.input_thread.click
self.clk.input_thread.has_input.clear()
if wheel != 0 and not self.clk.in_menu:
new_vol = self.clk.audio_thread.volume + self.clk.input_thread.wheel
self.clk.d_volume(new_vol)
elif click or wheel != 0:
self.clk.d_menu(click, wheel)
with self.clk.input_thread.lock:
self.clk.input_thread.wheel = 0
self.clk.input_thread.click = False
# elif clk.freeze > 0:
# clk.freeze -= 1
# clk.d_menu()
else:
self.clk.in_menu = False
self.clk.in_volume = False
self.clk.freeze = 0
self.clk.d_clock()
if not self.clk.in_menu:
self.clk.d_mplayer()
self.clk.d_signal()
self.clk.d_temp()
self.clk.d_audio()
self.clk.d_alarm()
self.clk.d_cpu()
self.clk.display()
if minutes != now.minute:
# refresh minutes
minutes = now.minute
if (now.microsecond > 100000):
resync = 0 - (now.microsecond/1000.0/1000.0)
# end here
d = (datetime.datetime.now()-now).total_seconds()
s = max(REFRESH_RATE - d + resync, 0)
if s > 0:
# time.sleep(s)
self.clk.input_thread.has_input.wait(s + 1*self.clk.freeze)
#.........这里部分代码省略.........