Hello everyone,
I'm using a modified version of SDK 15.0.0 ble_app_hids_keyboard on my nRF52 DK. It sends a volume up and a volume down command when I press buttons 1 or 2. However, the program gets stuck and won't stop sending that command. My button 4 which sends a pwm signal to led 4 seems to work fine. I've tried switching around the case lines in the button_event_handler function that I've attached here but that made things worse. Any help would be appreciated. Thank you.
static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
if (button_action == APP_BUTTON_PUSH)
{
switch (pin_no)
{
case VOLUP_BUTTON:
APP_ERROR_CHECK(consumer_control_send(CONSUMER_CTRL_VOL_UP));
break;
case VOLDOWN_BUTTON:
APP_ERROR_CHECK(consumer_control_send(CONSUMER_CTRL_VOL_DW));
break;
case IR_BUTTON:
{
if(!pwm_on && !nrf_gpio_pin_read(IR_BUTTON))
{
pwm_on = true;
app_pwm_channel_duty_set(&PWM1, 0, 50);
}
else
{
pwm_on = false;
app_pwm_channel_duty_set(&PWM1, 0, 0);
}
break;
}
case KEY_PRESS_BUTTON_PIN_NO:
{
APP_ERROR_CHECK(hid_kbd_send_string());
break;
}
default:
APP_ERROR_HANDLER(pin_no);
break;
} // end of switch
} // end of if(button....)
else if (button_action == APP_BUTTON_RELEASE)
{
switch (pin_no)
{
case IR_BUTTON:
break;
case VOLDOWN_BUTTON:
// Fall-through
case VOLUP_BUTTON:
APP_ERROR_CHECK(consumer_control_send(RELEASE_KEY));
break;
case KEY_PRESS_BUTTON_PIN_NO:
APP_ERROR_CHECK(hid_kbd_send_release());
break;
default:
APP_ERROR_HANDLER(pin_no);
break;
}
}
}