Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (32 sloc) 975 Bytes
#include <application.h>
// LED instance
bc_led_t led;
// Button instance
bc_button_t button;
void button_event_handler(bc_button_t *self, bc_button_event_t event, void *event_param)
{
if (event == BC_BUTTON_EVENT_PRESS)
{
bc_led_set_mode(&led, BC_LED_MODE_TOGGLE);
}
// Logging in action
bc_log_info("Button event handler - event: %i", event);
}
void application_init(void)
{
// Initialize logging
bc_log_init(BC_LOG_LEVEL_DUMP, BC_LOG_TIMESTAMP_ABS);
// Initialize LED
bc_led_init(&led, BC_GPIO_LED, false, false);
bc_led_set_mode(&led, BC_LED_MODE_ON);
// Initialize button
bc_button_init(&button, BC_GPIO_BUTTON, BC_GPIO_PULL_DOWN, false);
bc_button_set_event_handler(&button, button_event_handler, NULL);
}
void application_task(void)
{
// Logging in action
bc_log_debug("application_task run");
// Plan next run this function after 1000 ms
bc_scheduler_plan_current_from_now(1000);
}
You can’t perform that action at this time.