The visualSTATE project models a very simple application using the joystick and the LEDs on the AT91SAM7X-EK board. Let's take a look at the principal StateChart of the design. Start the visualSTATE Navigator, Choose File->Open WorkSpace, browse the the ./vs subdirectory of the example project and select demo_at91sam7x (a .vnw file). Then select Project->Designer (or F7) to open the visualSTATE Designer. In the Project Browser pane of Designer, double click the TopState called LedControl. A window opens with the LedControl_System (System View). Double click the LedControl topstate symbol in the System View to open another window with LedControl_System.LedControl (StateChart Diagram). It will look like this:
The application reacts to the following six events:
eKey_Left, eKey_Right, eKey_Up, eKey_Down, eKey_Push:eTimerTick:The outputs or actions of the system are very simple too: there are four action functions aLED1(parameter) through aLED4(parameter) that can switch the state of the individual associated LEDs on the board. Another action function is aLEDx(parameter) which switches all LEDs simultanuously. The pararameter of these functions is a Boolean declared in visualSTATE and can have value cON or cOFF.
The application has three 'modes' as modelled with the three states Idle, Manual and Auto. The initial default state is Idle. Upon Entry the Idle state switches off all LEDs. Pulling the joystick 'Up' will cause a transition to the state of Manual mode. One LED will light up. The very first time this will be LED3. Using the 'Left' and 'Right' joystick actions the other LEDs can be selected. The Left/Right action does not wrap around.
Using 'Up' again, the Auto mode is entered. Here, all LEDs will light sequentially from left to right (and wrapping around) as paced by the TimerTick event. When using 'Down' again, the Manual mode reappears, lighting the LED that was lit latest during the previous Manual mode. With 'down' again, the Idle mode is agian reached where all LEDs are off. You can 'push' the joystick once in Idle mode to switch on all LEDs. This cannot be reverted but you can do 'Up' again to reach manual mode where single latest Manual mode LED will again light.
In the next step, we will download the precompiled version of the project to the target, where you can verify actual operation. For now please close the visualSTATE Designer, but keep the visualSTATE Navigator open.