Skip to content
Browse files

Adjusting tests package.path for new location

  • Loading branch information...
1 parent 68b0eb4 commit 34bca9916f440458e07c4225032590d0a899b89b @Wiladams committed Nov 8, 2012
View
0 userland/metadata_fourcc.lua → experimental/metadata_fourcc.lua
File renamed without changes.
View
0 Djenne_128_128.raw → tests/Djenne_128_128.raw
File renamed without changes.
View
0 Gaudi_128_128.raw → tests/Gaudi_128_128.raw
File renamed without changes.
View
0 Lucca_128_128.raw → tests/Lucca_128_128.raw
File renamed without changes.
View
0 media/desktop.mp4 → tests/media/desktop.mp4
File renamed without changes.
View
BIN media/desktop.ppm → tests/media/desktop.ppm
Binary file not shown.
View
64 tests/snapper.lua
@@ -1,26 +1,25 @@
+package.path = package.path..";../?.lua"
local ffi = require "ffi"
+
+local Keyboard = require "Keyboard"
+local EventLoop = require "EventLoop"
+
local DMX = require "DisplayManX"
local Display = DMXDisplay();
-Display:SetBackground(0,0,0);
+--Display:SetBackground(0,0,0);
local screenWidth, screenHeight = Display:GetSize();
-local ratio = screenWidth / screenHeight;
local displayHeight = screenHeight;
local displayWidth = screenWidth;
---local displayHeight = 320;
---local displayWidth = 640;
---local displayHeight = 70;
---local displayWidth = displayHeight * ratio;
--- Create the view that will display the snapshot
-local displayView = Display:CreateView(
- displayWidth, displayHeight,
- 0, screenHeight-displayHeight-1,
- 0, ffi.C.VC_IMAGE_RGB888)
+-- Setup an event loop and keyboard
+local loop = EventLoop.new();
+local kbd = Keyboard.new();
+
local function WritePPM(filename, pixbuff)
@@ -43,18 +42,45 @@ local function WritePPM(filename, pixbuff)
fp:close();
end
+local function TakeSnapshot()
+ -- Create resource used for capturing screen
+ local resource = DMXResource(displayWidth, displayHeight, ffi.C.VC_IMAGE_RGB888);
+
+ -- Do the snapshot
+ Display:Snapshot(resource);
--- Do the snapshot
-Display:Snapshot(displayView.Resource);
+ local pixeldata, err = resource:ReadPixelData();
+ if pixeldata then
+ -- Write the data out
+ local filename = "media/desktop.ppm"
+
+ WritePPM(filename, pixeldata);
+ end
+
+ print("File Written: ", filename);
+end
-local pixeldata, err = displayView.Resource:ReadPixelData();
-if pixeldata then
- -- Write the data out
- local filename = "media/desktop.ppm"
--- print("Writing: ", filename);
- WritePPM(filename, pixeldata);
+OnKeyUp = function(kbd, keycode)
+ if keycode == KEY_SYSRQ then
+ TakeSnapshot();
+ end
+
+ -- Halt the loop if they press the "Esc" key
+ if keycode == KEY_ESC then
+ loop:Halt();
+ end
end
+
+
+-- Setup some keyboard with event handlers
+kbd.OnKeyUp = OnKeyUp;
+
+loop:AddObservable(kbd);
+
+loop:Run(15);
+
+
View
1 tests/test_picast.lua
@@ -1,3 +1,4 @@
+package.path = package.path..";../?.lua"
local ffi = require "ffi"
local DMX = require "DisplayManX"
View
2 tests/test_triangle.lua
@@ -1,4 +1,4 @@
-
+package.path = package.path..";../?.lua"
-- A rotating cube rendered with OpenGL|ES.
-- Three images used as textures on the cube faces.
View
15 tests/test_upvalue.lua
@@ -1,15 +0,0 @@
-local upvalue=nil
-
-function test()
- local last
- for j=1,20 do
- last = upvalue
- end
- print(last, upvalue)
-end
-
-for i=1,8 do
- upvalue = i
- test()
-end
-
View
1 tests/test_window_basic.lua
@@ -1,3 +1,4 @@
+package.path = package.path..";../?.lua"
local ffi = require "ffi"

0 comments on commit 34bca99

Please sign in to comment.
Something went wrong with that request. Please try again.