本文整理匯總了Python中pylcdsysinfo.LCDSysInfo.save_brightness方法的典型用法代碼示例。如果您正苦於以下問題:Python LCDSysInfo.save_brightness方法的具體用法?Python LCDSysInfo.save_brightness怎麽用?Python LCDSysInfo.save_brightness使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylcdsysinfo.LCDSysInfo
的用法示例。
在下文中一共展示了LCDSysInfo.save_brightness方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: clock_loop
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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: main_loop
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [as 別名]
def main_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)
class Data(object):
def __init__(self, d):
self.d = d
self.count = 0
data = Data(owner)
def onbuttondown(data):
data.count += 1
data.d.display_text_on_line(line_num, str(data.count), False, None, fg)
read_wait(onbuttondown=functools.partial(onbuttondown, owner))
示例3: displayErrorScreen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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)
示例4: clock_loop
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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.WHITE
line_num = 1
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)
jsonAfdak = domoticzData(805)
jsonBuiten = domoticzData(16)
jsonBinnen = domoticzData(447)
jsonPower = domoticzData(616)
d.display_text_on_line(2, 'Buiten:' + jsonBuiten['result'][0]['Data'], False, None, fg)
d.display_text_on_line(3, 'Afdak:' + jsonAfdak['result'][0]['Data'], False, None, fg)
d.display_text_on_line(4, 'Binnen:' + jsonBinnen['result'][0]['Data'], False, None, fg)
d.display_text_on_line(5, 'Verbruik:' + jsonPower['result'][0]['Usage'], False, None, fg)
d.display_text_on_line(6, 'Vandaag:' + jsonPower['result'][0]['CounterToday'], False, None, fg)
#print(jsonBuiten['Result']['Name'])
print(jsonBuiten['result'][0]['Data'])
timeout = time.time() + 60*2
while 1:
clock_str = str(datetime.datetime.now()).split('.')[0]
d.display_text_on_line(line_num, clock_str, False, None, fg)
if (time.time() > timeout):
break
# 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)
print('stopped after timeout')
d.clear_lines(TextLines.ALL, bg)
d.dim_when_idle(False)
d.set_brightness(0)
d.save_brightness(0, 255)
d.set_text_background_colour(bg)
示例5: main
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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)
示例6: showSimplifiedScreen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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)
示例7: Screen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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
示例8: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [as 別名]
# used to communicate with bitcoind rpc
import bitcoinrpc
from bitcoinrpc.exceptions import InsufficientFunds
# used to parse the webpage ticker data.
import urllib
import urllib2
import re
# Init the LCD screen
display = LCDSysInfo()
display.dim_when_idle(False)
display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
display.set_brightness(255)
display.save_brightness(100, 255)
# Connect to the remote bitcoind running on another machine (can be localhost too!)
# conn = bitcoinrpc.connect_to_remote('bbb6f1bd-b3aa-5c38-b8df-f0763e973aaa', 'BDBtoys1284', host='rpc.blockchain.info', port=8332)
conn = bitcoinrpc.connect_to_remote("greg", "socrates", host="192.168.69.40", port=8332)
# Grab the latest price from mtgox
aResp = urllib2.urlopen("http://data.mtgox.com/api/1/BTCUSD/ticker")
web_pg = aResp.read()
# read and 'strip' the resulting string so that it can be used.
# this is the response as string
str1 = str(web_pg)
# search for the following string
str2 = 'e":"'
# look for it in the result
示例9: LCDSysInfo
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [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(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:
示例10: showDefaultScreen
# 需要導入模塊: from pylcdsysinfo import LCDSysInfo [as 別名]
# 或者: from pylcdsysinfo.LCDSysInfo import save_brightness [as 別名]
def showDefaultScreen(firstTime, summary, mtgoxLastPrice, mtgoxDirectionCode, toggleSinceLast, mtgoxToggleState):
# extract just the data we want from the API result and
# build up display strings for each using the data
avg = float(summary['SUMMARY'][0]['MHS av'])
avgMhs = convertSize(avg*1000000.0)
foundBlocks = str(int(summary['SUMMARY'][0]['Found Blocks']))
difficultyAccepted = "A:" + str(int(summary['SUMMARY'][0]['Difficulty Accepted']))
if 'Pool Rejected%' in summary['SUMMARY'][0]:
rej = str(summary['SUMMARY'][0]['Pool Rejected%'])
if (rej == '0'):
rejp = rej + "%"
else:
rejp = rej.split('.')[0] + "." + rej.split('.')[1][:2] + "%"
else:
rejp = str(int(summary['SUMMARY'][0]['Difficulty Rejected']))
reject = "R:" + rejp
if 'Device Hardware%' in summary['SUMMARY'][0]:
hw = str(summary['SUMMARY'][0]['Device Hardware%'])
if (hw == '0'):
hwp = hw + "%"
else:
hwp = hw.split('.')[0] + "." + hw.split('.')[1][:2] + "%"
else:
hwp = str(int(summary['SUMMARY'][0]['Hardware Errors']))
hardware = "HW:" + hwp
bestShare = "S:" + convertSize(int(summary['SUMMARY'][0]['Best Share']))
workUtility = "WU:" + str(summary['SUMMARY'][0]['Work Utility']) + "/m"
# get current time, and format it per user selection
theTime = ""
time.ctime() # formatted like this: 'Mon Oct 18 13:35:29 2010'
if timeDisplayFormat == '12':
theTime = time.strftime("%I:%M%p") # 12 hour display
else:
theTime = time.strftime("%H:%M:%S") # 24 hour display
# strip common prefixes and suffixes off of the pool URL (to save display space)
# TODO add code to remove all ":dddd" instead of adding port numbers to ignore
commonStringPattern = ['http://', 'stratum+tcp://', 'stratum.', 'www.', '.com', 'mining.', ':3333', ':3334', ':8330']
shortPoolURL = str(poolURL)
for i in commonStringPattern:
shortPoolURL = shortPoolURL.replace(i, '', 1).rstrip()
# build the display strings
line1String = shortPoolURL + "\t" + theTime
line2String = "Uptime: " + upTime
line3String = "Avg:" + avgMhs + "h/s" + " B:" + foundBlocks
if int(foundBlocks) > 0:
line3Colour = TextColours.RED
else:
line3Colour = TextColours.GREEN
#line3String = "Avg:" + avgMhs + "\tB:" + foundBlocks
line4String = difficultyAccepted + " " + bestShare
line5String = reject + " " + hardware
if mtgoxToggleState: # if we have MtGox data, get ready to display it
line6String = "MtGox: " + mtgoxLastPrice
else:
line6String = workUtility
# 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):
# clear screen
display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
# write all lines
display.display_text_on_line(1, line1String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.YELLOW)
display.display_text_on_line(2, line2String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
display.display_text_on_line(3, line3String, True, (TextAlignment.LEFT), line3Colour)
display.display_text_on_line(4, line4String, True, (TextAlignment.LEFT), TextColours.GREEN)
display.display_text_on_line(5, line5String, True, (TextAlignment.LEFT), TextColours.GREEN)
# check to see if the mtgoxDisplay just toggled, if so, display black text to remove traces of previous icon
if toggleSinceLast == True:
display.display_text_anywhere(0, 197, ' ', TextColours.BLACK)
if mtgoxToggleState == True:
display.display_icon(41, mtgoxDirectionCode) # directionCode should contain the icon number for up or down arrow
display.display_text_anywhere(95, 200, line6String, TextColours.GREEN)
else:
display.display_text_on_line(6, line6String, True, (TextAlignment.LEFT), TextColours.GREEN)