This is my on-going spa control project. I am trying to consolidate "0" and "2" in the Display Functions. The program defaults to "0" Display Function and pushing the UP/DN buttons switches to "2" Display Function and then back to "0" as soon as you let go. This works, the problem is it won't go to the next Display Function("1") Minutes and allow adjustment, no matter how many times I push the "Program" button and beg it to work. Can't figure out a fix. everything else is OK. Please show me the way.
Oh and the simulation doesn't quite work right but it works in the board.
Thanks,
Scott
Trouble with Switch Icon
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Trouble with Switch Icon
Hi Scott
This is cause of your issue: you are using all OR (||) functions.
So:
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:
If it was me I would also add and additional decision:
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
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
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
Code: Select all
(Up = 1) || (Down = 1) || (UP_b = 1) || (Down_b = 1) then Count_4 = 0
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
Martin
Re: Trouble with Switch Icon
Of course, you are right
Thank you very much. After applying your code and advice, which fixed everything, I decided to try and have a slow then fast number change on "display function 1". I only tried on the RED buttons and they now count by two but not appreciably faster than the BLUE buttons nor can I tell why they count by two and the numbers selected, RED and BLUE, don't store in eeprom anymore. Is it possible to do? Any pointers?
Also, I don't know how to write "THEN Count_4 = 0" so V6 likes it. I looked around for a list of common functions (or is it arguments) like and, nand, or, nor, etc., but I couldn't find one yet.
Thanks,
Scott

Also, I don't know how to write "THEN Count_4 = 0" so V6 likes it. I looked around for a list of common functions (or is it arguments) like and, nand, or, nor, etc., but I couldn't find one yet.
Thanks,
Scott
- Attachments
-
- Spa_C_1.fcfx
- (66.56 KiB) Downloaded 237 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Trouble with Switch Icon
Hi Scott,
Then is just the Yes branch which is the same as true.
so all you do is: Perhaps a better more efficient way would be:
Take a look here
Martin
I will take a look at your flowchart an see if I can spot the issue.ionize wrote:RED and BLUE, don't store in eeprom anymore. Is it possible to do? Any pointers?
I just tried writing in pseudocode, sorry if confusing.ionize wrote: don't know how to write "THEN Count_4 = 0
Then is just the Yes branch which is the same as true.
so all you do is: Perhaps a better more efficient way would be:
If it was me I would use a long/short press detection.ionize wrote:I decided to try and have a slow then fast number change on "display function 1".
Take a look here
Martin
Martin