New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set work coordinate #1004
Set work coordinate #1004
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
===========================================
+ Coverage 29.94% 30.05% +0.1%
- Complexity 995 1007 +12
===========================================
Files 140 141 +1
Lines 9807 9871 +64
Branches 895 902 +7
===========================================
+ Hits 2937 2967 +30
- Misses 6584 6616 +32
- Partials 286 288 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is really cool. I would have expected it to be a lot more complicated, nice job.
@@ -187,7 +187,12 @@ public void resetCoordinatesToZero() throws Exception { | |||
public void resetCoordinateToZero(final Axis coord) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have resetCoordinateToZero
and resetCoordinatesToZero
have default implementations which call setWorkPosition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good idea!
* | ||
* @author wwinder | ||
*/ | ||
public class GrblUtils { | ||
// Note: 5 characters of this buffer reserved for real time commands. | ||
private static final DecimalFormat decimalFormatter = new DecimalFormat("0.0000"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a constant Localization.dfs
which can be used here to make sure the decimal separator doesn't change to a comma for different regions. new DecimalFormat("0.0000", Localization.dfs);
} | ||
|
||
@Override | ||
public void setWorkPositionUsingExpression(final Axis axis, final String expression) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is really cool. I had no idea you could do something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither, google was my friend! 😄
Wicked. How complex of equations can you do? I assume it only modifies the
current WCS?
…On Tue, Apr 10, 2018, 3:19 PM Will Winder, ***@***.***> wrote:
***@***.**** approved this pull request.
Wow, this is really cool. I would have expected it to be a lot more
complicated, nice job.
------------------------------
In
ugs-core/src/com/willwinder/universalgcodesender/AbstractController.java
<#1004 (comment)>
:
> @@ -187,7 +187,12 @@ public void resetCoordinatesToZero() throws Exception {
public void resetCoordinateToZero(final Axis coord) throws Exception {
Does it make sense to have resetCoordinateToZero and
resetCoordinatesToZero have default implementations which call
setWorkPosition?
------------------------------
In ugs-core/src/com/willwinder/universalgcodesender/GrblUtils.java
<#1004 (comment)>
:
> *
* @author wwinder
*/
public class GrblUtils {
-// Note: 5 characters of this buffer reserved for real time commands.
+ private static final DecimalFormat decimalFormatter = new DecimalFormat("0.0000");
There is a constant Localization.dfs which can be used here to make sure
the decimal separator doesn't change to a comma for different regions. new
DecimalFormat("0.0000", Localization.dfs);
------------------------------
In ugs-core/src/com/willwinder/universalgcodesender/model/GUIBackend.java
<#1004 (comment)>
:
> @@ -808,7 +812,33 @@ public void sendMessageForConsole(String msg) {
//should still send! Controller probably shouldn't ever be null.
}
}
-
+
+ @OverRide
+ public void setWorkPosition(Axis axis, double position) throws Exception {
+ controller.setWorkPosition(axis, position);
+ }
+
+ @OverRide
+ public void setWorkPositionUsingExpression(final Axis axis, final String expression) throws Exception {
Wow, this is really cool. I had no idea you could do something like this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1004 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQlzDI-qonNDx3hfZXt6byOoVFa2YbUgks5tnPeogaJpZM4TOsAz>
.
|
If the expression starts with +, -, * or / the current value is inserted to the left, otherwise it evaluates whatever you put in directly. So if the axis is at 10, "+ 2" is evaluated as "10 + 2". But if you type in "2 + 2" it evaluates to 4 even though you are at 10. The scripting language is javascript so you can put whatever you want in there. I tried the |
But you could do something like "/2 -29" when you want it to be 29mm away
from the center?
…On Tue, Apr 10, 2018, 4:53 PM Will Winder, ***@***.***> wrote:
If the expression starts with +, -, * or / the current value is inserted
to the left, otherwise it evaluates whatever you put in directly.
So if the axis is at 10, "+ 2" is evaluated as "10 + 2". But if you type
in "2 + 2" it evaluates to 4 even though you are at 10.
The scripting language is javascript so you can put whatever you want in
there. I tried the << bitshift operator and it worked, you can chain them
together so if you are at 11, * 1 << 1 it evaluates as 11*1<<1 which
turns into 22.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1004 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQlzDKAdtuRCZp2SV1BHgFD3SdtG5v_pks5tnQ2DgaJpZM4TOsAz>
.
|
How can I set the current position to a negative value? It seems like it
would attempt do perform math instead.
…On Tue, Apr 10, 2018 at 3:52 PM, Will Winder ***@***.***> wrote:
If the expression starts with +, -, * or / the current value is inserted
to the left, otherwise it evaluates whatever you put in directly.
So if the axis is at 10, "+ 2" is evaluated as "10 + 2". But if you type
in "2 + 2" it evaluates to 4 even though you are at 10.
The scripting language is javascript so you can put whatever you want in
there. I tried the << bitshift operator and it worked, you can chain them
together so if you are at 11, * 1 << 1 it evaluates as 11*1<<1 which
turns into 22.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1004 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANiDSYmIubJJOc8zGk3thCi3vmMJiwnfks5tnQ2DgaJpZM4TOsAz>
.
|
@jahnj0584 it would depend on your order of operations, but I think so. Let us know, I just merged it in :) |
@flounderscore you're right, you would have to do |
@flounderscore or zero out the axis first so that the math is right. |
Any chance to make the math feature optional? All my coordinates are typically <0. |
Added functionality for setting work coordinates requested in #977.
It's also possible to use simple mathematical expressions such as the following: