Shop OBEX P1 Docs P2 Docs Learn Events
Pseudo interrupt type behaviour — Parallax Forums

Pseudo interrupt type behaviour

TazmanTazman Posts: 6
edited 2010-11-11 11:39 in BASIC Stamp
Hi all,

I am in the process of coding my sumo bot (with BS2 brain). My bot has edge detectors that sense the boundaries of the playing field. I would like to handle detection of field edges like interrupts while hunting for opponents in the field.
What design patterns can I use to simulate an interrupt being generated by the edge detector while searching and pushing out opponents?
Any and all pointers would be much appreciated.
Thankx.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-10 20:46
    There are no interrupts or anything like them in the BS2. To accomplish what you want, you need to poll your edge detectors in every place where you have some kind of loop and jump out of the loop to some other place in your program where you can handle the edge detection. How you do this and how you resume whatever activity was "interrupted" depends heavily on how you've written your program and what it does. It's really difficult to give any sort of meaningful advice without much more information.
  • TazmanTazman Posts: 6
    edited 2010-11-11 11:26
    Thanks for the response, Mike. I was looking for confirmation that polling was my only solution and there were no other tricks available.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-11 11:39
    There are some additional "tricks" available on the BS2p/pe/px Stamps. You still can't "interrupt", but simple polling can be done automatically by the Stamp's interpreter. Look at the description of the POLLxxxx statements in the Stamp Manual.
Sign In or Register to comment.