Button S

![]() | ![]() |
Soft Touch Button
- Overview
- Drivers
- Samples
- Projects
Soft Touch Button
Key features • Single Soft Touch Button | Resources |
Function | Description |
---|---|
Init() | Initialize device |
DVer() | This driver version. |
Mode(mode) | Set mode. 0: interrupt - default, 1: direct mode |
IsPressed() | Return 1 if button is pressed. |
IsReleased() | Return 1 if button is release. |
The Code!
Modules ship with this script preloaded. Use Console to reload or modify the drivers. Additionally, some languages, such as Python, include DUELink.Engine.Record()
for recording scripts directly from the host.
##### Driver Code Starts Here ###
# Interrupt mode:
# Return button state by interrupt. A read clear last value to 0.
# If no read, the last value change will be kept for two seconds then reset to 0 if no read.
# Direct mode:
# Return button state as is
_m = 0 # 0: interrupt - default, 1: direct mode
fn Init()
Mode(1)
fend
fn Mode(m)
_m = m
if (_m = 0)
btnen(1, 1, 1) # pull up
else
btnen(1, 0, 0) # disable
end
fend
fn DVer()
return 0.1
fend
fn IsPressed()
if (_m = 0)
return btndown(1)
else
return !dread(1, 1)
end
fend
fn IsReleased()
if (_m = 0)
return btnup(1)
else
return dread(1, 1)
end
fend
Init()
##### User Code Starts Here #####
- Script
- Python
- JavaScript
Use Console to modify the default driver by adding this sample.
# Append this code at the bottom of the script, right after the driver.
# You MUST keep the driver code!!
while (1)
if (IsPressed())
println("Button pressed")
end
if (IsReleased())
println("Button released")
end
wait(100)
wend
from DUELink.DUELinkController import DUELinkController
import time
availablePort = DUELinkController.GetConnectionPort()
duelink = DUELinkController(availablePort)
//code
Coming soon!
Ordering Info
Description | Part Number | Price |
---|---|---|
Button S | GDL-HIBUTTONS-A | $00.00 |