Initialer commit der anzeigr Beispielnodes

This commit is contained in:
Christian Obersteiner 2014-01-09 21:46:01 +01:00
parent a5940b5a7e
commit 6e469f57a4
35 changed files with 694 additions and 0 deletions

View File

@ -2,3 +2,16 @@ anzeigr
=======
Info-Beamer based Infoscreen Playground
current_nodes enthaelt die aktuell anzuzeigenden nodes, dieses directory wird vom info-beamer angezeigt
unused_nodes ist der "parkplatz" fuer momentan nicht benoetigte nodes/nodes under development
Allgemeine Info:
http://info-beamer.org
Info-Beamer Sourcen:
https://github.com/dividuum/info-beamer
Weitere Beispiel-Nodes, 29C3, 30C3, ...:
https://github.com/dividuum/info-beamer-nodes

3
current_nodes/README Normal file
View File

@ -0,0 +1,3 @@
diese root node rotiert durch die child nodes
-> das Update script wird per user-cron jede Minute aufgerufen um neue Infos zu holen (space_state/upate, flipdot/update,...)

View File

@ -0,0 +1 @@
Diese Node zeigt das aktuelle flipdot Bild von schneiders brezn an

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,12 @@
gl.setup(1366, 100)
image = resource.load_image("logo_muccc_inv.png")
font = resource.load_font("silkscreen.ttf")
function node.render()
gl.clear(0.1, 0.1, 0.1, 1) -- dark grey
util.draw_correct(image, 0, 0, 150, 100)
font:write(160, 0, "flipdot", 100, 1,1,1,1)
end

Binary file not shown.

View File

@ -0,0 +1,15 @@
gl.setup(1366, 768)
image = resource.load_image("flipdot.png")
function node.render()
gl.clear(0, 0, 0, 1) -- black background
-- render logo
resource.render_child("header"):draw(0, 0, WIDTH, 100)
-- show current flipdot img
util.draw_correct(image, 100, 150, WIDTH-100, HEIGHT-50)
end

2
current_nodes/flipdot/update Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
wget http://brezn.muc.ccc.de/~schneider/flipdot/flipdot.png -O /home/pi/anzeigr/flipdot/flipdot.png

62
current_nodes/node.lua Normal file
View File

@ -0,0 +1,62 @@
gl.setup(1366, 768)
local interval = 10
util.auto_loader(_G)
local distort_shader = resource.create_shader([[
uniform sampler2D Texture;
uniform float effect;
varying vec2 TexCoord;
uniform vec4 Color;
void main() {
vec2 uv = TexCoord.st;
vec4 col;
col.r = texture2D(Texture, vec2(uv.x+sin(uv.y*20.0*effect)*0.2,uv.y)).r;
col.g = texture2D(Texture, vec2(uv.x+sin(uv.y*25.0*effect)*0.2,uv.y)).g;
col.b = texture2D(Texture, vec2(uv.x+sin(uv.y*30.0*effect)*0.2,uv.y)).b;
col.a = texture2D(Texture, vec2(uv.x,uv.y)).a;
vec4 foo = vec4(1.0,1.0,1.0,effect);
col.a = 1.0;
gl_FragColor = Color * col * foo;
}
]])
function make_switcher(childs, interval)
local next_switch = 0
local child
local function next_child()
child = childs.next()
next_switch = sys.now() + interval
end
local function draw()
if sys.now() > next_switch then
next_child()
end
util.draw_correct(resource.render_child(child), 0, 0, WIDTH, HEIGHT)
local remaining = next_switch - sys.now()
if remaining < 0.2 or remaining > interval - 0.2 then
--util.post_effect(distort_shader, {
-- effect = 5 + remaining * math.sin(sys.now() * 50);
--})
end
end
return {
draw = draw;
}
end
local switcher = make_switcher(util.generator(function()
local cycle = {}
for child, updated in pairs(CHILDS) do
table.insert(cycle, child)
end
return cycle
end), interval)
function node.render()
gl.clear(0, 0.02, 0.2, 1)
switcher.draw()
end

View File

@ -0,0 +1 @@
Beispielsweise Implementierung einer Preisliste für *le Party

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,12 @@
gl.setup(1366, 100)
image = resource.load_image("logo_muccc_inv.png")
font = resource.load_font("silkscreen.ttf")
function node.render()
gl.clear(0.1, 0.1, 0.1, 1) -- dark grey
util.draw_correct(image, 0, 0, 150, 100)
font:write(160, 0, "Preisliste", 100, 1,1,1,1)
end

Binary file not shown.

View File

@ -0,0 +1,71 @@
gl.setup(1366, 768)
font = resource.load_font("font.ttf")
local Absatz = "absatz"
local preise = {
{"Tschunk", "1,- €"},
{"Mate", "1,- €"},
{"Bier", "1,- €"},
Absatz,
{"Cola", "2,- €"},
}
function Preisliste(preise, x, y, spacing, size)
local row
local col
local next_kaputt
function select_next()
repeat
row = math.random(#preise)
until preise[row] ~= Absatz
local title, price = unpack(preise[row])
col = math.random(#title - 1)
next_kaputt = sys.now() + math.random() * 60 + 30
end
select_next()
function draw()
local yy = y
for n, item in pairs(preise) do
if item == Absatz then
yy = yy + size
else
local title, price = unpack(item)
if sys.now() > next_kaputt - 3 and n == row then
local a = title:sub(1, col-1)
local b = title:sub(col, col)
local c = title:sub(col+1, col+1)
local d = title:sub(col+2)
title = a .. c .. b .. d
font:write(x, yy, title, size, .1,.7,.1,1)
elseif sys.now() > next_kaputt then
select_next()
font:write(x, yy, title, size, .1,.7,.1,1)
else
font:write(x, yy, title, size, .1,.7,.1,1)
end
font:write(x + spacing, yy, price, size, .1,.7,.1,1)
yy = yy + size
end
end
end
return {
draw = draw;
}
end
local preisliste = Preisliste(preise, 50, 150, 1000, 105)
function node.render()
gl.clear(0, 0, 0, 1) -- black background
-- render logo
resource.render_child("header"):draw(0, 0, WIDTH, 100)
preisliste:draw()
end

View File

@ -0,0 +1,3 @@
Holt den aktuellen Kapselstatus von
http://api.muc.ccc.de/spaceapi.json

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,12 @@
gl.setup(1366, 100)
image = resource.load_image("logo_muccc_inv.png")
font = resource.load_font("silkscreen.ttf")
function node.render()
gl.clear(0.1, 0.1, 0.1, 1) -- dark grey
util.draw_correct(image, 0, 0, 150, 100)
font:write(160, 10, "luftschleuse", 80, 1,1,1,1)
end

Binary file not shown.

View File

@ -0,0 +1,377 @@
-----------------------------------------------------------------------------
-- JSON4Lua: JSON encoding / decoding support for the Lua language.
-- json Module.
-- Author: Craig Mason-Jones
-- Homepage: http://json.luaforge.net/
-- Version: 0.9.40
-- This module is released under the MIT License (MIT).
-- Please see LICENCE.txt for details.
--
-- USAGE:
-- This module exposes two functions:
-- encode(o)
-- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string.
-- decode(json_string)
-- Returns a Lua object populated with the data encoded in the JSON string json_string.
--
-- REQUIREMENTS:
-- compat-5.1 if using Lua 5.0
--
-- CHANGELOG
-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix).
-- Fixed Lua 5.1 compatibility issues.
-- Introduced json.null to have null values in associative arrays.
-- encode() performance improvement (more than 50%) through table.concat rather than ..
-- Introduced decode ability to ignore /**/ comments in the JSON string.
-- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Imports and dependencies
-----------------------------------------------------------------------------
local math = require('math')
local string = require("string")
local table = require("table")
local base = _G
-----------------------------------------------------------------------------
-- Module declaration
-----------------------------------------------------------------------------
module("json")
-- Public functions
-- Private functions
local decode_scanArray
local decode_scanComment
local decode_scanConstant
local decode_scanNumber
local decode_scanObject
local decode_scanString
local decode_scanWhitespace
local encodeString
local isArray
local isEncodable
-----------------------------------------------------------------------------
-- PUBLIC FUNCTIONS
-----------------------------------------------------------------------------
--- Encodes an arbitrary Lua object / variable.
-- @param v The Lua object / variable to be JSON encoded.
-- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode)
function encode (v)
-- Handle nil values
if v==nil then
return "null"
end
local vtype = base.type(v)
-- Handle strings
if vtype=='string' then
return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string
end
-- Handle booleans
if vtype=='number' or vtype=='boolean' then
return base.tostring(v)
end
-- Handle tables
if vtype=='table' then
local rval = {}
-- Consider arrays separately
local bArray, maxCount = isArray(v)
if bArray then
for i = 1,maxCount do
table.insert(rval, encode(v[i]))
end
else -- An object, not an array
for i,j in base.pairs(v) do
if isEncodable(i) and isEncodable(j) then
table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j))
end
end
end
if bArray then
return '[' .. table.concat(rval,',') ..']'
else
return '{' .. table.concat(rval,',') .. '}'
end
end
-- Handle null values
if vtype=='function' and v==null then
return 'null'
end
base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v))
end
--- Decodes a JSON string and returns the decoded value as a Lua data structure / value.
-- @param s The string to scan.
-- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1.
-- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil,
-- and the position of the first character after
-- the scanned JSON object.
function decode(s, startPos)
startPos = startPos and startPos or 1
startPos = decode_scanWhitespace(s,startPos)
base.assert(startPos<=string.len(s), 'Unterminated JSON encoded object found at position in [' .. s .. ']')
local curChar = string.sub(s,startPos,startPos)
-- Object
if curChar=='{' then
return decode_scanObject(s,startPos)
end
-- Array
if curChar=='[' then
return decode_scanArray(s,startPos)
end
-- Number
if string.find("+-0123456789.e", curChar, 1, true) then
return decode_scanNumber(s,startPos)
end
-- String
if curChar==[["]] or curChar==[[']] then
return decode_scanString(s,startPos)
end
if string.sub(s,startPos,startPos+1)=='/*' then
return decode(s, decode_scanComment(s,startPos))
end
-- Otherwise, it must be a constant
return decode_scanConstant(s,startPos)
end
--- The null function allows one to specify a null value in an associative array (which is otherwise
-- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null }
function null()
return null -- so json.null() will also return null ;-)
end
-----------------------------------------------------------------------------
-- Internal, PRIVATE functions.
-- Following a Python-like convention, I have prefixed all these 'PRIVATE'
-- functions with an underscore.
-----------------------------------------------------------------------------
--- Scans an array from JSON into a Lua object
-- startPos begins at the start of the array.
-- Returns the array and the next starting position
-- @param s The string being scanned.
-- @param startPos The starting position for the scan.
-- @return table, int The scanned array as a table, and the position of the next character to scan.
function decode_scanArray(s,startPos)
local array = {} -- The return value
local stringLen = string.len(s)
base.assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s )
startPos = startPos + 1
-- Infinite loop for array elements
repeat
startPos = decode_scanWhitespace(s,startPos)
base.assert(startPos<=stringLen,'JSON String ended unexpectedly scanning array.')
local curChar = string.sub(s,startPos,startPos)
if (curChar==']') then
return array, startPos+1
end
if (curChar==',') then
startPos = decode_scanWhitespace(s,startPos+1)
end
base.assert(startPos<=stringLen, 'JSON String ended unexpectedly scanning array.')
object, startPos = decode(s,startPos)
table.insert(array,object)
until false
end
--- Scans a comment and discards the comment.
-- Returns the position of the next character following the comment.
-- @param string s The JSON string to scan.
-- @param int startPos The starting position of the comment
function decode_scanComment(s, startPos)
base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos)
local endPos = string.find(s,'*/',startPos+2)
base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos)
return endPos+2
end
--- Scans for given constants: true, false or null
-- Returns the appropriate Lua type, and the position of the next character to read.
-- @param s The string being scanned.
-- @param startPos The position in the string at which to start scanning.
-- @return object, int The object (true, false or nil) and the position at which the next character should be
-- scanned.
function decode_scanConstant(s, startPos)
local consts = { ["true"] = true, ["false"] = false, ["null"] = nil }
local constNames = {"true","false","null"}
for i,k in base.pairs(constNames) do
--print ("[" .. string.sub(s,startPos, startPos + string.len(k) -1) .."]", k)
if string.sub(s,startPos, startPos + string.len(k) -1 )==k then
return consts[k], startPos + string.len(k)
end
end
base.assert(nil, 'Failed to scan constant from string ' .. s .. ' at starting position ' .. startPos)
end
--- Scans a number from the JSON encoded string.
-- (in fact, also is able to scan numeric +- eqns, which is not
-- in the JSON spec.)
-- Returns the number, and the position of the next character
-- after the number.
-- @param s The string being scanned.
-- @param startPos The position at which to start scanning.
-- @return number, int The extracted number and the position of the next character to scan.
function decode_scanNumber(s,startPos)
local endPos = startPos+1
local stringLen = string.len(s)
local acceptableChars = "+-0123456789.e"
while (string.find(acceptableChars, string.sub(s,endPos,endPos), 1, true)
and endPos<=stringLen
) do
endPos = endPos + 1
end
local stringValue = 'return ' .. string.sub(s,startPos, endPos-1)
local stringEval = base.loadstring(stringValue)
base.assert(stringEval, 'Failed to scan number [ ' .. stringValue .. '] in JSON string at position ' .. startPos .. ' : ' .. endPos)
return stringEval(), endPos
end
--- Scans a JSON object into a Lua object.
-- startPos begins at the start of the object.
-- Returns the object and the next starting position.
-- @param s The string being scanned.
-- @param startPos The starting position of the scan.
-- @return table, int The scanned object as a table and the position of the next character to scan.
function decode_scanObject(s,startPos)
local object = {}
local stringLen = string.len(s)
local key, value
base.assert(string.sub(s,startPos,startPos)=='{','decode_scanObject called but object does not start at position ' .. startPos .. ' in string:\n' .. s)
startPos = startPos + 1
repeat
startPos = decode_scanWhitespace(s,startPos)
base.assert(startPos<=stringLen, 'JSON string ended unexpectedly while scanning object.')
local curChar = string.sub(s,startPos,startPos)
if (curChar=='}') then
return object,startPos+1
end
if (curChar==',') then
startPos = decode_scanWhitespace(s,startPos+1)
end
base.assert(startPos<=stringLen, 'JSON string ended unexpectedly scanning object.')
-- Scan the key
key, startPos = decode(s,startPos)
base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
startPos = decode_scanWhitespace(s,startPos)
base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
base.assert(string.sub(s,startPos,startPos)==':','JSON object key-value assignment mal-formed at ' .. startPos)
startPos = decode_scanWhitespace(s,startPos+1)
base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
value, startPos = decode(s,startPos)
object[key]=value
until false -- infinite loop while key-value pairs are found
end
--- Scans a JSON string from the opening inverted comma or single quote to the
-- end of the string.
-- Returns the string extracted as a Lua string,
-- and the position of the next non-string character
-- (after the closing inverted comma or single quote).
-- @param s The string being scanned.
-- @param startPos The starting position of the scan.
-- @return string, int The extracted string as a Lua string, and the next character to parse.
function decode_scanString(s,startPos)
base.assert(startPos, 'decode_scanString(..) called without start position')
local startChar = string.sub(s,startPos,startPos)
base.assert(startChar==[[']] or startChar==[["]],'decode_scanString called for a non-string')
local escaped = false
local endPos = startPos + 1
local bEnded = false
local stringLen = string.len(s)
repeat
local curChar = string.sub(s,endPos,endPos)
-- Character escaping is only used to escape the string delimiters
if not escaped then
if curChar==[[\]] then
escaped = true
else
bEnded = curChar==startChar
end
else
-- If we're escaped, we accept the current character come what may
escaped = false
end
endPos = endPos + 1
base.assert(endPos <= stringLen+1, "String decoding failed: unterminated string at position " .. endPos)
until bEnded
local stringValue = 'return ' .. string.sub(s, startPos, endPos-1)
local stringEval = base.loadstring(stringValue)
base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos)
return stringEval(), endPos
end
--- Scans a JSON string skipping all whitespace from the current start position.
-- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached.
-- @param s The string being scanned
-- @param startPos The starting position where we should begin removing whitespace.
-- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string
-- was reached.
function decode_scanWhitespace(s,startPos)
local whitespace=" \n\r\t"
local stringLen = string.len(s)
while ( string.find(whitespace, string.sub(s,startPos,startPos), 1, true) and startPos <= stringLen) do
startPos = startPos + 1
end
return startPos
end
--- Encodes a string to be JSON-compatible.
-- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-)
-- @param s The string to return as a JSON encoded (i.e. backquoted string)
-- @return The string appropriately escaped.
function encodeString(s)
s = string.gsub(s,'\\','\\\\')
s = string.gsub(s,'"','\\"')
s = string.gsub(s,"'","\\'")
s = string.gsub(s,'\n','\\n')
s = string.gsub(s,'\t','\\t')
return s
end
-- Determines whether the given Lua type is an array or a table / dictionary.
-- We consider any table an array if it has indexes 1..n for its n items, and no
-- other data in the table.
-- I think this method is currently a little 'flaky', but can't think of a good way around it yet...
-- @param t The table to evaluate as an array
-- @return boolean, number True if the table can be represented as an array, false otherwise. If true,
-- the second returned value is the maximum
-- number of indexed elements in the array.
function isArray(t)
-- Next we count all the elements, ensuring that any non-indexed elements are not-encodable
-- (with the possible exception of 'n')
local maxIndex = 0
for k,v in base.pairs(t) do
if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair
if (not isEncodable(v)) then return false end -- All array elements must be encodable
maxIndex = math.max(maxIndex,k)
else
if (k=='n') then
if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements
else -- Else of (k=='n')
if isEncodable(v) then return false end
end -- End of (k~='n')
end -- End of k,v not an indexed pair
end -- End of loop across all pairs
return true, maxIndex
end
--- Determines whether the given Lua object / table / variable can be JSON encoded. The only
-- types that are JSON encodable are: string, boolean, number, nil, table and json.null.
-- In this implementation, all other types are ignored.
-- @param o The object to examine.
-- @return boolean True if the object should be JSON encoded, false if it should be ignored.
function isEncodable(o)
local t = base.type(o)
return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null)
end

