Miami Mike's blog View Details
Archive for March, 2019
Posted by Miami Mike | Mar 10, 2019 @ 03:26 PM | 5,691 Views
This is an extension of a discussion that started somewhere around here. It's a mix script that will convert a horizontal output and a vertical output into a pair of outputs that are confined within the boundary of a circle. Stick input that falls outside of the circle will be clipped.
Code:
--[[ circle.lua - a mix script to confine horizontal and vertical sources within a circle. By Miami Mike, 3/10/2019 ]]
local input = {{"Horz", SOURCE}, {"Vert", SOURCE}}
local output = {"newH", "newV"}
local function run_func(X, Y)
	X = X / 1024
	Y = Y / 1024
	local angle = math.atan2(Y,  X)
 	local R = math.sqrt(X ^ 2 + Y ^ 2)
	if R > 1 then -- clip.
		R = 1
	end
	newH = R * math.cos(angle)
	newV = R * math.sin(angle)
	return 1024 * newH, 1024 * newV
end
return {input=input, output=output, run=run_func}
 
 
If you're working on a way to accomplish this without Lua then this is what you're trying to duplicate. I don't think it can be done but I could be wrong.

When monitored with the mon ch.lua Taranis X9D+ telemetry script included below, circle.lua produces an output like this when the stick is moved around, with the original output displayed on the left and the processed output displayed on the right:



To set it up:
  1. Download circle.txt, rename it to circle.lua, and store it in SCRIPTS/MIXES.
  2. Set up a model memory for testing with the horizontal and vertical stick outputs on channels 1 and 2, respectively. Leave channels 3 and 4 empty
...Continue Reading