Skip to content
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

Add setting MY_INCLUSION_INDICATION_HANDLER (#1482) #1483

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions MyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,13 @@
#define MY_INCLUSION_BUTTON_PRESSED (LOW)
#endif

/**
* @def MY_INCLUSION_INDICATION_HANDLER
* @brief Define to use own inclusion mode indication handler.
*/
//#define MY_INCLUSION_INDICATION_HANDLER


/**************************************
* Ethernet Gateway Transport Defaults
***************************************/
Expand Down Expand Up @@ -2341,6 +2348,7 @@
#define MY_DEBUG_VERBOSE_GATEWAY
#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
#define MY_INCLUSION_LED_PIN
#define MY_INCLUSION_INDICATION_HANDLER
#define MY_GATEWAY_W5100
#define MY_GATEWAY_ENC28J60
#define MY_GATEWAY_ESP8266
Expand Down
13 changes: 10 additions & 3 deletions core/MyInclusionMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ inline void inclusionInit()
#if defined (MY_INCLUSION_LED_PIN)
// Setup LED pin that indicates inclusion mode
hwPinMode(MY_INCLUSION_LED_PIN, OUTPUT);
hwDigitalWrite(MY_INCLUSION_LED_PIN, LED_OFF);
#endif

inclusionModeSet(_inclusionMode);
}


void inclusionModeSet(bool newMode)
{
if (newMode != _inclusionMode) {
Expand All @@ -54,6 +52,7 @@ void inclusionModeSet(bool newMode)
#if defined (MY_INCLUSION_LED_PIN)
hwDigitalWrite(MY_INCLUSION_LED_PIN, _inclusionMode ? LED_ON : LED_OFF);
#endif
inclusionModeIndication(_inclusionMode);
}

inline void inclusionProcess()
Expand All @@ -70,3 +69,11 @@ inline void inclusionProcess()
inclusionModeSet(false);
}
}

#if !defined(MY_INCLUSION_INDICATION_HANDLER)
void inclusionModeIndication(bool newMode)
{
// empty function, resolves AVR-specific GCC optimization bug (<5.5) if handler not used
// see here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77326
}
#endif
4 changes: 4 additions & 0 deletions core/MyInclusionMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ void inclusionInit();
void inclusionModeSet(bool newMode);
void inclusionProcess();

/**
* Allow user to define their own inclusion mode indication handler.
*/
void inclusionModeIndication(bool mode);

#endif
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ MY_INCLUSION_BUTTON_FEATURE LITERAL1
MY_INCLUSION_MODE_BUTTON_PIN LITERAL1
MY_INCLUSION_MODE_DURATION LITERAL1
MY_INCLUSION_LED_PIN LITERAL1
MY_INCLUSION_INDICATION_HANDLER LITERAL1
MY_OTA_FIRMWARE_FEATURE LITERAL1
MY_OTA_FLASH_SS LITERAL1
MY_OTA_FLASH_JDECID LITERAL1
Expand Down