本文整理汇总了Python中PiStorms.PiStorms.battVoltage方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.battVoltage方法的具体用法?Python PiStorms.battVoltage怎么用?Python PiStorms.battVoltage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PiStorms.PiStorms
的用法示例。
在下文中一共展示了PiStorms.battVoltage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import battVoltage [as 别名]
import os,sys,inspect,time,thread
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Battery Voltage")
psm.screen.termPrintln(" ")
psm.BBS1.resetTouchesEV3()
exit = False
lastled = 0
while(not exit):
voltVal = psm.battVoltage()
psm.screen.termReplaceLastLine(str(voltVal) + "V")
if(voltVal >= 8and lastled != 1):
psm.led(1,0,255,0)
psm.led(2,0,255,0)
lastled = 1
if(voltVal < 8 and voltVal > 6 and lastled != 2):
psm.led(1,0,255,0)
psm.led(2,0,255,0)
lastled = 2
if(voltVal <= 6 and lastled != 3):
psm.led(1,255,0,0)
psm.led(2,255,0,0)
lastled = 3
if(psm.screen.isTouched()):
示例2: displayFullFileList
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import battVoltage [as 别名]
return displayFullFileList(fileList,index + 1)
try:
newResult = result + (index*4)
except TypeError:
newResult = result
return newResult
#
# main program loop
#
try:
while(True):
result = 0
if(psm.battVoltage()<=6.5):
psm.screen.askQuestion(["LOW BATTERY","Your battery is low","Change or charge your batteries"],["Ignore"])
#if(psm.isKeyPressed()):
# psm.screen.refresh()
files = listPrograms(PROGRAM_DIRECTORY)
file_id = displayFullFileList(files)
if ( isinstance( file_id, int ) ):
result = runProgram(files[file_id],PROGRAM_DIRECTORY)
elif ( file_id == "message"):
f = open(json_file, 'r')
try:
data = json.loads(f.read())
m = data['message'].split("\n")
s = data['status']
f.close()
except:
示例3: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import battVoltage [as 别名]
# This program introduces the process of continually updating a graph.
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile
plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('Voltage (V)')
plt.title('Battery Voltage')
plt.grid(True)
data = np.empty(0) # start with a completely empty data array
image = tempfile.NamedTemporaryFile() # we will be overwriting this same file
while psm.getKeyPressCount() < 1:
data = np.append(data, psm.battVoltage()) # add a data point with the current battery voltage
plt.plot(data, color="blue") # plot the data on the graph
plt.tight_layout() # make sure the entire plot fits on screen
plt.savefig(image.name, format="png") # save it
psm.screen.fillBmp(0,0, 320,240, image.name) # show it on screen
示例4: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import battVoltage [as 别名]
import ConfigParser
from PiStorms import PiStorms
psm = PiStorms()
config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")
homefolder = config.get("msdev", "homefolder")
try:
with open(os.path.join(homefolder, ".version"), "r") as f:
version_no = f.readline().strip()
except IOError:
version_no = "unknown"
psm.screen.drawDisplay("About Me")
psm.screen.termPrintln("Device: {}".format(psm.GetDeviceId().rstrip("\0")))
psm.screen.termPrintln("Feature: {}".format(psm.psc.GetDeviceFeatures().rstrip("\0")))
psm.screen.termPrintln("f/w version: {}".format(psm.GetFirmwareVersion().rstrip("\0")))
psm.screen.termPrintln("s/w version: {}".format(version_no))
psm.screen.termPrintln("Hostname: {}".format(socket.gethostname()))
psm.screen.termPrintln("Battery: {}V".format(psm.battVoltage()))
def getIP(iface):
ip = os.popen("ifconfig {} | tail +2 | awk '/inet / {{print $2}}'".format(iface)).read()
return ip if ip != '' else "not present"
def updateNetworkInfo():
psm.screen.termPrintAt(6, "eth0: {}".format(getIP("eth0")))
psm.screen.termPrintAt(7, "wlan0: {}".format(getIP("wlan0")))
psm.untilKeyPressOrTouch(updateNetworkInfo)
psm.screen.termPrintAt(8, "Exiting to menu")