Announcement

Collapse
No announcement yet.

Using a Winbutton to exit loop - Arduino Mega 2560 + Gen4-uLCD-50DT-A

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a Winbutton to exit loop - Arduino Mega 2560 + Gen4-uLCD-50DT-A

    Hi everybody,

    I am using a Gen4-uLCD-50DT-A Display in combination with an Arduino Mega 2560. The Arduino processes the inputs from the display.

    I have several Winbuttons which send a signal when they are pressed. Different functions are performed when these buttons are pressed. One of these buttons is used as a program start button. When it is pressed the Arduino performs a for loop of 10000 steps for(i=0; i<10000; i++){...}

    I would like to use the same button to pause the program (pause the loop) when pressed and to continue it when pressed again. I have another button which I would like to use to stop the process and exit the loop completely. What is the best way to do this?

    I realized my Arduino is unable to process new events as long as it is processing the loop. I tried to call the genie.DoEvents() function in my loop but it didn't work. I also tried to create a new "genieFrame Event2" and then "genie.DequeueEvent(&Event2)" it to process it but it also didn't work. It seems like this implicit function calling does not work or may be I did a mistake?

    I thought about using a "Service Interrupt Routine" but these are "Hardware-Connected" as far as I know. Can I get the display to trigger such a routine in my Arduino code?

    I hope you can help me with this. Thank you very much in advance!


  • #2
    Hi,

    One of these buttons is used as a program start button. When it is pressed the Arduino performs a for loop of 10000 steps for(i=0; i<10000; i++){...}
    Avoid using any blocking loop like the for-loop function. When this for-loop executes, it blocks other commands to execute because you have to wait for it to finish looping before executing other commands in the program.

    Best to edit your program that doesn't use any blocking loop so it will not halt any operations in your program needed to execute.

    Best regards.

    Comment

    Working...
    X