What's the best code loop-structure to handle multiple tasks without interruption?


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: What's the best code loop-structure to handle multiple tasks without interruption

    There are a bunch of PBP commands which cause delay which you can’t use, Pause being a good example,
    or at least not with a high value behind it
    and some commands that need to be used a particular way which is always contrary to the manual,
    in a manner that only deals with bytes at a time. Any serial command is a good example of that.

    For the LED display I don’t think any of these enter into it.
    Assuming just a loop, your program would be something like:

    Code:
    Set up an initial graphic frame
    cycle:
    Draw the frame to the LED display
    Delay to display the frame to the User
    Read input from buttons/interface
    Process the next frame based on input and/or the program
    goto cycle
    As the program progresses it may be the last step increases time to execute,
    and the deliberate delay can be shortened or eliminated.
    For an LED display it may or may not be helpful to use a timer for the framerate,
    but that doesn’t really relate to your question.
    Last edited by Art; - 13th July 2016 at 16:24.

  2. #2
    Join Date
    Jun 2016
    Location
    Melbourne, Australia
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: What's the best code loop-structure to handle multiple tasks without interruption

    Thanx so much for everyones input, something for me to consider and learn mroe about, i'd never even heard of co-opeartive multitasking, let along how to implement it in a pic/picaxe lol. (more reading for me).

    Overall, to simplify my initial question/example, I wanted to know what preferred methods programmers use when it comes to nesting loops and how to interlace them in order of importance, like loop 1 (main) is the housekeeping loop, loop2 is the led matrix data, loop 3 and 4 read posts & switches, then a preferred structure of how loop1,2,3&4 would nest together for fastest (least interruptions) code operation.

    I'm feeling Co-op multitasking is perhaps the best solution to consider? unless there's a general rule of thumb about nesting loops nicely to share time with eachother?

    Thanx again,
    Marty.

Similar Threads

  1. Replies: 27
    Last Post: - 9th April 2015, 04:51
  2. Hot to handle multiple interrupt sources?
    By elcrcp in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 22nd April 2013, 20:35
  3. Writing code for a feedback loop
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st December 2012, 16:38
  4. Interruption
    By ciroman in forum General
    Replies: 14
    Last Post: - 5th January 2010, 06:10
  5. Code entering endless loop
    By Blackhawk in forum mel PIC BASIC
    Replies: 11
    Last Post: - 26th November 2006, 09:12

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts