init
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.feemers.android.fftdrawer"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.feemers.android.fftdrawer", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.feemers.android.fftdrawer">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
|
||||
public interface Animation {
|
||||
void Draw(Canvas canvas);
|
||||
void SetBackgroundColor(int c);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
public class Bar {
|
||||
private float value;
|
||||
private int harmonics;
|
||||
private float frequency;
|
||||
private final int color;
|
||||
|
||||
public Bar(float value, int harmonics) {
|
||||
this.value = value;
|
||||
this.harmonics = harmonics;
|
||||
color = Color.rgb(0,255,0);
|
||||
}
|
||||
|
||||
public float getValue(){
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getHarmonics() {
|
||||
return harmonics;
|
||||
}
|
||||
|
||||
public int getColor(){
|
||||
return color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BarChart implements Animation {
|
||||
|
||||
private final int length;
|
||||
private ArrayList<Bar> bars = null;
|
||||
|
||||
private Paint paint;
|
||||
private int backgroundColor;
|
||||
|
||||
public BarChart(int length){
|
||||
this.length = length;
|
||||
bars = new ArrayList<>();
|
||||
|
||||
paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
backgroundColor = Color.rgb(0,0,0);
|
||||
}
|
||||
|
||||
public void newValues(double[] values){
|
||||
bars.clear();
|
||||
for(int i = 0; i < length; i++){
|
||||
float tmp = (float) values[i];
|
||||
bars.add(new Bar(tmp, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Draw(Canvas canvas) {
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
canvas.drawColor(backgroundColor);
|
||||
// find max
|
||||
float maxValue = 0;
|
||||
for(Bar b : bars){
|
||||
maxValue = maxValue >= b.getValue() ? maxValue : b.getValue();
|
||||
}
|
||||
for(Bar b : bars){
|
||||
paint.setColor(b.getColor());
|
||||
float width = canvas.getWidth();
|
||||
float heigth = canvas.getHeight();
|
||||
float widthOfBar = width / length;
|
||||
|
||||
float left= b.getHarmonics() * widthOfBar;
|
||||
float top = heigth - heigth * b.getValue() / maxValue;
|
||||
float rigth = (b.getHarmonics()+1) * widthOfBar;
|
||||
float buttom = heigth;
|
||||
|
||||
canvas.drawRect(left, top, rigth ,buttom, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetBackgroundColor(int c) {
|
||||
backgroundColor = c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
public class BarChartView extends SurfaceView implements Runnable {
|
||||
|
||||
private Animation animation;
|
||||
private SurfaceHolder surfaceHolder;
|
||||
private Thread thread = null;
|
||||
private volatile boolean running = false;
|
||||
private int backgroudColor = 0;
|
||||
private String name = "";
|
||||
private int sleepTime = 0;
|
||||
private volatile boolean update;
|
||||
|
||||
|
||||
public BarChartView(Context context) {
|
||||
super(context);
|
||||
surfaceHolder = getHolder();
|
||||
}
|
||||
public BarChartView(Context context, AttributeSet attributeSet){
|
||||
super(context, attributeSet);
|
||||
surfaceHolder = getHolder();
|
||||
ReadXML(attributeSet);
|
||||
}
|
||||
private void ReadXML(AttributeSet attributeSet){
|
||||
android.content.res.TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.BarChartView);
|
||||
//String s = typedArray.getString(R.styleable.GrafikView_android_text);
|
||||
//name = (s!=null) ? s : "";
|
||||
backgroudColor = typedArray.getColor(R.styleable.BarChartView_backgroundColor, Color.BLACK);
|
||||
typedArray.recycle();
|
||||
log(", hintergrundFarbe=" + backgroudColor);
|
||||
}
|
||||
|
||||
public void setAnimation(Animation animation){
|
||||
this.animation = animation;
|
||||
this.animation.SetBackgroundColor(backgroudColor);
|
||||
}
|
||||
|
||||
private void log(String s) {
|
||||
Log.d(this.getClass().getSimpleName(), s);
|
||||
}
|
||||
|
||||
public void Start(){
|
||||
running = true;
|
||||
thread = new Thread(this);
|
||||
thread.start();
|
||||
log("Thread started");
|
||||
}
|
||||
|
||||
public void Stop(){
|
||||
running = false;
|
||||
while(true){
|
||||
try{
|
||||
thread.join();
|
||||
log("Thread stopped");
|
||||
break;
|
||||
}catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Draw(){
|
||||
update = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running) {
|
||||
if (update) {
|
||||
if (!surfaceHolder.getSurface().isValid()) {
|
||||
continue;
|
||||
}
|
||||
Canvas canvas = surfaceHolder.lockCanvas();
|
||||
if (animation != null) {
|
||||
animation.Draw(canvas);
|
||||
update = false;
|
||||
}
|
||||
surfaceHolder.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import com.feemers.android.fftdrawer.SignalProcessing.DetectorTimedomain;
|
||||
import com.feemers.android.fftdrawer.SignalProcessing.Logger;
|
||||
import com.feemers.android.fftdrawer.SignalProcessing.SignalProcessingControl;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements Observer {
|
||||
private TextView textView1;
|
||||
private BarChartView grafikView1;
|
||||
private TextView textView2;
|
||||
private BarChartView grafikView2;
|
||||
private SignalProcessingControl signalProcessingControl;
|
||||
private DetectorTimedomain detectorTimedomain;
|
||||
private SensorManager sensorManager;
|
||||
private BarChart barChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
textView1 = findViewById(R.id.textView1);
|
||||
textView1.setText("Nr.1 ");
|
||||
textView2 = findViewById(R.id.textView2);
|
||||
textView2.setText("Nr. 2");
|
||||
|
||||
|
||||
double[] test = new double[64];
|
||||
for (int i = 0; i < 64; i++){
|
||||
test[i] = 0;
|
||||
}
|
||||
|
||||
barChart = new BarChart(64);
|
||||
barChart.newValues(test);
|
||||
|
||||
grafikView1 = findViewById(R.id.graficView1);
|
||||
grafikView1.setAnimation(barChart);
|
||||
grafikView2 = findViewById(R.id.graficView2);
|
||||
grafikView2.setAnimation(new BarChart(64));
|
||||
|
||||
Logger logger = new Logger(this.getClass().getSimpleName(), "");
|
||||
detectorTimedomain = new DetectorTimedomain(20);
|
||||
detectorTimedomain.setThreshold(12);
|
||||
|
||||
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
||||
signalProcessingControl = new SignalProcessingControl(sensorManager, logger);
|
||||
signalProcessingControl.init();
|
||||
|
||||
signalProcessingControl.getNotifier().addObserver(this);
|
||||
signalProcessingControl.start();
|
||||
|
||||
|
||||
grafikView1.Start();
|
||||
grafikView2.Start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
double[] newData = signalProcessingControl.getNotifier().getData();
|
||||
barChart.newValues(newData);
|
||||
grafikView1.Draw();
|
||||
grafikView2.Draw();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
/******************************************************************************
|
||||
* Compilation: javac Complex.java
|
||||
* Execution: java Complex
|
||||
*
|
||||
* Data type for complex numbers.
|
||||
*
|
||||
* The data type is "immutable" so once you create and initialize
|
||||
* a Complex object, you cannot change it. The "final" keyword
|
||||
* when declaring re and im enforces this rule, making it a
|
||||
* compile-time error to change the .re or .im instance variables after
|
||||
* they've been initialized.
|
||||
*
|
||||
* % java Complex
|
||||
* a = 5.0 + 6.0i
|
||||
* b = -3.0 + 4.0i
|
||||
* Re(a) = 5.0
|
||||
* Im(a) = 6.0
|
||||
* b + a = 2.0 + 10.0i
|
||||
* a - b = 8.0 + 2.0i
|
||||
* a * b = -39.0 + 2.0i
|
||||
* b * a = -39.0 + 2.0i
|
||||
* a / b = 0.36 - 1.52i
|
||||
* (a / b) * b = 5.0 + 6.0i
|
||||
* conj(a) = 5.0 - 6.0i
|
||||
* |a| = 7.810249675906654
|
||||
* tan(a) = -6.685231390246571E-6 + 1.0000103108981198i
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
public class Complex {
|
||||
private final double re; // the real part
|
||||
private final double im; // the imaginary part
|
||||
|
||||
// create a new object with the given real and imaginary parts
|
||||
public Complex(double real, double imag) {
|
||||
re = real;
|
||||
im = imag;
|
||||
}
|
||||
|
||||
// return a string representation of the invoking Complex object
|
||||
public String toString() {
|
||||
if (im == 0) return re + "";
|
||||
if (re == 0) return im + "i";
|
||||
if (im < 0) return re + " - " + (-im) + "i";
|
||||
return re + " + " + im + "i";
|
||||
}
|
||||
|
||||
// return abs/modulus/magnitude
|
||||
public double abs() {
|
||||
return Math.hypot(re, im);
|
||||
}
|
||||
|
||||
// return angle/phase/argument, normalized to be between -pi and pi
|
||||
public double phase() {
|
||||
return Math.atan2(im, re);
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is (this + b)
|
||||
public Complex plus(Complex b) {
|
||||
Complex a = this; // invoking object
|
||||
double real = a.re + b.re;
|
||||
double imag = a.im + b.im;
|
||||
return new Complex(real, imag);
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is (this - b)
|
||||
public Complex minus(Complex b) {
|
||||
Complex a = this;
|
||||
double real = a.re - b.re;
|
||||
double imag = a.im - b.im;
|
||||
return new Complex(real, imag);
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is (this * b)
|
||||
public Complex times(Complex b) {
|
||||
Complex a = this;
|
||||
double real = a.re * b.re - a.im * b.im;
|
||||
double imag = a.re * b.im + a.im * b.re;
|
||||
return new Complex(real, imag);
|
||||
}
|
||||
|
||||
// return a new object whose value is (this * alpha)
|
||||
public Complex scale(double alpha) {
|
||||
return new Complex(alpha * re, alpha * im);
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the conjugate of this
|
||||
public Complex conjugate() {
|
||||
return new Complex(re, -im);
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the reciprocal of this
|
||||
public Complex reciprocal() {
|
||||
double scale = re*re + im*im;
|
||||
return new Complex(re / scale, -im / scale);
|
||||
}
|
||||
|
||||
// return the real or imaginary part
|
||||
public double re() { return re; }
|
||||
public double im() { return im; }
|
||||
|
||||
// return a / b
|
||||
public Complex divides(Complex b) {
|
||||
Complex a = this;
|
||||
return a.times(b.reciprocal());
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the complex exponential of this
|
||||
public Complex exp() {
|
||||
return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the complex sine of this
|
||||
public Complex sin() {
|
||||
return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im));
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the complex cosine of this
|
||||
public Complex cos() {
|
||||
return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im));
|
||||
}
|
||||
|
||||
// return a new Complex object whose value is the complex tangent of this
|
||||
public Complex tan() {
|
||||
return sin().divides(cos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// a static version of plus
|
||||
public static Complex plus(Complex a, Complex b) {
|
||||
double real = a.re + b.re;
|
||||
double imag = a.im + b.im;
|
||||
Complex sum = new Complex(real, imag);
|
||||
return sum;
|
||||
}
|
||||
|
||||
// See Section 3.3.
|
||||
public boolean equals(Object x) {
|
||||
if (x == null) return false;
|
||||
if (this.getClass() != x.getClass()) return false;
|
||||
Complex that = (Complex) x;
|
||||
return (this.re == that.re) && (this.im == that.im);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class DetectorImpl implements IDetector {
|
||||
protected ArrayList<Double> m_buffer;
|
||||
protected int m_buffer_SIZE; //TODO: Make this this dependent to the sampleRate
|
||||
protected double m_sampleRate;
|
||||
protected ThresholdCalculator m_thresholdCalculator;
|
||||
protected double m_threshold;
|
||||
protected Notifier m_Notifier;
|
||||
|
||||
public DetectorImpl(int windowSize)
|
||||
{
|
||||
m_buffer = new ArrayList<>();
|
||||
m_buffer_SIZE = 128; //TODO later: Change this hardcoded value and calculate it during runtime -> depending on sampleRate
|
||||
m_sampleRate = 0;
|
||||
m_thresholdCalculator = new ThresholdCalculator(windowSize);
|
||||
m_threshold = m_thresholdCalculator.getThreshold();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewSample(double sample) {
|
||||
m_thresholdCalculator.onNewSample(sample);
|
||||
m_threshold = m_thresholdCalculator.getThreshold();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSampleRate(double sampleRate) {
|
||||
m_sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreshold(double threshold) {
|
||||
// Call this to set the constant part of the threshold determined by the user
|
||||
m_thresholdCalculator.setConstantThresholdPart(threshold);
|
||||
}
|
||||
|
||||
public void connectNotifier(Notifier notifier){
|
||||
if(notifier == null){
|
||||
throw new AssertionError("Notifier is null");
|
||||
}
|
||||
m_Notifier = notifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DetectorTimedomain extends DetectorImpl {
|
||||
private boolean m_calculate_amplitude;
|
||||
private int m_threshold_cnt;
|
||||
private int m_sample_cnt;
|
||||
|
||||
public DetectorTimedomain(int windowSize) {
|
||||
super(windowSize);
|
||||
Log.d("DetectorTimedomain", "DetectorTimedomain() - Constructor called");
|
||||
m_calculate_amplitude = false;
|
||||
m_threshold_cnt = 0;
|
||||
m_sample_cnt = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewSample(double sample) {
|
||||
super.onNewSample(sample);
|
||||
check_for_earthquake(sample);
|
||||
}
|
||||
|
||||
public void check_for_earthquake(double sample)
|
||||
{
|
||||
// This method checks if threshold was exceeded and calculates the amplitude if enough values are available
|
||||
// Possible combinitions of the return values:
|
||||
// 1: false, 0.0 -> Threshold wasn't exceeded
|
||||
// 2: true, 0.0 -> Threshold was exceeded, but no value for amplitude is available yet (because m_buffer isn't filled yet)
|
||||
// 3: true, amplitude -> Threshold was exceeded and a value for amplitude is available
|
||||
//TODO: find better solution for returning the results -> temp solution: No return-values but printing to logcat instead. Use Notifier later.
|
||||
|
||||
Pair<Boolean, Double> return_pair = new Pair<Boolean, Double>(false, 0.0);
|
||||
if ((sample > m_threshold) && !(m_calculate_amplitude)) {
|
||||
Log.d("DetectorTimedomain", "threshold was exceeded. threshold: " + m_threshold); //TODO: send this info with notifier instead
|
||||
m_threshold_cnt++;
|
||||
// Later: add Logger entry
|
||||
m_calculate_amplitude = true;
|
||||
m_buffer = new ArrayList<>(); //resetting to an empty ArrayList
|
||||
}
|
||||
|
||||
if (m_calculate_amplitude) {
|
||||
if (m_sample_cnt >= m_buffer_SIZE) {
|
||||
//Vector sensor_samples is filled -> determine amplitude
|
||||
double amplitude = calculate_maximum(m_buffer);
|
||||
m_sample_cnt = 0;
|
||||
m_calculate_amplitude = false;
|
||||
Log.d("DetectorTimedomain", "Maximum calculated: " + amplitude); //TODO: send this message with notifier instead
|
||||
return_pair = new Pair<Boolean, Double>(true, amplitude);
|
||||
// Later: add Logger entry
|
||||
} else {
|
||||
m_buffer.add(sample);
|
||||
m_sample_cnt++;
|
||||
return_pair = new Pair<Boolean, Double>(true, 0.0);
|
||||
}
|
||||
}
|
||||
m_Notifier.sendEvent();
|
||||
//return return_pair;
|
||||
}
|
||||
|
||||
private double calculate_maximum(ArrayList<Double> samples) {
|
||||
double maximum = 0;
|
||||
for (double sample : samples) {
|
||||
if (maximum < sample)
|
||||
maximum = sample;
|
||||
}
|
||||
return maximum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Compilation: javac FFT.java
|
||||
* Execution: java FFT n
|
||||
* Dependencies: Complex.java
|
||||
*
|
||||
* Compute the FFT and inverse FFT of a length n complex sequence
|
||||
* using the radix 2 Cooley-Tukey algorithm.
|
||||
|
||||
* Bare bones implementation that runs in O(n log n) time and O(n)
|
||||
* space. Our goal is to optimize the clarity of the code, rather
|
||||
* than performance.
|
||||
*
|
||||
* This implementation uses the primitive root of unity w = e^(-2 pi i / n).
|
||||
* Some resources use w = e^(2 pi i / n).
|
||||
*
|
||||
* Reference: https://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/05DivideAndConquerII.pdf
|
||||
*
|
||||
* Limitations
|
||||
* -----------
|
||||
* - assumes n is a power of 2
|
||||
*
|
||||
* - not the most memory efficient algorithm (because it uses
|
||||
* an object type for representing complex numbers and because
|
||||
* it re-allocates memory for the subarray, instead of doing
|
||||
* in-place or reusing a single temporary array)
|
||||
*
|
||||
* For an in-place radix 2 Cooley-Tukey FFT, see
|
||||
* https://introcs.cs.princeton.edu/java/97data/InplaceFFT.java.html
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
public class FFT {
|
||||
|
||||
// compute the FFT of x[], assuming its length n is a power of 2
|
||||
public static Complex[] fft(Complex[] x) {
|
||||
int n = x.length;
|
||||
|
||||
// base case
|
||||
if (n == 1) return new Complex[] { x[0] };
|
||||
|
||||
// radix 2 Cooley-Tukey FFT
|
||||
if (n % 2 != 0) {
|
||||
throw new IllegalArgumentException("n is not a power of 2");
|
||||
}
|
||||
|
||||
// compute FFT of even terms
|
||||
Complex[] even = new Complex[n/2];
|
||||
for (int k = 0; k < n/2; k++) {
|
||||
even[k] = x[2*k];
|
||||
}
|
||||
Complex[] evenFFT = fft(even);
|
||||
|
||||
// compute FFT of odd terms
|
||||
Complex[] odd = even; // reuse the array (to avoid n log n space)
|
||||
for (int k = 0; k < n/2; k++) {
|
||||
odd[k] = x[2*k + 1];
|
||||
}
|
||||
Complex[] oddFFT = fft(odd);
|
||||
|
||||
// combine
|
||||
Complex[] y = new Complex[n];
|
||||
for (int k = 0; k < n/2; k++) {
|
||||
double kth = -2 * k * Math.PI / n;
|
||||
Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
|
||||
y[k] = evenFFT[k].plus (wk.times(oddFFT[k]));
|
||||
y[k + n/2] = evenFFT[k].minus(wk.times(oddFFT[k]));
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
// compute the inverse FFT of x[], assuming its length n is a power of 2
|
||||
public static Complex[] ifft(Complex[] x) {
|
||||
int n = x.length;
|
||||
Complex[] y = new Complex[n];
|
||||
|
||||
// take conjugate
|
||||
for (int i = 0; i < n; i++) {
|
||||
y[i] = x[i].conjugate();
|
||||
}
|
||||
|
||||
// compute forward FFT
|
||||
y = fft(y);
|
||||
|
||||
// take conjugate again
|
||||
for (int i = 0; i < n; i++) {
|
||||
y[i] = y[i].conjugate();
|
||||
}
|
||||
|
||||
// divide by n
|
||||
for (int i = 0; i < n; i++) {
|
||||
y[i] = y[i].scale(1.0 / n);
|
||||
}
|
||||
|
||||
return y;
|
||||
|
||||
}
|
||||
|
||||
// compute the circular convolution of x and y
|
||||
public static Complex[] cconvolve(Complex[] x, Complex[] y) {
|
||||
|
||||
// should probably pad x and y with 0s so that they have same length
|
||||
// and are powers of 2
|
||||
if (x.length != y.length) {
|
||||
throw new IllegalArgumentException("Dimensions don't agree");
|
||||
}
|
||||
|
||||
int n = x.length;
|
||||
|
||||
// compute FFT of each sequence
|
||||
Complex[] a = fft(x);
|
||||
Complex[] b = fft(y);
|
||||
|
||||
// point-wise multiply
|
||||
Complex[] c = new Complex[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
c[i] = a[i].times(b[i]);
|
||||
}
|
||||
|
||||
// compute inverse FFT
|
||||
return ifft(c);
|
||||
}
|
||||
|
||||
|
||||
// compute the linear convolution of x and y
|
||||
public static Complex[] convolve(Complex[] x, Complex[] y) {
|
||||
Complex ZERO = new Complex(0, 0);
|
||||
|
||||
Complex[] a = new Complex[2*x.length];
|
||||
for (int i = 0; i < x.length; i++) a[i] = x[i];
|
||||
for (int i = x.length; i < 2*x.length; i++) a[i] = ZERO;
|
||||
|
||||
Complex[] b = new Complex[2*y.length];
|
||||
for (int i = 0; i < y.length; i++) b[i] = y[i];
|
||||
for (int i = y.length; i < 2*y.length; i++) b[i] = ZERO;
|
||||
|
||||
return cconvolve(a, b);
|
||||
}
|
||||
|
||||
// compute the DFT of x[] via brute force (n^2 time)
|
||||
public static Complex[] dft(Complex[] x) {
|
||||
int n = x.length;
|
||||
Complex ZERO = new Complex(0, 0);
|
||||
Complex[] y = new Complex[n];
|
||||
for (int k = 0; k < n; k++) {
|
||||
y[k] = ZERO;
|
||||
for (int j = 0; j < n; j++) {
|
||||
int power = (k * j) % n;
|
||||
double kth = -2 * power * Math.PI / n;
|
||||
Complex wkj = new Complex(Math.cos(kth), Math.sin(kth));
|
||||
y[k] = y[k].plus(x[j].times(wkj));
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Test client and sample execution
|
||||
*
|
||||
* % java FFT 4
|
||||
* x
|
||||
* -------------------
|
||||
* -0.03480425839330703
|
||||
* 0.07910192950176387
|
||||
* 0.7233322451735928
|
||||
* 0.1659819820667019
|
||||
*
|
||||
* y = fft(x)
|
||||
* -------------------
|
||||
* 0.9336118983487516
|
||||
* -0.7581365035668999 + 0.08688005256493803i
|
||||
* 0.44344407521182005
|
||||
* -0.7581365035668999 - 0.08688005256493803i
|
||||
*
|
||||
* z = ifft(y)
|
||||
* -------------------
|
||||
* -0.03480425839330703
|
||||
* 0.07910192950176387 + 2.6599344570851287E-18i
|
||||
* 0.7233322451735928
|
||||
* 0.1659819820667019 - 2.6599344570851287E-18i
|
||||
*
|
||||
* c = cconvolve(x, x)
|
||||
* -------------------
|
||||
* 0.5506798633981853
|
||||
* 0.23461407150576394 - 4.033186818023279E-18i
|
||||
* -0.016542951108772352
|
||||
* 0.10288019294318276 + 4.033186818023279E-18i
|
||||
*
|
||||
* d = convolve(x, x)
|
||||
* -------------------
|
||||
* 0.001211336402308083 - 3.122502256758253E-17i
|
||||
* -0.005506167987577068 - 5.058885073636224E-17i
|
||||
* -0.044092969479563274 + 2.1934338938072244E-18i
|
||||
* 0.10288019294318276 - 3.6147323062478115E-17i
|
||||
* 0.5494685269958772 + 3.122502256758253E-17i
|
||||
* 0.240120239493341 + 4.655566391833896E-17i
|
||||
* 0.02755001837079092 - 2.1934338938072244E-18i
|
||||
* 4.01805098805014E-17i
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
public interface IDetector {
|
||||
public void onNewSample(double sample);
|
||||
public void setSampleRate(double sampleRate);
|
||||
public void setThreshold(double threshold);
|
||||
public void connectNotifier(Notifier notifier);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
public interface ISensor {
|
||||
public double getSampleRate();
|
||||
|
||||
public void connectDetector(IDetector detector);
|
||||
|
||||
public void startSampling();
|
||||
|
||||
public void stopSampling();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
private TextView textView;
|
||||
private StringBuffer sb = new StringBuffer();
|
||||
private String tag;
|
||||
private Activity activity;
|
||||
|
||||
public Logger(String tag, String logInitText)
|
||||
{
|
||||
this.activity = null;
|
||||
this.tag = tag;
|
||||
sb.append(logInitText);
|
||||
}
|
||||
|
||||
public Logger(Activity activity, String tag, TextView textView, String logInitText)
|
||||
{
|
||||
this.activity = activity;
|
||||
this.tag = tag;
|
||||
this.textView = textView;
|
||||
sb.append(logInitText);
|
||||
}
|
||||
|
||||
public void log(String s)
|
||||
{
|
||||
Log.d(tag, s);
|
||||
sb.append(s).append("\n");
|
||||
if (textView != null)
|
||||
{
|
||||
if(activity !=null)
|
||||
{
|
||||
activity.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
textView.setText(sb.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
textView.setText(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Exception e)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
log(sw.toString());
|
||||
}
|
||||
|
||||
public void clearLog()
|
||||
{
|
||||
sb.setLength(0);
|
||||
if (textView != null)
|
||||
{
|
||||
textView.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
public String getLoggedText()
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class MySensor extends SensorImpl implements SensorEventListener {
|
||||
private SensorManager sensorManager;
|
||||
private Sensor m_sensor;
|
||||
private int sensorType = Sensor.TYPE_ACCELEROMETER;
|
||||
private long time_former_value;
|
||||
private long time_current_value;
|
||||
|
||||
private int sample_cnt;
|
||||
|
||||
public MySensor()
|
||||
{
|
||||
m_sensor = null;
|
||||
time_former_value = 0;
|
||||
time_current_value = 0;
|
||||
sample_cnt = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
//Log.d("MySensor","onSensorChanged()\n");
|
||||
|
||||
// Calculating the sample rate
|
||||
time_current_value = System.currentTimeMillis();
|
||||
long period = time_current_value - time_former_value;
|
||||
if ((time_former_value != 0) && (period != 0)) {
|
||||
m_sampleRate = (double) (1.0 / period) * 1000.0; // in Hz
|
||||
m_detector.setSampleRate(m_sampleRate);
|
||||
}
|
||||
|
||||
/*if (sample_cnt == 100) //TODO: Delete this part before final use (inc. sample_cnt) -> only meant for debugging
|
||||
{
|
||||
Log.d("MySensor", "m_sampleRate:" + m_sampleRate + "\n");
|
||||
Log.d("MySensor", "time_current_value:" + time_current_value + "\n");
|
||||
Log.d("MySensor", "time_former_value:" + time_former_value + "\n");
|
||||
Log.d("MySensor", "currentTimeMillis:" + System.currentTimeMillis() + "\n");
|
||||
Log.d("MySensor", "period:" + period + "\n");
|
||||
sample_cnt = 0;
|
||||
}*/
|
||||
|
||||
time_former_value = time_current_value;
|
||||
// Calculating the acceleration
|
||||
double acceleration = (Math.sqrt(event.values[0] * event.values[0] + event.values[1] * (event.values[1] + event.values[2] * event.values[2]))) - 9.81;
|
||||
m_detector.onNewSample(acceleration);
|
||||
sample_cnt++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
Log.d("MySensor","onAccuracyChanged()\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSampleRate() {
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSampling() {
|
||||
if (m_sensor != null) {
|
||||
if (sensorManager.registerListener(this, m_sensor, SensorManager.SENSOR_DELAY_GAME)) {
|
||||
Log.d("MySensor", "Bei Sensor angemeldet.\n");
|
||||
} else {
|
||||
Log.d("MySensor", "Kann dem Sensor keinen Beobachter hinzufügen\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSampling() {
|
||||
if (m_sensor != null) {
|
||||
sensorManager.unregisterListener(this, m_sensor);
|
||||
Log.d("MySensor","Von Sensor abgemeldet.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void connectSensorManager(SensorManager sensorManager){
|
||||
this.sensorManager = sensorManager;
|
||||
if (sensorManager.getSensorList(sensorType).size() == 0) {
|
||||
Log.d("MySensor", "Es gibt den Sensor nicht.\n");
|
||||
m_sensor = null;
|
||||
} else {
|
||||
m_sensor = sensorManager.getSensorList(sensorType).get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
public class Notifier extends Observable {
|
||||
private double[] data;
|
||||
|
||||
public Notifier(){
|
||||
|
||||
}
|
||||
public void sendEvent(){
|
||||
Log.d("Hi", "sendEvent: Test");
|
||||
}
|
||||
|
||||
public void onNewFFTData(double[] data){
|
||||
this.data = data;
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
public double[] getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
public class SensorFake extends SensorImpl {
|
||||
@Override
|
||||
public double getSampleRate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSampling() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSampling() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
public abstract class SensorImpl implements ISensor {
|
||||
protected IDetector m_detector;
|
||||
protected double m_sampleRate;
|
||||
|
||||
public SensorImpl()
|
||||
{
|
||||
m_detector = null;
|
||||
m_sampleRate = 0;
|
||||
}
|
||||
|
||||
public void connectDetector(IDetector detector){
|
||||
if(detector == null){
|
||||
throw new AssertionError("detector == null");
|
||||
}
|
||||
m_detector = detector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
import android.hardware.SensorManager;
|
||||
|
||||
import java.util.Observer;
|
||||
|
||||
|
||||
public class SignalProcessingControl {
|
||||
private IDetector detector;
|
||||
private ISensor sensor;
|
||||
private Notifier notifier;
|
||||
private Logger logger;
|
||||
|
||||
public SignalProcessingControl(SensorManager sensorManager, Logger logger) {
|
||||
this.logger = logger;
|
||||
logger.log("SignalProcessingControl()");
|
||||
|
||||
// create notifier
|
||||
notifier = new Notifier();
|
||||
|
||||
// create detector
|
||||
//detector = new DetectorTimedomain(20);
|
||||
detector = new DetectorFFT(20);
|
||||
detector.setThreshold(6); //TODO: Remove hardcoded threshold and read from GUI instead
|
||||
detector.connectNotifier(notifier);
|
||||
|
||||
// create & link hardware to sensor -> sensorManager
|
||||
MySensor mySensor = new MySensor();
|
||||
mySensor.connectSensorManager(sensorManager);
|
||||
this.sensor = mySensor;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
logger.log("SignalProcessingControl: init()");
|
||||
sensor.connectDetector(detector);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
logger.log("SignalProcessingControl: start()");
|
||||
sensor.startSampling();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
logger.log("SignalProcessingControl: stop()");
|
||||
sensor.stopSampling();
|
||||
}
|
||||
|
||||
public Notifier getNotifier() {
|
||||
return notifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.feemers.android.fftdrawer.SignalProcessing;
|
||||
|
||||
class ThresholdCalculator {
|
||||
private double[] m_buffer;
|
||||
private int m_windowSize;
|
||||
private int m_bufferCounter;
|
||||
private int m_bufferInitCounter;
|
||||
private double m_constantThresholdPart;
|
||||
private double m_adaptiveThresholdPart;
|
||||
|
||||
public ThresholdCalculator(int windowSize) {
|
||||
if (windowSize <= 0) {
|
||||
throw new AssertionError("windowSize should be postive");
|
||||
}
|
||||
m_windowSize = windowSize;
|
||||
reset();
|
||||
}
|
||||
|
||||
public double getThreshold() {
|
||||
// This method is meant for the use inside of a detector implementation
|
||||
// Should be called every time a new sensor value is available
|
||||
// Returns the sum of the constant part of the threshold (determined by the user) and the
|
||||
// adaptive part of the threshold (determined by the noise level of the signal)
|
||||
return m_constantThresholdPart + m_adaptiveThresholdPart;
|
||||
}
|
||||
|
||||
public void setConstantThresholdPart(double constantThresholdPart) {
|
||||
// This method should be called when the User changes the constant part of the threshold with the GUI
|
||||
this.m_constantThresholdPart = constantThresholdPart;
|
||||
}
|
||||
|
||||
public void onNewSample(double sample) {
|
||||
// store sample
|
||||
m_buffer[m_bufferCounter] = sample;
|
||||
// increase counter
|
||||
m_bufferCounter++;
|
||||
// check if we are on the end of Array -> go to start
|
||||
if (m_bufferCounter >= m_windowSize) {
|
||||
m_bufferCounter = 0;
|
||||
}
|
||||
|
||||
// when we start the application we will have an arry with emty values
|
||||
// hence we define how many values are already new
|
||||
// after N_sample == windowSize this will have no further effect
|
||||
if (m_bufferInitCounter < m_windowSize) {
|
||||
m_bufferInitCounter++;
|
||||
}
|
||||
|
||||
// now calculate Mean
|
||||
double absMean = 0;
|
||||
for (int i = 0; i < m_bufferInitCounter; i++) {
|
||||
double sampleVal = m_buffer[i];
|
||||
absMean += Math.sqrt(sampleVal * sampleVal);
|
||||
}
|
||||
m_adaptiveThresholdPart = absMean / m_bufferInitCounter;
|
||||
}
|
||||
|
||||
// for reset this class reset
|
||||
public void reset() {
|
||||
m_bufferCounter = 0;
|
||||
m_bufferInitCounter = 0;
|
||||
m_buffer = new double[m_windowSize];
|
||||
for (int i = 0; i < m_windowSize; i++) {
|
||||
m_buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:mynamespace="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity"
|
||||
android:orientation="vertical"
|
||||
tools:activity=".MainActivity">
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.feemers.android.fftdrawer.BarChartView
|
||||
android:id="@+id/graficView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
mynamespace:backgroundColor="#4C614C"/>
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.feemers.android.fftdrawer.BarChartView
|
||||
android:id="@+id/graficView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
mynamespace:backgroundColor="#75455E"/>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="BarChartView">
|
||||
<attr name="backgroundColor" format="color"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">FFTDrawer</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.feemers.android.fftdrawer;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||