From c3cc004ff6a1f894f53e06f9989565ccd032fb8c Mon Sep 17 00:00:00 2001 From: Karel Blavka Date: Fri, 21 Jul 2017 15:19:45 +0200 Subject: [PATCH] Add button --- app/application.c | 18 +++++++++++++++++- sdk | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/application.c b/app/application.c index fea62f9..bdf7a81 100644 --- a/app/application.c +++ b/app/application.c @@ -2,7 +2,7 @@ #define BATTERY_VOLTAGE_DATA_STREAM_SAMPLES 6 #define SIGFOX_FIRST_REPORT_SECONDS (10) -#define SIGFOX_REPORT_INTERVAL_SECONDS (60 * 60) +#define SIGFOX_REPORT_INTERVAL_SECONDS (15 * 60) #define BATTERY_MODULE_UPDATE_INTERVAL_SECONDS (SIGFOX_REPORT_INTERVAL_SECONDS / BATTERY_VOLTAGE_DATA_STREAM_SAMPLES ) #define HEADER_EVENT_ERROR 0xff @@ -15,6 +15,8 @@ bc_led_t led; bc_module_sigfox_t sigfox_module; +bc_button_t button; + uint8_t header = HEADER_EVENT_UPDATE; unsigned int channel_a_overflow_count = 0; @@ -72,6 +74,17 @@ void sigfox_module_event_handler(bc_module_sigfox_t *self, bc_module_sigfox_even } } +void button_event_handler(bc_button_t *self, bc_button_event_t event, void *event_param) +{ + (void) self; + (void) event_param; + + if (event == BC_BUTTON_EVENT_HOLD) + { + bc_scheduler_plan_now(0); + } +} + void application_init(void) { bc_data_stream_init(&stream_battery_voltage_mv, 1, &stream_buffer_battery_voltage_mv); @@ -91,6 +104,9 @@ void application_init(void) bc_module_sigfox_init(&sigfox_module, BC_MODULE_SIGFOX_REVISION_R2); bc_module_sigfox_set_event_handler(&sigfox_module, sigfox_module_event_handler, NULL); + bc_button_init(&button, BC_GPIO_BUTTON, BC_GPIO_PULL_DOWN, false); + bc_button_set_event_handler(&button, button_event_handler, NULL); + bc_scheduler_plan_absolute(0, SIGFOX_FIRST_REPORT_SECONDS * 1000); } diff --git a/sdk b/sdk index 2357a33..98a4f00 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 2357a33afe196b6b5dedce708c5ff1def582db18 +Subproject commit 98a4f00f0a3c4f543c50dfd41a73fbbe68a05df7