Skip to content

LiaTemplates/netswarm-simulator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetSwarm-Simulator

                     --{{0}}--

This document defines some basic macros for applying the JavaScript Arduino interpreter NetSwarm in LiaScript to make Arduino programs in Markdown executeable and editable.

Try it on LiaScript:

https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/netswarm-simulator/master/README.md

See the project on Github:

https://github.com/liaTemplates/netswarm-simulator

                     --{{1}}--

There are three ways to use this template. The easiest way is to use the import statement and the url of the raw text-file of the master branch or any other branch or version. But you can also copy the required functionality directly into the header of your Markdown document, see therefor the last slide. And of course, you could also clone this project and change it, as you wish.

{{1}}
  1. Load the macros via

    import: https://raw.githubusercontent.com/liaTemplates/netswarm-simulator/master/README.md

  2. Copy the definitions into your Project

  3. Clone this repository on GitHub

@NetSwarm.single_loop

                     --{{0}}--

If you want to execute the loop only once, use @NetSwarm.single_loop To use the Tau-Prolog interpreter, two macros are necessary. The first one is @Tau.program, which is called with a unique identifier. It defines the basic Prolog-program with all rules and definitions.

void setup() {
  Serial.println("Hello setup.");
}

void loop() {
  Serial.println("Hello loop.");
}

@NetSwarm.single_loop

@NetSwarm.sloop

void setup() {
  Serial.println("Hello stuff.");
}

void thing(char i) {
  switch(i) {
  case 0: Serial.println("a pear"); break;
  case 1: Serial.println("an apple"); break;
  case 2: Serial.println("an elephant"); break;
  case 3: Serial.println("an arduino"); break;
  }
}

void loop() {
  Serial.print("here's ");
  thing(random(4));
}

@NetSwarm.loop

Implementation