Positron Compiler Documentation

Touch_Active

Positron16 · Revision 1.1.3.5 · PDF pages 290–291

Assignment Variable = Touch_Active

Indicates if the graphic LCD's resistive touch membrane has been touched.

None Assignment Variable can be any valid variable type and holds 1 if the touch screen membrane has been touched with sufficient force.

' Demonstrate the Touch_Active command
'
  Device = 24HJ128GP502             ' Select the device to compile for
  Declare Xtal = 79.23
  Declare Hserial_Baud = 9600     ' USART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14   ' Select the pin used for TX with USART1
'
' Setup the ADS7846 touch screen chip's pins
'
  Declare Touch_DINPin = PORTB.13   ' Connect to the ADS7846 DIN pin
  Declare Touch_DOUTPin = PORTB.12  ' Connect to the ADS7846 DOUT pin
  Declare Touch_CLKPin = PORTB.11   ' Connect to the ADS7846 CLK pin
  Declare Touch_CSPin = PORTB.9     ' Connect to the ADS7846 CS pin

  Include "TouchScreen.inc" ' Load the touch screen routines into the program

'--------------------------------------------------------------------------
Main:
' Configure the internal oscillator to operate the device at 79.23MHz
'
  PLL_Setup(43, 2, 2, $0300)
  RPOR7 = 3                       ' Make Pin RP14 U1TX

  Do
     If Touch_Active = 1 Then      ' Has the LCD been touched?
       HRSOut "LCD is Touched\r"    ' Yes. So transmit a message serially
       DelayMs 200
     EndIf
  Loop
'--------------------------------------------------------------------------
' Configure for internal 7.37MHz oscillator with PLL
' OSC pins are general purpose I/O
'
  Config FBS = BWRP_WRPROTECT_OFF, BSS_NO_FLASH, BSS_NO_BOOT_CODE
  Config FSS = SWRP_WRPROTECT_OFF, SSS_NO_FLASH, RSS_NO_SEC_RAM
  Config FGS = GWRP_OFF, GCP_OFF
  Config FOSCSEL = FNOSC_FRCPLL, IESO_ON
  Config FOSC = POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSDCMD
  Config FWDT = WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF
  Config FPOR = FPWRT_PWR128, ALTI2C_OFF
  Config FICD = ICS_PGD1, JTAGEN_OFF
View original PDF page 290Open page in PDFOriginal PDF page 290

The touch screen commands used by the compiler are for use with an ADS7846 touch screen controller device. This device uses an SPI interface and connects to a 4-wire resistive touch screen membrane to give X and Y coordinates, as well as touch pressure.

The routines must be incorporated into the BASIC program by use of an include file named "TouchScreen.inc". This is written in Positron16 BASIC so that modifications or improvements are easy. It also exposes how the touch screen is interfaced with.

A suitable circuit for the ADS7846 touch screen controller is shown below:

Original diagram or table from Positron16, PDF page 291
Original figure / layout · PDF page 291
Text in this figure or table

RF filter +3v3

100nF10uF/6.3v
110
VCCVCC
10KΩ15
CSRB9
916
VrefSCKRB11

14

DINRB13
1112
PENIRQDOUTRB12

13 BUSY

4

X- From LCD YU

2

X+From LCD XR
73
VbatY+From LCD YD
85
AUXY-From LCD XL

GND 6 ADS7846

ADS7846 Touch controller circuit

See Also. Touch_Read, Touch_HotSpot

View original PDF page 291Open page in PDFOriginal PDF page 291