Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Sep 25, 2023
2 parents eedc54b + 8867d5b commit e5800e1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 57 deletions.
27 changes: 15 additions & 12 deletions mitosis-like/central/src/main.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/**
* @file main.c
* @brief
* @author ZiTe ([email protected])
* @brief ErgoSNM keyboard wireless mitosis-like edition firmware, central.
* @author SideraKB / ZiTe ([email protected])
* @note SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "main.h"

/* Key matrix size. */
#define ROW_COUNT (5)
#define COL_COUNT (8)

#define PIPE_NUMBER (0) /* Gazell pipe. */
#define TX_PAYLOAD_LENGTH (1)
#define MSG_SIZE (32)

#define EOT (0xFE)
#define ACK (0xF6)

/* UART. */
static const struct device *qmk_uart_device = DEVICE_DT_GET(DT_NODELABEL(uart1));

#define MSG_SIZE 32

/* queue to store up to 10 messages (aligned to 4-byte boundary) */
K_MSGQ_DEFINE(uart_msgq, MSG_SIZE, 10, 4);

Expand All @@ -23,11 +32,6 @@ uint8_t raw_mouse[6] = {0};

LOG_MODULE_REGISTER(app, LOG_LEVEL_DBG);

/* Pipe 0 is used in this example. */
#define PIPE_NUMBER 0

#define TX_PAYLOAD_LENGTH 1

/* Gazell Link Layer RX result structure */
struct gzll_rx_result
{
Expand Down Expand Up @@ -123,9 +127,8 @@ void qmk_uart_send_bytes(uint8_t *data, uint16_t len)

/**
* @brief Send keymatrix and mouse data to QMK.
* @param keymatrix Keymatrix[Row][Col].
* @param mouse_x Mouse X axix data.
* @param mouse_y Mouse Y axix data.
* @param keymatrix Keymatrix[Row].
* @param mouse mouse data.
*/
void qmk_uart_send(uint8_t *keymatrix, uint8_t *mouse)
{
Expand Down
11 changes: 2 additions & 9 deletions mitosis-like/central/src/main.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file main.h
* @brief
* @author ZiTe ([email protected])
* @brief ErgoSNM keyboard wireless mitosis-like edition firmware, central.
* @author SideraKB / ZiTe ([email protected])
* @note SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

Expand All @@ -21,13 +21,6 @@
#include <string.h>
#include <stdio.h>

/* Key matrix size. */
#define ROW_COUNT 4
#define COL_COUNT 3

#define EOT (0xFE)
#define ACK (0xF6)

bool qmk_uart_init(void);
void qmk_uart_callback(const struct device *dev, void *user_data);
void qmk_uart_send_bytes(uint8_t *buf, uint16_t len);
Expand Down
44 changes: 37 additions & 7 deletions mitosis-like/peripheral/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,74 @@
// compatible = "gpio-keys";
compatible = "gpio-km";
col0: column_0 {
gpios = <&gpio1 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 25 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 0";
};
col1: column_1 {
gpios = <&gpio1 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 1";
};
col2: column_2 {
gpios = <&gpio1 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 22 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 2";
};
col3: column_3 {
gpios = <&gpio0 20 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 3";
};
col4: column_4 {
gpios = <&gpio0 21 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 4";
};
col5: column_5 {
gpios = <&gpio0 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 5";
};
col6: column_6 {
gpios = <&gpio0 17 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 6";
};
col7: column_7 {
gpios = <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 7";
};

row0: row_0 {
gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
label = "Row 0";
};
row1: row_1 {
gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
label = "Row 1";
};
row2: row_2 {
gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
label = "Row 2";
};
row3: row_3 {
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
label = "Row 3";
};
row4: row_4 {
gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>;
label = "Row 4";
};
};

aliases {
col0 = &col0;
col1 = &col1;
col2 = &col2;
col3 = &col3;
col4 = &col4;
col5 = &col5;
col6 = &col6;
col7 = &col7;
row0 = &row0;
row1 = &row1;
row2 = &row2;
row3 = &row3;
row4 = &row4;
};

chosen {
Expand Down
50 changes: 34 additions & 16 deletions mitosis-like/peripheral/src/main.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
/**
* @file main.c
* @brief
* @author ZiTe ([email protected])
* @brief ErgoSNM keyboard wireless mitosis-like edition firmware, peripheral.
* @author SideraKB / ZiTe ([email protected])
* @note SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "main.h"

#define PMW3360_ENABLE
#define PMW3360_ENABLE /* Comment out to disable PMW3360. */

/* Key matrix size. */
#define ROW_COUNT (5)
#define COL_COUNT (8)

#define PIPE_NUMBER (0) /* Gazell pipe. */
#define MAX_TX_ATTEMPTS (100) /* Maximum number of transmission attempts */

#ifdef PMW3360_ENABLE
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 6 + 1)
#else
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 1)
#endif

#define EOT (0xFE)

LOG_MODULE_REGISTER(app, LOG_LEVEL_DBG);

Expand All @@ -16,32 +31,28 @@ static const struct gpio_dt_spec row0_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(row0),
static const struct gpio_dt_spec row1_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(row1), gpios, {0});
static const struct gpio_dt_spec row2_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(row2), gpios, {0});
static const struct gpio_dt_spec row3_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(row3), gpios, {0});
static const struct gpio_dt_spec row4_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(row4), gpios, {0});
static struct gpio_dt_spec row_gpios[ROW_COUNT];

static const struct gpio_dt_spec col0_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col0), gpios, {0});
static const struct gpio_dt_spec col1_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col1), gpios, {0});
static const struct gpio_dt_spec col2_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col2), gpios, {0});
static const struct gpio_dt_spec col3_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col3), gpios, {0});
static const struct gpio_dt_spec col4_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col4), gpios, {0});
static const struct gpio_dt_spec col5_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col5), gpios, {0});
static const struct gpio_dt_spec col6_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col6), gpios, {0});
static const struct gpio_dt_spec col7_gpio = GPIO_DT_SPEC_GET_OR(DT_ALIAS(col7), gpios, {0});
static struct gpio_dt_spec col_gpios[COL_COUNT];

uint8_t raw_keymatrix[ROW_COUNT] = {0};

int16_t mouse_x, mouse_y, mouse_v = 0;
int16_t mouse_x = 0;
int16_t mouse_y = 0;
int16_t mouse_v = 0;

const struct device *pmw3360_device = DEVICE_DT_GET_ONE(pixart_pmw3360);
// static struct sensor_trigger pmw3360_trigger;

/* Pipe 0 is used in this example. */
#define PIPE_NUMBER 0

#ifdef PMW3360_ENABLE
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 6 + 1)
#else
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 1)
#endif

/* Maximum number of transmission attempts */
#define MAX_TX_ATTEMPTS 100

/* Gazell Link Layer TX result structure */
struct gzll_tx_result
{
Expand Down Expand Up @@ -326,6 +337,11 @@ bool keymatrix_init(void)
col_gpios[0] = col0_gpio;
col_gpios[1] = col1_gpio;
col_gpios[2] = col2_gpio;
col_gpios[3] = col3_gpio;
col_gpios[4] = col4_gpio;
col_gpios[5] = col5_gpio;
col_gpios[6] = col6_gpio;
col_gpios[7] = col7_gpio;

for (uint8_t i = 0; i < COL_COUNT; i++)
{
Expand All @@ -349,6 +365,7 @@ bool keymatrix_init(void)
row_gpios[1] = row1_gpio;
row_gpios[2] = row2_gpio;
row_gpios[3] = row3_gpio;
row_gpios[4] = row4_gpio;

for (uint8_t i = 0; i < ROW_COUNT; i++)
{
Expand Down Expand Up @@ -383,6 +400,7 @@ bool keymatrix_init(void)
/**
* @brief Select a row and read columns. (Diode direction: Col-to-Row)
* @param row Selected row index.
* @return column pin status.
*/
uint8_t keymatrix_read_cols(uint8_t row)
{
Expand Down
15 changes: 2 additions & 13 deletions mitosis-like/peripheral/src/main.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file main.h
* @brief
* @author ZiTe ([email protected])
* @brief ErgoSNM keyboard wireless mitosis-like edition firmware, peripheral.
* @author SideraKB / ZiTe ([email protected])
* @note SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

Expand All @@ -22,17 +22,6 @@
#include <string.h>
#include <stdio.h>

/* Key matrix size. */
#define ROW_COUNT 4
#define COL_COUNT 3

#define EOT (0xFE)

bool qmk_uart_init(void);
void qmk_uart_callback(const struct device *dev, void *user_data);
void qmk_uart_send_bytes(uint8_t *buf, uint16_t len);
void qmk_uart_send(uint8_t keymatrix[][COL_COUNT], int16_t mouse_x, int16_t mouse_y);

bool keymatrix_init(void);
uint8_t keymatrix_read_cols(uint8_t row);
void keymatrix_scan(uint8_t *matrix);
Expand Down
1 change: 1 addition & 0 deletions mitosis-like/readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Mitosis-like

[ErgoSNM keyboard](https://github.com/siderakb/ergo-snm-keyboard) wireless mitosis-like edition firmware.

0 comments on commit e5800e1

Please sign in to comment.