|
Forum Index : Microcontroller and PC projects : What happens in "Pause"
| Author | Message | ||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Hi - Fairly new to MM so forgive what may seem a naive question. In VB, there is a command DOEVENTS which will process other things while waiting for something (like a display update) to happen. In MMBasic, if I use the PAUSE command, does processing just stop (apart from hardware interrupts) or can other things occur? The question arises because I am writing a controller interface that shows circulation of water as an 'ant trail' using a custom font and pausing 200mS between rewriting the string to give the 'movement'. Am I just blocking the system from doing anything else while this is displaying, or what? If so, I'm sure there's an obvious workaround, but I haven't yet discovered what it is! |
||||
MicroBlocks![]() Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Easiest is to 'simulate' a pause. You can do that by using a state machine and check the timer value. Microblocks. Build with logic. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
During pause MMbasic will process Ctrl-C, buffer UART I/O, Process GUI events, keep the clock running, process FIN, CIN, COUNT, check for pin interrupts, keep PWM running - basically everything except process inline Basic statements |
||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Thanks for the information above. I was hoping that there would be a way of accessing something like a timer interrupt, such as is available in the basic chip architecture, but it seems there isn't. |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hi Phil, I don't understand why are you not using a SUB as Microblocks suggests? Print Timer my_pause(500) Print Timer end Sub my_pause(duration As integer) Local t=Timer+duration Do While Timer<t Loop End Sub Regards Michael causality ≠ correlation ≠ coincidence |
||||
| disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 1044 |
Have a look here to see settick used to simulate a background process. pipeflow Regards Gerry F4 H7FotSF4xGT |
||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
You can also very easily create a pause that doesn't pause. do ' do something here PauseEnd=timer+interval BeginPausedStuff EndPausedStuff 'do something else here loop Sub BeginPausedStuff ' start the paused routine EndSub 'BeginPausedStuff Sub EndPausedStuff if timer>PauseEnd then ' wrap up the paused routine endif EndSub 'EndPausedStuff The loop will continue cycling doing other things until the timer exceeds PauseEnd at which time the pause termination code will run. Paul in NY |
||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Again, my thanks for the prompt responses, which I shall now study! The link that Gerry provided looks particularly interesting, but is going to take a little while to work through! |
||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
As I said at the very beginning, MMbasic is fairly new ground for me, and I had not appreciated the availability of SETTICK, which would seem to be the ideal solution to my problem! MMbasic is fairly unusual in 'free' software in that the documentation is very comprehensive, which is an excellent feature. However, it also means there is a lot to remember when you get stuck into it for the first time! |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
I wrote some timer handling routines that work with a state machine (they set flags when events occur) so you can pick them up nicely from a main loop - it also provides 10 timer events (instead of four and is easily expandable if you need more) and has both one-shot and continuous timers. You can stop a timer and disable then all temporarily and then re-enable them. http://fruitoftheshed.com/MMBasic.Edit.aspx?Page=MMBasic.AFTER-EVERY-REMAIN-Flexible-State-Machine-Timers-using-Semaphor es Just about every project, I use SM methodology because it just makes the code so easy to write and debug. I use an array of flags (upto 64 of them) in most of my code - the main loop then only has to check for a flag being set to trigger some activity. It really easily de-couples the various tasks within your code from the main thread, so you end up with code flow like Main: Do If FlagTest(myflag) Then DoMySub ... Loop |
||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Following the help received previously, I have now achieved the desired result in my water circulation modelling! I adapted Capt Boing's timer routines but used a different strategy from that shown in the example given by Gerry (above). This shows a (rather poor) image from the panel: ![]() or you can see the animation itself on this link: Animation In an effort to reduce processor time and storage, I elected to create a new font, using FontTweak. Each symbol has up to three variants showing the chevrons in different positions. The program then 'prints' the characters to the screen every 200mS resulting in the display shown. I haven't yet analysed the actual processor load, but my impression is that it is light. The font and the timer routines take up just 8% of the Library space which should leave me plenty for the remainder of the program! |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
the animation link doesn't work for me. repost? |
||||
pcaffalldavis![]() Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
Very interesting and nice work. I'd like to see more. The animation link does not go to the animation, but to an upload channel. We're all here 'cause we're not all there. |
||||
| PhilTilson Newbie Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Sorry about the link - try this one! |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
Neat animation. Geoff Graham - http://geoffg.net |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
nice work! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |