java-org.hwo/src/org/hwo/Smoother.java

57 lines
712 B
Java
Raw Normal View History

2014-07-26 01:34:58 +02:00
package org.hwo;
public class Smoother {
2016-12-12 11:34:44 +01:00
private int lastValue;
2014-07-26 01:34:58 +02:00
private int summe;
private int wert;
private int tn;
public Smoother()
{
setSumme(0);
setWert(0);
setTn(1);
}
public int cycle(int value)
{
2016-12-12 11:34:44 +01:00
lastValue = value;
2014-07-26 01:34:58 +02:00
summe += value;
wert = summe / tn;
summe -= wert;
return wert;
}
public int getSumme() {
return summe;
}
public void setSumme(int summe) {
this.summe = summe;
}
public int getWert() {
return wert;
}
public void setWert(int wert) {
2016-09-06 11:48:36 +02:00
this.setSumme( (wert * tn) - wert );
2014-07-26 01:34:58 +02:00
this.wert = wert;
}
public int getTn() {
return tn;
}
public void setTn(int tn) {
this.tn = tn;
}
2016-12-12 11:34:44 +01:00
public int getLastValue(){
return lastValue;
}
2014-07-26 01:34:58 +02:00
}