Shop OBEX P1 Docs P2 Docs Learn Events
Issue with 2 touch area of UOLED 4D system — Parallax Forums

Issue with 2 touch area of UOLED 4D system

JChrisJChris Posts: 58
edited 2014-12-20 14:17 in Propeller 1
I use UOLED 4D system that is the 32PTU.

I am trying to create a menu. When I create only one touch area, it works but when I create two touch areas, it doesn't work.
The program runs but there are two touch areas that don't work fine

If anyone has a hint, I would appreciate

My program is the following:

[Code]
{
************************************************************************************************************
* *
* AUTO-RECOVER NOTICE: This file was automatically recovered from an earlier Propeller Tool session. *
* *
* ORIGINAL FOLDER: D:\parallax\ *
* TIME AUTO-SAVED: over 1 day ago (14/08/2014 00:21:48) *
* *
* OPTIONS: 1) RESTORE THIS FILE by deleting these comments and selecting File -> Save. *
* The existing file in the original folder will be replaced by this one. *
* *
* -- OR -- *
* *
* 2) IGNORE THIS FILE by closing it without saving. *
* This file will be discarded and the original will be left intact. *
* *
************************************************************************************************************
.}
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5000000

rxpin = 3
txpin = 4
reset = 5

OLEDBaud = 115200



obj
LED : "uLCD(SK)-32PTU_v2.0"

var 'Used ONLY for DEMO
long Random,X[4],Y[4],Angle[4],OldX[4],OldY[4],C[8], stack1[50], stack2[50],Touch1, OldTouc1,TouchCount1,Flag1,i
word X1,X2,X3,Y1,Y2,Y3


PUB main

LED.start(rxpin, txpin, reset, OLEDBaud) ''Starts uOLED display

LED.touch_Set(0)

RentrerEnContact


PUB RentrerEnContact

LED.touch_DetectRegion(8,18,160,94)
LED.gfx_Rectangle(8,18,160,53,LED.RGB(255,255,0))
LED.gfx_Button(1,10,20,LED.RGB(128,128,128),LED.RGB(255,255,255),2,1,2,string("Rentrer en contact"))

' LED.touch_DetectRegion(8,58,151,94)
' LED.gfx_Rectangle(8,58,151,94,LED.RGB(255,255,0))
' LED.gfx_Button(1,10,60,LED.RGB(128,128,128),LED.RGB(255,255,255),2,1,2,string("Trouver personne"))

LED.txt_BGColor(LED.RGB(0,0,0)) ''Set FG/BG color text for PRESSED RELEASED
' txt_FGColor(color)
LED.txt_FGColor(LED.RGB(64,255,64))


i := 0

repeat

Touch1 := LED.touch_Get(0) ''<-Touch Detect 0-Screen STATUS
X1 := LED.touch_Get(1) ''<-Touch Detect 1-X coordinate
Y1 := LED.touch_Get(2) ''<-Touch Detect 2-Y coordinate

if (Touch1 == 1)
if ((X1>=8 AND X1<= 160) AND (Y1>=18 AND Y1<=53 ))
if Touch1 <> OldTouc1
LED.ClearScreen
Case Touch1
0 : LED.txt_MoveCursor(11,1)
'LED._putStr(string("NO TOUCH",10)) '' Not used in DEMO
1 : LED.txt_MoveCursor(11,1)
coucou
'telephone

2 : LED.txt_MoveCursor(11,1) '' to trap ONLY the window of interest
if Flag1 == 1
Flag1 := 0
LED._putStr(string("RELEASED",10))
TouchCount1 := 50 '' Set Extinguish after release timeout
' 3 : LED.txt_MoveCursor(11,1)
' LED._putStr(string("MOVING ",10)) '' Not used in DEMO
' OldTouch1 := Touch1

if TouchCount1>0 '' Extinguish after release
TouchCount1--
if TouchCount1 == 0
LED.txt_MoveCursor(11,1)
LED._putStr(string(" ",10))


PUB coucou | Touch2, OldTouch2, Flag2, TouchCount2

LED._putStr(string("Dis bijour a rorodolf",10))
' LED.touch_Set(0)
LED.touch_DetectRegion(8,18,160,53)
LED.gfx_Rectangle(8,18,160,53,LED.RGB(255,255,0))
LED.gfx_Button(1,10,20,LED.RGB(128,128,128),LED.RGB(255,255,255),2,1,2,string("coucou"))


repeat

