Since Lazarus is free and runs on PCs with Windows or Linux or on MACs or on 
Raspberry Pi, it's well worth the effort to learn how to write programs with it.
 
SimpleProgrammingLesson := ON;
 
You could write a command line oriented program or even supply text file with 
the parameters.  Or in Lazarus create a stock form with a menu bar and a save 
dialog component.  Place the TEdit boxes where you want and fill in the default 
text values.  I usually also change the name of the component from Edit1 to 
StartingXEdit.  Add TLabels and again using the Properties box on the side of 
the IDE enter in the captions. 
 
When I double click on the ManMeni1 I get a graphical design dialog that lets 
me set up each item I want and I can double click on that I'm taken directly to 
the code that is run when a user clicks on that menu entry.  For example 
there's a check box under options that selects metric or imperial.  The code 
converts all the fields with one of two functions I wrote called ToMetric or 
ToImperial.  So one click and all the TEdit fields are converted to metric or 
imperial including the IPM or mm/M TLAbels.
 
Same thing with the Save File.  Brings up the standard dialog so you can save 
the file (with default suffix) (.tap or .ngc) and when you click on SAVE in 
that dialog the main function that converts those parameters on the screen into 
G-Code runs.  That code could be in any language really.  It's just straight 
math and text processing and the time it takes to write that isn't really 
language dependent.
 

 
But when this program runs, on Windows it looks the same as it does on the 
MachineKit Beagle as well as LinuxCNC.  The Add Info button doesn't do anything 
but it could bring up an TMemo form where you could add pre-amble information 
unique to your machine.  
 
And so on.  If you don't like where the buttons are drag them.  Extra lines 
show up as the alignment with various objects occurs.  As a guide.
 
Beats drawing it out on graph paper and then creating each object in Python 
with the XY locations of each object.
 
Here's the code for switching between metric and imperial.  Knowing how I've 
identified each of the TEdit fields the code is almost self-documenting.  Add a 
few more fields that are dependent on metric/Imperial values and add the 
conversion in this function.
 
procedure TMakeBore_IJ_Form.MenuMetricUnitsClick(Sender: TObject);
begin
    if not MenuMetricUnits.checked then begin
       StartingXEdit.Text := ToMetric(StartingXEdit.Text);
       StartingYEdit.Text := ToMetric(StartingYEdit.Text);
       BoreDiameterEdit.Text := ToMetric(BoreDiameterEdit.Text);
       DepthPerPassEdit.Text := ToMetric(DepthPerPassEdit.Text);
       BoreDepthEdit.Text := ToMetric(BoreDepthEdit.Text);
       FeedCutWidthEdit.Text := ToMetric(FeedCutWidthEdit.Text);
       FinishCutWidthEdit.Text := ToMetric(FinishCutWidthEdit.Text);
       FeedRateEdit.Text := ToMetric(FeedRateEdit.Text);
       FeedRateLabel.Caption := '(mm/M)';
       FinishFeedRateEdit.Text := ToMetric(FinishFeedRateEdit.Text);
       FinishFeedRateLabel.Caption := '(mm/M)';
       MenuMetricUnits.checked := TRUE;
    end
    else begin
        StartingXEdit.Text := ToImperial(StartingXEdit.Text);
        StartingYEdit.Text := ToImperial(StartingYEdit.Text);
        BoreDiameterEdit.Text := ToImperial(BoreDiameterEdit.Text);
        DepthPerPassEdit.Text := ToImperial(DepthPerPassEdit.Text);
        BoreDepthEdit.Text := ToImperial(BoreDepthEdit.Text);
        FeedCutWidthEdit.Text := ToImperial(FeedCutWidthEdit.Text);
        FinishCutWidthEdit.Text := ToImperial(FinishCutWidthEdit.Text);
        FeedRateEdit.Text := ToImperial(FeedRateEdit.Text);
        FeedRateLabel.Caption := '(IPM)';
        FinishFeedRateEdit.Text := ToImperial(FinishFeedRateEdit.Text);
        FinishFeedRateLabel.Caption := '(IPM)';
        MenuMetricUnits.checked := FALSE;
    end;
end;
 
And there we have it.
SimpleProgrammingLesson := OFF;
 
John Dammeyer
 
> -----Original Message-----
> From: Jon Elson [mailto:[email protected]]
> Sent: July-15-20 7:40 PM
> To: Enhanced Machine Controller (EMC)
> Subject: Re: [Emc-users] New Spindle working.
> 
> On 07/15/2020 07:40 PM, John Dammeyer wrote:
> > After 3 decades of working with Turbo Pascal and then Delphi, Tcl/Python to 
> > me is such a step backwards it's painful to use.
> Yes, I'm with you.  I wrote some big programs in Pascal a
> LONG time ago.  The biggest one was a Gerber file to raster
> converter program.  Recently, I took that old source and
> recompiled it under FPC (Free Pascal Compiler) and got it
> running in very short order.
> 
> My experience with Pascal was that once I got the program to
> compile without errors (minor syntax and variable name
> errors) they generally worked first time, or at least came
> very close.
> 
> About 15 years ago I wrote several large GUIs to control
> data acquisition systems, using Tcl/Tk for the screen
> interface and C for the back end hardware control and
> database of settings.  The C part was very complex but
> pretty straightforward.  The Tcl part was close to a
> nightmare, due to all the quirks in Tcl.
> 
> I have recently created a few smaller GUIs with an initial
> structure set up with Glade, interfaced to a back end in C.
> Once the initial xml is set up with Glade, I then go in and
> hand-edit all the special interface options, as Glade
> doesn't seem able to go in and modify an xml file once it is
> built.  But, the xml is a much saner way to just build a GUI
> than with Tcl.
> 
> Jon
> 
> 
> _______________________________________________
> Emc-users mailing list
>  <mailto:[email protected]> [email protected]
>  <https://lists.sourceforge.net/lists/listinfo/emc-users> 
> https://lists.sourceforge.net/lists/listinfo/emc-users
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to