New "virtual pins" module for testing purposes

There’s a space between virtual_pin: and button, take that off, it should just be virtual_pin:button

Wow, that was quick. Thanks!
Next problem, I want to use a virtual pins as pre-gate sensors in Happy Hare, but how can I define a pin and assign it to the Happy Hare config? The code below shows the sensors in mainsail, but not in the virtual_pins object

[mmu_sensors]
pre_gate_switch_pin_0: virtual_pin:MMU_PRE_GATE_0 #^mmu:MMU_PRE_GATE_0
pre_gate_switch_pin_1: virtual_pin:MMU_PRE_GATE_1 #^mmu:MMU_PRE_GATE_1
pre_gate_switch_pin_2: virtual_pin:MMU_PRE_GATE_2 #^mmu:MMU_PRE_GATE_2
pre_gate_switch_pin_3: virtual_pin:MMU_PRE_GATE_3 #^mmu:MMU_PRE_GATE_3
pre_gate_switch_pin_4: virtual_pin:MMU_PRE_GATE_4 #^mmu:MMU_PRE_GATE_4
pre_gate_switch_pin_5: virtual_pin:MMU_PRE_GATE_5 #^mmu:MMU_PRE_GATE_5
pre_gate_switch_pin_6: virtual_pin:MMU_PRE_GATE_6 #^mmu:MMU_PRE_GATE_6
pre_gate_switch_pin_7: virtual_pin:MMU_PRE_GATE_7 #^mmu:MMU_PRE_GATE_7
pre_gate_switch_pin_8: virtual_pin:MMU_PRE_GATE_8 #^mmu:MMU_PRE_GATE_8
pre_gate_switch_pin_9: virtual_pin:MMU_PRE_GATE_9 #^mmu:MMU_PRE_GATE_9
pre_gate_switch_pin_10: virtual_pin:MMU_PRE_GATE_10 #^mmu:MMU_PRE_GATE_10
pre_gate_switch_pin_11: virtual_pin:MMU_PRE_GATE_11 #^mmu:MMU_PRE_GATE_11

I’m guessing it has something to do with:

        self._printer.register_event_handler("klippy:connect",
                                             self.handle_connect)

Happy hare creates the pin entries when it loads, which is after virual_pins is loaded

Ignore my previous message idea, I might have found out why it doesn’t work. Happy Hare creates a filament_switch_sensor dynamically:
https://www.klipper3d.org/Config_Reference.html?h=filament#filament_switch_sensor

AFAIK, your code doesn’t (yet) support these. Am I right?

Correct, those go through the button.py which at the moment is not supported… I haven’t found a way to intercept those yet!

Hi Pedro.
Is it necessary to include the [virtual_pins] section in the same file i define some virtual output pins, or can i just include this section in printer.cfg and define some virtual pins in other file (included in printer.cfg via include command) ?

Hi @JuanR3D , yes you do need to add an empty [virtual_pins] section before you actually use any virtual_pin: entry

Thanks @pedrolamas !!

And… could i define multiple [virtual_pins] sections in different config files?
For example:
In “macros.cfg” do:
[virtual_pins]
[output_pin some_pins]

And in generic…cfg
[virtual_pins]
[output_pins other_pins]

Hello, Im trying to use virtual_pin to set my ESP32 brightness value.

Right now i have set:
[output_pin WLED]
pin: virtual_pin:WLED_pin
pwm: True
value: 0
scale: 255

Which outputs as: SET_PIN PIN=WLED VALUE=0 (or 255 at 100%)

How do i actually make it send the numer 0 to 255 to the ESP without having to press a macro button?
Here is one of the ESP/WLED macro’s which is a dropdown button in the macro section

[gcode_macro WLED_CONTROL]
description: Control effect values and brightness
gcode:
  {% set strip = params.STRIP|default('lights')|string %}
  {% set brightness = params.BRIGHTNESS|default(-1)|int %}
  {% set intensity = params.INTENSITY|default(-1)|int %}
  {% set speed = params.SPEED|default(-1)|int %}

  {action_call_remote_method("set_wled_state",
                             strip=strip,
                             brightness=brightness,
                             intensity=intensity,
                             speed=speed)}

Im currently at loss on how to change any of this