Hi Scott
This is cause of your issue:
you are using all OR (||) functions.
So:
Code: Select all
If Up is 0 OR Down is 0 OR UP_b is 0 OR Down_b is 0 OR Count_4 > 30 then reset DisplayFunction to 0
Not sure that is what you want to do since as soon as this icon is reached,if no keys have been pressed then DisplayFunction to 0.
If you wanted a timeout of no keys being pressed after 30 seconds then you will need to change the above decision to:
Code: Select all
(Up = 0 || Down = 0 || UP_b = 0 || Down_b = 0) && Count_4 > 30
If it was me I would also add and additional decision:
Code: Select all
(Up = 1) || (Down = 1) || (UP_b = 1) || (Down_b = 1) then Count_4 = 0
What this would do is reset Count_4 to 0 each time a key is pressed.
This is because without the extra decision as soon as Count_4 = 31 then DisplayFunction will be reset to 0 even if you are still pressing the up/down keys.
So it changes to a time out of 31 seconds only from when no keys are detected.
Note: I enclose any multiple tests within in their own separate brackets.
This is because a long time ago I had a problem with a decision branching at the wrong time and the fix was to include brackets for every individual test e.g (Up = 1) || (Down = 1) || (UP_b = 1) etc.
That may not be the case now, but I still do that out of habit.
The other thing I have noticed is you are calling macro from within the interrupt.
That is bad practice and can cause all sorts of issues.
You must allow the interrupt to exit normally without any calls to macros.
Hope this helps?
Martin