Last active
September 25, 2020 05:18
-
-
Save luizsaluti/bf1a404a04b0f490be4e5fb2e927b0a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################## | |
######################## | |
######################## | |
# PLEASE READ THIS | |
# A newer and improved version of this filter was developed by WhiteMagic grab it at | |
# https://www.dropbox.com/s/2kdmku7tznbj42r/average_filter.py?dl=0 | |
import math | |
import time | |
import gremlin | |
from gremlin.spline import CubicSpline | |
from collections import deque | |
# Device creation | |
#new way | |
wingman = gremlin.input_devices.JoystickDecorator( | |
"Wingman", | |
"{3DC8CDC0-6AAC-11E9-8002-444553540000}", | |
"Default" | |
) | |
_threshold = 0.95 #safety measure to reach axis end | |
_last_values_x = [0] * 5 # define number of samples that will go into average (for both axes) | |
_last_values_y = [0] * 5 | |
last_values_x = deque(_last_values_x) | |
last_values_y = deque(_last_values_y) | |
curve = CubicSpline([ #the expected result here is a curve along with smoothing | |
(-1.0, -1.0), | |
(-0.74, -0.52), | |
( -0.176, -0.14), | |
( 0.176, 0.14), | |
( 0.74, 0.52), | |
( 1.0, 1.0) | |
]) | |
def averageAxis(axisval, last_values): | |
global _threshold | |
last_values.popleft() | |
last_values.append(axisval) | |
if abs(curve(axisval)) < _threshold: | |
return curve((sum(last_values) / len(last_values))) | |
else: | |
return curve(axisval) | |
@wingman.axis(1) | |
def roll(event, vjoy): | |
global last_values | |
vjoy[1].axis(1).value = averageAxis(event.value, last_values_x) | |
@wingman.axis(2) | |
def roll(event, vjoy): | |
global last_values | |
vjoy[1].axis(2).value = averageAxis(event.value, last_values_y) |
Hi @luizsaluti,
Did you ever get the attachment from hon0?
Or have a script that works in the new Gremlin?
Thanks!
Here it is! https://www.dropbox.com/s/2kdmku7tznbj42r/average_filter.py?dl=0 (Modified by WhiteMagic).
Thanks hon0!
I will point to this URL in the gist so users will find it easier
Em sex., 15 de mai. de 2020 às 03:12, danwatto <[email protected]>
escreveu:
… ***@***.**** commented on this gist.
------------------------------
Thanks hon0!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/bf1a404a04b0f490be4e5fb2e927b0a4#gistcomment-3304957>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH37MIPLFWN3X2AXH5AHARTRRTMOFANCNFSM4MDWJ57A>
.
The file was deleted, anyone have a copy?
The file was deleted, anyone have a copy?
Yep, added to my dropbox share: https://www.dropbox.com/s/4dz1ibrav2e11ci/Plugins.zip?dl=0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @luizsaluti,
Did you ever get the attachment from hon0?
Or have a script that works in the new Gremlin?
Thanks!