Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keyboard] Add nuphy air75 v2 keyboard #22751

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3995b36
[Keyboard] Add nuphy air75 v2 keyboard
nuphy-src Dec 25, 2023
3bcceb8
Merge branch 'master' into nuphy-air75
nuphy-src Dec 25, 2023
f4495d4
Fixed some issues as suggested
nuphy-src Dec 27, 2023
f5f1262
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Dec 27, 2023
8c1c967
Merge branch 'master' into nuphy-air75
nuphy-src Jan 2, 2024
7642708
[Keyboard] Adjusted the code format
nuphy-src Jan 7, 2024
9e0eb67
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Jan 7, 2024
1b27fec
Merge branch 'master' into nuphy-air75
nuphy-src Jan 7, 2024
1eb1205
Fix mac layer erroe.
nuphy-src Jan 7, 2024
dbab794
Solved the problem of not sending codes in RF mode
nuphy-src Jan 8, 2024
570bc9c
Add nuphy license header
nuphy-src Jan 8, 2024
2263f4d
Merge branch 'master' into nuphy-air75
nuphy-src Jan 9, 2024
c56e210
Merge branch 'master' into nuphy-air75
nuphy-src Jan 15, 2024
f0c395b
Fix error in info.json
nuphy-src Jan 16, 2024
47553fe
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Jan 16, 2024
2cabdbd
Use process_record_kb function at ansi.c
nuphy-src Jan 24, 2024
26eaa3f
Merge branch 'master' into nuphy-air75
GateLi Jan 31, 2024
05d4515
Fixed some issues as suggested
nuphy-src Feb 5, 2024
2c03060
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Feb 5, 2024
a3ba423
Merge branch 'master' into nuphy-air75
nuphy-src Feb 16, 2024
322c28f
Merge branch 'master' into nuphy-air75
nuphy-src Feb 18, 2024
98a848a
Merge branch 'master' into nuphy-air75
nuphy-src Feb 20, 2024
3e62c4b
Merge branch 'master' into nuphy-air75
nuphy-src Feb 29, 2024
3c28a2e
Fix some formatting issues.
nuphy-src Mar 18, 2024
7789c42
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Mar 18, 2024
29502d6
Modify readme.md
nuphy-src Mar 20, 2024
2b81cf3
Merge branch 'master' into nuphy-air75
nuphy-src Mar 20, 2024
166eb06
Merge branch 'master' into nuphy-air75
nuphy-src Mar 21, 2024
e327732
Merge branch 'master' into nuphy-air75
nuphy-src Mar 22, 2024
8d4f887
Rename some variables in the code.
nuphy-src Apr 1, 2024
67c0c7f
Merge branch 'nuphy-air75' of https://github.com/nuphy-src/qmk_firmwa…
nuphy-src Apr 1, 2024
889d8c3
Update keyboards/nuphy/air75_v2/ansi/info.json
nuphy-src May 6, 2024
00bc5af
Merge remote-tracking branch 'upstream/master' into nuphy-air75
nuphy-src Jul 2, 2024
a4f5754
update
nuphy-src Jul 2, 2024
ae0f28c
Update keyboards/nuphy/air75_v2/ansi/readme.md
nuphy-src Aug 23, 2024
0f6d5f7
rename info.json to keyboard.json
nuphy-src Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Solved the problem of not sending codes in RF mode
  • Loading branch information
nuphy-src committed Jan 8, 2024
commit dbab794c690032e0c99ab31c1081e748266d4e16
7 changes: 6 additions & 1 deletion keyboards/nuphy/air75_v2/ansi/ansi.c
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ extern bool f_bat_hold;
extern uint16_t no_act_time;
extern uint8_t rf_sw_temp;
extern uint16_t rf_sw_press_delay;
extern uint16_t rf_linking_time;
extern user_config_t user_config;
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
extern DEV_INFO_STRUCT dev_info;


/* qmk process record */
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
no_act_time = 0;
rf_linking_time = 0;

