Add SHELLY PLUS 1 board with support of relay, switch, BT gateway (#1349)
So that you know, the overtemperature protection is not implemented in the firmware.
This commit is contained in:
1 parent
8a767cf4b8
commit
31ffdf1e2b
9 files changed
+65
-19
No files matched your search
@@ -103,13 +103,16 @@ void MQTTtoONOFF(char* topicOri, char* datacallback) {
|
||||
}
|
||||
# endif
|
||||
|
||||
void ActuatorButtonTrigger() {
|
||||
uint8_t level = !digitalRead(ACTUATOR_ONOFF_GPIO);
|
||||
char* level_string = "ON";
|
||||
if (level != ACTUATOR_ON) {
|
||||
level_string = "OFF";
|
||||
void ActuatorManualTrigger(uint8_t level) {
|
||||
# ifdef ACTUATOR_BUTTON_TRIGGER_LEVEL
|
||||
if (level == ACTUATOR_BUTTON_TRIGGER_LEVEL) {
|
||||
// Change level value to the opposite of the current level
|
||||
level = !digitalRead(ACTUATOR_ONOFF_GPIO);
|
||||
}
|
||||
Log.trace(F("Actuator triggered %s by button" CR), level_string);
|
||||
# else
|
||||
level = !digitalRead(ACTUATOR_ONOFF_GPIO);
|
||||
# endif
|
||||
Log.trace(F("Actuator triggered %d" CR), level);
|
||||
digitalWrite(ACTUATOR_ONOFF_GPIO, level);
|
||||
// Send the state of the switch to the broker so as to update the status
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
|
||||
@@ -34,11 +34,11 @@ unsigned long resetTime = 0;
|
||||
# endif
|
||||
unsigned long lastDebounceTime = 0;
|
||||
int InputState = 3; // Set to 3 so that it reads on startup
|
||||
int lastInputState = 3;
|
||||
int previousInputState = 3;
|
||||
|
||||
void setupGPIOInput() {
|
||||
Log.notice(F("Reading GPIO at pin: %d" CR), INPUT_GPIO);
|
||||
pinMode(INPUT_GPIO, INPUT_PULLUP); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
|
||||
pinMode(INPUT_GPIO, GPIO_INPUT_TYPE); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
|
||||
}
|
||||
|
||||
void MeasureGPIOInput() {
|
||||
@@ -49,7 +49,7 @@ void MeasureGPIOInput() {
|
||||
// since the last press to ignore any noise:
|
||||
|
||||
// If the switch changed, due to noise or pressing:
|
||||
if (reading != lastInputState) {
|
||||
if (reading != previousInputState) {
|
||||
// reset the debouncing timer
|
||||
lastDebounceTime = millis();
|
||||
}
|
||||
@@ -75,7 +75,6 @@ void MeasureGPIOInput() {
|
||||
# endif
|
||||
// if the Input state has changed:
|
||||
if (reading != InputState) {
|
||||
InputState = reading;
|
||||
Log.trace(F("Creating GPIOInput buffer" CR));
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject GPIOdata = jsonBuffer.to<JsonObject>();
|
||||
@@ -88,15 +87,15 @@ void MeasureGPIOInput() {
|
||||
if (GPIOdata.size() > 0)
|
||||
pub(subjectGPIOInputtoMQTT, GPIOdata);
|
||||
|
||||
# ifdef ZactuatorONOFF
|
||||
if (InputState == ACTUATOR_BUTTON_TRIGGER_LEVEL) {
|
||||
ActuatorButtonTrigger();
|
||||
}
|
||||
# if defined(ZactuatorONOFF) && defined(ACTUATOR_TRIGGER)
|
||||
//Trigger the actuator if we are not at startup
|
||||
if (InputState != 3) ActuatorManualTrigger(InputState);
|
||||
# endif
|
||||
InputState = reading;
|
||||
}
|
||||
}
|
||||
|
||||
// save the reading. Next time through the loop, it'll be the lastInputState:
|
||||
lastInputState = reading;
|
||||
// save the reading. Next time through the loop, it'll be the previousInputState:
|
||||
previousInputState = reading;
|
||||
}
|
||||
#endif
|
||||
@@ -42,6 +42,10 @@ extern void GPIOInputtoMQTT();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GPIO_INPUT_TYPE
|
||||
# define GPIO_INPUT_TYPE INPUT_PULLUP
|
||||
#endif
|
||||
|
||||
#define INPUT_GPIO_ON_VALUE "HIGH"
|
||||
#define INPUT_GPIO_OFF_VALUE "LOW"
|
||||
|
||||
|
||||
+4
-1
@@ -41,7 +41,10 @@ extern void MQTTtoONOFF(char* topicOri, JsonObject& RFdata);
|
||||
#endif
|
||||
//# define ACTUATOR_ONOFF_DEFAULT !ACTUATOR_ON // ACTUATOR_ON or !ACTUATOR_ON, set to the state desired on reset.
|
||||
#ifndef ACTUATOR_BUTTON_TRIGGER_LEVEL
|
||||
# define ACTUATOR_BUTTON_TRIGGER_LEVEL LOW // 0 or 1, set to the sensing level which to detect a button press to change the actuator state.
|
||||
//# define ACTUATOR_BUTTON_TRIGGER_LEVEL LOW // 0 or 1, set to the sensing level which to detect a button press to change the actuator state.
|
||||
#endif
|
||||
#ifndef ACTUATOR_TRIGGER
|
||||
# define ACTUATOR_TRIGGER false // false or true, enable to control an actuator directly from the board switch (default behavior if true), or by button if ACTUATOR_BUTTON_TRIGGER_LEVEL is defined
|
||||
#endif
|
||||
|
||||
/*-------------------PIN DEFINITIONS----------------------*/
|
||||
|
||||
Reference in new issue
Block a user