Added indicators to show margin to alarm for both spectral power and ratio.
This commit is contained in:
@@ -37,6 +37,7 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -50,6 +51,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
@@ -359,13 +361,35 @@ public class MainActivity extends Activity {
|
|||||||
if (mConnection.mSdServer.mSdData.batteryPc >= 40)
|
if (mConnection.mSdServer.mSdData.batteryPc >= 40)
|
||||||
tv.setBackgroundColor(okColour);
|
tv.setBackgroundColor(okColour);
|
||||||
|
|
||||||
tv = (TextView) findViewById(R.id.debugTv);
|
// Set ProgressBars to show margin to alarm.
|
||||||
String specStr = "";
|
long powerPc = mConnection.mSdServer.mSdData.roiPower * 100 /
|
||||||
for (int i = 0; i < 10; i++)
|
mConnection.mSdServer.mSdData.alarmThresh;
|
||||||
specStr = specStr
|
long specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 /
|
||||||
+ mConnection.mSdServer.mSdData.simpleSpec[i]
|
mConnection.mSdServer.mSdData.specPower) /
|
||||||
+ ", ";
|
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
||||||
tv.setText("Spec = " + specStr);
|
|
||||||
|
((TextView)findViewById(R.id.powerTv)).setText("Power = "+mConnection.mSdServer.mSdData.roiPower+
|
||||||
|
" (threshold = "+mConnection.mSdServer.mSdData.alarmThresh+")");
|
||||||
|
((TextView)findViewById(R.id.spectrumTv)).setText("Spectrum Ratio = "+10 * mConnection.mSdServer.mSdData.roiPower /
|
||||||
|
mConnection.mSdServer.mSdData.specPower+
|
||||||
|
" (threshold = "+mConnection.mSdServer.mSdData.alarmRatioThresh+")");
|
||||||
|
|
||||||
|
ProgressBar pb;
|
||||||
|
pb = ((ProgressBar)findViewById(R.id.powerProgressBar));
|
||||||
|
pb.setMax(100);
|
||||||
|
pb.setProgress((int)powerPc);
|
||||||
|
int colour = Color.BLUE;
|
||||||
|
if (powerPc>75) colour = Color.YELLOW;
|
||||||
|
if (powerPc>100) colour = Color.RED;
|
||||||
|
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
|
pb = ((ProgressBar)findViewById(R.id.spectrumProgressBar));
|
||||||
|
pb.setMax(100);
|
||||||
|
pb.setProgress((int)specPc);
|
||||||
|
colour = Color.BLUE;
|
||||||
|
if (specPc>75) colour = Color.YELLOW;
|
||||||
|
if (specPc>100) colour = Color.RED;
|
||||||
|
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
||||||
} else {
|
} else {
|
||||||
tv = (TextView) findViewById(R.id.alarmTv);
|
tv = (TextView) findViewById(R.id.alarmTv);
|
||||||
tv.setText("Not Connected to Server");
|
tv.setText("Not Connected to Server");
|
||||||
|
|||||||
@@ -87,12 +87,31 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/debugTv"
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="battTv"
|
android:text="Power"
|
||||||
/>
|
android:id="@+id/powerTv" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/powerProgressBar" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Spectal Range"
|
||||||
|
android:id="@+id/spectrumTv" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/spectrumProgressBar"
|
||||||
|
android:indeterminate="false" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -104,6 +123,6 @@
|
|||||||
android:id="@+id/chart1"
|
android:id="@+id/chart1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_above="@+id/seekBar1" />
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user