Page 1 of 2

Button set and apply in screeneditor

Posted: Fri Nov 01, 2019 8:32 pm
by 4minnovations
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.

Re: Button set and apply in screeneditor

Posted: Fri Nov 01, 2019 9:19 pm
by TomKerekes
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

Re: Button set and apply in screeneditor

Posted: Tue Nov 05, 2019 4:00 pm
by 4minnovations
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.

Re: Button set and apply in screeneditor

Posted: Tue Nov 05, 2019 4:07 pm
by 4minnovations
Hi Tom,

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

Re: Button set and apply in screeneditor

Posted: Tue Nov 05, 2019 6:28 pm
by TomKerekes
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


Re: Button set and apply in screeneditor

Posted: Wed Nov 06, 2019 2:16 pm
by 4minnovations
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.

Re: Button set and apply in screeneditor

Posted: Wed Nov 06, 2019 5:41 pm
by TomKerekes
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);
}

Re: Button set and apply in screeneditor

Posted: Wed Nov 06, 2019 6:02 pm
by 4minnovations
Thank you so much.

Re: Button set and apply in screeneditor

Posted: Wed Nov 06, 2019 6:50 pm
by 4minnovations
Where I can initialise my things before the screen appear?

Re: Button set and apply in screeneditor

Posted: Wed Nov 06, 2019 7:48 pm
by TomKerekes
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