Button Types

I’m looking through the options for buttons, and it seems like there’s a fair bit here that’s seemingly undocumented, so I’m curious about usage.

From the POD page, the 4 button “Types” discussed are Button, LatchingButton, InvertedLatchingButton, and TouchButton.

Howver, looking through the code I also see:

  • PullDownButton (which I’d love some info on what pads are off-limits on a V3 and v1.5 for!),
  • FastButton (which doesn’t seem like its intended to be used on its own…),
  • PotClass and DualPotClass (these also seem like I’m missing something, as they don’t have ctors which match what I’d expect), several classes related to rotary switches of (seemingly) different types, not to mention
  • FloatingButton, which seems simply incomplete?

Several of these classes seem like either they or some other implementing class would exist to use them like “normal” buttons, or is there maybe some other way to use “buttons” in ProffieOS that I’m unaware of?

Basically, are all these usable, and if so, how/what would that look like?

PullDownButton is basically the same as “Button”, but it detects when the pin goes from low to high rather than from high to low. This can be useful, because you can use a single + wire to drive an accent LED and a button. The negative wire can’t be shared in the same way since we normally use LED1-6 for that, and when they are turned off, they can’t pull a button low.

All data, serial, button and free pins can use PullDownButton, however, if the + wire contains 3.7 volts, then the pin must also be 5-volt tolerant. Most pins are 5v-tolerant, but there may be a few that are not. I would need to go read the data sheets to figure out which ones though.

FastButton is not really meant for buttons. It’s meant to be used with something that generates very short pulses, like a coulple of microseconds… The person who asked for this is tryhing to build a product out of it, so I’m not going to explain the details for now.

PotClass and DualPotClass should work just fine. However, you need to specify what you want them to do by giving a pointer to a “receiver” to the constructor. So you could use it something like:

ChangeVariationAnalogReceiver receiver;
PotClass pot(data4pin, &receiver);

They haven’t been used much though, so I don’t know how well they work…

Note that pots are not really buttons, but they are “input devices”. I probably should have named the directory “input” rather than “buttons”… Maybe one day I’ll change it.

FloatingButton looks incomplete because it’s meant to be wrapped in a LatchingButtonTemplate<>. It’s normally only used for the blade detect function, and you can see how it works here:

1 Like

Gotcha, neat example use case too!

Makes sense, good to know that it’s just an mcu tolerance thing.

Sounds like an invitation :wink: Whenever I go back through all this I’ll make a point to.

@profezzorn pots as in potentiometers?

Yes, which I have these bits of notes on:

// Analog Potentiometer

ChangeVolumeAnalogReceiver volume_function;
PotClass pot(0, &volume_function);

// Or, you can use it to change the variation (color):

ChangeVariationAnalogReceiver variation_function;
PotClass pot(0, &variation_function);

As opposed to a rotary encoder, which I have these bits of notes on:
Rotary Encoder (see rotary.h)

ChangePresetRotaryReceiver rotary_receiver;
Rotary<8, 9> rotary(&rotary_receiver);

The receiver decides what the rotary events do.
There are currently receivers for changing presets,
changing variation and one that just prints things out.
More receivers can be added as needed.*/

1 Like

Yep, that is correct.