kopia lustrzana https://github.com/ge0rg/aprsdroid
hack to store the smart beaconing log over time
rodzic
f5acfc8a8c
commit
163340e712
|
@ -12,6 +12,7 @@
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
||||||
<uses-library android:name="com.google.android.maps" />
|
<uses-library android:name="com.google.android.maps" />
|
||||||
|
|
|
@ -207,6 +207,15 @@ class AprsService extends Service with LocationListener {
|
||||||
((SB_SLOW_RATE - SB_FAST_RATE) * (SB_FAST_SPEED - speed) / (SB_FAST_SPEED-SB_SLOW_SPEED)).toInt
|
((SB_SLOW_RATE - SB_FAST_RATE) * (SB_FAST_SPEED - speed) / (SB_FAST_SPEED-SB_SLOW_SPEED)).toInt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def LogF(s : String) {
|
||||||
|
import java.io._
|
||||||
|
val path = android.os.Environment.getExternalStorageDirectory()
|
||||||
|
Log.d(TAG, s)
|
||||||
|
val f = new FileWriter(new File(path, "aprsdroid.log"), true)
|
||||||
|
f.write("%s\n".format(s))
|
||||||
|
f.close()
|
||||||
|
}
|
||||||
|
|
||||||
// returns the angle between two bearings
|
// returns the angle between two bearings
|
||||||
def getBearingAngle(alpha : Float, beta : Float) : Float = {
|
def getBearingAngle(alpha : Float, beta : Float) : Float = {
|
||||||
val delta = math.abs(alpha-beta)%360
|
val delta = math.abs(alpha-beta)%360
|
||||||
|
@ -230,7 +239,7 @@ class AprsService extends Service with LocationListener {
|
||||||
// threshold depends on slope/speed [mph]
|
// threshold depends on slope/speed [mph]
|
||||||
val threshold = SB_TURN_MIN + SB_TURN_SLOPE/(getSpeed(location)*2.23693629)
|
val threshold = SB_TURN_MIN + SB_TURN_SLOPE/(getSpeed(location)*2.23693629)
|
||||||
|
|
||||||
Log.d(TAG, "smartBeaconCornerPeg: %1.0f < %1.0f %d/%d".format(turn, threshold,
|
LogF("smartBeaconCornerPeg: %1.0f < %1.0f %d/%d".format(turn, threshold,
|
||||||
t_diff/1000, SB_TURN_TIME))
|
t_diff/1000, SB_TURN_TIME))
|
||||||
// need to corner peg if turn time reached and turn > threshold
|
// need to corner peg if turn time reached and turn > threshold
|
||||||
(t_diff/1000 >= SB_TURN_TIME && turn > threshold)
|
(t_diff/1000 >= SB_TURN_TIME && turn > threshold)
|
||||||
|
@ -247,7 +256,7 @@ class AprsService extends Service with LocationListener {
|
||||||
val speed = getSpeed(location)
|
val speed = getSpeed(location)
|
||||||
//if (location.hasSpeed && location.hasBearing)
|
//if (location.hasSpeed && location.hasBearing)
|
||||||
val speed_rate = smartBeaconSpeedRate(speed)
|
val speed_rate = smartBeaconSpeedRate(speed)
|
||||||
Log.d(TAG, "smartBeaconCheck: %1.0fm, %1.2fm/s -> %d/%ds - %s".format(dist, speed,
|
LogF("smartBeaconCheck: %1.0fm, %1.2fm/s -> %d/%ds - %s".format(dist, speed,
|
||||||
t_diff/1000, speed_rate, (t_diff/1000 >= speed_rate).toString))
|
t_diff/1000, speed_rate, (t_diff/1000 >= speed_rate).toString))
|
||||||
if (t_diff/1000 >= speed_rate)
|
if (t_diff/1000 >= speed_rate)
|
||||||
true
|
true
|
||||||
|
@ -259,8 +268,6 @@ class AprsService extends Service with LocationListener {
|
||||||
override def onLocationChanged(location : Location) {
|
override def onLocationChanged(location : Location) {
|
||||||
val upd_int = prefs.getStringInt("interval", 10) * 60000
|
val upd_int = prefs.getStringInt("interval", 10) * 60000
|
||||||
val upd_dist = prefs.getStringInt("distance", 10) * 1000
|
val upd_dist = prefs.getStringInt("distance", 10) * 1000
|
||||||
//Log.d(TAG, "onLocationChanged: n=" + location)
|
|
||||||
//Log.d(TAG, "onLocationChanged: l=" + lastLoc)
|
|
||||||
if (/* smart beaconing == */ true) {
|
if (/* smart beaconing == */ true) {
|
||||||
if (!smartBeaconCheck(location))
|
if (!smartBeaconCheck(location))
|
||||||
return
|
return
|
||||||
|
|
Ładowanie…
Reference in New Issue