This repository was archived by the owner on Sep 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
ruuvi_examples/ruuvi_firmware Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 55#define APP_DEVICE_NAME APPLICATION_DEVICE_NAME /**< TODO: Refactoring **/
66#define APP_DEVICE_NAME_LENGTH APPLICATION_DEVICE_NAME_LENGTH
77#define APP_TX_POWER 4 /**< dBm **/
8- #define INIT_FWREV "2.5.6 " /**< Github tag. Do not include specifiers such as "alpha" so you can accept ready binaries as they are **/
8+ #define INIT_FWREV "2.5.7 " /**< Github tag. Do not include specifiers such as "alpha" so you can accept ready binaries as they are **/
99#define INIT_SWREV INIT_FWREV /**< FW and SW are same thing in this context **/
1010
1111// milliseconds until main loop timer function is called. Other timers can bring
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ static uint64_t debounce = 0; // Flag for avoiding double press
110110static uint16_t acceleration_events = 0 ; // Number of times accelerometer has triggered
111111static volatile uint16_t vbat = 0 ; // Update in interrupt after radio activity.
112112static uint64_t last_battery_measurement = 0 ; // Timestamp of VBat update.
113+ static volatile bool pressed = false; // Debounce flag
113114
114115// Possible modes of the app
115116#define RAWv1 0
@@ -223,8 +224,14 @@ static void store_mode(void* data, uint16_t length)
223224 */
224225static void reboot (void * p_context )
225226{
226- NRF_LOG_WARNING ("Rebooting\r\n" )
227- NVIC_SystemReset ();
227+ // Reboot if we've not registered a button press, OR
228+ // if we have registered a button press and the button is still pressed (debounce)
229+ if (!pressed || (pressed && !(nrf_gpio_pin_read (BUTTON_1 ))))
230+ {
231+ NRF_LOG_WARNING ("Rebooting\r\n" )
232+ NVIC_SystemReset ();
233+ }
234+ pressed = false;
228235}
229236
230237/**@brief Function for handling button events.
@@ -237,8 +244,7 @@ static void reboot(void* p_context)
237244 */
238245ret_code_t button_press_handler (const ruuvi_standard_message_t message )
239246{
240- // Avoid double presses
241- static bool pressed = false;
247+ // Debounce
242248 if (false == message .payload [1 ] && ((millis () - debounce ) > DEBOUNCE_THRESHOLD ) && !pressed )
243249 {
244250 NRF_LOG_INFO ("Button pressed\r\n" );
You can’t perform that action at this time.
0 commit comments