def get_raw_value(self, percentage): """ Takes a percentage value and returns the corresponding raw PPM signal value. """ percentage = clamp(percentage, -100, 100) if percentage < 0: return int(interpolate(percentage, -100, 0, self._min, self._center)) else: return int(interpolate(percentage, 0, 100, self._center, self._max))
def get_charge(self, raw_value): """ Returns the given raw value as a percentage. 100 = full 0 = empty """ return int(interpolate(raw_value, self._empty, self._full, 0, 100))
def scale_axis_value(self, value, axis): """ Scales the given value for the given axis to a number from -1 to 1 for the stick, and 0 to 1 for the throttle. """ range = None low, high = -1.0, 1.0 if axis == X_AXIS: range = self.x_range elif axis == Y_AXIS: range = self.y_range elif axis == T_AXIS: range = self.t_range low = 0.0 return interpolate(value, range.low, range.high, low, high)