PiStorms  4.015
PiStorms Library Reference by mindsensors.com
 All Classes Namespaces Files Functions Variables
PiStorms_GRX.PiStorms_GRX Class Reference

PiStorms_GRX: This class provides functions for the PiStorms-GRX. More...

Public Member Functions

def __init__
 Create an object which represents the PiStorms-GRX. More...
 
def command
 Send a command to the PiStorms. More...
 
def shutdown
 Shutdown the Raspberry Pi. More...
 
def batteryVoltage
 Returns the input battery voltage. More...
 
def getFirmwareVersion
 Returns the PiStorms firmware version. More...
 
def getVendorName
 Returns the PiStorms vendor name. More...
 
def getDeviceModel
 Returns the PiStorms model name. More...
 
def getDeviceFeatures
 Returns the PiStorms feature (read from bank A) (ex: "GRX-A") More...
 
def led
 Writes to the specified RGB LED. More...
 
def isKeyPressed
 
def waitForKeyPress
 Wait until the GO button is pressed. More...
 
def untilKeyPress
 Repeat an action until the GO button is pressed. More...
 
def untilKeyPressOrTouch
 Repeat an action until the GO button is pressed or the touchscreen is touched. More...
 
def untilTouch
 Repeat an action until the touchscreen is touched. More...
 
def getKeyPressValue
 Check if any function button is pressed. More...
 
def isF1Pressed
 Check if F1 function button is pressed. More...
 
def isF2Pressed
 Check if F2 function button is pressed. More...
 
def isF3Pressed
 Check if F3 function button is pressed. More...
 
def isF4Pressed
 Check if F4 function button is pressed. More...
 
def getKeyPressCount
 Returns the number of times the GO button has been pressed. More...
 
def resetKeyPressCount
 Resets the GO button press count to 0. More...
 

Public Attributes

 screen
 

Detailed Description

PiStorms_GRX: This class provides functions for the PiStorms-GRX.

GrovePort, RCServo, and RCServoEncoder are all separate classes and should be initialized as needed.

Constructor & Destructor Documentation

def PiStorms_GRX.PiStorms_GRX.__init__ (   self,
  name = "PiStorms_GRX",
  rotation = 3 
)

Create an object which represents the PiStorms-GRX.

Parameters
nameThe display title that will appear at the top of the LCD touchscreen.
rotationThe rotation of the LCD touchscreen.
Remarks
There is no need to use this function directly. To initialize the PiStorms_GRX class in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()

Member Function Documentation

def PiStorms_GRX.PiStorms_GRX.batteryVoltage (   self)

Returns the input battery voltage.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 volts = psm.batteryVoltage()
5 if(volts > 6):
6  # do some task
def PiStorms_GRX.PiStorms_GRX.command (   self,
  cmd 
)

Send a command to the PiStorms.

Parameters
cmdThe command byte to send. This should be a value of GRXCom.COMMAND.
Note
The command will be sent to bank A. This will be important for operations such as resetting the encoder values.
Remarks
You shouldn't need to use this method directly in your programs, but if you do:
1 from PiStorms_GRX import PiStorms_GRX
2 from PiStormsCom_GRX import GRXCom
3 ...
4 PiStorms_GRX.command(GRXCom.COMMAND.SHUTDOWN)
def PiStorms_GRX.PiStorms_GRX.getDeviceFeatures (   self)

Returns the PiStorms feature (read from bank A) (ex: "GRX-A")

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 feature = psm.getDeviceModel()
5 print str(feature)
def PiStorms_GRX.PiStorms_GRX.getDeviceModel (   self)

Returns the PiStorms model name.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 model = psm.getDeviceModel()
5 print str(model)
def PiStorms_GRX.PiStorms_GRX.getFirmwareVersion (   self)

Returns the PiStorms firmware version.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 fwVersion = psm.getFirmwareVersion()
5 print str(fwVersion)
def PiStorms_GRX.PiStorms_GRX.getKeyPressCount (   self)

Returns the number of times the GO button has been pressed.

See also
untilKeyPress
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 initialKeyPressCount = psm.getKeyPressCount()
5 ...
6 if(psm.getKeyPressCount() != initialKeyPressCount):
7  # the GO button has been pressed at least once (or reset)
def PiStorms_GRX.PiStorms_GRX.getKeyPressValue (   self)

Check if any function button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 key = psm.getKeyValue()
5 if(key == 0):
6  # no function button is pressed
def PiStorms_GRX.PiStorms_GRX.getVendorName (   self)

Returns the PiStorms vendor name.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 venName = psm.getVendorName()
5 print str(venName)
def PiStorms_GRX.PiStorms_GRX.isF1Pressed (   self)

Check if F1 function button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 if psm.isF1Pressed():
5  # F1 is pressed, do some task
def PiStorms_GRX.PiStorms_GRX.isF2Pressed (   self)

Check if F2 function button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 if psm.isF1Pressed():
5  # F2 is pressed, do some task
def PiStorms_GRX.PiStorms_GRX.isF3Pressed (   self)

Check if F3 function button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 if psm.isF1Pressed():
5  # F3 is pressed, do some task
def PiStorms_GRX.PiStorms_GRX.isF4Pressed (   self)

Check if F4 function button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 if psm.isF1Pressed():
5  # F4 is pressed, do some task
def PiStorms_GRX.PiStorms_GRX.led (   self,
  lednum,
  red,
  green,
  blue 
)

Writes to the specified RGB LED.

Parameters
lednumThe number to specify the LED (1 for BankA, 2 for BankB).
redThe red value to write to the specified LED (0-255).
greenThe green value to write to the specified LED (0-255).
blueThe blue value to write to the specified LED (0-255).
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 psm.led(1,255,0,0)
def PiStorms_GRX.PiStorms_GRX.resetKeyPressCount (   self)

Resets the GO button press count to 0.

See also
untilKeyPress
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 psm.resetKeyPressCount()
5 ...
6 if(psm.getKeyPressCount() != 0):
7  # the GO button has been pressed at least once
def PiStorms_GRX.PiStorms_GRX.shutdown (   self)

Shutdown the Raspberry Pi.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 psm.Shutdown()
def PiStorms_GRX.PiStorms_GRX.untilKeyPress (   self,
  func,
  args,
  kwargs 
)

Repeat an action until the GO button is pressed.

Parameters
funcThe function to be called repeatedly
argsPositional arguments to be passed to func
kwargsKeyword arguments to be passed to func
Warning
Beware of scope issues! In Python, functions introduce a new scope. You might have to use the keyword "global" to achieve your intended behavior.
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 
5 def mainLoop():
6  psm.screen.termPrintln(psm.battVoltage())
7 
8 psm.untilKeyPress(mainLoop)
def PiStorms_GRX.PiStorms_GRX.untilKeyPressOrTouch (   self,
  func,
  args,
  kwargs 
)

Repeat an action until the GO button is pressed or the touchscreen is touched.

Parameters
funcThe function to be called repeatedly
argsPositional arguments to be passed to func
kwargsKeyword arguments to be passed to func
Warning
Beware of scope issues! In Python, functions introduce a new scope. You might have to use the keyword "global" to achieve your intended behavior.
Note
This is not a class method because it needs self.screen, an instance attribute
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 
5 def mainLoop():
6  psm.screen.termPrintln(psm.battVoltage())
7 
8 psm.untilKeyPressOrTouch(mainLoop)
def PiStorms_GRX.PiStorms_GRX.untilTouch (   self,
  func,
  args,
  kwargs 
)

Repeat an action until the touchscreen is touched.

Parameters
funcThe function to be called repeatedly
argsPositional arguments to be passed to func
kwargsKeyword arguments to be passed to func
Warning
Beware of scope issues! In Python, functions introduce a new scope. You might have to use the keyword "global" to achieve your intended behavior.
Note
This is not a class method because it needs self.screen, an instance attribute
Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 
5 def mainLoop():
6  psm.screen.termPrintln(psm.battVoltage())
7 
8 psm.untilTouch(mainLoop)
def PiStorms_GRX.PiStorms_GRX.waitForKeyPress (   self)

Wait until the GO button is pressed.

Remarks
To use this function in your program:
1 from PiStorms_GRX import PiStorms_GRX
2 ...
3 psm = PiStorms_GRX()
4 psm.screen.termPrintln("Press GO to continue...")
5 psm.waitForKeyPress()

The documentation for this class was generated from the following file: