// Path: src/com/ezio/multiwii/helpers/LowPassFilter.java
// public class LowPassFilter {
// 	/*
// 	 * time smoothing constant for low-pass filter 0 ≤ alpha ≤ 1 ; a smaller
// 	 * value basically means more smoothing See: http://en.wikipedia.org/wiki
// 	 * /Low-pass_filter#Discrete-time_realization
// 	 */
// 	float ALPHA = 0f;
// 	float lastOutput = 0;
// 
// 	public LowPassFilter(float ALPHA) {
// 		this.ALPHA = ALPHA;
// 	}
// 
// 	public float lowPass(float input) {
// 		if (Math.abs(input - lastOutput) > 170) {
// 			lastOutput = input;
// 			return lastOutput;
// 		}
// 		lastOutput = lastOutput + ALPHA * (input - lastOutput);
// 		return lastOutput;
// 	}
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import com.ezio.multiwii.R;
import com.ezio.multiwii.helpers.LowPassFilter;
		// MUST CALL THIS
		setMeasuredDimension(width, height);

	}

	// Scale and keep aspect ratio
	static public Bitmap scaleToFill(Bitmap b, int width, int height) {
		float factorH = height / (float) b.getWidth();
		float factorW = width / (float) b.getWidth();
		float factorToUse = (factorH > factorW) ? factorW : factorH;
		return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), true);
	}

	// Scale and keep aspect ratio
	static public Bitmap scaleToFill(Bitmap b, float factorToUse) {
		return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), true);
	}

	float getFactor(Bitmap b, int width, int height) {
		float factorH = height / (float) b.getWidth();
		float factorW = width / (float) b.getWidth();
		float factorToUse = (factorH > factorW) ? factorW : factorH;
		return factorToUse;
	}

	public static int map(int x, int in_min, int in_max, int out_min, int out_max) {
		return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
	}

	public static float map(float x, float in_min, float in_max, float out_min, float out_max) {
// Path: src/com/ezio/multiwii/helpers/LowPassFilter.java
// public class LowPassFilter {
// 	/*
// 	 * time smoothing constant for low-pass filter 0 ≤ alpha ≤ 1 ; a smaller
// 	 * value basically means more smoothing See: http://en.wikipedia.org/wiki
// 	 * /Low-pass_filter#Discrete-time_realization
// 	 */
// 	float ALPHA = 0f;
// 	float lastOutput = 0;
// 
// 	public LowPassFilter(float ALPHA) {
// 		this.ALPHA = ALPHA;
// 	}
// 
// 	public float lowPass(float input) {
// 		if (Math.abs(input - lastOutput) > 170) {
// 			lastOutput = input;
// 			return lastOutput;
// 		}
// 		lastOutput = lastOutput + ALPHA * (input - lastOutput);
// 		return lastOutput;
// 	}
// }


// Path: src/com/ezio/multiwii/dashboard/dashboard3/VarioView.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import com.ezio.multiwii.R;
import com.ezio.multiwii.helpers.LowPassFilter;

		// MUST CALL THIS
		setMeasuredDimension(width, height);

	}

	// Scale and keep aspect ratio
	static public Bitmap scaleToFill(Bitmap b, int width, int height) {
		float factorH = height / (float) b.getWidth();
		float factorW = width / (float) b.getWidth();
		float factorToUse = (factorH > factorW) ? factorW : factorH;
		return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), true);
	}

	// Scale and keep aspect ratio
	static public Bitmap scaleToFill(Bitmap b, float factorToUse) {
		return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), true);
	}

	float getFactor(Bitmap b, int width, int height) {
		float factorH = height / (float) b.getWidth();
		float factorW = width / (float) b.getWidth();
		float factorToUse = (factorH > factorW) ? factorW : factorH;
		return factorToUse;
	}

	public static int map(int x, int in_min, int in_max, int out_min, int out_max) {
		return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
	}

	public static float map(float x, float in_min, float in_max, float out_min, float out_max) {
		return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;