FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lua-gpiod/gpiod_example.lua at main · HsOjo/lua-gpiod · GitHub
HsOjo
/
lua-gpiod
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lua-gpiod
/
gpiod_example.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (37 loc) · 1.12 KB
Breadcrumbs
lua-gpiod
/
gpiod_example.lua
Copy path
File metadata and controls
45 lines (37 loc) · 1.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!
/usr/bin/env lua
--[[
Complete gpiod Lua wrapper library usage example
Demonstrates how to use the generic gpiod library for GPIO operations
]]
--
Add current directory to package path
local
gpiod
=
require
(
"
gpiod
"
)
print
(
"
=== gpiod Lua Wrapper Library Example ===
"
)
print
(
"
gpiod version:
"
,
gpiod
.
version
())
--
Open GPIO chip
local
chip
=
gpiod
.
chip_open
(
"
gpiochip4
"
)
print
(
"
Chip name:
"
,
chip
:
name
())
print
(
"
Chip label:
"
,
chip
:
label
())
print
(
"
Number of GPIO lines:
"
,
chip
:
num_lines
())
--
Get GPIO line (e.g., GPIO 18)
local
line
=
chip
:
get_line
(
18
)
print
(
"
GPIO line offset:
"
,
line
:
offset
())
print
(
"
GPIO line name:
"
,
line
:
name
()
or
"
No name
"
)
print
(
"
Is line used:
"
,
line
:
is_used
())
--
Request output mode
line
:
request_output
(
"
example
"
,
0
)
print
(
"
GPIO direction:
"
,
line
:
direction
())
print
(
"
Consumer:
"
,
line
:
consumer
())
--
LED blinking example
print
(
"
Starting GPIO 18 blinking (5 times)...
"
)
for
i
=
1
,
5
do
print
(
"
Setting high level
"
)
line
:
set_value
(
1
)
gpiod
.
sleep
(
0.5
)
print
(
"
Setting low level
"
)
line
:
set_value
(
0
)
gpiod
.
sleep
(
0.5
)
end
--
Clean up resources
line
:
release
()
chip
:
close
()
print
(
"
Example completed
"
)
Back
|
FazBrowse Home
|
New Git URL