Difference between revisions of "Exercise - Using Component Macros"

From Flowcode Help
Jump to navigationJump to search
Line 31: Line 31:
 
:* Click on the 'Add to system panel' option to select it.
 
:* Click on the 'Add to system panel' option to select it.
 
:* Zoom in until the LCD image is big enough to read.(See [[System Panel]] for information on how to zoom.)
 
:* Zoom in until the LCD image is big enough to read.(See [[System Panel]] for information on how to zoom.)
 +
[[File:gen_exerciseUsingCompMacros_compmacprops_01.png|300px|right]]
 
* Click and drag an infinite loop between the 'BEGIN' and 'END' icons.
 
* Click and drag an infinite loop between the 'BEGIN' and 'END' icons.
 
* Inside the loop:
 
* Inside the loop:
[[File:gen_exerciseUsingCompMacros_compmacprops_01.png|300px|right]]
+
 
 
:* Click and drag a 'Component macro' icon.[[File:Btn_Component_Macro.gif|30px]]
 
:* Click and drag a 'Component macro' icon.[[File:Btn_Component_Macro.gif|30px]]
  
Line 39: Line 40:
 
::: The program 'knows' which components you have added to the System or Dashboard panel, and modifies the list of available commands accordingly.
 
::: The program 'knows' which components you have added to the System or Dashboard panel, and modifies the list of available commands accordingly.
 
::: Under 'Components', the LCD will be listed, and underneath it the list of commands.
 
::: Under 'Components', the LCD will be listed, and underneath it the list of commands.
 +
::* Scroll down to the bottom of the list and click on the 'Start' command.
 +
::* Rename the 'Display name' as "Start the LCD".
 +
::* Click on 'OK'.
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
[[File:gen_exerciseUsingCompMacros_compmacprops2_01.png|300px|right]]
 +
:* Click and drag a second 'Component macro' icon just below the first.
 +
::* Double click on it to open the dialogue box.
 +
::* Scroll down to the 'PrintString' command and click on it.
 +
::* Rename the 'Display name' as "Elapsed time".
 +
::* In the 'Expression' box, type "Elapsed time" (making sure you include the quotation marks "".)
 +
::* Click on 'OK'.

Revision as of 16:17, 20 June 2013

Component macros are sections of code that have been written to support the components included with Flowcode 6.
They take all the effort out of using these components.
This exercise uses them to control a particularly complicated, but very common device, the Liquid Crystal Display (LCD).
In this case, it uses a LCD to display elapsed time.


The core sequence

The flowchart sequence for the elapsed time will be:

Check if the switch is pressed.
If it isn't, go back to the beginning.
If it is:
initialize the LCD;
display the text "Elapsed time";
initialize the time;
display the time
wait for one second;
increment the time;
display the new time;
loop back and repeat this process.


Set up the flowchart


Create the core sequence

  • Locate the 'LCD' inside the 'Outputs' toolbox in the Icons toolbar.
  • Hover over the image to the left of the 'LCD' label, and click on the down-arrow that appears.
  • Click on the 'Add to system panel' option to select it.
  • Zoom in until the LCD image is big enough to read.(See System Panel for information on how to zoom.)
  • Click and drag an infinite loop between the 'BEGIN' and 'END' icons.
  • Inside the loop:
  • Click and drag a 'Component macro' icon.Btn Component Macro.gif
  • Double click on it to open the dialogue box, so that you can configure it.
The program 'knows' which components you have added to the System or Dashboard panel, and modifies the list of available commands accordingly.
Under 'Components', the LCD will be listed, and underneath it the list of commands.
  • Scroll down to the bottom of the list and click on the 'Start' command.
  • Rename the 'Display name' as "Start the LCD".
  • Click on 'OK'.





  • Click and drag a second 'Component macro' icon just below the first.
  • Double click on it to open the dialogue box.
  • Scroll down to the 'PrintString' command and click on it.
  • Rename the 'Display name' as "Elapsed time".
  • In the 'Expression' box, type "Elapsed time" (making sure you include the quotation marks "".)
  • Click on 'OK'.