durken1 / pierce

split 5x3 column stagger keyboard
MIT License
159 stars 8 forks source link

Identify pair #13

Closed Biisairo closed 2 days ago

Biisairo commented 3 days ago

Asked a question from the wrong github account and reposted it

Hi, I have a question. How do I know that multiple keyboards and multiple receivers are paired with each other? Is there any relevant code in the NRF firmware?

durken1 commented 2 days ago

Hi,

While the wireless protocol used (gazelle) supports pairing, I did not use it in this keyboard. So the keyboard halves and receiver are not actually paired.

This means if using several keyboards in proximity there is a high risk of interference between them. Not sure if this is your problem but it could be mitigated by using different pipe pairs for different keyboards (the halves transmit over pipe 0 and 1 by default and the receiver identifies which half is sending what matrix scan by looking at what pipe it was transmitted over). Another option would be to implement the gazelle pairing layer as well.

Biisairo commented 2 days ago

For multiple keyboards to work together without problems fix the keyboard part

void matrix_send(uint8_t *matrix) {
nrf_gzll_add_packet_to_tx_fifo(PIPE_NUMBER, matrix, ROWS); }

and reciever part

void nrf_gzll_host_rx_data_ready(uint32_t pipe, nrf_gzll_host_rx_info_t rx_info) { uint32_t data_payload_length = 4;

nrf_gzll_fetch_packet_from_rx_fifo(pipe, m_data_payload, &data_payload_length);

if (data_payload_length > 0)
{
    if (pipe == 0)
    {
        for(uint8_t i = 0;i < data_payload_length; ++i)
        {
            matrix[i] = m_data_payload[i];
        }
    }

    else
    {
        for(uint8_t i = 0;i < data_payload_length; ++i)
        {
            matrix[i+4] = m_data_payload[i];
        }
    }
}

}

durken1 commented 2 days ago

For the keyboard part you should change the pipe numbers here:

https://github.com/durken1/pierce/blob/master/wireless_modules_firmware%2Fwireless%2Fconfig%2Fpierce.h#L6

And here

https://github.com/durken1/pierce/blob/master/wireless_modules_firmware%2Fwireless%2Fconfig%2Fpierce.h#L32

The lines in the receiver code are correct, change the if checks to correspond to the correct pipe numbers.