A slider has several segments and the CapSense is interpolating the touch to give a result that is of finer grade than just the number of segments.
Buttons are different and are single points of sensing a finger press, so do not mix them.
Your problem seems to be soved easily with a technique named "State machine".
Make a table for each state (give it a number, better a name) and write down what elements are on or off and what event causes a transfer to what state.
This can be programmed easily to fulfill all your requirements using a C-switch statement, preferrably using named states (enum is good for that), so that you can see what your state machine performs.
I ment that I have 4 segments available. For the simplicity I mentioned it as buttons.
I have designed my board with a bit bigger size thean the standard board. I'm using the slider centroid algorithm for it.
Can you suggest me notes on 'state machines', C-switch statement & enum.
The problem I have is I'm trying to implement 5 states while the controling switches I have is 4. I have implemented the slider with 4 states & 1 contolling button for ON-OFF. Now I wish to reduce that button from combo of 1BTN+4SLDRsegments, but without loosing the ON-OFF control.
Thanks & Regards-
You should google for the items you don't know or ask Mrs. Wiki Pedia for explanations.
The exact syntax you will find in a C-Book like this: publications.gbdirect.co.uk/c_book/ which you may read online.
Hi Dana, Bob & all, check this out & tell me how to implement & run the state diagram in PSoC for the conditions I have mentioned.
Find the details in the attachment.
Thanks & Regards-
upload_Presentation1_cyp.pptx 119.5 K
Thanks Dana the application notes were of real help understanding the state m/c part.
Easiest would be now to create a table from your state diagram.
Here is an example
| State Name | Actions to take | Events and State Transfers | Comment
| StInit | All LEDs Off | SW1: StBootLoad | Initialization
| | PWR LED On | Nothing: StWaitProxi |
|StWaitProxi | | Proxi: StSeeProxi | Wait for proximity switch
|StSeeProxi | LED1 On | Button1: StBtn1 | Handle button presses
| | | Button2: StBtn2 |
| StBtn2 | ..... And so on.
When the table is complete, you declare an enum with all the state names.
Then with a switch statement you write for all the cases (States names) what to do and where to go to when which event occurs like
if(Button1) NextState = StBtn1;
all this goes into a single function or into main() from which you break out only in case of an error.