switch (keycode) {
case RF_DFU:
if (record->event.pressed) {
Expand Down Expand Up @@ -231,6 +234,8 @@ bool rgb_matrix_indicators_user(void)
if(f_bat_num_show) {
num_led_show();
}

// fix power-on brightness is abnormal
rgb_matrix_set_color(RGB_MATRIX_LED_COUNT-1, 0, 0, 0);
return true;
}
Expand All @@ -253,7 +258,7 @@ void housekeeping_task_user(void) {

uart_receive_pro();

uart_send_report_func();
uart_send_report_repeat();

dev_sts_sync();

Expand Down
113 changes: 57 additions & 56 deletions keyboards/nuphy/air75_v2/ansi/rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "user_kb.h"
#include "uart.h" // qmk uart.h
#include "ansi.h"
#include "rf_driver.h"

USART_MGR_STRUCT Usart_Mgr;
#define RX_SBYTE Usart_Mgr.RXDBuf[0]
Expand All @@ -39,7 +40,6 @@ uint8_t uart_bit_report_buf[32] = {0};
uint8_t func_tab[32] = {0};
uint8_t bitkb_report_buf[32] = {0};
uint8_t bytekb_report_buf[8] = {0};
uint8_t mouse_report_buf[5] = {0};
uint16_t conkb_report = 0;
uint16_t syskb_report = 0;
uint8_t sync_lost = 0;
Expand All @@ -64,42 +64,12 @@ void uart_receive_pro(void);
void break_all_key(void);
uint16_t host_last_consumer_usage(void);

/**
* @brief Uart send consumer keys report.
* @note Call in host.c
*/
void uart_send_consumer_report(void) {
no_act_time = 0;
conkb_report = host_last_consumer_usage();
uart_send_report(CMD_RPT_CONSUME, (uint8_t *)(&conkb_report), 2);
}

/**
* @brief Uart send mouse keys report.
* @note Call in host.c
*/
void uart_send_mouse_report(void) {
report_mouse_t mouse_report = mousekey_get_report();

no_act_time = 0;
memcpy(mouse_report_buf, &mouse_report.buttons, 5);
uart_send_report(CMD_RPT_MS, mouse_report_buf, 5);
}

/**
* @brief Uart send system keys report.
* @note Call in host.c
*/
void uart_send_system_report(void) {
no_act_time = 0;
syskb_report = host_last_system_usage();
uart_send_report(CMD_RPT_SYS, (uint8_t *)(&syskb_report), 2);
}

/**
* @brief Uart auto nkey send
*/
bool f_f_bit_kb_act = 0;
bool f_bit_kb_act = 0;
static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report, uint8_t size)
{
uint8_t i, j, byte_index;
Expand All @@ -125,8 +95,6 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
break;
}
}


if (byte_index >= 8) {
uart_bit_report_buf[i] |= offset_mask;
f_bit_send = 1;
Expand All @@ -137,7 +105,6 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
bytekb_report_buf[byte_index] = 0;
f_byte_send = 1;
break;
;
}
}
if (byte_index >= 8) {
Expand All @@ -152,7 +119,7 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
}

if (f_bit_send) {
f_f_bit_kb_act = 1;
f_bit_kb_act = 1;
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
}

Expand All @@ -164,43 +131,77 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report

/**
* @brief Uart send keys report.
* @note Call in host.c
*/
void uart_send_report_func(void)
void uart_send_report_repeat(void)
{
static uint32_t interval_timer = 0;

if (dev_info.link_mode == LINK_USB) return;
keyboard_protocol = 1;

if(keymap_config.nkro)
nkro_report->mods = get_mods() | get_weak_mods();

if ((dev_info.sys_sw_state == SYS_SW_MAC) && (memcmp(bytekb_report_buf, &keyboard_report->mods, 8))) {
no_act_time = 0;
keyboard_report->reserved = 0;
memcpy(bytekb_report_buf, &keyboard_report->mods, 8);
uart_send_report(CMD_RPT_BYTE_KB, bytekb_report_buf, 8);
}
else if ((dev_info.sys_sw_state == SYS_SW_WIN) && (memcmp(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS+1))) {
no_act_time = 0;
uart_auto_nkey_send(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS+1);
memcpy(&bitkb_report_buf[0], &nkro_report->mods, NKRO_REPORT_BITS+1);
}
else if (timer_elapsed32(interval_timer) > 100) {
if (timer_elapsed32(interval_timer) > 50) {
interval_timer = timer_read32();
if (no_act_time <= 200) {
uart_send_report(CMD_RPT_BYTE_KB, bytekb_report_buf, 8);
wait_us(200);

if(f_f_bit_kb_act)
if(f_bit_kb_act)
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
}
else {
f_f_bit_kb_act = 0;
f_bit_kb_act = 0;
}
}
}

/**
* @brief Uart send consumer keys report.
* @note Call in rf_driver.c
*/
void uart_send_consumer_report(report_extra_t *report) {
no_act_time = 0;
uart_send_report(CMD_RPT_CONSUME, (uint8_t *)(&report->usage), 2);
}

/**
* @brief Uart send mouse keys report.
* @note Call in rf_driver.c
*/
void uart_send_mouse_report(report_mouse_t *report) {
no_act_time = 0;
uart_send_report(CMD_RPT_MS, &report->buttons, 5);
}

/**
* @brief Uart send system keys report.
* @note Call in rf_driver.c
*/
void uart_send_system_report(report_extra_t *report) {
no_act_time = 0;
uart_send_report(CMD_RPT_SYS, (uint8_t *)(&report->usage), 2);
}

/**
* @brief Uart send byte keys report.
* @note Call in rf_driver.c
*/
void uart_send_report_keyboard(report_keyboard_t *report) {
no_act_time = 0;
report->reserved = 0;
uart_send_report(CMD_RPT_BYTE_KB, &report->mods, 8);
memcpy(bytekb_report_buf, &report->mods, 8);
}

/**
* @brief Uart send bit keys report.
* @note Call in rf_driver.c
*/
void uart_send_report_nkro(report_nkro_t *report) {
no_act_time = 0;
uart_auto_nkey_send(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS + 1);
memcpy(&bitkb_report_buf[0], &nkro_report->mods, NKRO_REPORT_BITS + 1);
}

/**
* @brief Parsing the data received from the RF module.
*/
Expand Down Expand Up @@ -468,7 +469,7 @@ void dev_sts_sync(void) {
if (host_mode != HOST_RF_TYPE) {
host_mode = HOST_RF_TYPE;
break_all_key();
host_set_driver(0);
host_set_driver(&rf_host_driver);
}

if (dev_info.rf_state != RF_CONNECT) {
Expand Down
48 changes: 48 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/rf_driver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "host_driver.h"
#include "rf_driver.h"
#include "host.h"
#include "user_kb.h"

/* Variable declaration */
extern DEV_INFO_STRUCT dev_info;

/* Host driver */
static uint8_t rf_keyboard_leds(void);
static void rf_send_keyboard(report_keyboard_t *report);
static void rf_send_nkro(report_nkro_t *report);
static void rf_send_mouse(report_mouse_t *report);
static void rf_send_extra(report_extra_t *report);
host_driver_t rf_host_driver = {rf_keyboard_leds, rf_send_keyboard, rf_send_nkro, rf_send_mouse, rf_send_extra};

/* defined in rf.c */
extern void uart_send_report_keyboard(report_keyboard_t *report);
extern void uart_send_report_nkro(report_nkro_t *report);
extern void uart_send_mouse_report(report_mouse_t *report);
extern void uart_send_consumer_report(report_extra_t *report);
extern void uart_send_system_report(report_extra_t *report);

static uint8_t rf_keyboard_leds(void) {
return dev_info.rf_led;
}

static void rf_send_keyboard(report_keyboard_t *report) {
keyboard_protocol = 1;
uart_send_report_keyboard(report);
}

static void rf_send_nkro(report_nkro_t *report) {
keyboard_protocol = 1;
uart_send_report_nkro(report);
}

static void rf_send_mouse(report_mouse_t *report) {
uart_send_mouse_report(report);
}

static void rf_send_extra(report_extra_t *report) {
if (report->report_id == REPORT_ID_CONSUMER) {
uart_send_consumer_report(report);
} else if (report->report_id == REPORT_ID_SYSTEM) {
uart_send_system_report(report);
}
}
3 changes: 3 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/rf_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

extern host_driver_t rf_host_driver;
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions keyboards/nuphy/air75_v2/ansi/rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SRC += side.c
SRC += rf.c
SRC += sleep.c
SRC += rf_driver.c
SRC += user_kb.c
SRC += side_driver.c
QUANTUM_LIB_SRC += uart.c
19 changes: 11 additions & 8 deletions keyboards/nuphy/air75_v2/ansi/user_kb.c
nuphy-src marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "user_kb.h"
#include "ansi.h"
#include "usb_main.h"
#include "rf_driver.h"

user_config_t user_config;
DEV_INFO_STRUCT dev_info = {
Expand Down Expand Up @@ -173,18 +174,20 @@ void long_press_key(void) {
* @brief Release all keys, clear keyboard report.
*/
void break_all_key(void) {
uint8_t report_buf[16];
uint8_t report_buf[NKRO_REPORT_BITS + 1];
bool nkro_temp = keymap_config.nkro;

clear_weak_mods();
clear_mods();
clear_keyboard();

// break nkro key
keymap_config.nkro = 1;
memset(keyboard_report, 0, sizeof(report_keyboard_t));
host_keyboard_send(keyboard_report);
memset(nkro_report, 0, sizeof(report_nkro_t));
host_nkro_send(nkro_report);
wait_ms(10);

// break byte key
keymap_config.nkro = 0;
memset(keyboard_report, 0, sizeof(report_keyboard_t));
host_keyboard_send(keyboard_report);
Expand All @@ -193,7 +196,7 @@ void break_all_key(void) {
keymap_config.nkro = nkro_temp;

if (dev_info.link_mode != LINK_USB) {
memset(report_buf, 0, 16);
memset(report_buf, 0, NKRO_REPORT_BITS + 1);
uart_send_report(CMD_RPT_BIT_KB, report_buf, 16);
wait_ms(10);
uart_send_report(CMD_RPT_BYTE_KB, report_buf, 8);
Expand Down Expand Up @@ -224,8 +227,7 @@ void switch_dev_link(uint8_t mode) {
rf_link_show_time = 0;
} else {
host_mode = HOST_RF_TYPE;

host_set_driver(0);
host_set_driver(&rf_host_driver);
}
}

Expand Down Expand Up @@ -298,7 +300,7 @@ void dial_sw_scan(void) {
f_first = false;

if (dev_info.link_mode != LINK_USB) {
host_set_driver(0);
host_set_driver(&rf_host_driver);
}
}
}
Expand Down Expand Up @@ -378,6 +380,7 @@ void timer_pro(void) {
m_host_driver = host_get_driver();
}

// step 10ms
if (timer_elapsed32(interval_timer) < 10)
return;
else
Expand Down Expand Up @@ -413,4 +416,4 @@ void londing_eeprom_data(void) {
side_rgb = user_config.ee_side_rgb;
side_colour = user_config.ee_side_colour;
}
}
}
4 changes: 2 additions & 2 deletions keyboards/nuphy/air75_v2/ansi/user_kb.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typedef struct
void dev_sts_sync(void);
void rf_uart_init(void);
void rf_device_init(void);
void uart_send_report_func(void);
void uart_send_report_repeat(void);
void uart_receive_pro(void);
void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_size);
void side_speed_contol(uint8_t dir);
Expand All @@ -164,4 +164,4 @@ void dial_sw_scan(void);
void dial_sw_fast_scan(void);
void timer_pro(void);
void londing_eeprom_data(void);
uint8_t uart_send_cmd(uint8_t cmd, uint8_t ack_cnt, uint8_t delayms);
uint8_t uart_send_cmd(uint8_t cmd, uint8_t ack_cnt, uint8_t delayms);
Loading