Can you change an input pin in a .COMP?

More
02 Apr 2017 00:42 - 02 Apr 2017 00:44 #90746 by rodw
I am writing a simple component that has a GUI screen variable as an input
In a perfect world, I also wanted to change the value using an analog value in Gcode
pin in  float gcode_input  = 95          "Gcode analog input set by M68 command";
pin in  float target_volts = 95          "The target volts (default 95.0 volts) set in GUI";
So, I would like the screen variable updated if a value is set by a gcode M68 command to keep everything in step like this
target_volts = gcode_input;

I get a compiler lvalue required error. So I am assuming that means input pins are read only and cannot be modifed within a component.

Is this the case and is there any workaround.?
Last edit: 02 Apr 2017 00:44 by rodw.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
05 Apr 2017 13:21 #90928 by andypugh
You can use an internal value that is set by the higher (or lower) of either of the two inputs.
Or maybe have a handler in the GUI that allows the GUI value to be over-written by an M-code.

Please Log in or Create an account to join the conversation.

More
05 Apr 2017 21:25 #90949 by rodw

You can use an internal value that is set by the higher (or lower) of either of the two inputs.
Or maybe have a handler in the GUI that allows the GUI value to be over-written by an M-code.


Andy, thanks, I think the GUI approach would be best. Gmocappy uses glade and I have edited the plasma.glade XML file in the sim by hand.to tidy up a couple of things but I don't really know where to start to add a new GUI handler that overwrites the target voltage. I guess that would get done in plasma.py.

Can you give me an idea on where to start?

Would the first step be to add a screen variable for the M68 value and set the target voltage in the python file to that value?

Please Log in or Create an account to join the conversation.

More
31 Mar 2022 23:12 #238958 by fsabbatini
Sorry for responding years later but yes, there is a way,

each input pin you define is just a macro, so first just undefine temporarily, for example:

POS_CMD is an input from simple_tp.comp. I just added feedback to that component so when simple_tp is disabled i want pos_cmd=pos_fb, so what you must do is push the macro in the preprocessor stack, undefine the input pin macro, modify it as dereference access (like if you where in a "normal" c component) and then pop from the stack

#pragma push_macro("remove_pos_cmd")
#undef pos_cmd
*(__comp_inst->pos_cmd) = curr_pos;
#pragma pop_macro("remove_pos_cmd")

best regards
Franco

Please Log in or Create an account to join the conversation.

More
04 Apr 2022 12:05 #239237 by andypugh
There is also a (kludgy) way to check if a pin is connected and set the value internally if it is not.

sourceforge.net/p/emc/mailman/message/26519176/

Please Log in or Create an account to join the conversation.

Time to create page: 0.083 seconds
Powered by Kunena Forum