Trapping a flag/state change (rapidly)


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default Trapping a flag/state change (rapidly)

    So, I'm learning about HPWM...and for this project just using a few LEDs to set some simple patterns running.

    I'm using DT's interrupts to trap a button being pressed, in the interrupt routine I increment a 'pattern' variable for each button press. This bit all works fine, so no problems there.

    So the interrupt returns to the main program loop ....but the variable (flag) change is not trapped until the program gets to the point where it tests the variable. Once it tests the variable, it jumps to a new loop (to change the LEDS sequence).

    Ok, here's the problem....

    For the sake of example, lets say Pattern 1 is a chaser (leds lighting up/extinguishing in sequence) & pattern is all LEDS on. What's happening here is that Pattern1 is running (leds sequencing),then the button gets pressed....but after the button is realeased it takes a finite time for the variable change to be picked up upon (trapped) in the main loop ...so the LEDs still continue to 'sequence' until the pattern change is trapped in the main loop - it then jumps to the new Pattern routine (all LEDS on) just fine. It's this lag between the button being pressed & the main loop picking up on it, that's causing me troubles...it's not a huge lag, but it is discernible & I'm sure there a slicker way

    I'm conscious that I'm still very much in the n00b camp & there must be a better way of having a program act in a zippy way to variable/flag changes.
    Last edited by HankMcSpank; - 29th April 2011 at 09:54.

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