hello everyone,
I am working on Marlin program I made some changes for xyz prop and I do not make a definition as #define PRB_GCODE_END "G92 X-" XOFF "Y" XOFF "Z" ZOFF "\ n" to send the final xyz coordinates as gcode at the end of the promulgation procedure. is required. If anyone has any idea how to use float type variables during macro definition please help.
Hello there,
Thank you for your interest.
All operations related to String () are not allowed in Marlin software, especially when sending gcode command. However, it is only allowed to send gcode commands with macros defined by #define. In other words, it is not possible for gcode commands to be created as string () first and then sent by #define. When defining the macro, variable values should be put into this definition.
fatihcem:
it is only allowed to send gcode commands with macros defined by #define.
not clear what you mean by "#define"
#define is a C pre-processor operation that defines a symbol (e.g. MyDef(x)) with the text that #define associates it with. both the c-preprocessor directives (e.g. #define) and the symbol do not appear in the the code processed by the compiler.
#define PRB_GCODE_END "G92 X-" XOFF " Y" YOFF " Z" ZOFF "\ n"
the problem is here.
XOFF , YOFF, ZOFF is float and calculated before PRB_GCODE_END defination
and should be put as a float value into PRB_GCODE_END definition.
fatihcem:
All operations related to String () are not allowed in Marlin software, especially when sending gcode command. However, it is only allowed to send gcode commands with macros defined by #define. In other words, it is not possible for gcode commands to be created as string () first and then sent by #define. When defining the macro, variable values should be put into this definition.
I'm pretty sure this is nonsense. If it can be sent from a #defined macro, then it can more than likely be sent from a variable. Show us the prototype for the function that does the sending.
The PSTR() in this line is storing a text literal in program (flash) memory. This means that the arguments must be quoted text litetals, so you cannot use variables, and the text must be known at compile time.
fatihcem, do you have experience in a scripting language ?
The original 'C' language was written for the possibilities of the processors at that time. The assembly code for the processor can almost be seen right through the statements. The 'C++' language has very nice additions, but the compiler does not do something automatically for you. You have to tell the compiler what it should do.
Koepel:
fatihcem, do you have experience in a scripting language ?
The original 'C' language was written for the possibilities of the processors at that time. The assembly code for the processor can almost be seen right through the statements. The 'C++' language has very nice additions, but the compiler does not do something automatically for you. You have to tell the compiler what it should do.
So, have you any idea for this . how can we make a macro defination (using with #define) with variables ??
While defining PRB_GCODE_END, ensuring that float type variables are included in this definition. For example: Considering that the variables XOFF, YOFF and ZOFF are calculated as 12.85, 11.25 and 10.50 respectively. PRB_GCODE_END should occur as follows.
G92 X-12.85 Y 11.25 Z10.50 \ n
david_2018:
Note the define starts with an underscore.
yes, writing this way is not a problem. Problem: While defining PRB_GCODE_END, ensuring that float type variables are included in this definition. For example: Considering that the variables XOFF, YOFF and ZOFF are calculated as 12.85, 11.25 and 10.50 respectively. PRB_GCODE_END should occur as follows. G92 X-12.85 Y11.25 Z10.50 \n
david_2018:
Note the define starts with an underscore.
yes, writing this way is not a problem. Problem: While defining PRB_GCODE_END, ensuring that float type variables are included in this definition. For example: Considering that the variables XOFF, YOFF and ZOFF are calculated as 12.85, 11.25 and 10.50 respectively. PRB_GCODE_END should occur as follows.
fatihcem:
So, have you any idea for this . how can we make a macro defination (using with #define) with variables ??
While defining PRB_GCODE_END, ensuring that float type variables are included in this definition. For example: Considering that the variables XOFF, YOFF and ZOFF are calculated as 12.85, 11.25 and 10.50 respectively. PRB_GCODE_END should occur as follows.
G92 X-12.85 Y 11.25 Z10.50 \ n
In this case, the value of the variables must be known at compile time. The _user_gcode_exe() function takes an argument that is a text string stored in program memory, which cannot be altered at run time. Also, the #define must be one or more quoted texts, so the float value must be surrounded by quotes.
I'm not where I can look at the Marlin source code go see if _user_gcode_exe has an overload for char* instead of const char*, which would let you use a char array in ram.