Skip to content

paulcuth/lua-tessel

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

lua-tessel

A CLI for scripting a Tessel device in Lua.


Getting started

git clone git@github.com:paulcuth/lua-tessel.git
cd lua-tessel
npm install -g
lua-tessel run examples/blink/blink.lua

Features

You can currently run scripts on, push to and erase a USB-connected Tessel device. For everything else you will need to use the official Tessel CLI. There are currently no plans to replicate any other functionality of the Tessel CLI.

Interacting with NPM packages

You can use NPM packages in your Lua code (packages for Tessel modules, for example) by require()ing them much like you would Lua modules. To do this, use the install command:

lua-tessel install ambient-attx4

This will download the package from the NPM registy and create ambient-attx4.lua.tar in the current working directory. You can then move this .tar file around in your project and require() it like you would a Lua module. See /examples/ambient/ambient.lua for example code.

Make sure you've also read the Things to note when using JavaScript modules from Lua.

Built-in modules

lua-tessel restores the developement environment on the Tessel back to a default Lua 5.1 environment. However, the following modules have also been added to package.preload and are available to require().

You should also be aware of the Things to note when using JavaScript modules from Lua.

bit32

Bitwise operations as described in the Lua docs.

http

HTTP functions as described in the Node docs.

json

JSON functions as described on MDN.

tessel

Allows access to features on the board. The API is described in the Tessel docs.

util

Provides some useful functionality that is available in the Tessel runtime. Currently, the following methods are available:

  • util.clearImmediate(ref) - Prevents an immediate callback from executing.
  • util.clearInterval(ref) - Stops an interval.
  • util.clearTimeout(ref) - Prevents a timeout from executing.
  • timestamp = getTimestamp() - Returns the unix tmiestamp for the current time.
  • ref = util.setImmediate(func) - Execute a callback on the next tick.
  • ref = util.setInterval(func, delay) - Execute a callback repeatedly with a specified delay (in ms).
  • ref = util.setTimeout(func, delay) - Execute a callback once after a specified delay (in ms).

If you know of any other functionality in the Tessel runtime and you'd like to see it here, please create an issue or send a pull request.

Things to note when using JavaScript modules from Lua

  • Always use colon syntax when calling methods on JS modules from Lua.
  • Numerical table keys are shifted to 1-based. Therefore, the LEDs are referenced by tessel.led[1] and tessel.led[2] and same for pins, GPIO, etc.
  • .end() is used in some of the JS modules, but t:end() is invalid syntax in Lua. t['end']() can be used, but a t:fin() alias method is added for convenience.

Issues

Please report any new issues you find in the issue tracker.

If you find a blocking issue, please consider fixing it and submitting a pull request.

Acknowledgements

While this is a rewrite rather than a fork of the official Tessel CLI, there are several chucks of code taken from that project.

License

MIT

About

A CLI that enables the scripting of a Tessel device in Lua.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published