Fix inclusion button problem.

Add option when having external pullup for inclusion button.
MY_INCLUSION_BUTTON_EXTERNAL_PULLUP.

Change the default led pins for serial gateway that was wrong.
This commit is contained in:
Henrik Ekblad
2015-11-02 20:50:22 +01:00
parent 9b7c99d499
commit 6baf605b0d
5 changed files with 24 additions and 8 deletions
+6
View File
@@ -187,6 +187,12 @@
#define MY_INCLUSION_MODE_DURATION 60 #define MY_INCLUSION_MODE_DURATION 60
#endif #endif
#if defined(MY_INCLUSION_BUTTON_EXTERNAL_PULLUP)
#define MY_INCLUSION_BUTTON_PRESSED HIGH
#else
#define MY_INCLUSION_BUTTON_PRESSED LOW
#endif
/********************************** /**********************************
* Message Signing Settings * Message Signing Settings
***********************************/ ***********************************/
+2 -2
View File
@@ -34,7 +34,7 @@ inline void inclusionInit() {
void inclusionModeSet(boolean newMode) { void inclusionModeSet(boolean newMode) {
if (newMode != inclusionMode) { if (newMode != _inclusionMode) {
_inclusionMode = newMode; _inclusionMode = newMode;
// Send back mode change to controller // Send back mode change to controller
gatewayTransportSend(buildGw(_msg, I_INCLUSION_MODE).set(_inclusionMode?1:0)); gatewayTransportSend(buildGw(_msg, I_INCLUSION_MODE).set(_inclusionMode?1:0));
@@ -46,7 +46,7 @@ void inclusionModeSet(boolean newMode) {
inline void inclusionProcess() { inline void inclusionProcess() {
#ifdef MY_INCLUSION_BUTTON_FEATURE #ifdef MY_INCLUSION_BUTTON_FEATURE
if (!inclusionMode && digitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == LOW) { if (!_inclusionMode && digitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == MY_INCLUSION_BUTTON_PRESSED) {
// Start inclusion mode // Start inclusion mode
inclusionModeSet(true); inclusionModeSet(true);
} }
@@ -22,8 +22,6 @@
#include "MySensorCore.h" #include "MySensorCore.h"
unsigned long inclusionStartTime;
bool inclusionMode;
extern bool gatewayTransportSend(MyMessage &message); extern bool gatewayTransportSend(MyMessage &message);
@@ -44,6 +44,10 @@
#define MY_RADIO_NRF24 #define MY_RADIO_NRF24
//#define MY_RADIO_RFM69 //#define MY_RADIO_RFM69
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable serial gateway // Enable serial gateway
#define MY_GATEWAY_SERIAL #define MY_GATEWAY_SERIAL
@@ -52,18 +56,25 @@
// Set blinking period // Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300 #define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
//#define MY_WITH_LEDS_BLINKING_INVERSE
// Enable inclusion mode // Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE #define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway // Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE #define MY_INCLUSION_BUTTON_FEATURE
// Inverses behavior of inclusion button (if using external pullup)
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
// Set inclusion mode duration (in seconds) // Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60 #define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button // Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3 #define MY_INCLUSION_MODE_BUTTON_PIN 3
#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin #define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin #define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED #define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <SPI.h> #include <SPI.h>
#include <MySensor.h> #include <MySensor.h>
+2 -1
View File
@@ -98,4 +98,5 @@ MY_IP_SUBNET_ADDRESS LITERAL1
MY_W5100_SPI_EN LITERAL1 MY_W5100_SPI_EN LITERAL1
MY_RS485 LITERAL1 MY_RS485 LITERAL1
MY_RS485_BAUD_RATE LITERAL1 MY_RS485_BAUD_RATE LITERAL1
MY_RS485_MAX_MESSAGE_LENGTH LITERAL1 MY_RS485_MAX_MESSAGE_LENGTH LITERAL1
MY_INCLUSION_BUTTON_EXTERNAL_PULLUP LITERAL1