Ball Balancer Project
Public Member Functions | Public Attributes | List of all members
touchpanel.TouchPanel Class Reference

The class for initializing, reading, filtering, and calibrating the 3-wire resistive touch panel. More...

Public Member Functions

def __init__ (self)
 Initializes the touch panel, creating necessary objects and variables. More...
 
def xScan (self)
 Scans the touch panel for the x-position of the ball. More...
 
def yScan (self)
 Scans the touch panel for the y-position of the ball. More...
 
def zScan (self)
 Scans the touch panel to see if the ball is making contact. More...
 
def Scan (self)
 Scans the touch panel for the total position of the ball. More...
 
def Filter (self, ADC_Data)
 An alpha-beta filter for removing "noise" from the ADC position measurements. More...
 
def Calibrate (self)
 This function walks the user through the steps to calibrate the touchpanel. More...
 
def Beta (self)
 This function uses the 5 data points from the calibration procedure to calculate the matrix of calibration coefficients. More...
 
def Read_Panel (self, Beta)
 This fucntion is a combination of the scan, filter, and calibration fucntions defined earlier. More...
 

Public Attributes

 Pinym
 
 Pinxm
 
 Pinyp
 
 Pinxp
 
 contact
 
 initial_time
 
 vx_hat
 
 vy_hat
 
 Cal_step
 
 Calibrated
 
 y1_print
 
 y2_print
 
 y3_print
 
 y4_print
 
 y5_print
 
 Y6_print
 
 Y
 
 ymADC
 
 xpos
 
 xmADC
 
 ypos
 
 xpADC
 
 x_hat
 
 y_hat
 
 current_time
 
 ts
 
 x1
 
 y1
 
 x2
 
 y2
 
 x3
 
 y3
 
 x4
 
 y4
 
 x5
 
 y5
 
 X
 
 X_T
 
 Beta
 
 x_cal
 
 y_cal
 

Detailed Description

The class for initializing, reading, filtering, and calibrating the 3-wire resistive touch panel.

This class is responsible for alll of the basic fucntionality of the touch panel.

Constructor & Destructor Documentation

◆ __init__()

def touchpanel.TouchPanel.__init__ (   self)

Initializes the touch panel, creating necessary objects and variables.

This function initialzes the touch panel pins, creates a few variables for future use, and creates the Y matrix containing the calibration points.

Member Function Documentation

◆ Beta()

def touchpanel.TouchPanel.Beta (   self)

This function uses the 5 data points from the calibration procedure to calculate the matrix of calibration coefficients.

Using the ADC data from the 5 points tapped on the touch panel, this function calculates the matrix Beta, which contains the calibration coefficients for the panel.

Returns
Beta is the matrix returned. It contains the 6 numbers used to calibate the touch panel and convert the ADC units to units of mm.

◆ Calibrate()

def touchpanel.TouchPanel.Calibrate (   self)

This function walks the user through the steps to calibrate the touchpanel.

As the user is instructed to tap 5 points on the touchpanel, this fucntion stores the ADC data points associated with points that were touched. These data points will be used in Beta(), which will calculate the calibration coefficients based on the positions and ADC data.

◆ Filter()

def touchpanel.TouchPanel.Filter (   self,
  ADC_Data 
)

An alpha-beta filter for removing "noise" from the ADC position measurements.

This function uses predictions to filter values from the touchpanel, making the data more cohesive.

Parameters
ADC_Datais an input to this fucntion: a tuple containing xpos, ypos (ADC units), and contact (boolean).
Returns
This function returns a tuple in the same format as the input, only now it contains filtered xpos and ypos values.

◆ Read_Panel()

def touchpanel.TouchPanel.Read_Panel (   self,
  Beta 
)

This fucntion is a combination of the scan, filter, and calibration fucntions defined earlier.

This will scan the x, y, and z components of the touch panel, and filter the data. The filtered data will then be scaled with the calibration coefficients from the Beta matrix.

Parameters
Betais the matrix containing the 6 numbers used to calibrate the touch panel and convert the ADC units to units of mm.
Returns
The output of this function is a tuple containing the filtered and calibrated xpos, ypos (ADC units), contact (boolean), and time_span (microseconds).

◆ Scan()

def touchpanel.TouchPanel.Scan (   self)

Scans the touch panel for the total position of the ball.

This function sets up the touch panel pins to be able to read the position of the ball in the x-direction, y-direction, and z-direction (contact).

Returns
This returns a tuple containing xpos, ypos, contact, and timespan. The positions are in ADC units and the timespan is in microseconds (for testing).

◆ xScan()

def touchpanel.TouchPanel.xScan (   self)

Scans the touch panel for the x-position of the ball.

This function sets up the touch panel pins to be able to read the position of the ball in the x-direction.

Returns
xpos is the x-position of the ball in ADC units.

◆ yScan()

def touchpanel.TouchPanel.yScan (   self)

Scans the touch panel for the y-position of the ball.

This function sets up the touch panel pins to be able to read the position of the ball in the y-direction.

Returns
ypos is the y-position of the ball in ADC units.

◆ zScan()

def touchpanel.TouchPanel.zScan (   self)

Scans the touch panel to see if the ball is making contact.

This function sets up the touch panel pins to be able to read read if something is contacting the panel.

Returns
contact is a boolean telling if there is something on the panel.

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