Button set and apply in screeneditor

Moderators: TomKerekes, dynomotion

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Button set and apply in screeneditor

Post by 4minnovations » Fri Nov 01, 2019 8:32 pm

Hi, I try to find where are the control for the button "set" (IDC_SetX for example) and I din't find anything about how you open a windows (Set Value) and how you change the value IDC_PosX with the new value.

Also, I try to find where are the control for the button "apply" (IDC_SpindleRateApply for example) and I didn't find anything about how you change the value.

User avatar
TomKerekes
Posts: 614
Joined: Mon Dec 04, 2017 1:49 am

Re: Button set and apply in screeneditor

Post by TomKerekes » Fri Nov 01, 2019 9:19 pm

Hi,

Those buttons basically have fixed functionality that can't be changed. You could replace them with new buttons that do something else. What exactly are you trying to do?

To bring up a numeric input box from a C Program see the example: MessageInputBox.c

To set a GCode Fixture Offset from a C Program see the example: SetFixtureX.c

To change the Spindle Speed Override from a C Program you might call DoPCFloat(PC_COMM_SET_SSO,SSO); similar as FRO is set in the example SetFROwithPot.c To change the current SSO by a factor use: PC_COMM_SET_SSO_INC instead of PC_COMM_SET_SSO.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Re: Button set and apply in screeneditor

Post by 4minnovations » Tue Nov 05, 2019 4:00 pm

Hi,

I try to make a button and a label.
When you push the button, I want a new window for enter a numerical value. When your number is enter and you push ok, I would like to enter this number in the label and I want to use it in my c program.

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Re: Button set and apply in screeneditor

Post by 4minnovations » Tue Nov 05, 2019 4:07 pm

Hi Tom,

the MessageInputBox.c make what I want, but I would like to write the value in a label.

User avatar
TomKerekes
Posts: 614
Joined: Mon Dec 04, 2017 1:49 am

Re: Button set and apply in screeneditor

Post by TomKerekes » Tue Nov 05, 2019 6:28 pm

Hi,

You might consider just using an Edit Control to enter a value instead of an Input dialog box.

See the Add Example of how to write a value to a DROLabel. See the Video here at the 13 minute mark




Another example showing instantaneous Feed Rate in a DROLabel on the screen

Regards,

Tom Kerekes
Dynomotion, Inc.

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Re: Button set and apply in screeneditor

Post by 4minnovations » Wed Nov 06, 2019 2:16 pm

Thanks Tom,
with your help I can make what I want with the button and the label.

But, how I can store the value in a "persistent" place, i.e. when I change the screen or when I rebbot, the value is kept.

User avatar
TomKerekes
Posts: 614
Joined: Mon Dec 04, 2017 1:49 am

Re: Button set and apply in screeneditor

Post by TomKerekes » Wed Nov 06, 2019 5:41 pm

Hi,

Again if you used Edit Controls they automatically persist into file <>\KMotion\Data\EditControlPersist.txt. Here is a video that included demonstrating Edit Controls




Otherwise to get persistence you would need to write the value to a PC Disk file and read the value from the PC Disk file on Initialization. See the example DiskWriteRead.c:

Code: Select all

#include "KMotionDef.h"

main()
{
    FILE *f;
    char s[256];
    double a=123.456,b=999.999,c=0.001;
    double x=0,y=0,z=0;
    int result;
    
    // write 3 comma separated values to a disk file
    f=fopen("c:\\Temp\\KFlopData.txt","wt");
    fprintf(f,"%f,%f,%f\n",a,b,c);
    fclose(f);
    
    // read them back in
    f=fopen("c:\\Temp\\KFlopData.txt","rt");
    if (!f)
    {
        printf("Unable to open file\n");
        return;
    }
    
    // read a line and convert 3 doubles
    result=fscanf(f,"%lf,%lf,%lf",&x,&y,&z);
    fclose(f);
    
    printf("# values converted = %d, x=%f, y=%f, z=%f\n",result,x,y,z);
}
Regards,

Tom Kerekes
Dynomotion, Inc.

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Re: Button set and apply in screeneditor

Post by 4minnovations » Wed Nov 06, 2019 6:02 pm

Thank you so much.

4minnovations
Posts: 15
Joined: Fri Nov 01, 2019 7:18 pm

Re: Button set and apply in screeneditor

Post by 4minnovations » Wed Nov 06, 2019 6:50 pm

Where I can initialise my things before the screen appear?

User avatar
TomKerekes
Posts: 614
Joined: Mon Dec 04, 2017 1:49 am

Re: Button set and apply in screeneditor

Post by TomKerekes » Wed Nov 06, 2019 7:48 pm

Hi,

One method is that any simple Label Control that has a Screen Script associated with it will execute the Script whenever the Screen has been loaded.

So for example here is the example DualPane3AxisCode.scr with a new DROLabel and simple Label added. The DROLabel will be initialized (to 1234) whenever the Screen Loads:
DROLabelScreenLoad.png


The DROLabel is configured as shown here:
DROLabel.png


The Label with associated Screen Script is shown here. The Program SetLabel.c will be executed whenever the screen loads. Any existing Label or hidden Label may also be used:
LabelWithScriptOnScreenLoad.png


A simple SetLabel.c program that puts 1234 into the DROLabel. Of course data could be anything from anywhere.

Code: Select all

#include "KMotionDef.h"

#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"


main()
{
	// Put it onto the Screen
	DROLabel(1000, 162, "1234");
	printf("SetLabel\n");
}
HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply