-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
@@ -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 | ||
{ | ||
|
@@ -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) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
@@ -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 | ||
{ | ||
|
@@ -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++) | ||
{ | ||
|
@@ -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++) | ||
{ | ||
|
@@ -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) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |