|
reprappro firmware: getting probe values into a spreadsheet February 10, 2016 12:11AM |
Registered: 11 years ago Posts: 280 |
|
Re: reprappro firmware: getting probe values into a spreadsheet February 10, 2016 02:20AM |
Registered: 12 years ago Posts: 1,159 |
|
Re: reprappro firmware: getting probe values into a spreadsheet February 10, 2016 02:42AM |
Registered: 12 years ago Posts: 14,691 |
|
Re: reprappro firmware: getting probe values into a spreadsheet February 10, 2016 05:35AM |
Registered: 13 years ago Posts: 735 |
import System.Random
xyRange :: Int
xyRange = 96
xyInc :: Int
xyInc = 12
radiusSq :: Int
radiusSq = 124*124
speed :: Int
speed = 90*60
height :: Int
height = 14
probeCmd :: String
probeCmd = "G30 S-1"
main :: IO ()
main = mkBgn >> go (shuffle 0 points)
where
go [] = return ()
go ((x,y):rest) =
if x*x + y*y > radiusSq then go rest else do
putStrLn $ mkG0 x y
putStrLn probeCmd
go rest
mkBgn = mapM_ putStrLn
[ "G28"
, "G0 X0 Y0 Z" ++ show height ++ " F" ++ show speed ]
mkG0 x y =
showString "G1 X" $ shows x $ showString " Y" $ shows y $ showString " Z" $ show height
points :: [(Int,Int)]
points =
let range = [0-xyRange, xyInc-xyRange .. xyRange] in
concat $ map (\r -> zip range (repeat r)) range
shuffle :: Int -> [a] -> [a]
shuffle seed lst =
let ll = length lst in
if ll < 2 then lst else
pick lst $ mkRandomSeq (ll-1) (randomRs (0, ll-1) $ mkStdGen seed) ll
pick :: [a] -> [Int] -> [a]
pick rv@[] _ = rv
pick rv@[_] _ = rv
pick _ [] = undefined
pick lst (p:ps) =
let (prefix, x:sufix) = splitAt p lst in
x : pick (prefix ++ sufix) ps
mkRandomSeq :: Int -> [Int] -> Int -> [Int]
mkRandomSeq maxRandomNumber randomNumbers rvLength = go randomNumbers rvLength
where
go [] _ = []
go _ 0 = []
go (r:rs) cnt =
let upperLimit = cnt * ((maxRandomNumber+1) `div` cnt) in
if r >= upperLimit then go rs cnt else
(r `rem` cnt) : go rs (cnt-1)
|
Re: reprappro firmware: getting probe values into a spreadsheet February 10, 2016 06:27PM |
Registered: 11 years ago Posts: 280 |
|
Re: reprappro firmware: getting probe values into a spreadsheet February 11, 2016 02:54AM |
Registered: 12 years ago Posts: 14,691 |