Browse Source

Add a text scroller

rorist 9 months ago
parent
commit
3b5e065bc2
2 changed files with 30 additions and 4 deletions
  1. BIN
      background.png
  2. 30 4
      node.lua

BIN
background.png


+ 30 - 4
node.lua

@@ -15,7 +15,6 @@ function fixme()
         logo:draw(WIDTH-250,5,WIDTH-35,185)
         font:write(50, 0, "FIXME", 100, 1,1,1,1)
         font:write(50, 90, "Hackerspace", 100, 1,1,1,1)
-        font:write(50, 720, "https://git.fixme.ch/FIXME/screen", 32, 1,1,1,1)
    end
 
    return {
@@ -23,9 +22,36 @@ function fixme()
    }
 
 end
-
 local fix = fixme()
 
+function scroller()
+
+    function texts()
+        return {
+            "https://git.fixme.ch/FIXME/screen",
+            "Next bus (Renens-Village) " .. bus,
+        }
+    end
+
+	local text = util.running_text{
+		font = font;
+		size = 40;
+		speed = 150;
+		color = {1,1,1,1};
+		generator = util.generator(texts)
+	}
+
+    function draw()
+        text:draw(HEIGHT-60)
+    end
+
+    return {
+        draw = draw;
+    }
+
+end
+local scroll = scroller()
+
 local events = {}
 util.file_watch("events.json", function(data)
     evt = json.decode(data)
@@ -46,9 +72,9 @@ end)
 function node.render()
 
     fix:draw()
+    scroll:draw()
 
-   font:write(50, 220, "Power: " .. power, 50, 1,1,1,1)
-   font:write(50, 290, "Next bus (Renens-Village) " .. bus, 50, 1,1,1,1)
+   font:write(50, 240, "Power: " .. power, 80, 1,1,1,1)
 
    pos = 430
    font:write(50, pos-70, "Next Events:", 50, 1,1,1,1)