12Blocks
Welcome | Contents | Getting Started | Reference | Hardware | FAQ | Buy
Blog | Forum
Overview | Editor Interface | Editor Dialogs | Advanced | Language | Blocks

Library Customization

Library Customization

12Blocks is very flexible and can support different devices through customization of subdirectories of "Program Files/12Blocks/Hardware".

Example:
Here is the "DemoBoard" directory, it contains the "device.xml" file which uses the xml format to specify parameters for this device:
graphic
To customize support for other hardware you'll most likely copy an existing "12Blocks/Hardware" subdirectory and make changes to the device.xml file.  12Blocks includes the name of subdirectories which include a "device.xml" file in the library chooser. 

The first part of the device.xml file defines variables such as:
description, website: information about the hardware
export: 12Blocks will save code using this name and extension- "$fullfile.spin" will use the $fullfile variable which includes the target directory- and append the ".spin" extension.
encoding: Character encoding of the file- "unicode", or "us-ascii".
include: Names of hardware directories to include for linking referenced objects
connect:Baud rate of connection- either 2000000,1000000,115200, or 38400 for text
device:Name of device- defaults to Propeller- can also be bs2

You can also define custom variables for use with the template engine.  For example, defining "$motor_req" to value "_ggmtr" will replace later instances of "$motor_req" with "_ggmtr".

The second part lets customize the library. 
You can remove parts of the library by:
"path"- all blocks whose section starts with the path are removed
"class"- all blocks whose class starts with the value are removed
"id"- block with that exact id are removed

You can add blocks to the library using xml:
<node help="" tab="sensor" color="red" name="read line sensor($,$)" code="_tirmtr.getline($,$)" req="_tirmtr" result="+">
                <param name="button" value="left" type="tline" c2="line sensor to read"/>
               <param name="sensordata" value="value" type="tsensordata"/>
</node>

The above block referenced an object with the code value- define objects like this:
<req category="TBot Motor and IR" file="t_ir_motor" main="_tirmtr.start" name="_tirmtr" />

The above block reference a type called tsensordata- which we define like this:
<enum name="tsensordata" values="0,1,2,3,4,5" names="minimum,maximum,p0,p1,rate,value"/>


  

Advanced Editing

Infinite Undo/Redo: 12Blocks lets you undo each change you've made since opening a file.

Selection:
·     Cut, Copy, Delete: These actions work on selected block.  Copied/Cut blocks are available for pasting in 12Blocks as blocks and in text editors as text.
·     Paste: Pastes content from clipboard as a blocks. 
·     Select a Single Block: Left click on the desired block
·     Multiple Select: Left click on blocks while holding down the Ctrl key.  Ctrl-clicking a selected block de-selects it.
·     Lasso: Start a left-drag on the worksheet and lasso blocks to select them.
graphic
            Selecting with lasso

Dragging:
·     Left drag to move stack: left drag a block to move the block and any blocks attached to it
·     Right drag to clone a block: right drag a block to drag a clone of that block
·     Left ctrl+drag to move selected blocks: left drag while holding the ctrl key to drag all selected blocks.
·     Right ctrl+drag to clone stack: right drag while holding the ctrl key to drag a clone of the block and any blocks attached to it.

graphic
            Cloning with right drag
  

Folder Structure

The 12Blocks installer checks for a valid .net Framework installation, presents the license agreement and installs files as follows:

Program Files/12Blocks
            12Blocks.exe
                        core application 
            unins000.dat/unins00.exe
                        uninstall files
            *.dll, *.xml, *.exe
                        core library files
            excel client.xls
                        Sample excel worksheet which interfaces with 12Blocks
            /Help
                        Help documents viewable in your browser
            /Plugins
                        Additional plugins
            /CustomGui
                        Visual Studio solution files to create custom user interface blocks
            /Hardware
Each subdirectory contains files that define a library for a specific platform.  See Device Manager                        
            /View
                        Images used by some interface blocks
My Documents/12Blocks/Tutorials/*.12B, progress.xml
Files used by to provide the "Guided Tutorials" feature.  Copied here from "Program Files/Blocks/Docs" when program is first run
My Documents/12Blocks/Samples/*.12B
            Example files.   Copied here from "Program Files/Blocks/Docs" when program is first run