Skip to content

Commit

Permalink
EngineDriver - line endings revert
Browse files Browse the repository at this point in the history
  • Loading branch information
mstevetodd committed Jun 21, 2017
1 parent e6b1281 commit 66e5703
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
5 changes: 3 additions & 2 deletions assets/about_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
</head>
<h1>Engine Driver Throttle for Android</h1>
<img src="file:///android_asset/engine_driver_icon.png" height="144" width="166" style="float:left;padding:0 8px 8px 0"/>
<p>Engine Driver version 2.14-test2 includes:<br />
<p>Engine Driver version 2.14-test3 includes:<br />
request and show function labels for JMRI consists,<br />
show activeProfile on About page.
show activeProfile on About page,<br />
new preference to prevent direction change while moving.
<br /><em><a href="https://raw.githubusercontent.com/JMRI/EngineDriver/master/changelog-and-todo-list.txt" target="_blank" title="View complete EngineDriver changelog">[view complete changelog]</a></em></p>
<p>This free application can connect to a <a href="http://jmri.sourceforge.net/help/en/package/jmri/jmrit/withrottle/UserInterface.shtml" target="_blank">JMRI WiThrottle</a> server running on a computer,
or to an <a href="http://www.modelrectifier.com/category-s/332.htm" target="_blank">MRC Prodigy WiFi</a>
Expand Down
6 changes: 4 additions & 2 deletions changelog-and-todo-list.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**Version 2.14
* request and show function labels for JMRI consists - mstevetodd
* show activeProfile on About page
* show activeProfile on About page - mstevetodd
* new preference to prevent direction change while moving - flash62au
**Version 2.13
* allow app to be moved to SD card - mstevetodd
* Added selective sound routing preference for consists - Robin Becker
Expand Down Expand Up @@ -320,7 +321,7 @@
* TODO: move socket timeout values to preference
* TODO: redo hard-coded 29 in function arrays (29 is hard-coded in WiT side, so no rush)
* throttle:
* TODO: add preference to disable "Select Loco" and Direction buttons if speed > 0
* TODO: add preference to disable "Select Loco" if speed > 0
* TODO: make Stop "sticky" and ignore slider unless direction is selected
* TODO: new preference to reverse order of Forward and Reverse buttons
* TODO: send "appropriate" functions to just consist trail instead of all consist
Expand Down Expand Up @@ -350,6 +351,7 @@
* These require changes to WiThrottle
* allow setting of undefined turnouts (JMRI Turnout Tool creates them on-the-fly, so we could too)
* resend turnout and routes when items are added or removed, by adding listeners to WiT
* resend roster list when items are added or removed, by adding listeners to WiT
* support resend of function and direction commands, even when WiT knows it has already sent (may be there now)
* WiT send MT-xxx when commands are received from a client for a loco that is not active. (to get ED up to date with server after connection loss)
* add "available" roster/address list to select_loco_activity (need "in use" indicator from WiT)
Expand Down
1 change: 1 addition & 0 deletions res/values/bool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
<bool name="prefHideSliderDefaultValue">false</bool>
<bool name="prefSwipeThroughTurnoutsDefaultValue">true</bool>
<bool name="prefSwipeThroughRoutesDefaultValue">true</bool>
<bool name="prefDirChangeWhileMovingDefaultValue">true</bool>
</resources>
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
<string name="prefIncreaseSliderHeightSummary">Use a taller slider for throttles.</string>
<string name="prefHideSliderTitle">Hide Speed Slider?</string>
<string name="prefHideSliderSummary">Do not show speed slider, use speed buttons instead.</string>
<string name="prefDirChangeWhileMovingTitle">Direction change?</string>
<string name="prefDirChangeWhileMovingSummary">Allow direction change while Moving.</string>
<string name="prefNumOfThrottles">Number of throttles</string>
<string name="prefNumOfThrottlesSummary">Choose how many throttles you want to display.</string>
<string name="prefNumOfThrottlesDefault">Two</string>
Expand Down
7 changes: 7 additions & 0 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@
android:summary="@string/prefSelectiveLeadSoundSummary"
android:title="@string/prefSelectiveLeadSoundTitle" >
</CheckBoxPreference>
<CheckBoxPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="@bool/prefDirChangeWhileMovingDefaultValue"
android:key="DirChangeWhileMovingPreference"
android:summary="@string/prefDirChangeWhileMovingSummary"
android:title="@string/prefDirChangeWhileMovingTitle"></CheckBoxPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefSelectLocoTitle" >
<CheckBoxPreference
Expand Down
23 changes: 21 additions & 2 deletions src/jmri/enginedriver/throttle.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@ void speedUpdate(char whichThrottle, int speed) {
}
}

// get the current speed of the throttle
int getSpeed(char whichThrottle) {
SeekBar throttle_slider;
if (whichThrottle == 'T') {
throttle_slider = sbT;
} else if (whichThrottle == 'G') {
throttle_slider = sbG;
} else {
throttle_slider = sbS;
}
int lastSpeed = throttle_slider.getProgress();
return lastSpeed;
}

// change speed slider by scaled display unit value
int speedChange(char whichThrottle, int change) {
SeekBar throttle_slider;
Expand Down Expand Up @@ -975,15 +989,20 @@ public boolean onTouch(View v, MotionEvent event) {

private void handleAction(int action) {
String throt = Character.toString(whichThrottle);
boolean dirChangeWhileMoving = prefs.getBoolean("DirChangeWhileMovingPreference", getResources().getBoolean(R.bool.prefDirChangeWhileMovingDefaultValue));

switch (action) {
case MotionEvent.ACTION_DOWN: {
switch (this.function) {
case function_button.FORWARD:
case function_button.REVERSE: {
int dir = (function == function_button.FORWARD ? 1 : 0);
showDirectionRequest(whichThrottle, dir); // update requested direction indication
setEngineDirection(whichThrottle, dir, false); // update direction for each engine on this throttle

// don't allow direction change while moving if the preference is set
if ((dirChangeWhileMoving) || (getSpeed(whichThrottle)==0)) {
showDirectionRequest(whichThrottle, dir); // update requested direction indication
setEngineDirection(whichThrottle, dir, false); // update direction for each engine on this throttle
}
break;
}
case function_button.STOP:
Expand Down

0 comments on commit 66e5703

Please sign in to comment.