1. Home
  2. Docs
  3. Code Overview
  4. Command Snippets

Command Snippets

Command Snippets is a CLI feature that empowers you to build small applications without writing or compiling any code. Simply get your USB-UART cable and open a terminal window wherever you are. Command Snippets are groups of CLI commands that can be executed based on a conditional event. Snippets are running continuously and simultaneously in the module backend at a rate governed by the FreeRTOS scheduler-about 1 kHz (think about ladder programming for industrial controllers). Snippets are stored in the emulated EEPROM, so they get executed even after a power cycle. Currently, you can store up to 5 command snippets, however, you can add or delete snippets at any time, and they will be executed sequentially. You can also pause and resume snippet execution at any time. Paused snippets are not executed on each cycle, but they hold their place in the snippets buffer.

The general format for a command snippet is (each line separated by ENTER key):

if snippet condition
command 1
command 2
end if

The command snip displays a list of available snippets along with their execution status. Use the commands:

pause-snip i

act-snip i

del-snip i

To pause, activate (resume) and delete snippet i, respectively, where i is snippet order as shown by the snip command.

Snippet conditions can be one of four categories:

  1. Port button event: This condition evaluates the state of one of port button events (clicked, double-clicked, pressed for X1, pressed for X2, pressed for X3, released for Y1, released for Y2, released for Y3).
  2. Module event: This condition evaluates module events.
  3. Module parameter with a constant: This condition compares a module parameter with a constant. Mathematical comparison operations are: equal “=”, greater than “>”, smaller than “<“, greater or equal “>=”, smaller or equal “≤”, not equal “!=”.
  4. Module parameter with a module parameter: This condition compares a module parameter with another module parameter using the same comparison operators.

Here are some examples for port button events:

if b1.clicked
end if
if b1.pressed for 3
color magenta 50
end if

And for comparing module parameter with a constant (range is a parameter for H08R6 module):

If range < 200
end if

Note 1: Be careful when comparing float numbers and parameters using the equal or not-equal operators, as the condition might never be true.

Note 2: You can’t change the order of snippet execution. However, once you delete a snippet, subsequent ones get shifted to fill the empty place.

How can we help?