Touch1 := LED.touch_Get(0) ''<-Touch Detect 0-Screen STATUS
X1 := LED.touch_Get(1) ''<-Touch Detect 1-X coordinate
Y1 := LED.touch_Get(2) ''<-Touch Detect 2-Y coordinate

if (Touch1 == 1)
if ((X1>=8 AND X1<= 160) AND (Y1>=18 AND Y1<=53 ))
if Touch1 <> OldTouc1
LED.ClearScreen
Case Touch1
0 : LED.txt_MoveCursor(11,1)
'LED._putStr(string("NO TOUCH",10)) '' Not used in DEMO
1 : LED.txt_MoveCursor(11,1)
LED._putStr(string("Pressed",10))
bonjour

2 : LED.txt_MoveCursor(11,1) '' to trap ONLY the window of interest
if Flag1 == 1
Flag1 := 0
LED._putStr(string("RELEASED",10))
TouchCount1 := 50 '' Set Extinguish after release timeout
' 3 : LED.txt_MoveCursor(11,1)
' LED._putStr(string("MOVING ",10)) '' Not used in DEMO
' OldTouch1 := Touch1

if TouchCount1>0 '' Extinguish after release
TouchCount1--
if TouchCount1 == 0
LED.txt_MoveCursor(11,1)
LED._putStr(string(" ",10))


PUB bonjour | Touch3, OldTouch3, Flag3, TouchCount3, Touch2, OldTouch2, Flag2, TouchCount2

LED._putStr(string("Dis bonjour a bibi",10))
' LED.touch_Set(2)
LED.touch_DetectRegion(8,18,160,53)
LED.gfx_Rectangle(8,18,160,53,LED.RGB(255,255,0))
LED.gfx_Button(1,10,20,LED.RGB(128,128,128),LED.RGB(255,255,255),2,1,2,string("au revoir"))

LED.touch_DetectRegion(8,58,151,94)
LED.gfx_Rectangle(8,58,151,94,LED.RGB(255,255,0))
LED.gfx_Button(1,10,60,LED.RGB(128,128,128),LED.RGB(255,255,255),2,1,2,string("boujour"))

repeat
Touch3 := LED.touch_Get(0) ''<-Touch Detect 0-Screen STATUS
X3 := LED.touch_Get(1) ''<-Touch Detect 1-X coordinate
Y3 := LED.touch_Get(2) ''<-Touch Detect 2-Y coordinate

Touch2 := LED.touch_Get(0) ''<-Touch Detect 0-Screen STATUS
X2 := LED.touch_Get(1) ''<-Touch Detect 1-X coordinate
Y2 := LED.touch_Get(2)


if (Touch3 == 1)
if ((X3>=8 AND X3<= 151) AND (Y3>=53 AND Y3<=94 ))
if Touch3 <> OldTouch3
Case Touch3
0 : LED.txt_MoveCursor(11,1)
LED._putStr(string("pas touch

Comments

  • OldFartRadiomanOldFartRadioman Posts: 30
    edited 2014-12-18 09:02
    Little bit of a mystery here, I seem to be having trouble finding uLCD(SK)-32PTU_v2.0.
  • JChrisJChris Posts: 58
    edited 2014-12-18 14:36
    It used to be there
    http://obex.parallax.com/object/722

    Apparently it has been removed by Parallax for an unknown reason...

    Might still be somewhere on the forum.

    Here is the library (uLCD(SK)-32PTU_v2.0) that I managed to download when it was still available on the parallax site.

    uLCD(SK)-32PTU_v2.0.spin
  • kuronekokuroneko Posts: 3,623
    edited 2014-12-18 22:56
    JChris wrote: »
    If anyone has a hint, I would appreciate
    Not sure if (or how) related or not but you should review your program structure first. You're basically calling one method from within another. Method calls expect to return to the calling point so if you don't (circular calls) you'll eventually run out of stack.
  • avsa242avsa242 Posts: 452
    edited 2014-12-20 14:17
    Just a cursory look, I'm wondering if the use of the assignment form of "Is Greater-than (>=)/Is Less-than (<=)" operators was really intended, or if "Is Greater-than or equal to (=>)/Is Less-than or equal to (=<)" was what was really meant in the sections that check for a range in X and Y.

    Also, the last instance,
          if ((X2>=8 AND X2<= 160) AND (Y2>=18 AND Y2<53 ))
    
    is missing an equals sign = from the "Y2<53"
Sign In or Register to comment.