Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 17:13 20 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MM Backpack Help Touch calibration not sticking

Author Message
snarf
Newbie

Joined: 16/03/2020
Location: Australia
Posts: 4
Posted: 06:04am 28 Mar 2020
Copy link to clipboard 
Print this post



I am trying for the first time to use the MM backpack V2 (28 pin), and have produced some code to set up buttons successfully. I am trying to configure the touch command for them and get


> run
[98] If Touch(X) <> -1 And Touch(Y) > 198 Then GoSub KEYPRESS
Error: Touch not calibrated


I then successfully run GUI calibrate, but then get the same result when I run the program again from the MM Chat window.

I have loaded and successfully run 2 demo programs that draw touch buttons on then screen.  The touch function works perfectly well on both of them.

Here is the bit of code that I have written.

Hope someone can give me some help why the calibration is not being saved in the MM.

'Rod's Smoker Damper Controller v1
 
 ProbeTemp = 150
 SetTemp = 100
 CountdownTimer = 9  
 CountdownTimerBackgroundColour = RGB(Black)
 
 OPTION LCDPANEL ILI9341, L, 2, 23, 6
 option touch 7, 15      
 
 timer = 200000 ' remove when not needed
 
 
 
 'add background colour for full screen and remove box from welcome
 
 
 'welcome
 text 160, 40, "Welcome David", CM, 1, 3, RGB(White), RGB(blue)
 text 160,120, "You're", CM, 1, 3, RGB(White), RGB(blue)
 text 160, 160, "Smokin..", CM, 1, 4, RGB(White), RGB(blue)
 
 '  pause 5000
 
 cls
 'draw boxes
 rbox 5, 5, 200, 60, 10, rgb(blue), RGB(yellow)  'oven temp box
 rbox 212, 5, 101, 60, 10, rgb(blue), RGB(yellow)  'settemp   box
 rbox 5, 67, 310, 18, 10, rgb(blue), RGB(yellow) 'comment box
 box 5, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'set temp up box
 box 45, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'set temp down box
 box 85, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'countdown timer up box
 box 125, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'countdown timer down box
 box 165, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'start box
 box 205, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'pause box
 box 245, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'end box
 box 285, 198, 36, 40, 1, rgb(blue), RGB(yellow) 'cancel alarm box
 rbox 212, 87, 101, 18, 1,rgb(blue), RGB(Yellow) 'countdown timer box
 
 'add text to boxes
 text 20, 10, "Oven", L, 1, 2, RGB(WHITE), RGB(yellow)
 text 20, 35, "Temp", L, 1, 2, RGB(WHITE), RGB(yellow)
 
 TExT 100,10, str$(ProbeTemp), L, 1, 4, RGB(BLACK), RGB(green) ' displays oven temp
 
 
 text 220, 20, "Set", L, 1, 1, RGB(WHITE), RGB(yellow)
 text 220, 35, "Temp", L, 1, 1, RGB(WHITE), RGB(yellow)
 
 TExT 260,20, str$(SetTemp), L, 1, 2, RGB(BLACK), RGB(green)     ' displays set temp
 
 TEXT 20,70, "Enter Set Temp & Countdown Timer", L, 1, 1, RGb(Black), RGB(Yellow) 'message line
 
 TEXT 10, 200, "Set", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 8, 212, "Temp", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 6, 224, " Up", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 49, 200, "Set", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 47, 212, "Temp", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 47, 224, "Down", L, 1, 1, RGB(Black), RGB(Yellow)               'to do  interupts & touch buttons
 
 TEXT 87, 207, "Time", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 87, 219, " Up", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 127, 207, "Time", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 127, 219, "Down", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 167, 212, " Go", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 207, 212, "Paus", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 250, 212, "End", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 286, 207, "Stop", L, 1, 1, RGB(Black), RGB(Yellow)
 TEXT 286, 219, "Alrm", L, 1, 1, RGB(Black), RGB(Yellow)
 
 TEXT 214,88, "End", L, 1, 1, RGb(Black), RGB(Yellow)
 TEXT 285,88, "Hrs", L, 1, 1, RGb(Black), RGB(Yellow)
 
 
 CountdownTime = CountDownTimer - (timer/120000)    ' converts millisecs to hours
 
 'If no countdowntimer set then countdown is blanked, or countdowntime is calculated if countdowntimer is set to > 0
 
 
 if  CountdownTimer = 0 then
   rbox 212, 87, 101, 18, 1, rgb(black), CountdownTimerBackgroundColour  'countdown timer box  set to black
 end if
 
 if CountdownTimer > 0 then
   text 250, 88, STR$(CountdownTime, 1, 1 ), L, 1, 1, RGB(Black), RGB(Green)   'poke countdown timer value   into box
 endif
 
 
 'setting up touch buttons
 
 
 if touch(X) <> -1 and TOUCH(Y) > 198 then gosub KEYPRESS
 
 sub keypress
    IF 41 > TOUCH(X) > 5 then SetTemp = SetTemp + 1
    if 45 > touch(X) >81 then SetTemp = SettTmp - 1
    if 85 > Touch(x) >121 then CountdownTimer = CountdownTimer + 1
    IF 125 > touch(x) > 161 then CountdownTimer = CountdownTimer - 1
    IF 165 > Touch(x) > 201 then print 100
    if 205> touch(x) > 241 then print 100
    if 245 > touch(x) >281 then  print 100
    if 285 > touch(x) >212 then  rint 100
 end sub
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 07:02am 28 Mar 2020
Copy link to clipboard 
Print this post

You appear to have

OPTION LCDPANEL ILI9341, L, 2, 23, 6
option touch 7, 15      

in your code.


This should only be done from the command prompt once.

It is because  you run the commands in your program that all calibration is lost.
VK7JH
MMedit   MMBasic Help
 
snarf
Newbie

Joined: 16/03/2020
Location: Australia
Posts: 4
Posted: 07:33am 28 Mar 2020
Copy link to clipboard 
Print this post

Thanks TassyJim,

I have done what you said and don't have the error now. Still no change to LCD display on touching but I will look  at that now.

Again thanks for your advice.

regards snarf
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024