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
Exemple #2
0
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield


import os,sys,inspect,time
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.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
 
    pass
    
    psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
    psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
    if (psm.screen.checkButton(0,0,320,320)):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True
        
# 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
Exemple #4
0
if (version < 2.05):
    m = [
        "LED-sample", "This feature is not implemented on",
        "PiStorms Firmware: V2.04 and earlier.",
        "Please upgrade your PiStorms.", "  ", "Click OK to exit."
    ]
    psm.screen.askQuestion(m, ["OK"])
    exit = True
else:
    exit = False
    psm.screen.termPrintAt(8, "Press Go button to exit")

d1 = 0.2
d2 = 0.2
oldKeyPressCount = psm.getKeyPressCount()
while (not exit):

    psm.led(2, 0, 255, 0)
    time.sleep(d1)
    psm.led(1, 0, 255, 0)
    time.sleep(d2)
    psm.led(2, 255, 0, 0)
    time.sleep(d1)
    psm.led(1, 255, 0, 0)
    time.sleep(d2)
    psm.led(2, 0, 0, 255)
    time.sleep(d1)
    psm.led(1, 0, 0, 255)
    time.sleep(d2)
if(version < 2.05):
    m = ["LED-sample", "This feature is not implemented on",
 "PiStorms Firmware: V2.04 and earlier.",
 "Please upgrade your PiStorms.",
 "  ",
 "Click OK to exit."]
    psm.screen.askQuestion(m,["OK"])
    exit = True
else:
    exit = False
    psm.screen.termPrintAt(8, "Press Go button to exit")

d1 = 0.2
d2 = 0.2
oldKeyPressCount = psm.getKeyPressCount()
while(not exit):

    psm.led(2,0,255,0)
    time.sleep(d1)
    psm.led(1,0,255,0)
    time.sleep(d2)
    psm.led(2,255,0,0)
    time.sleep(d1)
    psm.led(1,255,0,0)
    time.sleep(d2)
    psm.led(2,0,0,255)
    time.sleep(d1)
    psm.led(1,0,0,255)
    time.sleep(d2)
Exemple #6
0
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield


import os,sys,inspect,time
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.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):

    pass

    psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
    psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
    if (psm.screen.isTouched()):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True