@@ -532,69 +532,79 @@ AxesBitmap HangprinterKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool di
532532// Write the parameters to a file, returning true if success
533533bool HangprinterKinematics::WriteCalibrationParameters (FileStore *f) const noexcept
534534{
535- bool ok = f->Write (" ; Hangprinter parameters\n " );
536- if (ok)
535+ bool ok = false ;
536+ String<255 > scratchString;
537+
538+ scratchString.printf (" ; Hangprinter parameters\n " );
539+ scratchString.printf (" M669 K6 " );
540+ ok = f->Write (scratchString.c_str ());
541+ if (!ok) return false ;
542+
543+ for (size_t i = 0 ; i < HANGPRINTER_AXES; ++i)
537544 {
538- String<100 > scratchString;
539- scratchString.printf (" M669 K6 A%.3f:%.3f:%.3f B%.3f:%.3f:%.3f" ,
540- (double )anchors[A_AXIS][X_AXIS], (double )anchors[A_AXIS][Y_AXIS], (double )anchors[A_AXIS][Z_AXIS],
541- (double )anchors[B_AXIS][X_AXIS], (double )anchors[B_AXIS][Y_AXIS], (double )anchors[B_AXIS][Z_AXIS]);
542- ok = f->Write (scratchString.c_str ());
543- if (ok)
544- {
545- scratchString.printf (" C%.3f:%.3f:%.3f D%.3f:%.3f:%.3f P%.1f\n " ,
546- (double )anchors[C_AXIS][X_AXIS], (double )anchors[C_AXIS][Y_AXIS], (double )anchors[C_AXIS][Z_AXIS],
547- (double )anchors[D_AXIS][X_AXIS], (double )anchors[D_AXIS][Y_AXIS], (double )anchors[D_AXIS][Z_AXIS],
548- (double )printRadius);
549- ok = f->Write (scratchString.c_str ());
550- if (ok)
551- {
552- scratchString.printf (" M666 Q%.6f R%.3f:%.3f:%.3f:%.3f U%d:%d:%d:%d" ,
553- (double )spoolBuildupFactor, (double )spoolRadii[A_AXIS],
554- (double )spoolRadii[B_AXIS], (double )spoolRadii[C_AXIS], (double )spoolRadii[D_AXIS],
555- (int )mechanicalAdvantage[A_AXIS], (int )mechanicalAdvantage[B_AXIS],
556- (int )mechanicalAdvantage[C_AXIS], (int )mechanicalAdvantage[D_AXIS]
557- );
558- ok = f->Write (scratchString.c_str ());
559- if (ok)
560- {
561- scratchString.printf (" O%d:%d:%d:%d L%d:%d:%d:%d H%d:%d:%d:%d J%d:%d:%d:%d" ,
562- (int )linesPerSpool[A_AXIS], (int )linesPerSpool[B_AXIS],
563- (int )linesPerSpool[C_AXIS], (int )linesPerSpool[D_AXIS],
564- (int )motorGearTeeth[A_AXIS], (int )motorGearTeeth[B_AXIS],
565- (int )motorGearTeeth[C_AXIS], (int )motorGearTeeth[D_AXIS],
566- (int )spoolGearTeeth[A_AXIS], (int )spoolGearTeeth[B_AXIS],
567- (int )spoolGearTeeth[C_AXIS], (int )spoolGearTeeth[D_AXIS],
568- (int )fullStepsPerMotorRev[A_AXIS], (int )fullStepsPerMotorRev[B_AXIS],
569- (int )fullStepsPerMotorRev[C_AXIS], (int )fullStepsPerMotorRev[D_AXIS]
570- );
571- ok = f->Write (scratchString.c_str ());
572- if (ok)
573- {
574- scratchString.printf (" W%.2f S%.2f I%.1f:%.1f:%.1f:%.1f X%.1f:%.1f:%.1f:%.1f" ,
575- (double )moverWeight_kg, (double )springKPerUnitLength,
576- (double )minPlannedForce_Newton[A_AXIS], (double )minPlannedForce_Newton[B_AXIS],
577- (double )minPlannedForce_Newton[C_AXIS], (double )minPlannedForce_Newton[D_AXIS],
578- (double )maxPlannedForce_Newton[A_AXIS], (double )maxPlannedForce_Newton[B_AXIS],
579- (double )maxPlannedForce_Newton[C_AXIS], (double )maxPlannedForce_Newton[D_AXIS]
580- );
581- ok = f->Write (scratchString.c_str ());
582- if (ok)
583- {
584- scratchString.printf (" Y%.1f:%.1f:%.1f:%.1f T%.1f C%.4f:%.4f:%.4f:%.4f\n " ,
585- (double )guyWireLengths[A_AXIS], (double )guyWireLengths[B_AXIS],
586- (double )guyWireLengths[C_AXIS], (double )guyWireLengths[D_AXIS],
587- (double )targetForce_Newton,
588- (double )torqueConstants[A_AXIS], (double )torqueConstants[B_AXIS],
589- (double )torqueConstants[C_AXIS], (double )torqueConstants[D_AXIS]
590- );
591- ok = f->Write (scratchString.c_str ());
592- }
593- }
594- }
595- }
596- }
545+ scratchString.catf (" %c%.3f:%.3f:%.3f " , ANCHOR_CHARS[i], (double )anchors[i][X_AXIS], (double )anchors[i][Y_AXIS], (double )anchors[i][Z_AXIS]);
597546 }
547+ ok = f->Write (scratchString.c_str ());
548+ if (!ok) return false ;
549+
550+ scratchString.printf (" P%.1f" , (double )printRadius);
551+ ok = f->Write (scratchString.c_str ());
552+ if (!ok) return false ;
553+
554+ scratchString.printf (" M666 Q%.6f " , (double )spoolBuildupFactor);
555+ ok = f->Write (scratchString.c_str ());
556+ if (!ok) return false ;
557+
558+ scratchString.printf (" R%.3f:%.3f:%.3f:%.3f" , (double )spoolRadii[A_AXIS], (double )spoolRadii[B_AXIS], (double )spoolRadii[C_AXIS], (double )spoolRadii[D_AXIS]);
559+ ok = f->Write (scratchString.c_str ());
560+ if (!ok) return false ;
561+
562+ scratchString.printf (" U%d:%d:%d:%d" , (int )mechanicalAdvantage[A_AXIS], (int )mechanicalAdvantage[B_AXIS], (int )mechanicalAdvantage[C_AXIS], (int )mechanicalAdvantage[D_AXIS]);
563+ ok = f->Write (scratchString.c_str ());
564+ if (!ok) return false ;
565+
566+ scratchString.printf (" O%d:%d:%d:%d" , (int )linesPerSpool[A_AXIS], (int )linesPerSpool[B_AXIS], (int )linesPerSpool[C_AXIS], (int )linesPerSpool[D_AXIS]);
567+ ok = f->Write (scratchString.c_str ());
568+ if (!ok) return false ;
569+
570+ scratchString.printf (" L%d:%d:%d:%d" , (int )motorGearTeeth[A_AXIS], (int )motorGearTeeth[B_AXIS], (int )motorGearTeeth[C_AXIS], (int )motorGearTeeth[D_AXIS]);
571+ ok = f->Write (scratchString.c_str ());
572+ if (!ok) return false ;
573+
574+ scratchString.printf (" H%d:%d:%d:%d" , (int )motorGearTeeth[A_AXIS], (int )motorGearTeeth[B_AXIS], (int )motorGearTeeth[C_AXIS], (int )motorGearTeeth[D_AXIS]);
575+ ok = f->Write (scratchString.c_str ());
576+ if (!ok) return false ;
577+
578+ scratchString.printf (" J%d:%d:%d:%d" , (int )fullStepsPerMotorRev[A_AXIS], (int )fullStepsPerMotorRev[B_AXIS], (int )fullStepsPerMotorRev[C_AXIS], (int )fullStepsPerMotorRev[D_AXIS]);
579+ ok = f->Write (scratchString.c_str ());
580+ if (!ok) return false ;
581+
582+ scratchString.printf (" W%.2f S%.2f" , (double )moverWeight_kg, (double )springKPerUnitLength);
583+ ok = f->Write (scratchString.c_str ());
584+ if (!ok) return false ;
585+
586+ scratchString.printf (" I%.1f:%.1f:%.1f:%.1f" ,
587+ (double )minPlannedForce_Newton[A_AXIS], (double )minPlannedForce_Newton[B_AXIS], (double )minPlannedForce_Newton[C_AXIS], (double )minPlannedForce_Newton[D_AXIS]);
588+ ok = f->Write (scratchString.c_str ());
589+ if (!ok) return false ;
590+
591+ scratchString.printf (" X%.1f:%.1f:%.1f:%.1f" ,
592+ (double )maxPlannedForce_Newton[A_AXIS], (double )maxPlannedForce_Newton[B_AXIS], (double )maxPlannedForce_Newton[C_AXIS], (double )maxPlannedForce_Newton[D_AXIS]);
593+ ok = f->Write (scratchString.c_str ());
594+ if (!ok) return false ;
595+
596+ scratchString.printf (" Y%.1f:%.1f:%.1f:%.1f" ,
597+ (double )guyWireLengths[A_AXIS], (double )guyWireLengths[B_AXIS], (double )guyWireLengths[C_AXIS], (double )guyWireLengths[D_AXIS]);
598+ ok = f->Write (scratchString.c_str ());
599+ if (!ok) return false ;
600+
601+ scratchString.printf (" T%.1f" , (double )targetForce_Newton);
602+ ok = f->Write (scratchString.c_str ());
603+ if (!ok) return false ;
604+
605+ scratchString.printf (" C%.4f:%.4f:%.4f:%.4f\n " , (double )torqueConstants[A_AXIS], (double )torqueConstants[B_AXIS], (double )torqueConstants[C_AXIS], (double )torqueConstants[D_AXIS]);
606+ ok = f->Write (scratchString.c_str ());
607+
598608 return ok;
599609}
600610
0 commit comments