User`s manual

89 x[i+1] = i >> 6
90 y[i+1] = i & ((1 << 6) - 1)
91 end
92
93 # do the spline interpolation
94 # we do linear fits for now
95 # as we add more points, we can do something more sophisticated
96 x_deg = 2;
97 y_deg = 2;
98 # we also use a smoothing factor
99 # this trades off exact interpolation vs weighted least squares
100 # for more details, see doc at: https://github.com/kbarbary/Dierckx.jl
101 smooth_factor = 454.0;
102 spline_x1 = Spline2D(x_accel, y_accel, x1; kx=x_deg, ky=y_deg, s=smooth_factor)
103 spline_x2 = Spline2D(x_accel, y_accel, x2; kx=x_deg, ky=y_deg, s=smooth_factor)
104 spline_x3 = Spline2D(x_accel, y_accel, x3; kx=x_deg, ky=y_deg, s=smooth_factor)
105 spline_x4 = Spline2D(x_accel, y_accel, x4; kx=x_deg, ky=y_deg, s=smooth_factor)
106 spline_y1 = Spline2D(x_accel, y_accel, y1; kx=x_deg, ky=y_deg, s=smooth_factor)
107 spline_y2 = Spline2D(x_accel, y_accel, y2; kx=x_deg, ky=y_deg, s=smooth_factor)
108 spline_y3 = Spline2D(x_accel, y_accel, y3; kx=x_deg, ky=y_deg, s=smooth_factor)
109 spline_y4 = Spline2D(x_accel, y_accel, y4; kx=x_deg, ky=y_deg, s=smooth_factor)
110 x1_interp = int128(evaluate(spline_x1, x, y))
111 x2_interp = int128(evaluate(spline_x2, x, y))
112 x3_interp = int128(evaluate(spline_x3, x, y))
113 x4_interp = int128(evaluate(spline_x4, x, y))
114 y1_interp = int128(evaluate(spline_y1, x, y))
115 y2_interp = int128(evaluate(spline_y2, x, y))
116 y3_interp = int128(evaluate(spline_y3, x, y))
117 y4_interp = int128(evaluate(spline_y4, x, y))
118
119 # threshold x, y coords at appropriate values
120 # this is to guarantee we are not putting garbage into the lut
121 low_x = 0
122 low_y = 0
123 upp_x = 639
124 upp_y = 479
125 saturate!(x1_interp, low_x, upp_x)
126 saturate!(x2_interp, low_x, upp_x)
127 saturate!(x3_interp, low_x, upp_x)
128 saturate!(x4_interp, low_x, upp_x)
129 saturate!(y1_interp, low_y, upp_y)
130 saturate!(y2_interp, low_y, upp_y)
131 saturate!(y3_interp, low_y, upp_y)
132 saturate!(y4_interp, low_y, upp_y)
133
134 # compute quad_corners
218