40 #define CONFIG_LED1() CONFIG_RB14_AS_DIG_OUTPUT()
41 #define LED1 _LATB14 //led1 state
45 CONFIG_RB13_AS_DIG_INPUT();
50 #define SW1 _RB13 //switch state
51 #define SW1_PRESSED() (SW1==0) //switch test
52 #define SW1_RELEASED() (SW1==1) //switch test
57 STATE_WAIT_FOR_RELEASE
60 STATE e_lastState = STATE_RESET;
62 void printNewState (STATE e_currentState) {
63 if (e_lastState != e_currentState) {
64 switch (e_currentState) {
65 case STATE_WAIT_FOR_PRESS:
68 case STATE_WAIT_FOR_RELEASE:
76 e_lastState = e_currentState;
88 e_mystate = STATE_WAIT_FOR_PRESS;
91 printNewState(e_mystate);
93 case STATE_WAIT_FOR_PRESS:
94 if (SW1_PRESSED()) e_mystate = STATE_WAIT_FOR_RELEASE;
96 case STATE_WAIT_FOR_RELEASE:
99 e_mystate = STATE_WAIT_FOR_PRESS;
103 e_mystate = STATE_WAIT_FOR_PRESS;