Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
modified: DisplayManX.lua
new file: PixelBuffer.lua modified: test_dispmanx.lua new file: test_snapshot.lua new file: tests/test_upvalue.lua
- Loading branch information
Showing
5 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
local ffi = require "ffi" | ||
local bit = require "bit" | ||
local bnot = bit.bnot | ||
local band = bit.band | ||
local bor = bit.bor | ||
local rshift = bit.rshift | ||
local lshift = bit.lshift | ||
|
||
local DMX = require "DisplayManX" | ||
|
||
local ALIGN_UP = function(x,y) | ||
return band((x + y-1), bnot(y-1)) | ||
end | ||
|
||
local PixelBuffer = {} | ||
local PixelBuffer_mt = { | ||
__index = PixelBuffer | ||
} | ||
|
||
PixelBuffer.new = function(width, height, imgtype) | ||
imgtype = imgtype or ffi.C.VC_IMAGE_RGB565 | ||
|
||
local pitch = ALIGN_UP(width*sizeofpixel, 32); | ||
local aligned_height = ALIGN_UP(height, 16); | ||
|
||
local obj = { | ||
PixelFormat = imgtype; | ||
Width = width; | ||
Height = height; | ||
Pitch = pitch; | ||
Data = ffi.new("uint8_t[?]", pitch * height); | ||
} | ||
|
||
setmetatable(obj, PixelBuffer_mt); | ||
|
||
return obj; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
local ffi = require "ffi" | ||
local DMX = require "DisplayManX" | ||
|
||
local Display = DMXDisplay(); | ||
|
||
local width = 640; | ||
local height = 480; | ||
local layer = 0; -- keep the snapshot view on top | ||
|
||
-- Create a resource to copy image into | ||
local pixmap = DMX.DMXResource(width,height); | ||
|
||
-- create a view with the snapshot as | ||
-- the backing store | ||
local mainView = DMX.DMXView.new(Display, 200, 200, width, height, layer, pformat, pixmap); | ||
|
||
for i=1,20 do | ||
-- Do the snapshot | ||
mainView:Hide(); | ||
Display:Snapshot(pixmap); | ||
mainView:Show(); | ||
|
||
ffi.C.sleep(1); | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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 | ||
|