LightBus/LuaServer

Aus Wiki CCC Göttingen
Zur Navigation springen Zur Suche springen

Zugriff

Der Server ist (zur Zeit) auf brickme.nok.lab im Neotopia-Netzwerk auf TCP Port 1167 erreichbar.

Man kann ihm Lua-Code schicken, der dann ausgeführt wird (jajaja, unsicher, blablabla, aber lustig).

Dokumentation der Lua-API

    LBUS: busmaster: host: example network effect server
    
    This implements an effect server (srv.lua) which listens on TCP
    port 1167 and waits for Lua code there. An API is presented that
    allows to send animation functions (effects) to the server which
    it will then run.
    
    Uses LJSyscall for implementing the server functionality.
    
    API is accessible for the functions in the "api" variable. It
    offers the following methods:
    
    api:set(x, y, r, g, b, alpha)
      set Pixel at x, y to the values r, g, b using alpha value
    
    api:effect_list()
      return a list of currently loaded/active effects
    
    api:effect_add(prio, name, effect)
      add an effect
      effect is a function:
        function(time, data)
      when called by the server in distinct intervals, time is the
      current time (in seconds), data is a table containing data
      that can be configured at runtime (see api:effect_set())
    
    api:effect_del(name)
      remove an effect
    
    api:effect_set(name, data_name, value)
      set an effect's data_name value

Siehe zur Implementation https://github.com/hwhw/stm32-projects/blob/master/lbus_usb_master/host_tools/luajit/srv.lua

Beispiele für Lua-Code, den man an den Server schicken kann, finden sich hier: https://github.com/hwhw/stm32-projects/tree/master/lbus_usb_master/host_tools/luajit/srv_effects