Usage - GammaGames/kano_wand GitHub Wiki
Demos available at the kano-wand-demos repo
First, you'll want to create a Shop
. It handles scanning for new wands and will return an array of wand objects. There are a few different ways to use the wands:
-
Use the wands returned by scanning
- Create a shop and start to scan, returning an array of found wands
- For each wand, call methods like
set_led
orvibrate
on the wand object - Call the
on
method with an event type ("position"
,"button"
, etc) and a callback function to process events - Call the
off
method with a callback's id (returned fromon
) to remove a callback
-
Use a custom wand class
- Create a class that inherits from
Wand
- Override the
post_connect
method in the new class to call methods and subscribe to events - Override methods (such as
on_position
oron_button
) to use the data from the wand - Pass the class to the Shop using the
wand_class
argument on creation - Start scanning, and let the program run while it uses your custom wand class
- Create a class that inherits from
-
Use a combination of the two
- Create a custom class that inherits from wand
- Add event callbacks with the
on
method - Override methods (such as
on_position
oron_button
) to process events - Remove event callbacks with the
off
method, passingcontinue_notifications=True
to prevent the notification thread from stopping
You can pass debug=True
to the Shop or set self.debug = True
in the wand to print debug messages, as well. When using the module, you should run it with sudo as it won't scan properly otherwise.