Welcome! Log In Create A New Profile

Advanced

is there any way of send a gcode to marlin to change a define

Posted by ekpp 
is there any way of send a gcode to marlin to change a define
October 24, 2018 06:02PM
Hi, Im new on marlin but I have done many develops on other languages so
Im asking if is posible to use any unused gcode or M to send to marlin to change a #define directly why?
1st Im using a dual extruder whith marlin and a cyclop hotends -nozzle but
sometimes I would like to use a chimera-nozzles so I have to change all my configs on marlin
or may try the new feachure duplication mode and have to change all again

so I would like to do is on top of configuration.h and configuration adv.h define a actual_ config whid a case maybe or some ifs

like

# define actual_config (and here get the value of Gcode or Mcode Example M568 C1 or M568 C2 etc)

so the value of actual_config =1 or 2 or whatever

Is that posible?

if that I will do a CASE: or like so and

on anu case put my values for each configs and defines

case:1 //sed for cyclops

#define EXTRUDERS 1
#define MIXING_EXTRUDER
#define DIRECT_MIXING_IN_G1

case2 // used for chimera

#define EXTRUDERS 2
#define HOTEND_OFFSET_X {0.0, 20.00} // (mm) relative X-offset for each nozzle

case3: //used for duplication mode ETC

of course zizes PId , steps and all that will be the same and I dont tuch them.

So I dont know if you get my idea and if its posible, thenks I hope you understend my english
Re: is there any way of send a gcode to marlin to change a define
October 24, 2018 08:34PM
"but I have done many develops on other languages so"

and yet you have no idea that this is a preprocessor directive and nothing to do with the language it self...

The final compiled code knows nothing of any #define or their values so they cannot be changed in code.



In theory anything that is currently a #define can be re written to use a variable, and thus be editable by code or gcode. But you have to change it in all places that defined string occurs.
It will use more memory and more code and run slower...
Re: is there any way of send a gcode to marlin to change a define
October 24, 2018 09:15PM
yes you are right

and yet you have no idea that this is a preprocessor directive and nothing to do with the language it self...

I know is compiled but

In theory anything that is currently a #define can be re written to use a variable, and thus be editable by code or gcode. But you have to change it in all places that defined string occurs.

You may not understeend my idea, just put my important defines inside a case so the program uses one or other, no bouth and in sted of been oll over the configuration they will be on top

and yes the final compiled will be a little biger but not much and also dont think that works slower becouse dont uses all of them just what needs.

But you have to change it in all places that defined string occurs.

I dont wont to change any define string, Just enable or disable (not use undef all that uses inside my code on top)

So apart from all this you know where I can see some information about this
and how to get or declare a Gcode or M to use

Thank you
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 01:03AM
Just take a look at Marlin_main.c

gcode is a large nested switch statement, look for process_parsed_command()

basically each gcode is implemented as its own function called from each case of the switch
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 02:52AM
Quote
Dust
Just take a look at Marlin_main.c

gcode is a large nested switch statement, look for process_parsed_command()

basically each gcode is implemented as its own function called from each case of the switch

Thank you , yes did that and foud a code that my be useful I dont wont to create My own so

/**
* M118: Display a message in the host console.
*
* A1 Prepend '// ' for an action command, as in OctoPrint
* E1 Have the host 'echo:' the text
*/

Im tring to understend the A1 , and others my be intresting too but many do not have implemented on marlin

any ideas?
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 03:54AM
Why don't you look at RepRapFirmware instead of Marlin? RepRapFirmware is completely configured by M-codes, not #defines.

Edited 1 time(s). Last edit at 10/25/2018 03:57AM by dc42.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 03:56AM
see M118

Edited 1 time(s). Last edit at 10/25/2018 03:57AM by Dust.
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 04:08AM
Quote
dc42
Why don't you look at RepRapFirmware instead of Marlin? RepRapFirmware is completely configured by M-codes, not #defines.

well my machine cam with marlin,, I never try other but maybe I will some day, but I have all most configurated allready and also my code is compilating ok and maybe tomorrow i will finish my new code, hope so, if not I will try reprap

Edited 1 time(s). Last edit at 10/25/2018 04:11AM by ekpp.
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 05:37AM
RepRapFirmware doesn't run on your hardware

this is a thinly veiled attempt to sell duets based boards....
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 05:50AM
Quote
Dust
RepRapFirmware doesn't run on your hardware

this is a thinly veiled attempt to sell duets based boards....


Thank you for that info, so reprapfirmware dont work on arduino 2560 based boards whit ramps 1.4?
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 08:44AM
RepRapFirmware is 32-bit firmware so it doesn't run on 8-bit boards. There are builds for many 32-bit boards, not just Duets.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: is there any way of send a gcode to marlin to change a define
October 25, 2018 02:15PM
Quote
dc42
RepRapFirmware is 32-bit firmware so it doesn't run on 8-bit boards. There are builds for many 32-bit boards, not just Duets.

A dum question. If they are 32bits culd be aplyed on a 32bits pc?
Re: is there any way of send a gcode to marlin to change a define
October 26, 2018 04:29AM
Hi, well as i sed its posible to do a send code or text thrue M118 A1 but the problem is that a define acts like a constant, not a variable, so it my be posible to do what I wont flushin on eprom and then reloadin thrue M501, 2 ,3 or around there but I dont wont to mess whith PROGMEM by naw so im asking if someone did this or know how to do it,
Its a text from arduino reference about #define

This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text).

that is what i need to do, if anyone know i will be very hapy

thank you
Re: is there any way of send a gcode to marlin to change a define
October 31, 2018 05:00AM
Ok, so in case someone is interested the code is going well, I tested and works as i expected, know I´m on configuration_store as i need to save my new value i changed the eeprom layer and some rutines on m500 and m501 so it can be saved and retribed , its taking me some time becouse CRC diferences and also as sed on top of file version that i sould change, and that is the first cheq the sistem does its been a bit triky on all that but allready saving and reading so I THINK ITS POSIBLE and will be very useful thanks
Sorry, only registered users may post in this forum.

Click here to login