Created
May 7, 2018 19:59
-
-
Save phpfiddle/d3b482a343eb16de23fbaa03ddd1cdee to your computer and use it in GitHub Desktop.
[ Posted by Sebastian ] BedLeveling Function BED_LEVELING_METHOD == 1 of Repetier in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The code from http://php.net/manual/en/imagick.examples-1.php | |
* | |
* Make sure only using PHP builtin fonts(http://php.net/manual/en/haru.builtin.fonts.php) | |
* | |
* @package PhpFiddle | |
* @link http://phpfiddle.org | |
* @since 2012 | |
**/ | |
/* Set width and height in proportion of genuine PHP logo */ | |
$width = 410; | |
$height = 410; | |
/* Create an Imagick object with transparent canvas */ | |
$img = new Imagick(); | |
$img->newImage($width, $height, new ImagickPixel('transparent')); | |
/* New ImagickDraw instance for ellipse draw */ | |
$draw = new ImagickDraw(); | |
/* Set purple fill color for ellipse */ | |
$draw->setFillColor('#777bb4'); | |
$draw->setStrokeWidth(2); | |
$draw->setFontSize(72); | |
$draw->rectangle(10, 10, 300, 300); | |
$img->drawImage($draw); | |
$draw->setFillColor('red'); | |
$draw->setStrokeWidth(1); | |
$draw->line(11,11,11,301); | |
$draw->line(11,299,299,299); | |
$img->drawImage($draw); | |
$draw->setStrokeColor('white'); | |
$draw->setStrokeWidth(1); | |
$delta = 10; | |
for ($i = 0; $i < 30; $i++) { | |
for ($j = 0; $j < 30; $j++) { | |
$x = 11 + $i * $delta; | |
$y = 11 + $j * $delta; | |
$draw->line($x, $y, $x++,$y++); | |
} | |
} | |
$draw->setStrokeColor('pink'); | |
$draw->setStrokeWidth(2); | |
$img->drawImage($draw); | |
$zx1 = 30; | |
$zy1 = 30; | |
$zx2 = 30; | |
$zy2 = 170; | |
$zx3 = 170; | |
$zy3 = 170; | |
$zxmirr = 170; | |
$zymirr = 30; | |
$zxmax = 170; | |
$zymax = 170; | |
$BED_LEVELING_GRID_SIZE = 4; | |
$delta = 1.0 / ($BED_LEVELING_GRID_SIZE - 1); | |
$ox = $zx1; | |
$oy = $zy1; | |
$ax = $delta * ($zx2 - $zx1); | |
$ay = $delta * ($zy2 - $zy1); | |
$bx = $delta * ($zx3 - $zx1); | |
$by = $delta * ($zy3 - $zy1); | |
$draw->setStrokeColor('green'); | |
$draw->setFillColor('green'); | |
$draw->setStrokeWidth(2); | |
//$draw->circle(40, 40, 41,41); | |
//$img->drawImage($draw); | |
for($ix = 0; $ix < $BED_LEVELING_GRID_SIZE; $ix++) { | |
for($iy = 0; $iy < $BED_LEVELING_GRID_SIZE; $iy++) { | |
$px = $ox + $ix * $ax + $iy * $bx; | |
$py = $oy + $ix * $ay + $iy * $by; | |
$draw->setStrokeColor('green'); | |
$draw->setFillColor('green'); | |
$draw->setStrokeWidth(2); | |
$draw->circle($px, $py, $px+2,$py); | |
$img->drawImage($draw); | |
// echo '<font color=red>'.$px . '</font> ,<font color=blue> ' . $py . '</font><br/>'; | |
// $draw->line($px, $py, $px++,$py++); | |
//Printer::moveTo(px, py, IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed()); | |
//float h = Printer::runZProbe(false, false); | |
//if(h == ILLEGAL_Z_PROBE) | |
// return false; | |
//builder.addPoint(px, py, h); | |
} | |
} | |
$draw->setStrokeColor('white'); | |
$draw->setFillColor('white'); | |
$draw->setStrokeWidth(2); | |
$draw->circle($zx1, $zy1, $zx1+2,$zy1); | |
$draw->setStrokeColor('white'); | |
$draw->setFillColor('white'); | |
$draw->setStrokeWidth(2); | |
$draw->circle($zx2, $zy2, $zx2+2,$zy2); | |
$draw->setStrokeColor('white'); | |
$draw->setFillColor('white'); | |
$draw->setStrokeWidth(2); | |
$draw->circle($zx3, $zy3, $zx3+2,$zy3); | |
$draw->setStrokeColor('#FF00FF'); | |
$draw->setFillColor('#FF00FF'); | |
$draw->setStrokeWidth(2); | |
$draw->circle($zxmirr, $zymirr, $zxmirr+2,$zymirr); | |
$img->drawImage($draw); | |
/* | |
float delta = 1.0 / (BED_LEVELING_GRID_SIZE - 1); | |
float ox = EEPROM::zProbeX1(); | |
float oy = EEPROM::zProbeY1(); | |
float xmax = EEPROM::zProbeX2(); | |
float ymax = EEPROM::zProbeY3(); | |
float deltax = delta * (xmax - ox); | |
float deltay = delta * (ymax - oy); | |
for(int ix = 0; ix < BED_LEVELING_GRID_SIZE; ix++) { | |
for(int iy = 0; iy < BED_LEVELING_GRID_SIZE; iy++) { | |
float px = ox + static_cast<float>(ix) * deltax; | |
float py = oy + static_cast<float>(iy) * deltay; | |
Printer::moveTo(px, py, IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed()); | |
float h = Printer::runZProbe(false, false); | |
if(h == ILLEGAL_Z_PROBE) | |
return false; | |
builder.addPoint(px, py, h); | |
} | |
} | |
*/ | |
$img->setImageFormat('png'); | |
/* Set appropriate header for PNG and output the image */ | |
header('Content-Type: image/png'); | |
echo $img; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you can see by these computed images, bed level area is not where it should be