Lucas Murray ME 305 Portfolio
Public Member Functions | Public Attributes | List of all members
touch.Touch Class Reference

Public Member Functions

def __init__ (self, xP, xM, yP, yM, a, b, x0, y0)
 Initializes and returns a resistive touch panel object. More...
 
def zScan (self)
 Scans for a voltage in the z-direction from an ADC. More...
 
def xScan (self)
 Scans for a voltage in the x-direction from an ADC. More...
 
def yScan (self)
 Scans for a voltage in the y-direction from an ADC. More...
 
def cart (self)
 Runs all three scans and converts data into usable values. More...
 
def calibrate (self, hFlag)
 Calibrates the resistive touch panel. More...
 
def setCalCoefficients (self)
 Writes the newly obtained calibration coefficients of the touch panel to a new file. More...
 
def getCalCoefficients (self)
 Sets the calibration coefficients of the touch panel from a file or from manual calibration. More...
 

Public Attributes

 xP
 
 xM
 
 yP
 
 yM
 
 Kxx
 
 Kxy
 
 Kyx
 
 Kyy
 
 a
 
 b
 
 x0
 
 y0
 
 count
 
 nxt
 
 lastScan
 
 calStatus
 
 coefficients
 

Constructor & Destructor Documentation

◆ __init__()

def touch.Touch.__init__ (   self,
  xP,
  xM,
  yP,
  yM,
  a,
  b,
  x0,
  y0 
)

Initializes and returns a resistive touch panel object.

Parameters
xPThe initial x+ pin configuration
xMThe initial x- pin configuration
yPThe initial y+ pin configuration
yMThe initial y- pin configuration
aThe alpha value for the alpha-beta filtering
bThe beta value for the alpha-beta filtering
x0The initial x-direction offset
y0The initial y-direction offset

Member Function Documentation

◆ calibrate()

def touch.Touch.calibrate (   self,
  hFlag 
)

Calibrates the resistive touch panel.

Takes the average of one hundred measurements at three different board positions to accurately calculate the scaling factors and offsets needed to line up the theoretical board with the actual.

Parameters
hFlagBoolean variable shared between taskPanel and taskMotor for the haptic feedback command
Returns
Boolean True when the calibration is finished

◆ cart()

def touch.Touch.cart (   self)

Runs all three scans and converts data into usable values.

Takes the average of ten converted position values for each scan and performs alpha-beta filtering to minimize effects of bad measurement values and gather position data. It then accounts for the offsets to get the true positions.

Returns
list Converted position, zScan, and velocity values

◆ getCalCoefficients()

def touch.Touch.getCalCoefficients (   self)

Sets the calibration coefficients of the touch panel from a file or from manual calibration.

If the calibration file already exists, it will read it and set the calibration coefficients of the touch panel from the read data, and if the file doesn't exist, it runs the calibration process and sends the new touch panel coefficients over to setCalCoefficients().

◆ setCalCoefficients()

def touch.Touch.setCalCoefficients (   self)

Writes the newly obtained calibration coefficients of the touch panel to a new file.

Only accessed when getCalCoefficients() doesn't find a calibration file, it will run the calibrate() function and write the necessary values to a new file with the required name.

◆ xScan()

def touch.Touch.xScan (   self)

Scans for a voltage in the x-direction from an ADC.

Sets the touch panel pins and ADC to the necessary configurations and reads the ADC for a voltage in the x-direction

Returns
list Scaled values of the ADC reading

◆ yScan()

def touch.Touch.yScan (   self)

Scans for a voltage in the y-direction from an ADC.

Sets the touch panel pins and ADC to the necessary configurations and reads the ADC for a voltage in the y-direction

Returns
list Scaled values of the ADC reading

◆ zScan()

def touch.Touch.zScan (   self)

Scans for a voltage in the z-direction from an ADC.

Sets the touch panel pins and ADC to the necessary configurations and reads the ADC for contact with the board by measuring z-axis voltage

Returns
Boolean True if there is contact with the board, otherwise false

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