Bugfixes
This commit is contained in:
parent
1ae9b58eba
commit
14cc93aab0
|
|
@ -1,6 +1,3 @@
|
||||||
[submodule "lib/Control-Surface"]
|
|
||||||
path = lib/Control-Surface
|
|
||||||
url = https://github.com/tttapa/Control-Surface.git
|
|
||||||
[submodule "lib/cs-midi"]
|
[submodule "lib/cs-midi"]
|
||||||
path = lib/cs-midi
|
path = lib/cs-midi
|
||||||
url = https://git.else-if.org/jess/cs-midi.git
|
url = https://git.else-if.org/jess/cs-midi.git
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ target_link_libraries(fractional_looper
|
||||||
pico_btstack_ble
|
pico_btstack_ble
|
||||||
pico_btstack_classic
|
pico_btstack_classic
|
||||||
pico_btstack_cyw43
|
pico_btstack_cyw43
|
||||||
|
pico_btstack_flash_bank
|
||||||
hardware_adc
|
hardware_adc
|
||||||
cs_midi
|
cs_midi
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -53,5 +53,6 @@
|
||||||
|
|
||||||
#define ENABLE_SOFTWARE_AES128
|
#define ENABLE_SOFTWARE_AES128
|
||||||
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
|
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
|
||||||
|
#define ENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 3a75d0cc19052b6331ad72ca01e18f65111156d1
|
|
||||||
15
main.cpp
15
main.cpp
|
|
@ -1,6 +1,11 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "pico/cyw43_arch.h"
|
#include "pico/cyw43_arch.h"
|
||||||
|
#include "pico/btstack_flash_bank.h"
|
||||||
|
#include "btstack_tlv_flash_bank.h"
|
||||||
|
#include "hci.h"
|
||||||
|
#include "ble/le_device_db_tlv.h"
|
||||||
|
#include "classic/btstack_link_key_db_tlv.h"
|
||||||
|
|
||||||
#include <cs_midi.h>
|
#include <cs_midi.h>
|
||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
|
|
@ -39,7 +44,17 @@ int main() {
|
||||||
}
|
}
|
||||||
printf("FractionalLooper: CYW43 initialized\n");
|
printf("FractionalLooper: CYW43 initialized\n");
|
||||||
|
|
||||||
|
// Persistent bonding storage — survives power cycles
|
||||||
|
static btstack_tlv_flash_bank_t tlv_context;
|
||||||
|
const hal_flash_bank_t *flash_bank = pico_flash_bank_instance();
|
||||||
|
const btstack_tlv_t *tlv_impl = btstack_tlv_flash_bank_init_instance(
|
||||||
|
&tlv_context, flash_bank, NULL);
|
||||||
|
btstack_tlv_set_instance(tlv_impl, &tlv_context);
|
||||||
|
le_device_db_tlv_configure(tlv_impl, &tlv_context);
|
||||||
|
hci_set_link_key_db(btstack_link_key_db_tlv_get_instance(tlv_impl, &tlv_context));
|
||||||
|
|
||||||
cs::BluetoothMIDI_Interface ble;
|
cs::BluetoothMIDI_Interface ble;
|
||||||
|
ble.ble_settings.initiate_security = true;
|
||||||
ble.begin();
|
ble.begin();
|
||||||
printf("BLE MIDI started\n");
|
printf("BLE MIDI started\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
#define NUM_ENCODERS 4
|
#define NUM_ENCODERS 4
|
||||||
|
|
||||||
// A/B swapped on encoders 0-2 to correct rotation direction.
|
// A/B swapped on encoders
|
||||||
// Encoder 0 rewired to GPIO 17/18. Encoder 3 left as-is (already correct).
|
static constexpr uint8_t ENC_PIN_A[NUM_ENCODERS] = {2, 5, 8, 9};
|
||||||
static constexpr uint8_t ENC_PIN_A[NUM_ENCODERS] = {17, 5, 8, 9};
|
static constexpr uint8_t ENC_PIN_B[NUM_ENCODERS] = {0, 3, 6, 11};
|
||||||
static constexpr uint8_t ENC_PIN_B[NUM_ENCODERS] = {18, 3, 6, 11};
|
|
||||||
static constexpr uint8_t BTN_PINS[NUM_ENCODERS] = {1, 4, 7, 10};
|
static constexpr uint8_t BTN_PINS[NUM_ENCODERS] = {1, 4, 7, 10};
|
||||||
|
|
||||||
void encoders_init();
|
void encoders_init();
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
.pio_version 0
|
|
||||||
|
|
||||||
; Quadrature encoder decoder for non-adjacent A/B pins.
|
|
||||||
;
|
|
||||||
; Pin layout per encoder: A = in_base+0, (switch = in_base+1), B = in_base+2.
|
|
||||||
; On each B transition, samples A and B into the ISR and pushes to RX FIFO.
|
|
||||||
; Software decodes direction from the state table.
|
|
||||||
;
|
|
||||||
; Set clock divider for ~10 kHz to filter mechanical bounce.
|
|
||||||
|
|
||||||
.program encoder
|
|
||||||
.wrap_target
|
|
||||||
wait 1 pin 2 ; wait for B (base+2) to go high
|
|
||||||
in pins, 3 ; sample A, switch, B (3 bits from base)
|
|
||||||
push noblock
|
|
||||||
wait 0 pin 2 ; wait for B to go low
|
|
||||||
in pins, 3 ; sample again
|
|
||||||
push noblock
|
|
||||||
.wrap
|
|
||||||
|
|
||||||
% c-sdk {
|
|
||||||
#include "hardware/clocks.h"
|
|
||||||
#include "hardware/gpio.h"
|
|
||||||
|
|
||||||
static inline void encoder_program_init(PIO pio, uint sm, uint offset,
|
|
||||||
uint pin_a) {
|
|
||||||
// Pin layout: A = pin_a, switch = pin_a+1, B = pin_a+2
|
|
||||||
uint pin_sw = pin_a + 1;
|
|
||||||
uint pin_b = pin_a + 2;
|
|
||||||
|
|
||||||
pio_gpio_init(pio, pin_a);
|
|
||||||
pio_gpio_init(pio, pin_b);
|
|
||||||
gpio_pull_up(pin_a);
|
|
||||||
gpio_pull_up(pin_b);
|
|
||||||
pio_sm_set_consecutive_pindirs(pio, sm, pin_a, 3, false);
|
|
||||||
|
|
||||||
pio_sm_config c = encoder_program_get_default_config(offset);
|
|
||||||
sm_config_set_in_pins(&c, pin_a);
|
|
||||||
sm_config_set_in_shift(&c, false, false, 32);
|
|
||||||
|
|
||||||
float div = (float)clock_get_hz(clk_sys) / 10000.0f;
|
|
||||||
sm_config_set_clkdiv(&c, div);
|
|
||||||
|
|
||||||
pio_sm_init(pio, sm, offset, &c);
|
|
||||||
pio_sm_set_enabled(pio, sm, true);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
Loading…
Reference in New Issue