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

Nuphy air75 cleanup #7

Open
wants to merge 22 commits into
base: nuphy-air75
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
274 changes: 274 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
/*
Copyright 2023 @ Nuphy <https://nuphy.com/>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "kb_util.h"
#include "ansi.h"
#include "usb_main.h"

extern bool f_rf_sw_press;
extern bool f_sleep_show;
extern bool f_dev_reset_press;
extern bool f_bat_num_show;
extern bool f_rgb_test_press;
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 kb_config_t kb_config;
extern DEV_INFO_STRUCT dev_info;

/* qmk process record */
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) {
return false;
}
no_act_time = 0;
rf_linking_time = 0;

switch (keycode) {
case RF_DFU:
if (record->event.pressed) {
if (dev_info.link_mode != LINK_USB) {
return false;
}
uart_send_cmd(CMD_RF_DFU, 10, 20);
}
return false;

case LNK_USB:
if (record->event.pressed) {
break_all_key();
} else {
dev_info.link_mode = LINK_USB;
uart_send_cmd(CMD_SET_LINK, 10, 10);
}
return false;

case LNK_RF:
if (record->event.pressed) {
if (dev_info.link_mode != LINK_USB) {
rf_sw_temp = LINK_RF_24;
f_rf_sw_press = 1;
break_all_key();
}
} else if (f_rf_sw_press) {
f_rf_sw_press = 0;

if (rf_sw_press_delay < RF_LONG_PRESS_DELAY) {
dev_info.link_mode = rf_sw_temp;
dev_info.rf_channel = rf_sw_temp;
dev_info.ble_channel = rf_sw_temp;
uart_send_cmd(CMD_SET_LINK, 10, 20);
}
}
return false;

case LNK_BLE1:
if (record->event.pressed) {
if (dev_info.link_mode != LINK_USB) {
rf_sw_temp = LINK_BT_1;
f_rf_sw_press = 1;
break_all_key();
}
} else if (f_rf_sw_press) {
f_rf_sw_press = 0;

if (rf_sw_press_delay < RF_LONG_PRESS_DELAY) {
dev_info.link_mode = rf_sw_temp;
dev_info.rf_channel = rf_sw_temp;
dev_info.ble_channel = rf_sw_temp;
uart_send_cmd(CMD_SET_LINK, 10, 20);
}
}
return false;

case LNK_BLE2:
if (record->event.pressed) {
if (dev_info.link_mode != LINK_USB) {
rf_sw_temp = LINK_BT_2;
f_rf_sw_press = 1;
break_all_key();
}
} else if (f_rf_sw_press) {
f_rf_sw_press = 0;

if (rf_sw_press_delay < RF_LONG_PRESS_DELAY) {
dev_info.link_mode = rf_sw_temp;
dev_info.rf_channel = rf_sw_temp;
dev_info.ble_channel = rf_sw_temp;
uart_send_cmd(CMD_SET_LINK, 10, 20);
}
}
return false;

case LNK_BLE3:
if (record->event.pressed) {
if (dev_info.link_mode != LINK_USB) {
rf_sw_temp = LINK_BT_3;
f_rf_sw_press = 1;
break_all_key();
}
} else if (f_rf_sw_press) {
f_rf_sw_press = 0;

if (rf_sw_press_delay < RF_LONG_PRESS_DELAY) {
dev_info.link_mode = rf_sw_temp;
dev_info.rf_channel = rf_sw_temp;
dev_info.ble_channel = rf_sw_temp;
uart_send_cmd(CMD_SET_LINK, 10, 20);
}
}
return false;

case MAC_VOICE:
if (record->event.pressed) {
host_consumer_send(0xcf);
} else {
host_consumer_send(0);
}
return false;

case MAC_DND:
if (record->event.pressed) {
host_system_send(0x9b);
} else {
host_system_send(0);
}
return false;

case SIDE_VAI:
if (record->event.pressed) {
side_light_control(1);
}
return false;

case SIDE_VAD:
if (record->event.pressed) {
side_light_control(0);
}
return false;

case SIDE_MOD:
if (record->event.pressed) {
side_mode_control(1);
}
return false;

case SIDE_HUI:
if (record->event.pressed) {
side_colour_control(1);
}
return false;

case SIDE_SPI:
if (record->event.pressed) {
side_speed_control(1);
}
return false;

case SIDE_SPD:
if (record->event.pressed) {
side_speed_control(0);
}
return false;

case DEV_RESET:
if (record->event.pressed) {
f_dev_reset_press = 1;
break_all_key();
} else {
f_dev_reset_press = 0;
}
return false;

case SLEEP_MODE:
if (record->event.pressed) {
if (kb_config.sleep_enable) {
kb_config.sleep_enable = false;
} else {
kb_config.sleep_enable = true;
}
f_sleep_show = 1;
eeconfig_update_kb_datablock(&kb_config);
}
return false;

case BAT_SHOW:
if (record->event.pressed) {
f_bat_hold = !f_bat_hold;
}
return false;

case BAT_NUM:
f_bat_num_show = record->event.pressed;
return false;

case RGB_TEST:
f_rgb_test_press = record->event.pressed;
return false;

default:
return true;
}
return true;
}

bool rgb_matrix_indicators_kb(void) {
if (!rgb_matrix_indicators_user()) {
return false;
}
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;
}

/* qmk keyboard post init */
void keyboard_post_init_kb(void) {
gpio_init();
rf_uart_init();
wait_ms(500);
rf_device_init();

break_all_key();
dial_sw_fast_scan();
londing_eeprom_data();
keyboard_post_init_user();
}

/* qmk housekeeping task */
void housekeeping_task_kb(void) {
timer_pro();

uart_receive_pro();

uart_send_report_repeat();

dev_sts_sync();

long_press_key();

dial_sw_scan();

side_led_show();

sleep_handle();
}
50 changes: 50 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/ansi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2023 @ Nuphy <https://nuphy.com/>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "quantum.h"

enum custom_keycodes {
RF_DFU = QK_KB_0,
LNK_USB,
LNK_RF,
LNK_BLE1,
LNK_BLE2,
LNK_BLE3,

MAC_VOICE,
MAC_DND,

SIDE_VAI,
SIDE_VAD,
SIDE_MOD,
SIDE_HUI,
SIDE_SPI,
SIDE_SPD,

DEV_RESET,
SLEEP_MODE,
BAT_SHOW,
BAT_NUM,
RGB_TEST
};

#define SYS_PRT G(S(KC_3))
#define MAC_PRTA G(S(KC_4))
#define WIN_PRTA G(S(KC_S))
#define MAC_SEARCH G(KC_SPC)
36 changes: 36 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2023 @ Nuphy <https://nuphy.com/>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define DEV_MODE_PIN C0
#define SYS_MODE_PIN C1
#define DC_BOOST_PIN C2
#define NRF_RESET_PIN B4
#define NRF_TEST_PIN B5
#define NRF_WAKEUP_PIN B8
#define DRIVER_LED_CS_PIN C6
#define DRIVER_SIDE_PIN C8
#define DRIVER_SIDE_CS_PIN C9

#define SERIAL_DRIVER SD1
#define SD1_TX_PIN B6
#define SD1_TX_PAL_MODE 0
#define SD1_RX_PIN B7
#define SD1_RX_PAL_MODE 0

#define EECONFIG_KB_DATA_SIZE 8
23 changes: 23 additions & 0 deletions keyboards/nuphy/air75_v2/ansi/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2023 @ Nuphy <https://nuphy.com/>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include_next <halconf.h>

#undef HAL_USE_SERIAL
#define HAL_USE_SERIAL TRUE
Loading
Loading