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?

@A_Rogue_Child
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.

@profezzorn On the Proffieboard V3 page the pad pinout/capability table has specifically Button 1, Button 2, and Button 3 listed for touch capability.

Is it indeed the case that only those three can be used? Can any GPIO pin be used?

Only those are properly wired for touch support.

1 Like

I guess I should’ve asked also… is that the case for the V1 and V2 as well? Just the button pads?

yes, that is correct

Awesome, thank you!

@profezzorn,
I know you can have the switch common go to ground (normal) or 3.3 volts (PullDownButton), but can I just double-check that both actual button pads are 5 volt tolerant? I have an install on the bench in which it may be useful to have the switch common go to Batt+ rather than ground or 3.3 volts.

1 Like

Proffieboard V1 and V2:

From Datasheet Table 22: 6.3.1 “General Operating Conditions”

All I/O except TT_xx: Min(Min(VDD, VDDA, VDDUSB, VLCD)+3.6V, 5.5V)

The translation being all I/O except TT_xx are 5V tolerant.
TT_xx IO are 3.3V tolerant only (with a ±0.3 tolerance for variance)

The TT_xx Pins on Proffieboard V1/V2:

(the ones that aren’t 5V tolerant)

Extracted From Datasheet Table 15

MCU Pin V1 Function V2 Function
13 Free1/Data4 vtest, internal
14 vtest, internal Free1/Data4
15 SD Card SCLK, internal SD Card SCLK, internal

So the only effective pin you can’t use as a pulldown button pin (besides the obvious) on both the V1 and V2 are the respective Data4 pins.

Proffieboard V3:

From Datasheet Table 23 6.3.1 “General Operating Conditions”

All I/O except TT_xx: Min(Min(VDD, VDDA, VDDUSB)+3.6V, 5.5V)

Similarly this means that all non-TT_xx pins are 5V tolerant, and still TT_xx I/O are 3.3V tolerant only.

The TT_xx Pins on Proffieboard V3:

(the ones that aren’t 5V tolerant)

Extracted From Datasheet Table 16

MCU Pin V3 Function
G3 SD Power Enable, internal
H3 Data4
F4 Unused

So once again, the pin you can’t use on the V3 is still Data4.

I did say I needed to look into this eventually (among other things), so I figured I may as well do the work and make it pretty for others :slight_smile:

3 Likes

This is perfect. Thanks Ryry. :slight_smile:
My knowledge of this kind of data sheet is patchy, so thanks for unpicking the salient details from it. :pray: :slight_smile: