mirror of
https://github.com/ctruLua/uCompat.git
synced 2025-10-28 17:19:31 +00:00
Added Image, Motion and Sprite libraries
This commit is contained in:
parent
6d3ec78c8c
commit
0166ba6bce
6 changed files with 307 additions and 2 deletions
63
Motion.lua
Normal file
63
Motion.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
--[[
|
||||
Motion related µLua compatibility layer/lib for ctrµLua
|
||||
|
||||
Nobody actually used this module. So please use directly the ctrµLua functions.
|
||||
]]
|
||||
|
||||
-- Local
|
||||
|
||||
local hid = require("hid")
|
||||
|
||||
calX, calY, calZ = 0,0,0 -- for Motion.calibrate
|
||||
|
||||
-- Module
|
||||
|
||||
Motion = {}
|
||||
|
||||
|
||||
function Motion.init()
|
||||
return true
|
||||
end
|
||||
|
||||
function Motion.calibrate()
|
||||
hid.read()
|
||||
calX, calY, calZ = hid.gyro()
|
||||
end
|
||||
|
||||
function Motion.readX()
|
||||
local x,y,z = hid.gyro()
|
||||
return (calX-x)
|
||||
end
|
||||
|
||||
function Motion.readY()
|
||||
local x,y,z = hid.gyro()
|
||||
return (calY-y)
|
||||
end
|
||||
|
||||
function Motion.readZ()
|
||||
local x,y,z = hid.gyro()
|
||||
return (calZ-z)
|
||||
end
|
||||
|
||||
function Motion.accelerationX()
|
||||
local x,y,z = hid.accel()
|
||||
return x
|
||||
end
|
||||
|
||||
function Motion.accelerationY()
|
||||
local x,y,z = hid.accel()
|
||||
return y
|
||||
end
|
||||
|
||||
function Motion.accelerationZ()
|
||||
local x,y,z = hid.accel()
|
||||
return z
|
||||
end
|
||||
|
||||
function Motion.readGyro()
|
||||
return (Motion.readX()*Motion.readY()*Motion.readZ())
|
||||
end
|
||||
|
||||
function Motion.rotation()
|
||||
return (Motion.accelerationX()*Motion.accelerationY()*Motion.accelerationZ())
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue