Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if starting:
- system.setThreadTiming(TimingTypes.HighresSystemTimer)
- system.threadExecutionInterval = 5
- def calculate_rate(max, time):
- if time > 0:
- return max / (time / system.threadExecutionInterval)
- else:
- return max
- int32_max = (2 ** 14) - 1
- int32_min = -int32_max
- v = vJoy[0]
- v.x = (int32_min) * 8
- # =============f
- # Axis inversion setting (mul): normal = 1; inverted = -1
- # =============
- global t_max, t_min, target_throttle, throttle, lowThrottle, inversion, increase_time, decrease_time
- inversion = 1
- lowThrottle = 25 # How much do you want the throttle to be pushed when holding both alt and W? (as a percentage of full throttle)
- increase_time = 150 # In milliseconds
- decrease_time = 30 # In milliseconds
- # Init values, do not change
- t_max = int32_max * inversion
- t_min = int32_min * inversion
- throttle = t_min
- global increase_rate, decrease_rate
- # Set behaviour with the increase time,
- increase_rate = calculate_rate(t_max, increase_time)
- decrease_rate = calculate_rate(t_max, decrease_time)
- # ============================
- ALT = keyboard.getKeyDown(Key.LeftAlt)
- W = keyboard.getKeyDown(Key.W)
- if W and ALT:
- target_throttle = t_max - t_max * 2 * (100 - lowThrottle) / 100
- elif W:
- target_throttle = t_max
- else:
- target_throttle = t_min
- if throttle < (target_throttle - increase_rate):
- throttle += increase_rate
- elif throttle > (target_throttle + decrease_rate):
- throttle -= decrease_rate
- else:
- throttle = target_throttle
- v.x = throttle
- #set axis x to ang
- # PIE diagnostics
- diagnostics.watch(v.x)
Advertisement
Add Comment
Please, Sign In to add comment