Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toogle_digital_output support - allow user to add changeable GPIO via g-code #45

Closed
wants to merge 4 commits into from

Conversation

dragonnn
Copy link

@dragonnn dragonnn commented Nov 12, 2017

User can now create a section in config:

[toogle_digital_output my_toogle_pins]
pins: ar63

This add pin ar63 so it state can be switched with a g-code command:
SET_DIGITAL TOOGLE=my_toogle_pins PIN=ar63 STATE=1

when command is executed the PIN state is changed but after a few seconds it goes back and after a few commands klipper reports an error "Missed scheduling of next pin event"
Fixed pin state holding and error "Missed scheduling of next pin event"
@lenne0815
Copy link

What is the syntax to set it via gcode console ?

@dragonnn
Copy link
Author

Hmmm it is this SET_DIGITAL TOOGLE=my_toogle_pins PIN=ar63 STATE=1
Where my_toogle_pins is the name of config section, ar63 is the name of the PIN, you can define more by separating it whit comma. 1 set the state (1 - on, 0 - off).

sometimes it is really needed to move axis without homing the printer. With M120 you can disable endstops so you wont need to home, with M121 you can enable endstops back.
@dragonnn
Copy link
Author

Hmmm strange, I am new to git. I had think when I create a pull requests it add only commits at the time when it was created. Well those can be merged too :D.

@KevinOConnor
Copy link
Collaborator

Thanks. It looks like you've found the correct way to implement this feature.

I have some changes planned to how gcode.py handles extended g-code commands, so I'm not looking to add this feature to the main Klipper code right now - I'll look again in a couple of weeks.

@hg42
Copy link

hg42 commented Dec 11, 2017

I think, if the pins are listed in printer.cfg, then they should get a name and the gcode command should use the symbolical name instead.
Also, I would consider future extensions.
Example:

[digital_output NAME1]
pin = ar61

[digital_pwm NAME2]
pin = ar62

[digital_input NAME3]
pin = ar63

[analog_input NAME4]
pin = ar64
min=...
max=...
offset=...

and

GPIO_SET PIN=NAME1 VALUE=1
GPIO_SET PIN=NAME2 VALUE=128
GPIO_GET PIN=NAME3
  -> NAME3=1
GPIO_GET PIN=NAME4
  -> NAME4=25.6

For debugging purposes, it would also be nice to use pins directly, but I think then they should be also configurable by the command (pinMode etc.).

Intentions:

If we replace one of the MCUs, the configuration should allow to hide hardware dependencies (e.g. pins that are free, or that can do PWM etc.). The usage from outside should stay the same.

I see the configuration as a kind of hardware abstraction layer. So everything should be abstract when used outside.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants