Skip to content

Commit

Permalink
Make rssi-algo more realistic
Browse files Browse the repository at this point in the history
  • Loading branch information
cmorty committed Jul 10, 2015
1 parent f69fbdc commit 6db0d05
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class Edge {

static DecimalFormat fm = new DecimalFormat("0.00");


private double rssi2d(double rssi) {
return Math.pow(10d, (-rssi) / (10 * 2)) / 100;
}

public double len(GraphPanel.Elength el) {
double orssi = rssi_min;
double olqi = lqi_min;
Expand All @@ -146,9 +151,9 @@ public double len(GraphPanel.Elength el) {
}
switch (el) {
case RSSI:
return (100*100)/(-(rssi + orssi) / 2);
return rssi2d ((rssi + orssi)/ 2);
case RSSI_min:
return (100*100)/(-Math.max(rssi, orssi));
return rssi2d(Math.max(rssi, orssi));
case LQI:
return (100*100)/((lqi + olqi) / 2);
case LQI_min:
Expand Down Expand Up @@ -474,6 +479,7 @@ void relax() {
double len = Math.sqrt(vx * vx + vy * vy);
len = (len == 0) ? .0001 : len;
double f = (e.len(view) * scale / 10 - len) / (len * 3);
System.out.println("LEn: " + e.len(view));
double dx = f * vx;
double dy = f * vy;
// I-Regler
Expand Down

0 comments on commit 6db0d05

Please sign in to comment.