本文整理匯總了Python中pylcdsysinfo.LCDSysInfo.display_text_on_line方法的典型用法代碼示例。如果您正苦於以下問題:Python LCDSysInfo.display_text_on_line方法的具體用法?Python LCDSysInfo.display_text_on_line怎麽用?Python LCDSysInfo.display_text_on_line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylcdsysinfo.LCDSysInfo
的用法示例。
在下文中一共展示了LCDSysInfo.display_text_on_line方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: clock_loop
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
def clock_loop(bg=None, fg=None):
update_display_period = 1 # number of seconds to wait before updating display
floor = math.floor # minor optimization
if bg is None:
bg = BackgroundColours.BLACK
if fg is None:
fg = TextColours.GREEN
line_num = 3
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, bg)
d.dim_when_idle(False)
d.set_brightness(127)
d.save_brightness(127, 255)
d.set_text_background_colour(bg)
while 1:
clock_str = str(datetime.datetime.now()).split('.')[0]
d.display_text_on_line(line_num, clock_str, False, None, fg)
# Work out when to wake up for the next round/whole (non-fractional) time
start_time = time.time()
future_time = floor(start_time) + update_display_period # pure float math
sleep_time = future_time - start_time
time.sleep(sleep_time)
示例2: displayErrorScreen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
def displayErrorScreen(e):
# set up to write to the LCD screen
# Init the LCD screen
display = LCDSysInfo()
display.dim_when_idle(False)
display.set_brightness(255)
display.save_brightness(100, 255)
# Always clear the whole screen
display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
display.display_text_on_line(3, "Error: Check Miner", True, (TextAlignment.LEFT), TextColours.RED)
display.display_text_on_line(4, e, True, (TextAlignment.LEFT), TextColours.RED)
示例3: main
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
def main():
uptime = getUptime()
bg = BackgroundColours.BLACK
fb = TextColours.WHITE
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, bg)
d.dim_when_idle(False)
d.set_brightness(127)
d.save_brightness(127, 255)
d.set_text_background_colour(bg)
d.display_text_on_line(3, "Uptime:", False, None, fb)
d.display_text_on_line(4, uptime, False, None, fb)
示例4: Screen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
class Screen():
def __init__(self):
self.lcd = LCDSysInfo()
self.lcd.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
self.lcd.dim_when_idle(False)
self.lcd.set_brightness(127)
self.lcd.save_brightness(127, 127)
def clear(self):
self.lcd.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
def printc(self, data, sensors_to_display):
line = 1
for key in sensors_to_display:
for sensor in data:
if sensor['id'] == key:
value = str(sensor['value'])
txt = unicode(sensor['name'] + "\t " + value + "" + sensor['unit'])
txt = txt.replace(u"\u00B0", "^")
txt = unicodedata.normalize('NFKD', txt).encode('ascii', 'ignore')
print(txt)
self.lcd.display_text_on_line(line, txt, False, TextAlignment.LEFT, TextColours.LAVENDER)
line +=1
示例5: showSimplifiedScreen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
def showSimplifiedScreen(firstTime, summary):
# extract just the data we want from the API result
hardwareErrors = str(summary['SUMMARY'][0]['Hardware Errors'])
avg = int(summary['SUMMARY'][0]['MHS av'])
avgStr = convertSize(avg*1000000.0)
avgMhs = "Average: " + avgStr
# set up to write to the LCD screen
# Init the LCD screen
display = LCDSysInfo()
display.dim_when_idle(False)
display.set_brightness(255)
display.save_brightness(100, 255)
if (firstTime == True):
display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
display.display_text_on_line(1, str(poolURL), True, (TextAlignment.LEFT), TextColours.LIGHT_BLUE)
display.display_text_on_line(2, "Uptime: \t" + upTime, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
display.display_text_on_line(3, avgMhs + "h/s", True, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
display.display_text_on_line(4, "HW Errors: " + hardwareErrors, True, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
示例6: str
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
#Look for it in the result
subStringFindVol = str1.find(str3);
#strip it
substringvolume = str1[subStringFindVol + 15:];
#extract it
volume = substringvolume[0 : 0 +10];
#get the balance from our remote bitcoind and store it.
btcbalance = str(conn.getbalance());
# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)
#loop through each line to display, filling in the variables.
for line in range(1, 7):
if line == 1:
display.display_text_on_line(line, '1 BTC at MtGox', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.BLUE)
elif line == 2:
display.display_text_on_line(line, '$' + str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
elif line == 3:
display.display_text_on_line(line, 'Volume: ' + str(volume), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED)
elif line == 4:
display.display_text_on_line(line, btcbalance + " btc", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
elif line == 5:
display.display_text_on_line(line, 'Total local wallet:', False, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
else:
#calculate our wallet value with mtgox's price to get a dollar price on our wallet.
# Shorten the resulting value to two decimals for easier readability
display.display_text_on_line(line, str("%.2f" % (float(price) * float(btcbalance))) + " usd", True, TextAlignment.RIGHT, TextColours.DARK_BLUE)
#time.sleep(10)
示例7: range
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
substringbtc = str2[subStringFindBTC + 20:];
#extract the price
btc = substringbtc[0 : 0 +6];
#BTC at BTC-E
str6 ="last"
#look for it in the result
subStringFindBTCE = str3.find(str6);
#strip the string to 'keep' the price
substringbtce = str3[subStringFindBTCE + 6:];
#extract the price
btce = substringbtce[0 : 0 +6];
# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)
#loop through each line to display, filling in the variables.
for line in range(1, 7):
if line == 1:
display.display_text_on_line(line, '1 LTC at BTC-E', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
elif line == 2:
display.display_text_on_line(line, '$' + str(ltc) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
elif line == 3:
display.display_text_on_line(line, '1 BTC at Mt. Gox ', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
elif line == 4:
display.display_text_on_line(line, '$' + str(btc) + " USD", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
elif line == 5:
display.display_text_on_line(line, '1 BTC at BTC-E ', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
elif line == 6:
display.display_text_on_line(line, '$' + str(btce) + " USD", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
示例8: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(127)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
f = open('yw', 'r')
c = 1
col = TextColours.GREEN
for line in f:
if c == 2:
col = TextColours.PURPLE
if c == 3:
col = TextColours.YELLOW
if c == 4:
col = TextColours.LIGHT_BLUE
if c == 5:
col = TextColours.ORANGE
if c == 6:
col = TextColours.RED
d.display_text_on_line(c, line, False, TextAlignment.LEFT, col)
c = c + 1
if c > 6:
break
示例9: EventHandler
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
class EventHandler(pyinotify.ProcessEvent):
last_updated = 0
def __init__(self, path):
super(EventHandler, self).__init__()
self.lcd = LCDSysInfo()
self.lcd.set_brightness(BRIGHTNESS)
self.lcd.dim_when_idle(False)
self.lcd.clear_lines(TextLines.ALL, BGCOLOR)
self.old_lines = [''] * 6
self.path = path
@staticmethod
def fmt_task(task):
try:
if task.startswith('+'):
task = '+ ' + task[1:]
else:
task = '- ' + task
return '____%s' % task
except AttributeError as err:
return '- %s' % err
@staticmethod
def _parse_todos(path):
with open(path, 'rU') as fobj:
yobj = yaml.safe_load_all(fobj)
# Python 2/3 adapter
if hasattr(yobj, 'next'):
yobj_next = yobj.next
elif hasattr(yobj, '__next__'):
yobj_next = yobj.__next__
else:
raise Exception("Python is broken")
# Skip header text
yobj_next()
return yobj_next() or {}
def process_IN_MODIFY(self, event):
# Workaround for race condition when using IN_MODIFY
# (Because IN_CLOSE_WRITE | IN_MOVED_TO doesn't fire with Leafpad)
this_stat, waited = os.stat(self.path), 0
while this_stat.st_size == 0 and waited < 3:
time.sleep(0.3)
this_stat = os.stat(self.path)
waited += 0.3
# Ensure we fire only once per change
if self.last_updated == this_stat.st_mtime:
return
try:
data = self._parse_todos(self.path)
except BaseException as err:
log.debug("Couldn't parse data from file: %s", self.path)
lines = ["Error parsing TODO YAML",
"%d bytes" % this_stat.st_size,
"",
str(err)]
print(err)
else:
tasks = data.get('TODO', None)
if tasks:
lines = ["TODO:"] + [self.fmt_task(x) for x in tasks]
else:
lines = ["No TODOs found"]
# Waste as little time as possible overwriting lines that haven't
# changed
for pos, line in enumerate(lines[:6]):
if line != self.old_lines[pos]:
# Work around the ASCII-only-ness of the USBLCD API
if isinstance(line, bytes):
line = line.decode('utf8', 'replace')
line = unidecode(line)
self.lcd.display_text_on_line(pos + 1, line, False,
TextAlignment.LEFT, FGCOLOR)
self.old_lines[pos] = line
# Only erase lines that used to have something on them
mask = 0
for pos in range(len(lines), 6):
if self.old_lines[pos]:
mask += 1 << int(pos)
self.old_lines[pos] = ''
if mask:
self.lcd.clear_lines(mask, BGCOLOR)
# Only update this if we successfuly parsed and applied an update
self.last_updated = this_stat.st_mtime
示例10: str
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
jsondata = jsonp[ jsonp.index("(")+1 : jsonp.rindex(")") ]
data = json.loads(jsondata)
totalchecks = data['result']['stats'][0]['checks']
totalerrors = data['result']['stats'][0]['check_errors']
except urllib2.URLError, e:
print 'no valid data received'
print json.dumps(data)
bad = " "
line = str("WatchM err " + totalerrors + "/" + totalchecks )
#print line
col = TextColours.GREEN
d.display_text_on_line(6, line, False, TextAlignment.LEFT, col)
f = open('yw', 'r')
c = 1
for line in f:
if c == 2:
col = TextColours.PURPLE
if c == 3:
col = TextColours.PURPLE
if c == 4:
col = TextColours.LIGHT_BLUE
if c == 5:
col = TextColours.LIGHT_BLUE
if c == 6:
col = TextColours.RED
d.display_text_on_line(c, line, False, TextAlignment.LEFT, col)
示例11: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
# generate client name and connect to mqtt
mypid = os.getpid()
client_uniq = "pubclient_"+str(mypid)
# set the screen up
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, bg)
d.dim_when_idle(False)
d.set_brightness(127)
d.save_brightness(127, 255)
d.set_text_background_colour(bg)
# connect mqtt
connect()
#remain connected and publis
mqttc.loop_forever()
# bad
logging.info("Dropped out of the loop, Exiting")
time.sleep(2)
sys.exit(1)
except Exception, e:
# exit with error, supervisord will restart it.
d.clear_lines(TextLines.ALL, bg)
d.display_text_on_line(3, "Error", False, TextAlignment.CENTRE, TextColours.CYAN)
logging.error(e)
logging.error(traceback.format_exc())
time.sleep(10)
sys.exit(1)
示例12: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, 0, 1)
d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)
for pos in range(0, 48):
d.display_icon(pos, 1 + pos % 32)
d.clear_lines(63, BackgroundColours.WHITE)
d.set_text_background_colour(BackgroundColours.BLUE)
sleep(1)
for line in range(1, 7):
d.display_text_on_line(line, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", False, TextAlignment.LEFT, TextColours.WHITE)
示例13: EventHandler
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
class EventHandler(pyinotify.ProcessEvent):
last_updated = 0
def __init__(self, path):
super(EventHandler, self).__init__()
self.lcd = LCDSysInfo()
self.lcd.set_brightness(BRIGHTNESS)
self.lcd.dim_when_idle(False)
self.lcd.clear_lines(TextLines.ALL, BGCOLOR)
self.old_lines = [""] * 6
self.path = path
@staticmethod
def fmt_task(task):
if task.startswith("+"):
task = "+ " + task[1:]
else:
task = "- " + task
return "____%s" % task
@staticmethod
def _parse_todos(path):
with open(path, "rU") as fobj:
yobj = yaml.safe_load_all(fobj)
yobj.next() # Skip header text
return yobj.next() or {}
def process_IN_MODIFY(self, event):
# Workaround for race condition when using IN_MODIFY
# (Because IN_CLOSE_WRITE | IN_MOVED_TO doesn't fire with Leafpad)
this_stat, waited = os.stat(self.path), 0
while this_stat.st_size == 0 and waited < 3:
time.sleep(0.3)
this_stat = os.stat(self.path)
waited += 0.3
# Ensure we fire only once per change
if self.last_updated == this_stat.st_mtime:
return
try:
data = self._parse_todos(self.path)
except BaseException:
log.debug("Couldn't parse data from file: %s", self.path)
lines = ["Error parsing TODO YAML", "%d bytes" % this_stat.st_size]
else:
tasks = data.get("TODO", None)
if tasks:
lines = ["TODO:"] + [self.fmt_task(x) for x in tasks]
else:
lines = ["No TODOs found"]
# Waste as little time as possible overwriting lines that haven't
# changed
for pos, line in enumerate(lines[:6]):
if line != self.old_lines[pos]:
self.lcd.display_text_on_line(pos + 1, line, False, TextAlignment.LEFT, FGCOLOR)
self.old_lines[pos] = line
# Only erase lines that used to have something on them
mask = 0
for pos in range(len(lines), 6):
if self.old_lines[pos]:
mask += 1 << int(pos)
self.old_lines[pos] = ""
if mask:
self.lcd.clear_lines(mask, BGCOLOR)
# Only update this if we successfuly parsed and applied an update
self.last_updated = this_stat.st_mtime
示例14: range
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
#strip it
substringvwap = str1[subStringFindVwap + 16:];
#extract it
vwap = substringvwap[0 : 0 +6];
#get the high price
str7 = "high"
#look for it
subStringFindHigh = str1.find(str7);
#strip it
substringhigh = str1[subStringFindHigh + 16:];
#extract it
high = substringhigh[0 : 0 +6];
# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)
#loop through each line to display, filling in the variables.
for line in range(1, 7):
if line == 1:
display.display_text_on_line(line, '1 BTC at MtGox', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
elif line == 2:
display.display_text_on_line(line, 'Last $' + str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
elif line == 3:
display.display_text_on_line(line, 'Volume: ' + str(volume), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED)
elif line == 4:
display.display_text_on_line(line, 'High $' + str(high), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
elif line == 5:
display.display_text_on_line(line, 'Low $' + str(low), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
elif line == 6:
display.display_text_on_line(line, 'Avg $' + str(vwap), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
示例15: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import display_text_on_line [as 別名]
import socket
import time
from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep
hostname=socket.gethostname()
#Get IP address and concatenate with "IP: " string
t_ipaddress=socket.gethostbyname(hostname)
ipaddress="IP: " + t_ipaddress
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
while True:
d.display_text_on_line(2, "Hostname: ", True, TextAlignment.LEFT, TextColours.GREEN)
d.display_text_on_line(4, ipaddress, True, TextAlignment.LEFT, TextColours.WHITE)
time.sleep(5)
d.display_text_on_line(2, hostname, True, TextAlignment.LEFT, TextColours.GREEN)
d.display_text_on_line(4, ipaddress, True, TextAlignment.LEFT, TextColours.WHITE)
time.sleep(5)
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
sys.exit(0)