ME 405: Mechatronics Portfolio
TouchDriver.py File Reference

Resistive Touch Panel Driver
More...

Classes

class  TouchDriver.TouchDriver
  Resistive touch panel driver class
More...
 

Variables

 TouchDriver.pinxp = Pin(Pin.cpu.A7)
 Positive x-direction pin object.
 
 TouchDriver.pinxm = Pin(Pin.cpu.A1)
 Negative x-direction pin object.
 
 TouchDriver.pinyp = Pin(Pin.cpu.A6)
 Positive y-direction pin object.
 
 TouchDriver.pinym = Pin(Pin.cpu.A0)
 Negative y-direction pin object.
 
float TouchDriver.width = 0.108
 Width of the touch plate (y-direction)
 
float TouchDriver.length = 0.186
 Length of the touch plate (x-direction)
 
list TouchDriver.center = [0.105,0.067]
 Coordinates of the center of the plate.
 
 TouchDriver.touchObject = TouchDriver(pinxp,pinxm,pinyp,pinym,width,length,center)
 Touch panel driver object.
 
 TouchDriver.startTime = utime.ticks_us()
 The time in microseconds directly before method starts.
 
 TouchDriver.zTest = touchObject.zScan()
 Test output of zScan() method.
 
 TouchDriver.endTime = utime.ticks_us()
 The time in microseconds after method ends.
 
 TouchDriver.xTest = touchObject.xScan()
 Test output of xScan() method.
 
 TouchDriver.yTest = touchObject.yScan()
 Test output of yScan() method.
 
int TouchDriver.timeSum = 0
 Total time for 100 read() methods to run.
 
 TouchDriver.readTest = touchObject.read()
 Test output of read() method.
 
 TouchDriver.testTime = utime.ticks_diff(endTime,startTime)
 The time for one single iteration of the read() method to complete.
 
int TouchDriver.timeAvg = timeSum/100
 The average time for the read() method to complete over 100 runs.
 

Detailed Description

Resistive Touch Panel Driver

Author
Miles Young
Date
02/25/2021 This driver class can be used to scan for a point of contact on a resistive touch panel. Its constructor requires 4 pin objects - one for each of the nodes of the resistive elements within the panel - as well as a measurement for the width and length of the panel in units of cm. The center coordinate of the panel can also be defined, although it is set as an origin by default. This class has 4 methods; xscan() and yscan() determine the x- and y-position, respectively, of the point of contact on the panel from the center coordinates; zscan() determines whether an object is in contact with the panel; and read() scans all three consecutively and returns a tuple containing their readings.
Source https://bitbucket.org/MilesYoung/lab-4-term-project/src/master/Lab09/TouchDriver.py