disable buttons for now
This commit is contained in:
parent
d31ef13e96
commit
c8f83cbc5f
|
@ -19,7 +19,6 @@ add_executable(vibe-check
|
|||
src/main.c
|
||||
src/state.c
|
||||
src/vibe_bt.c
|
||||
src/buttons.c
|
||||
)
|
||||
|
||||
target_link_libraries(vibe-check
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
#include "buttons.h"
|
||||
#include "btstack.h"
|
||||
#include "hardware/gpio.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "state.h"
|
||||
#include "vibe_bt.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define POLL_PERIOD_MS 100
|
||||
|
||||
#define BUTTON_PIN_POWER 20
|
||||
#define BUTTON_PIN_PLUS 19
|
||||
#define BUTTON_PIN_MINUS 18
|
||||
|
||||
#define BUTTON_STEP 25
|
||||
|
||||
static btstack_timer_source_t button_timer;
|
||||
|
||||
// What power do we return to when the power button is pressed while off?
|
||||
static uint8_t resume_power = 50;
|
||||
|
||||
static void button_timer_callback(struct btstack_timer_source* ts) {
|
||||
// TODO: Debounce this.
|
||||
if (gpio_get(BUTTON_PIN_POWER)) {
|
||||
if (bt_connected) {
|
||||
printf("=> Ignoring input, bluetooth connected.\n");
|
||||
} else if (target_power == 0) {
|
||||
printf("= Resuming: %i%% -> %i%%\n", target_power, resume_power);
|
||||
state_set_power(resume_power);
|
||||
} else {
|
||||
printf("= Suspending: %i%% -> %i%%\n", target_power, resume_power);
|
||||
resume_power = target_power;
|
||||
state_set_power(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (gpio_get(BUTTON_PIN_PLUS)) {
|
||||
if (bt_connected) {
|
||||
printf("+> Ignoring input, bluetooth connected.\n");
|
||||
} else if (target_power <= (100 - BUTTON_STEP)) {
|
||||
printf("+ Increasing power: %i%% -> %i%%\n", target_power, target_power + BUTTON_STEP);
|
||||
state_set_power(target_power + BUTTON_STEP);
|
||||
} else {
|
||||
printf("+ Increasing power: %i%% -> %i%%\n", target_power, 100);
|
||||
state_set_power(100);
|
||||
}
|
||||
}
|
||||
if (gpio_get(BUTTON_PIN_MINUS)) {
|
||||
if (bt_connected) {
|
||||
printf("-> Ignoring input, bluetooth connected.\n");
|
||||
} else if (target_power >= BUTTON_STEP) {
|
||||
printf("- Reducing power: %i%% -> %i%%\n", target_power, target_power - BUTTON_STEP);
|
||||
state_set_power(target_power - BUTTON_STEP);
|
||||
} else {
|
||||
printf("- Reducing power: %i%% -> %i%%\n", target_power, 0);
|
||||
state_set_power(0);
|
||||
}
|
||||
}
|
||||
|
||||
btstack_run_loop_set_timer(ts, POLL_PERIOD_MS);
|
||||
btstack_run_loop_add_timer(ts);
|
||||
}
|
||||
|
||||
void buttons_init() {
|
||||
gpio_set_dir(BUTTON_PIN_POWER, GPIO_IN);
|
||||
gpio_set_dir(BUTTON_PIN_PLUS, GPIO_IN);
|
||||
gpio_set_dir(BUTTON_PIN_MINUS, GPIO_IN);
|
||||
|
||||
button_timer.process = button_timer_callback;
|
||||
button_timer.process(&button_timer);
|
||||
|
||||
// Why do these not trigger??
|
||||
// printf("Setting interrupts for buttons...\n");
|
||||
// gpio_set_irq_callback(button_callback);
|
||||
// gpio_set_irq_enabled(BUTTON_PIN_POWER, BUTTON_EVENTS, true);
|
||||
// gpio_set_irq_enabled(BUTTON_PIN_PLUS, BUTTON_EVENTS, true);
|
||||
// gpio_set_irq_enabled(BUTTON_PIN_MINUS, BUTTON_EVENTS, true);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef BUTTONS_H
|
||||
#define BUTTONS_H
|
||||
|
||||
void buttons_init();
|
||||
|
||||
#endif
|
|
@ -1,5 +1,4 @@
|
|||
#include "btstack.h"
|
||||
#include "buttons.h"
|
||||
#include "hci_dump.h"
|
||||
#include "hci_dump_segger_rtt_stdout.h"
|
||||
#include "pico/btstack_cyw43.h"
|
||||
|
@ -47,9 +46,6 @@ int main() {
|
|||
// set initial state
|
||||
state_init();
|
||||
|
||||
// hook up buttons
|
||||
buttons_init();
|
||||
|
||||
att_server_init(profile_data, bt_att_read_callback, bt_att_write_callback);
|
||||
|
||||
hci_event_callback_registration.callback = &bt_packet_handler;
|
||||
|
|
Loading…
Reference in a new issue