
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Arbitrary Input for Terminal or a Pi, or Aitpi (pronounced 'eight pi')
The goal of this project is to provide a simple, but arbitrary, input mechanism for use with a raspberry pi, or a terminal keyboard (maybe more SBCs in the future?!).
This program can be configured with two simple json files.
The project supports:
To configure your setup, you can create up to three types of json files:
A registry of commands that will interact directly with your user program
[
{
"type": "normal",
"input_type": "button",
"id": "1",
"name": "command0"
},
{
"id": "1",
"input_type": "button",
"path": "../temp/",
"type": "presets",
"name": "howdy"
},
{
"id": "1",
"input_type": "button",
"path": "../temp/",
"type": "presets",
"name": "test"
},
{
"id": "1",
"input_type": "button",
"path": "../temp/",
"type": "presets",
"name": "another.txt"
}
]
The list of all 'input units' that your system uses
[
{
"name": "Button0",
"type": "button",
"mechanism": "rpi_gpio",
"trigger": "5",
"reg_link": "commandName0"
},
{
"name": "Encoder0",
"type": "encoder",
"mechanism": "rpi_gpio",
"left_trigger": "17",
"right_trigger": "24",
"reg_link": "commandName2"
}
]
Foldered commands allows you to consider all the files in a folder as a 'command' in the registry. This uses the watchdog python package to monitor folders and update on the fly. All commands added will be deleted and reloaded upon program startup.
[
{
"name": "Folder0",
"path": "/path/to/your/folder",
"type": "<registry_type>",
"id": "3",
"input_type": "button"
},
{
"name": "Folder1",
"path": "/another/path",
"type": "<registry_type>",
"id": "4",
"input_type": "encoder"
}
]
# import the base aitpi
import aitpi
from aitpi import router
# In order to receive messages can either make an object with a consume(message) function
# or just provide a function `def consume(message)`
class Watcher():
def consume(self, message):
print("Got command: %s" % message.name)
print("On event: %s" % message.event)
print("All attributes: %s" % message.attributes)
watcher = Watcher()
# Here we add a consumer that will receive commands with ids 0,1,2,3,4, these ids are the same
# as defined in your registry json file
router.addConsumer([0,1,2,3,4], watcher)
# We must first initialize our command registry before we can start getting input
aitpi.addRegistry("<path_to_json>/command_reg.json", "<path_to_json>/foldered_commands.json")
# We can add multiple registries, and do not need the foldered commands
aitpi.addRegistry("<path_to_json>/another_reg.json")
# Once we initialize our system, all interrupt based commands can be sent imediately.
# Therefore, make sure you are ready to handle any input in your functions before calling this.
aitpi.initInput("<path_to_json>/example_input.json")
# For synchronous input (not interrupt based) using the 'key_input' input mechanism is desireable
# You can setup a custom progromatic form of input using this (If it is good enough, add it to AITPI!)
while (True):
aitpi.takeInput(input())
FAQs
A tool to setup arbitrary button configurations
We found that aitpi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.