View File

@ -0,0 +1,24 @@
gl.setup(1366, 768)
json = require "json"
font = resource.load_font("silkscreen.ttf")
util.loaders.json = function(filename)
return json.decode(resource.load_file(filename))
end
util.auto_loader(_G)
function node.render()
gl.clear(0, 0, 0, 1) -- black background
-- render logo
resource.render_child("header"):draw(0, 0, WIDTH, 100)
font:write(100, 200, "current state:", 110, 1,1,1,1)
-- show spacestate
font:write(100, 350, spaceapi.state.message, 130, 1,1,0,1)
end

Binary file not shown.

View File

@ -0,0 +1,28 @@
{
"location" : {
"lat" : 48.15367,
"address" : "Heßstrasse 90, München, Germany",
"lon" : 11.56078
},
"contact" : {
"email" : "info@muc.ccc.de",
"irc" : "irc://ray.blafasel.de/#ccc",
"twitter" : "@muccc",
"ml" : "talk@lists.muc.ccc.de"
},
"projects" : [
"https://wiki.muc.ccc.de/projekte",
"https://github.com/muccc"
],
"space" : "MuCCC",
"api" : "0.13",
"state" : {
"open" : true,
"message" : "members only"
},
"logo" : "http://muc.ccc.de/lib/tpl/muc3/images/muc3_klein.gif",
"url" : "https://muc.ccc.de",
"issue_report_channels" : [
"email"
]
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
wget http://api.muc.ccc.de/spaceapi.json -O spaceapi.raw
< spaceapi.raw json_pp > /home/pi/anzeigr/space_state/spaceapi.json

3
current_nodes/updates Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/home/pi/anzeigr/space_state/update
/home/pi/anzeigr/flipdot/update

BIN
current_nodes/video/1.mp4 Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
Simple Video Playlist
Put the filenames of your videos in playlist.txt. One video file name per line.
Filenames are case sensitive. The playlist can be changed during runtime by
updating the file playlist.txt and saving it.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,12 @@
gl.setup(1366, 100)
image = resource.load_image("logo_muccc_inv.png")
font = resource.load_font("silkscreen.ttf")
function node.render()
gl.clear(0.1, 0.1, 0.1, 1) -- dark grey
util.draw_correct(image, 0, 0, 150, 100)
font:write(160, 0, "NYAN!", 100, 1,1,1,1)
end

Binary file not shown.

View File

@ -0,0 +1,33 @@
gl.setup(1366, 768)
local playlist
local current_video_idx
util.file_watch("playlist.txt", function(content)
playlist = {}
for filename in string.gmatch(content, "[^\r\n]+") do
playlist[#playlist+1] = filename
end
current_video_idx = 0
print("new playlist")
pp(playlist)
end)
function next_video()
current_video_idx = current_video_idx + 1
if current_video_idx > #playlist then
current_video_idx = 1
end
video = util.videoplayer(playlist[current_video_idx], {loop=false})
end
function node.render()
gl.clear(0, 0, 0, 1) -- black background
-- render logo
resource.render_child("header"):draw(0, 0, WIDTH, 100)
if not video or not video:next() then
next_video()
end
util.draw_correct(video, (WIDTH-640)/2, (HEIGHT-480)/2, (WIDTH+640)/2, (HEIGHT+480)/2)
end

View File

@ -0,0 +1 @@
1.mp4

1
unused_nodes/README Normal file
View File

@ -0,0 +1 @@
alte, ungebrauchte, noch nicht fertige nodes