-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua bindings #527
Open
dedok
wants to merge
3
commits into
eclipse:master
Choose a base branch
from
dedok:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Lua bindings #527
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,31 @@ | ||
#!/usr/bin/env lua | ||
|
||
-- Author: Vasiliy Soshnikov <[email protected], [email protected]> | ||
-- Copyright (c) 2016 Intel Corporation. | ||
-- | ||
-- Permission is hereby granted, free of charge, to any person obtaining | ||
-- a copy of this software and associated documentation files (the | ||
-- "Software"), to deal in the Software without restriction, including | ||
-- without limitation the rights to use, copy, modify, merge, publish, | ||
-- distribute, sublicense, and/or sell copies of the Software, and to | ||
-- permit persons to whom the Software is furnished to do so, subject to | ||
-- the following conditions: | ||
-- | ||
-- The above copyright notice and this permission notice shall be | ||
-- included in all copies or substantial portions of the Software. | ||
-- | ||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
-- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
mraa = require('mraa') | ||
|
||
print (mraa.getVersion()) | ||
|
||
x = mraa.Aio(0) | ||
print (x:read()) | ||
print ("%.5f" % x:readFloat()) |
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,42 @@ | ||
#!/usr/bin/env lua | ||
|
||
-- Author: Vasiliy Soshnikov <[email protected], [email protected]> | ||
-- Copyright (c) 2016 Intel Corporation. | ||
-- | ||
-- Permission is hereby granted, free of charge, to any person obtaining | ||
-- a copy of this software and associated documentation files (the | ||
-- "Software"), to deal in the Software without restriction, including | ||
-- without limitation the rights to use, copy, modify, merge, publish, | ||
-- distribute, sublicense, and/or sell copies of the Software, and to | ||
-- permit persons to whom the Software is furnished to do so, subject to | ||
-- the following conditions: | ||
-- | ||
-- The above copyright notice and this permission notice shall be | ||
-- included in all copies or substantial portions of the Software. | ||
-- | ||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
-- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
mraa = require('mraa') | ||
os = require('os') | ||
|
||
x = mraa.Gpio(8) | ||
x:dir(mraa.DIR_OUT) | ||
|
||
local function my_sleep(sec) | ||
os.execute('sleep ' .. tonumber(sec)) | ||
end | ||
|
||
while true do | ||
-- On | ||
x:write(1) | ||
my_sleep(0.2) | ||
-- off | ||
x:write(0) | ||
my_sleep(0.2) | ||
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,44 @@ | ||
#!/usr/bin/env lua | ||
|
||
-- Author: Vasiliy Soshnikov <[email protected], [email protected]> | ||
-- Copyright (c) 2016 Intel Corporation. | ||
-- | ||
-- Permission is hereby granted, free of charge, to any person obtaining | ||
-- a copy of this software and associated documentation files (the | ||
-- "Software"), to deal in the Software without restriction, including | ||
-- without limitation the rights to use, copy, modify, merge, publish, | ||
-- distribute, sublicense, and/or sell copies of the Software, and to | ||
-- permit persons to whom the Software is furnished to do so, subject to | ||
-- the following conditions: | ||
-- | ||
-- The above copyright notice and this permission notice shall be | ||
-- included in all copies or substantial portions of the Software. | ||
-- | ||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
-- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
mraa = require('mraa') | ||
os = require('os') | ||
|
||
local function my_sleep(sec) | ||
os.execute('sleep ' .. tonumber(sec)) | ||
end | ||
|
||
x = mraa.Pwm(3) | ||
x:period_us(700) | ||
x:enable(true) | ||
value = 0.0 | ||
|
||
while true do | ||
x:write(value) | ||
my_sleep(0.05) | ||
value = value + 0.01 | ||
if value >= 1 then | ||
value = 0.0 | ||
end | ||
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,29 @@ | ||
#!/usr/bin/env lua | ||
|
||
-- Author: Soshnikov Vasiliy <[email protected], [email protected]> | ||
-- Copyright (c) 2016 Intel Corporation. | ||
-- | ||
-- Permission is hereby granted, free of charge, to any person obtaining | ||
-- a copy of this software and associated documentation files (the | ||
-- "Software"), to deal in the Software without restriction, including | ||
-- without limitation the rights to use, copy, modify, merge, publish, | ||
-- distribute, sublicense, and/or sell copies of the Software, and to | ||
-- permit persons to whom the Software is furnished to do so, subject to | ||
-- the following conditions: | ||
-- | ||
-- The above copyright notice and this permission notice shall be | ||
-- included in all copies or substantial portions of the Software. | ||
-- | ||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
-- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
mraa = require('mraa') | ||
|
||
print (mraa.getVersion()) | ||
|
||
mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0"); |
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,30 @@ | ||
#!/usr/bin/env lua | ||
|
||
-- Author: Vasiliy Soshnikov <[email protected], [email protected]> | ||
-- Copyright (c) 2016 Intel Corporation. | ||
-- | ||
-- Permission is hereby granted, free of charge, to any person obtaining | ||
-- a copy of this software and associated documentation files (the | ||
-- "Software"), to deal in the Software without restriction, including | ||
-- without limitation the rights to use, copy, modify, merge, publish, | ||
-- distribute, sublicense, and/or sell copies of the Software, and to | ||
-- permit persons to whom the Software is furnished to do so, subject to | ||
-- the following conditions: | ||
-- | ||
-- The above copyright notice and this permission notice shall be | ||
-- included in all copies or substantial portions of the Software. | ||
-- | ||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
-- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
mraa = require('mraa') | ||
|
||
print (mraa.getVersion()) | ||
x = mraa.Gpio(13) | ||
x:dir(mraa.DIR_OUT) | ||
x:write(1) |
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,50 @@ | ||
find_package (Lua REQUIRED) | ||
|
||
include_directories( | ||
${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
${LUA_INCLUDE_DIR} | ||
) | ||
|
||
set_source_files_properties (mraa.i PROPERTIES CPLUSPLUS ON) | ||
set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src") | ||
swig_add_module (lua-mraa lua mraa.i) | ||
swig_link_libraries (lua-mraa mraa ${LUA_LIBRARIES}) | ||
|
||
if (DOXYGEN_FOUND) | ||
foreach (_file ${DOCCLASSES}) | ||
add_dependencies (${SWIG_MODULE_lua-mraa_REAL_NAME} ${_file}class_doc_i) | ||
endforeach () | ||
add_dependencies (${SWIG_MODULE_lua-mraa_REAL_NAME} common_hpp_doc_i) | ||
|
||
add_custom_target (pydoc | ||
pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/ | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMENT "Generating API documentation with pydoc" VERBATIM | ||
) | ||
endif () | ||
|
||
set_target_properties (${SWIG_MODULE_lua-mraa_REAL_NAME} PROPERTIES | ||
OUTPUT_NAME mraa | ||
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIG=${SWIG_FOUND}" | ||
) | ||
|
||
execute_process ( | ||
COMMAND lua -e | ||
"string.gsub(package.path, '[^;]+', function(e) | ||
if e:find('/usr/local') == 1 then | ||
p = e:gsub('(?.lua)', '') | ||
io.write(p) | ||
os.exit(0) | ||
end | ||
end) | ||
os.exit(1) | ||
" | ||
OUTPUT_VARIABLE LUA_SITE_DIR | ||
) | ||
|
||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.so | ||
DESTINATION ${LUA_SITE_DIR}) | ||
|
||
message(STATUS "Lua site dir: ${LUA_SITE_DIR}") | ||
|
||
add_subdirectory (docs) |
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,41 @@ | ||
if (DOXYGEN_FOUND) | ||
find_package (Sphinx) | ||
if (SPHINX_FOUND) | ||
if (NOT DEFINED SPHINX_THEME) | ||
set (SPHINX_THEME default) | ||
endif () | ||
|
||
if (NOT DEFINED SPHINX_THEME_DIR) | ||
set (SPHINX_THEME_DIR) | ||
endif () | ||
|
||
# configured documentation tools and intermediate build results | ||
set (BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
|
||
# Sphinx cache with pickled ReST documents | ||
set (SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctrees") | ||
|
||
# HTML output directory | ||
set (SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") | ||
|
||
# doc .rst locations | ||
set (SPHINX_DOC_LOATION "${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" | ||
"${BINARY_BUILD_DIR}/conf.py" | ||
@ONLY | ||
) | ||
|
||
add_custom_target(sphinx ALL | ||
${SPHINX_EXECUTABLE} -b html | ||
-c "${BINARY_BUILD_DIR}" | ||
-d "${SPHINX_CACHE_DIR}" | ||
"${SPHINX_DOC_LOATION}" | ||
"${SPHINX_HTML_DIR}" | ||
COMMENT "Building HTML documentation with Sphinx" | ||
) | ||
|
||
add_dependencies (sphinx ${SWIG_MODULE_lua-mraa_REAL_NAME}) | ||
endif () | ||
endif () |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of confused why all these are needed, if you use a build/ directory then everything will get ignored. Let's keep this stuff out unless there's a good reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not use build/ directory :)
Okay if you don't like these changes I can remove them out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
building in tree is not recommended for cmake (or any other builds really tbh), any good reason why you can't just build somewhere outside of git or simply add an ignore for your build directory? In any case such stuff doesn't belong in commits adding Lua support so please remove.