https://github.com/skythecodemaster/vex-python
Various pieces of code that I use in my Vex Robotics projects
https://github.com/skythecodemaster/vex-python
Last synced: about 2 months ago
JSON representation
Various pieces of code that I use in my Vex Robotics projects
- Host: GitHub
- URL: https://github.com/skythecodemaster/vex-python
- Owner: SkyTheCodeMaster
- Created: 2021-10-27T23:42:32.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T22:11:22.000Z (over 3 years ago)
- Last Synced: 2025-02-05T18:06:48.167Z (4 months ago)
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vex-python
Various pieces of code that I use in my Vex Robotics projects# Docs
## [Event Handler](https://github.com/SkyTheCodeMaster/vex-python/blob/master/events.py)The event handler abstracts adding functions as callbacks into a simple decorator interface.
In order to use it, you must copy the `EventHandler` class into your code.
Examples:
```py
MyEvents = EventHandler(controller_1)@MyEvents.on("controllerAxis1")
def PrintAxis(pos):
print(pos)
```Event Reference
| Event Name | Argument 1 | Argument 2 |
|---------------------------------|------------|------------|
| `controllerAxis1` | `pos` | |
| `controllerAxis2` | `pos` | |
| `controllerAxis3` | `pos` | |
| `controllerAxis4` | `pos` | |
| | | |
| `controllerButtonAPressed` | | |
| `controllerButtonBPressed` | | |
| `controllerButtonXPressed` | | |
| `controllerButtonYPressed` | | |
| `controllerButtonUpPressed` | | |
| `controllerButtonDownPressed` | | |
| `controllerButtonLeftPressed` | | |
| `controllerButtonRightPressed` | | |
| `controllerButtonL1Pressed` | | |
| `controllerButtonL2Pressed` | | |
| `controllerButtonR1Pressed` | | |
| `controllerButtonR2Pressed` | | |
| | | |
| `controllerButtonAReleased` | | |
| `controllerButtonBReleased` | | |
| `controllerButtonXReleased` | | |
| `controllerButtonYReleased` | | |
| `controllerButtonUpReleased` | | |
| `controllerButtonDownReleased` | | |
| `controllerButtonLeftReleased` | | |
| `controllerButtonRightReleased` | | |
| `controllerButtonL1Released` | | |
| `controllerButtonL2Released` | | |
| `controllerButtonR1Released` | | |
| `controllerButtonR2Released` | | |
| | | |
| `screenPressed` | `x` | `y` |
| `screenReleased` | `x` | `y` |## [Loop Decorator](https://github.com/SkyTheCodeMaster/vex-python/blob/master/loop.py)
This decorator simply loops a function every X milliseconds.
Usage:
```py
@loop(50) # Argument is in milliseconds
def myLoopedFunction():
print("loop")
```
The function starts running immediately when called with the decorator, you do not need to do `myLoopedFunction()` later on in your code.