Skip to content
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

Feature request: random function for gcode macro language #4001

Closed
wavexx opened this issue Apr 5, 2020 · 3 comments · Fixed by #5219
Closed

Feature request: random function for gcode macro language #4001

wavexx opened this issue Apr 5, 2020 · 3 comments · Fixed by #5219

Comments

@wavexx
Copy link
Contributor

wavexx commented Apr 5, 2020

I'd love to have a simple no-frills implementation of rnd() for the gcode macro language, returning a random float in range 0-1. Or rnd(max) if you prefer.

I'd like to randomize the position of the purge line a bit to avoid scarring the PEI too much on the same spot. Having such a function would allow me to choose a different spot and/or direction (from left to right or vice-versa) without any additional feature.

Is this a new feature request?
Yes

@gitcnd
Copy link

gitcnd commented Oct 31, 2020

LOL - I just had the same thought - I've not tested it yet, but I did this :-

#555 = #555 + 1 ;This is a permanent variable (saved between power cycles) - add one, so our prime doesn't over-write the last prime
#555 = #555 MOD 25 ; keeps our parameter within the range 0..24
#556 = #555 + 15 ; add 15mm so I do not prime on the very edge
G1 X10 Y#556 F1500 ; move to prime
... prime code here...

I'm assuming Y#556 will tell my printer to move the Y axis to the value of the variable #556 - and I'm assuming my FFF gocde supports both permanent variables and the MOD function...

@ardenpm
Copy link
Contributor

ardenpm commented Nov 22, 2020

I've just added this and will submit a pull request soon. It will add a macro function random(min,max) which can be used to give a value in the given range, double and integer variants.

@gitcnd
Copy link

gitcnd commented Nov 22, 2020

AWESOME!! My gcode idea using permanent variables did not work out... the variables turned out not to be permanent - I guess they simply never supported that when they wrote the gcode for my Anycubic...

@bubnikv bubnikv closed this as completed in 003ccf3 Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants