Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:21 11 Nov 2025 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 : Endless loop display TFT

Author Message
miyek.ard
Newbie

Joined: 31/03/2018
Location: Malaysia
Posts: 24
Posted: 09:46am 09 Apr 2018
Copy link to clipboard 
Print this post

I have a big problem (I guess) and I don't know to solve this.

I try to run some program using "XMODEM RECEIVE" command in Tera Term. However, the problem comes when I realize my program has endless loop! My TFT keep displaying page 1, 2, and 3 simultaneously nonstop.

How should I end the loop? This is my third set of MM+ LCD Backpack, I would cry if I have to purchase another set


OPTION AUTORUN ON

PWM 2, 1000,25 ' Set LCD Backlight brightness
CLS RGB(black)
font 4

const pg1 = 1, pg2 = 3, pg3 = 8

gui setup 1
gui CAPTION #1, "Please Enter Password", 30,90

gui setup 2
gui CAPTION #3, "Hydrogen Generator", 15, 13

gui setup 3
gui CAPTION #8, "Setting", 105,10

do
page 1
for i=0 to 10
next i
page 2
for h=0 to 10
next h
page 3
for j=0 to 10
next j
LOOP


Please help!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 10:05am 09 Apr 2018
Copy link to clipboard 
Print this post

From the Micromite Manual page 16 (don't worry, a lot of people miss it):
  Quote  In the first 100 ms after powering up the Micromite will set the console to 38400 baud and check to see if an exclamation mark is received. If so, it will then wait for two seconds to see if it is going to get more than 30 of them in that time. If this is the case the Micromite will reset itself to its initial defaults and send the message "MMBasic reset completed" to the console.
This reset can be accomplished by simply setting the terminal emulator to 38400 baud and holding down the exclamation key and rely on the automatic keyboard repeat while powering up the Micromite (on most keyboards this requires holding down shift and the number one key). This will even work if the console has been set to a non standard baud rate.

Geoff Graham - http://geoffg.net
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 11:29am 09 Apr 2018
Copy link to clipboard 
Print this post

Your "do loop" loops between the 3 pages with a small (very brief in mm time) counter loop between each screen.

So the program, as it is above, is supposed to loop quickly between pages 1,2 & 3 and then start again.

What is it you want it to do?

You should also use the option explicit off command and then declare your variables as integer or whatever you want them to be. Currently they are being auto defined as floats.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 12:05pm 09 Apr 2018
Copy link to clipboard 
Print this post

EDIT: To stop your code running when it has gone mad like this, use CTRL-C. IE: Hold down the CTRL key on your keyboard, and press 'C'. That should stop the code, and return you to the command prompt.

As Azure mentions, you have no delays in the FOR/NEXT loops, and they will complete very quickly(within a ms or two - if that, as they are not DOING anything), and so the pages will display one after another very quickly.

Try this:


OPTION AUTORUN ON

PWM 2, 1000,25 ' Set LCD Backlight brightness
CLS RGB(black)
font 4

const pg1 = 1, pg2 = 3, pg3 = 8

gui setup 1
gui CAPTION #1, "Please Enter Password", 30,90

gui setup 2
gui CAPTION #3, "Hydrogen Generator", 15, 13

gui setup 3
gui CAPTION #8, "Setting", 105,10

do
page 1
for i=0 to 10
PAUSE 500
next i
page 2
for h=0 to 10
PAUSE 500
next h
page 3
for j=0 to 10
PAUSE 500
next j
LOOP


The PAUSE 500 delays in the FOR/NEXT loops will cause the code to show page after page, but with a 5 second delay between showing the pages.(500mS x 10 = 5 seconds)

Azure also has a point in that you should start using OPTION EXPLICIT(and defining all your variables) if you have not done so already. It makes debugging later much easier.
Edited by Grogster 2018-04-10
Smoke makes things work. When the smoke gets out, it stops!
 
miyek.ard
Newbie

Joined: 31/03/2018
Location: Malaysia
Posts: 24
Posted: 01:13am 10 Apr 2018
Copy link to clipboard 
Print this post

  Quote  EDIT: To stop your code running when it has gone mad like this, use CTRL-C. IE: Hold down the CTRL key on your keyboard, and press 'C'. That should stop the code, and return you to the command prompt.

This really helps, thanks!

  Quote  Your "do loop" loops between the 3 pages with a small (very brief in mm time) counter loop between each screen.
So the program, as it is above, is supposed to loop quickly between pages 1,2 & 3 and then start again.

What is it you want it to do?


Actually I just want to test the display only as I am newbie to this MM+. I want to try 'GUI SETUP #' and 'PAGE #' command. But I forgot to consider about the delay and else.

  Quote  The PAUSE 500 delays in the FOR/NEXT loops will cause the code to show page after page, but with a 5 second delay between showing the pages.(500mS x 10 = 5 seconds)

Okay will try this later!

I'll update once I'm done. Thanks!!
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025