Add analog_only option, though this is a stub for now.
This commit is contained in:
10
Button.cpp
10
Button.cpp
@ -13,7 +13,8 @@ void Button::ReleaseButtons(Joystick* js) {
|
||||
js->ReleaseButton(vbutton);
|
||||
}
|
||||
|
||||
SwitchButton::SwitchButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux) : Button(vbutton) {
|
||||
// TODO: make analog_only work... how to handle that with debouncer?
|
||||
SwitchButton::SwitchButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux, bool analog_only) : Button(vbutton) {
|
||||
this->mux = mux;
|
||||
|
||||
uint8_t mode = INPUT;
|
||||
@ -32,6 +33,7 @@ SwitchButton::SwitchButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux)
|
||||
bool SwitchButton::BouncerUpdate() {
|
||||
if (mux != NULL) {
|
||||
mux->channel(channel_id);
|
||||
delayMicroseconds(500);
|
||||
}
|
||||
|
||||
return bouncer.update();
|
||||
@ -44,7 +46,7 @@ bool SwitchButton::On() {
|
||||
}
|
||||
|
||||
|
||||
PassthruButton::PassthruButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux) : SwitchButton(pin, vbutton, pullup, mux) {
|
||||
PassthruButton::PassthruButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux, bool analog_only) : SwitchButton(pin, vbutton, pullup, mux, analog_only) {
|
||||
this->type = BUTTON_PASSTHRU;
|
||||
}
|
||||
|
||||
@ -56,7 +58,7 @@ bool PassthruButton::Update(Joystick* js) {
|
||||
}
|
||||
|
||||
|
||||
LatchedButton::LatchedButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux) : SwitchButton(pin, vbutton, pullup, mux) {
|
||||
LatchedButton::LatchedButton(uint8_t pin, uint8_t vbutton, bool pullup, Mux* mux, bool analog_only) : SwitchButton(pin, vbutton, pullup, mux, analog_only) {
|
||||
this->type = BUTTON_LATCHED_MOMENTARY;
|
||||
this->pressed = false;
|
||||
}
|
||||
@ -78,7 +80,7 @@ bool LatchedButton::Update(Joystick* js) {
|
||||
}
|
||||
|
||||
|
||||
PulsedButton::PulsedButton(uint8_t pin, uint8_t vbutton, bool double_action, bool split, bool pullup, Mux* mux) : SwitchButton(pin, vbutton, pullup, mux) {
|
||||
PulsedButton::PulsedButton(uint8_t pin, uint8_t vbutton, bool double_action, bool split, bool pullup, Mux* mux, bool analog_only) : SwitchButton(pin, vbutton, pullup, mux, analog_only) {
|
||||
if (double_action) {
|
||||
if (split) {
|
||||
this->type = BUTTON_PULSED_DOUBLE_ACTION_SPLIT;
|
||||
|
Reference in New Issue
Block a user