ME 305 Group 6 Documentation
Public Member Functions | Public Attributes | List of all members
touchPanel.TouchPanel Class Reference

A driver class for a 4-wire resistive touch panel. More...

Public Member Functions

def __init__ (self, pyb.Pin YmPin, pyb.Pin YpPin, pyb.Pin XmPin, pyb.Pin XpPin, PrintQueue print_queue=None)
 Initializes a touchpad object. More...
 
def calibrate (self, touch_calib_status=None)
 Calibrates the touchpad. More...
 
def scan (self)
 Scans the touch panel and returns the position of contact. More...
 

Public Attributes

 YmPin
 -Y Pin More...
 
 YpPin
 +Y Pin More...
 
 XmPin
 -X Pin More...
 
 XpPin
 +X Pin More...
 
 tim
 Timer for the ADC. More...
 
 buf
 Buffer for readings. More...
 
 calibCoeffs
 Calibration Coefficients. More...
 
 print_queue
 Print queue object. More...
 
 xADC
 ADC object for the X scans. More...
 
 yzADC
 ADC object for the Y and Z scans. More...
 

Detailed Description

A driver class for a 4-wire resistive touch panel.

Contains methods for initializing, calibrating, and scanning a touch panel.

Constructor & Destructor Documentation

◆ __init__()

def touchPanel.TouchPanel.__init__ (   self,
pyb.Pin  YmPin,
pyb.Pin  YpPin,
pyb.Pin  XmPin,
pyb.Pin  XpPin,
PrintQueue   print_queue = None 
)

Initializes a touchpad object.

Touchpad pin modes are preconfigured for the first X scan. A timer is also created for use by the ADC.read_timed() method. A buffer is also preallocated to hold the values from ADC.read_timed()

Parameters
YmPinNegative pin of the Y-dimension circuit.
YpPinPositive pin of the Y-dimension circuit.
XmPinNegative pin of the X-dimension circuit.
XpPinPositive pin of the X_dimension circuit.
print_queueA shared variable used for passing print statements out to the print function in taskUser.py

Member Function Documentation

◆ calibrate()

def touchPanel.TouchPanel.calibrate (   self,
  touch_calib_status = None 
)

Calibrates the touchpad.

Requests 5 known points be pressed by the user: (-80, -40), (-80, 40), (0, 0), (80, -40), (80, 40) These values are processed to determine calibration coefficients.

Parameters
touch_calib_statusA shared variable used to indicate when the calibration process is finished.

◆ scan()

def touchPanel.TouchPanel.scan (   self)

Scans the touch panel and returns the position of contact.

The panel is scanned in X, Z, and Y, in that order. X and Y return the position in mm, and Z returns True if contact is made, otherwise, False is returned.

Member Data Documentation

◆ buf

touchPanel.TouchPanel.buf

Buffer for readings.

ADC readings are read into this buffer before being averaged. Changing it's size changes how many readings are made.

◆ calibCoeffs

touchPanel.TouchPanel.calibCoeffs

Calibration Coefficients.

An array holding the correlations used to convert ADC readings to useful positions.

◆ print_queue

touchPanel.TouchPanel.print_queue

Print queue object.

Items to be printed are added to the queue using this object.

◆ tim

touchPanel.TouchPanel.tim

Timer for the ADC.

Used to trigger readings from ADC.read_timed()

◆ xADC

touchPanel.TouchPanel.xADC

ADC object for the X scans.

Attached to the +Y pin

◆ XmPin

touchPanel.TouchPanel.XmPin

-X Pin

Negative pin of the X-dimension circuit.

◆ XpPin

touchPanel.TouchPanel.XpPin

+X Pin

Positive pin of the X_dimension circuit.

◆ YmPin

touchPanel.TouchPanel.YmPin

-Y Pin

Negative pin of the Y-dimension circuit.

◆ YpPin

touchPanel.TouchPanel.YpPin

+Y Pin

Positive pin of the Y-dimension circuit.

◆ yzADC

touchPanel.TouchPanel.yzADC

ADC object for the Y and Z scans.

Attached to the +X pin


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