Netcruzer Library API
V2.03
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Macros
Groups
Pages
nz_menuFsm.h
Go to the documentation of this file.
1
44
/*********************************************************************
45
* @section nz_menuFsm_lic Software License Agreement
46
*
47
* The software supplied herewith is owned by Modtronix Engineering, and is
48
* protected under applicable copyright laws. The software supplied herewith is
49
* intended and supplied to you, the Company customer, for use solely and
50
* exclusively on products manufactured by Modtronix Engineering. The code may
51
* be modified and can be used free of charge for commercial and non commercial
52
* applications. All rights are reserved. Any use in violation of the foregoing
53
* restrictions may subject the user to criminal sanctions under applicable laws,
54
* as well as to civil liability for the breach of the terms and conditions of this license.
55
*
56
* THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS,
57
* IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
58
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE
59
* COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
60
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
61
**********************************************************************
62
* File History
63
*
64
* 2005-10-06, David Hosken (DH):
65
* - Initial version
66
*********************************************************************/
67
68
#ifndef _fsmMenu_H_
69
#define _fsmMenu_H_
70
71
typedef
struct
_FSM
{
72
uint8_t stateTop;
//Current state
73
uint8_t stateSub1;
//State of sub1 Sub Menu, 0 means it is disabled
74
uint8_t action;
//Current action - is a SMT_ACTION_XXX define
75
}
FSM
;
76
77
#define FSM_ACTION_ENTRY 0 //Action to take when entering the state
78
#define FSM_ACTION_EXIT 1 //Action to take when existing the state
79
#define FSM_ACTION_INPUT 2 //Execute the action dependent on present state and input conditions. Will normally spend most time in this state!
80
#define FSM_ACTION_TRANS 3 //Execute the action when performing a certain transition
81
85
#define fsmSetAction2Entry(sm) {sm.action = FSM_ACTION_ENTRY;}
86
90
#define fsmSetAction2Exit(sm) {sm.action = FSM_ACTION_EXIT;}
91
95
#define fsmSetAction2Input(sm) {sm.action = FSM_ACTION_INPUT;}
96
100
#define fsmSetAction2Transition(sm) {sm.action = FSM_ACTION_TRANS;}
101
105
#define fsmSetState(sm, newState) {sm.stateTop=newState; sm.stateSub1=0; sm.action=FSM_ACTION_ENTRY;}
106
110
#define fsmIncState(sm, lastState) { (sm.stateTop==lastState) ? sm.stateTop=0 : sm.stateTop++; sm.stateSub1=0; sm.action=FSM_ACTION_ENTRY;}
111
115
#define fsmDecState(sm, lastState) { (sm.stateTop==0) ? sm.stateTop=lastState : sm.stateTop--; sm.stateSub1=0; sm.action=FSM_ACTION_ENTRY;}
116
120
#define fsmSetStateSub1(sm, newState) {sm.stateSub1=newState; sm.action=FSM_ACTION_ENTRY;}
121
125
#define fsmIncStateSub1(sm, lastState) { (sm.stateSub1==lastState) ? sm.stateSub1=1 : sm.stateSub1++; sm.action=FSM_ACTION_ENTRY;}
126
130
#define fsmDecStateSub1(sm, lastState) { (sm.stateSub1==1) ? sm.stateSub1=lastState : sm.stateSub1--; sm.action=FSM_ACTION_ENTRY;}
131
#endif
132
netcruzer
lib
nz_menuFsm.h
Generated on Tue Dec 9 2014 15:08:19 for Netcruzer Library API by
1.8.4