-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[P109] add button pin mode #5066
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
base: mega
Are you sure you want to change the base?
Changes from 2 commits
4d93059
62e13db
4517850
5b41b4d
2c04e1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,13 +171,15 @@ boolean Plugin_109(uint8_t function, struct EventStruct *event, String& string) | |
| } | ||
|
|
||
| addFormPinSelect(PinSelectPurpose::Generic_input, F("Button left/down"), F("taskdevicepin1"), CONFIG_PIN1); | ||
| addFormCheckBox(F("Button left/down Pull mode (0=IntPullUp, 1=Input)"), F("invertbutton1"), P109_GET_BUTTON1_INVERT); | ||
|
||
| addFormPinSelect(PinSelectPurpose::Generic_input, F("Button right/up"), F("taskdevicepin2"), CONFIG_PIN2); | ||
| addFormCheckBox(F("Button right/up Pull mode (0=IntPullUp, 1=Input)"), F("invertbutton2"), P109_GET_BUTTON2_INVERT); | ||
| addFormPinSelect(PinSelectPurpose::Generic_input, F("Button mode"), F("taskdevicepin3"), CONFIG_PIN3); | ||
|
|
||
| addFormCheckBox(F("Button Mode Pull mode (0=IntPullUp, 1=Input)"), F("invertbutton3"), P109_GET_BUTTON3_INVERT); | ||
| addFormPinSelect(PinSelectPurpose::Generic_output, F("Relay"), F("heatrelay"), P109_CONFIG_RELAYPIN); | ||
|
|
||
| addFormCheckBox(F("Invert relay-state (0=on, 1=off)"), F("invertrelay"), P109_GET_RELAY_INVERT); | ||
|
|
||
| { | ||
| const __FlashStringHelper *options4[] = { F("0.2"), F("0.5"), F("1") }; | ||
| const int optionValues4[] = { 2, 5, 10 }; | ||
|
|
@@ -213,6 +215,9 @@ boolean Plugin_109(uint8_t function, struct EventStruct *event, String& string) | |
| bitWrite(lSettings, P109_FLAG_TASKNAME_IN_TITLE, isFormItemChecked(F("ptask"))); | ||
| bitWrite(lSettings, P109_FLAG_ALTERNATE_HEADER, !isFormItemChecked(F("palt"))); // Inverted | ||
| bitWrite(lSettings, P109_FLAG_RELAY_INVERT, isFormItemChecked(F("invertrelay"))); | ||
| bitWrite(lSettings, P109_FLAG_BUTTON1_INVERT, isFormItemChecked(F("invertbutton1"))); | ||
| bitWrite(lSettings, P109_FLAG_BUTTON2_INVERT, isFormItemChecked(F("invertbutton2"))); | ||
| bitWrite(lSettings, P109_FLAG_BUTTON3_INVERT, isFormItemChecked(F("invertbutton3"))); | ||
| P109_FLAGS = lSettings; | ||
|
|
||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,9 @@ bool P109_data_struct::plugin_init(struct EventStruct *event) { | |
| _varIndex = event->BaseVarIndex; | ||
| _relaypin = P109_CONFIG_RELAYPIN; | ||
| _relayInverted = P109_GET_RELAY_INVERT; | ||
| _buttonInverted[0] = P109_GET_BUTTON1_INVERT; | ||
| _buttonInverted[1] = P109_GET_BUTTON2_INVERT; | ||
| _buttonInverted[2] = P109_GET_BUTTON3_INVERT; | ||
| _setpointTimeout = P109_CONFIG_SETPOINT_DELAY - P109_SETPOINT_OFFSET; | ||
|
||
|
|
||
| if (P109_CONFIG_DISPLAYTYPE == 1) { | ||
|
|
@@ -120,7 +123,7 @@ bool P109_data_struct::plugin_init(struct EventStruct *event) { | |
|
|
||
| for (uint8_t pin = 0; pin < 3; ++pin) { | ||
| if (validGpio(PIN(pin))) { | ||
| pinMode(PIN(pin), INPUT_PULLUP); | ||
| pinMode(PIN(pin), _buttonInverted[pin] ? INPUT : INPUT_PULLUP); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -198,7 +201,7 @@ bool P109_data_struct::plugin_ten_per_second(struct EventStruct *event) { | |
| if (_initialized) { | ||
| uint32_t current_time; | ||
|
|
||
| if (validGpio(CONFIG_PIN1) && !digitalRead(CONFIG_PIN1)) { | ||
| if (validGpio(CONFIG_PIN1) && (_buttonInverted[0] ? digitalRead(CONFIG_PIN1) : !digitalRead(CONFIG_PIN1))) { | ||
| current_time = millis(); | ||
|
|
||
| if (_buttons[0] + P109_BUTTON_DEBOUNCE_TIME_MS < current_time) { | ||
|
|
@@ -207,7 +210,7 @@ bool P109_data_struct::plugin_ten_per_second(struct EventStruct *event) { | |
| } | ||
| } | ||
|
|
||
| if (validGpio(CONFIG_PIN2) && !digitalRead(CONFIG_PIN2)) { | ||
| if (validGpio(CONFIG_PIN2) && (_buttonInverted[1] ? digitalRead(CONFIG_PIN2) : !digitalRead(CONFIG_PIN2))) { | ||
| current_time = millis(); | ||
|
|
||
| if (_buttons[1] + P109_BUTTON_DEBOUNCE_TIME_MS < current_time) { | ||
|
|
@@ -216,7 +219,7 @@ bool P109_data_struct::plugin_ten_per_second(struct EventStruct *event) { | |
| } | ||
| } | ||
|
|
||
| if (validGpio(CONFIG_PIN3) && !digitalRead(CONFIG_PIN3)) { | ||
| if (validGpio(CONFIG_PIN3) && (_buttonInverted[2] ? digitalRead(CONFIG_PIN3) : !digitalRead(CONFIG_PIN3))) { | ||
| current_time = millis(); | ||
|
|
||
| if (_buttons[2] + P109_BUTTON_DEBOUNCE_TIME_MS < current_time) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these are optional selections, right?