mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
AndroidGCS Tuning: Finish the SmartSave utility
This commit is contained in:
parent
71d5f9d090
commit
e9effa593d
@ -41,6 +41,7 @@ public class TuningActivity extends ObjectManagerActivity {
|
|||||||
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.pitchRateKi), "PitchRatePID", 1);
|
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.pitchRateKi), "PitchRatePID", 1);
|
||||||
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.rollKp), "RollPI", 0);
|
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.rollKp), "RollPI", 0);
|
||||||
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.pitchKp), "PitchPI", 0);
|
smartSave.addControlMapping((ScrollBarView) findViewById(R.id.pitchKp), "PitchPI", 0);
|
||||||
|
smartSave.refreshSettingsDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import android.widget.Button;
|
|||||||
public class SmartSave {
|
public class SmartSave {
|
||||||
|
|
||||||
private final static String TAG = SmartSave.class.getSimpleName();
|
private final static String TAG = SmartSave.class.getSimpleName();
|
||||||
|
private final static boolean DEBUG = false;
|
||||||
|
|
||||||
//! Create a smart save button attached to the object manager and an apply and ave button
|
//! Create a smart save button attached to the object manager and an apply and ave button
|
||||||
public SmartSave(UAVObjectManager objMngr, UAVObject obj, Button saveButton, Button applyButton) {
|
public SmartSave(UAVObjectManager objMngr, UAVObject obj, Button saveButton, Button applyButton) {
|
||||||
@ -102,6 +103,8 @@ public class SmartSave {
|
|||||||
|
|
||||||
//! Update the settings in the UI from the mappings
|
//! Update the settings in the UI from the mappings
|
||||||
public void refreshSettingsDisplay() {
|
public void refreshSettingsDisplay() {
|
||||||
|
if (DEBUG) Log.d(TAG, "Refreshing display");
|
||||||
|
|
||||||
Set<ObjectFieldMappable> keys = controlFieldMapping.keySet();
|
Set<ObjectFieldMappable> keys = controlFieldMapping.keySet();
|
||||||
Iterator<ObjectFieldMappable> iter = keys.iterator();
|
Iterator<ObjectFieldMappable> iter = keys.iterator();
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
@ -135,10 +138,12 @@ public class SmartSave {
|
|||||||
persistence.addUpdatedObserver(ObjectPersistenceUpdated);
|
persistence.addUpdatedObserver(ObjectPersistenceUpdated);
|
||||||
|
|
||||||
// 3. Send save operation
|
// 3. Send save operation
|
||||||
obj.getField("ObjectID").setValue(obj.getObjID());
|
Long objId = obj.getObjID();
|
||||||
obj.getField("Operation").setValue("Save");
|
if (DEBUG) Log.d(TAG, "Saving object ID: " + objId);
|
||||||
obj.getField("Selection").setValue("SingleObject");
|
persistence.getField("ObjectID").setValue(objId);
|
||||||
obj.updated();
|
persistence.getField("Operation").setValue("Save");
|
||||||
|
persistence.getField("Selection").setValue("SingleObject");
|
||||||
|
persistence.updated();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -196,6 +201,8 @@ public class SmartSave {
|
|||||||
|
|
||||||
//! Get the value from the UAVO field
|
//! Get the value from the UAVO field
|
||||||
double getValue(UAVObject obj) {
|
double getValue(UAVObject obj) {
|
||||||
|
double val = obj.getField(fieldName).getDouble(fieldIndex);
|
||||||
|
if (DEBUG) Log.d(TAG, "Getting value from: " + fieldName + " " + val);
|
||||||
return obj.getField(fieldName).getDouble(fieldIndex);
|
return obj.getField(fieldName).getDouble(fieldIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +217,7 @@ public class SmartSave {
|
|||||||
private final Observer ApplyCompleted = new Observer() {
|
private final Observer ApplyCompleted = new Observer() {
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable observable, Object data) {
|
public void update(Observable observable, Object data) {
|
||||||
Log.d(TAG, "Apply called");
|
if (DEBUG) Log.d(TAG, "Apply called");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -218,7 +225,7 @@ public class SmartSave {
|
|||||||
private final Observer ObjectUpdated = new Observer() {
|
private final Observer ObjectUpdated = new Observer() {
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable observable, Object data) {
|
public void update(Observable observable, Object data) {
|
||||||
Log.d(TAG, "Object updated");
|
if (DEBUG) Log.d(TAG, "Object updated");
|
||||||
refreshSettingsDisplay();
|
refreshSettingsDisplay();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -227,7 +234,7 @@ public class SmartSave {
|
|||||||
private final Observer ObjectPersistenceUpdated = new Observer() {
|
private final Observer ObjectPersistenceUpdated = new Observer() {
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable observable, Object data) {
|
public void update(Observable observable, Object data) {
|
||||||
Log.d(TAG, "Object persistence updated");
|
if (DEBUG) Log.d(TAG, "Object persistence updated");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,5 +253,4 @@ public class SmartSave {
|
|||||||
//! Handle to the UAVO this class works with
|
//! Handle to the UAVO this class works with
|
||||||
private final UAVObject obj;
|
private final UAVObject obj;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user