mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
Fixed some issues as suggested
This commit is contained in:
parent
3995b3669c
commit
f4495d4d41
@ -15,422 +15,22 @@ 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 "user_kb.h"
|
||||
#include "ansi.h"
|
||||
#include "usb_main.h"
|
||||
|
||||
user_config_t user_config;
|
||||
DEV_INFO_STRUCT dev_info = {
|
||||
.rf_baterry = 100,
|
||||
.link_mode = LINK_USB,
|
||||
.rf_state = RF_IDLE,
|
||||
};
|
||||
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 user_config_t user_config;
|
||||
extern DEV_INFO_STRUCT dev_info;
|
||||
|
||||
bool f_bat_hold = 0;
|
||||
bool f_sys_show = 0;
|
||||
bool f_sleep_show = 0;
|
||||
bool f_send_channel = 0;
|
||||
bool f_dial_sw_init_ok = 0;
|
||||
bool f_rf_sw_press = 0;
|
||||
bool f_dev_reset_press = 0;
|
||||
bool f_rgb_test_press = 0;
|
||||
bool f_bat_num_show = 0;
|
||||
|
||||
uint16_t rf_linking_time = 0;
|
||||
uint16_t rf_link_show_time = 0;
|
||||
uint8_t rf_blink_cnt = 0;
|
||||
uint16_t no_act_time = 0;
|
||||
uint8_t rf_sw_temp = 0;
|
||||
uint16_t dev_reset_press_delay = 0;
|
||||
uint16_t rf_sw_press_delay = 0;
|
||||
uint16_t rgb_test_press_delay = 0;
|
||||
uint8_t host_mode = 0;
|
||||
host_driver_t *m_host_driver = 0;
|
||||
|
||||
extern bool f_rf_new_adv_ok;
|
||||
extern report_keyboard_t *keyboard_report;
|
||||
extern report_nkro_t *nkro_report;
|
||||
extern uint8_t bitkb_report_buf[32];
|
||||
extern uint8_t bytekb_report_buf[8];
|
||||
extern uint8_t side_mode;
|
||||
extern uint8_t side_light;
|
||||
extern uint8_t side_speed;
|
||||
extern uint8_t side_rgb;
|
||||
extern uint8_t side_colour;
|
||||
|
||||
void dev_sts_sync(void);
|
||||
void rf_uart_init(void);
|
||||
void rf_device_init(void);
|
||||
void uart_send_report_func(void);
|
||||
void uart_receive_pro(void);
|
||||
uint8_t uart_send_cmd(uint8_t cmd, uint8_t ack_cnt, uint8_t delayms);
|
||||
void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_size);
|
||||
void side_speed_contol(uint8_t dir);
|
||||
void side_light_contol(uint8_t dir);
|
||||
void side_colour_control(uint8_t dir);
|
||||
void side_mode_control(uint8_t dir);
|
||||
void side_led_show(void);
|
||||
void sleep_handle(void);
|
||||
void bat_led_close(void);
|
||||
void num_led_show(void);
|
||||
void rgb_test_show(void);
|
||||
|
||||
/**
|
||||
* @brief gpio initial.
|
||||
*/
|
||||
void gpio_init(void) {
|
||||
/* enable led power driver */
|
||||
setPinOutput(DRIVER_LED_CS_PIN);
|
||||
setPinOutput(DRIVER_SIDE_CS_PIN);
|
||||
writePinLow(DRIVER_LED_CS_PIN);
|
||||
writePinLow(DRIVER_SIDE_CS_PIN);
|
||||
/* set side led pin output low */
|
||||
setPinOutput(DRIVER_SIDE_PIN);
|
||||
writePinLow(DRIVER_SIDE_PIN);
|
||||
/* config RF module pin */
|
||||
setPinOutput(NRF_WAKEUP_PIN);
|
||||
writePinHigh(NRF_WAKEUP_PIN);
|
||||
setPinInputHigh(NRF_TEST_PIN);
|
||||
/* reset RF module */
|
||||
setPinOutput(NRF_RESET_PIN);
|
||||
writePinLow(NRF_RESET_PIN);
|
||||
wait_ms(50);
|
||||
writePinHigh(NRF_RESET_PIN);
|
||||
/* config dial switch pin */
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
/* open led DC driver */
|
||||
setPinOutput(DC_BOOST_PIN);
|
||||
writePinHigh(DC_BOOST_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief long press key process.
|
||||
*/
|
||||
void long_press_key(void) {
|
||||
static uint32_t long_press_timer = 0;
|
||||
|
||||
if (timer_elapsed32(long_press_timer) < 100) return;
|
||||
long_press_timer = timer_read32();
|
||||
|
||||
// Open a new RF device
|
||||
if (f_rf_sw_press) {
|
||||
rf_sw_press_delay++;
|
||||
if (rf_sw_press_delay >= RF_LONG_PRESS_DELAY) {
|
||||
f_rf_sw_press = 0;
|
||||
|
||||
dev_info.link_mode = rf_sw_temp;
|
||||
dev_info.rf_channel = rf_sw_temp;
|
||||
dev_info.ble_channel = rf_sw_temp;
|
||||
|
||||
uint8_t timeout = 5;
|
||||
while (timeout--) {
|
||||
uart_send_cmd(CMD_NEW_ADV, 0, 1);
|
||||
wait_ms(20);
|
||||
uart_receive_pro();
|
||||
if (f_rf_new_adv_ok) break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rf_sw_press_delay = 0;
|
||||
}
|
||||
|
||||
// The device is restored to factory Settings
|
||||
if (f_dev_reset_press) {
|
||||
dev_reset_press_delay++;
|
||||
if (dev_reset_press_delay >= DEV_RESET_PRESS_DELAY) {
|
||||
f_dev_reset_press = 0;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
if (dev_info.link_mode != LINK_RF_24) {
|
||||
dev_info.link_mode = LINK_BT_1;
|
||||
dev_info.ble_channel = LINK_BT_1;
|
||||
dev_info.rf_channel = LINK_BT_1;
|
||||
}
|
||||
} else {
|
||||
dev_info.ble_channel = LINK_BT_1;
|
||||
dev_info.rf_channel = LINK_BT_1;
|
||||
}
|
||||
|
||||
uart_send_cmd(CMD_SET_LINK, 10, 10);
|
||||
wait_ms(500);
|
||||
uart_send_cmd(CMD_CLR_DEVICE, 10, 10);
|
||||
|
||||
void device_reset_show(void);
|
||||
void device_reset_init(void);
|
||||
|
||||
eeconfig_init();
|
||||
device_reset_show();
|
||||
device_reset_init();
|
||||
|
||||
if (dev_info.sys_sw_state == SYS_SW_MAC) {
|
||||
default_layer_set(1 << 0);
|
||||
keymap_config.nkro = 0;
|
||||
} else {
|
||||
default_layer_set(1 << 2);
|
||||
keymap_config.nkro = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev_reset_press_delay = 0;
|
||||
}
|
||||
|
||||
// Enter the RGB test mode
|
||||
if (f_rgb_test_press) {
|
||||
rgb_test_press_delay++;
|
||||
if (rgb_test_press_delay >= RGB_TEST_PRESS_DELAY) {
|
||||
f_rgb_test_press = 0;
|
||||
rgb_test_show();
|
||||
}
|
||||
} else {
|
||||
rgb_test_press_delay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release all keys, clear keyboard report.
|
||||
*/
|
||||
void break_all_key(void) {
|
||||
uint8_t report_buf[16];
|
||||
bool nkro_temp = keymap_config.nkro;
|
||||
|
||||
clear_weak_mods();
|
||||
clear_mods();
|
||||
clear_keyboard();
|
||||
|
||||
keymap_config.nkro = 1;
|
||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
||||
host_keyboard_send(keyboard_report);
|
||||
wait_ms(10);
|
||||
|
||||
keymap_config.nkro = 0;
|
||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
||||
host_keyboard_send(keyboard_report);
|
||||
wait_ms(10);
|
||||
|
||||
keymap_config.nkro = nkro_temp;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
memset(report_buf, 0, 16);
|
||||
uart_send_report(CMD_RPT_BIT_KB, report_buf, 16);
|
||||
wait_ms(10);
|
||||
uart_send_report(CMD_RPT_BYTE_KB, report_buf, 8);
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
memset(bitkb_report_buf, 0, sizeof(bitkb_report_buf));
|
||||
memset(bytekb_report_buf, 0, sizeof(bytekb_report_buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief switch device link mode.
|
||||
* @param mode : link mode
|
||||
*/
|
||||
void switch_dev_link(uint8_t mode) {
|
||||
if (mode > LINK_USB) return;
|
||||
|
||||
break_all_key();
|
||||
|
||||
dev_info.link_mode = mode;
|
||||
|
||||
dev_info.rf_state = RF_IDLE;
|
||||
f_send_channel = 1;
|
||||
|
||||
if (mode == LINK_USB) {
|
||||
host_mode = HOST_USB_TYPE;
|
||||
host_set_driver(m_host_driver);
|
||||
rf_link_show_time = 0;
|
||||
} else {
|
||||
host_mode = HOST_RF_TYPE;
|
||||
|
||||
host_set_driver(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief scan dial switch.
|
||||
*/
|
||||
void dial_sw_scan(void) {
|
||||
uint8_t dial_scan = 0;
|
||||
static uint8_t dial_save = 0xf0;
|
||||
static uint8_t debounce = 0;
|
||||
static uint32_t dial_scan_timer = 0;
|
||||
static bool f_first = true;
|
||||
|
||||
if (!f_first) {
|
||||
if (timer_elapsed32(dial_scan_timer) < 20) return;
|
||||
}
|
||||
dial_scan_timer = timer_read32();
|
||||
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
|
||||
if (readPin(DEV_MODE_PIN)) dial_scan |= 0X01;
|
||||
if (readPin(SYS_MODE_PIN)) dial_scan |= 0X02;
|
||||
|
||||
if (dial_save != dial_scan) {
|
||||
break_all_key();
|
||||
|
||||
no_act_time = 0;
|
||||
rf_linking_time = 0;
|
||||
|
||||
dial_save = dial_scan;
|
||||
debounce = 25;
|
||||
f_dial_sw_init_ok = 0;
|
||||
return;
|
||||
} else if (debounce) {
|
||||
debounce--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dial_scan & 0x01) {
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
switch_dev_link(LINK_USB);
|
||||
}
|
||||
} else {
|
||||
if (dev_info.link_mode != dev_info.rf_channel) {
|
||||
switch_dev_link(dev_info.rf_channel);
|
||||
}
|
||||
}
|
||||
|
||||
if (dial_scan & 0x02) {
|
||||
if (dev_info.sys_sw_state != SYS_SW_MAC) {
|
||||
f_sys_show = 1;
|
||||
default_layer_set(1 << 0);
|
||||
dev_info.sys_sw_state = SYS_SW_MAC;
|
||||
keymap_config.nkro = 0;
|
||||
break_all_key();
|
||||
}
|
||||
} else {
|
||||
if (dev_info.sys_sw_state != SYS_SW_WIN) {
|
||||
f_sys_show = 1;
|
||||
default_layer_set(1 << 2);
|
||||
dev_info.sys_sw_state = SYS_SW_WIN;
|
||||
keymap_config.nkro = 1;
|
||||
break_all_key();
|
||||
}
|
||||
}
|
||||
|
||||
if (f_dial_sw_init_ok == 0) {
|
||||
f_dial_sw_init_ok = 1;
|
||||
f_first = false;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
host_set_driver(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief power on scan dial switch.
|
||||
*/
|
||||
void dial_sw_fast_scan(void) {
|
||||
{
|
||||
uint8_t dial_scan_dev = 0;
|
||||
uint8_t dial_scan_sys = 0;
|
||||
uint8_t dial_check_dev = 0;
|
||||
uint8_t dial_check_sys = 0;
|
||||
uint8_t debounce = 0;
|
||||
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
|
||||
// Debounce to get a stable state
|
||||
for(debounce=0; debounce<10; debounce++) {
|
||||
dial_scan_dev = 0;
|
||||
dial_scan_sys = 0;
|
||||
if (readPin(DEV_MODE_PIN)) dial_scan_dev = 0x01;
|
||||
else dial_scan_dev = 0;
|
||||
if (readPin(SYS_MODE_PIN)) dial_scan_sys = 0x01;
|
||||
else dial_scan_sys = 0;
|
||||
if((dial_scan_dev != dial_check_dev)||(dial_scan_sys != dial_check_sys))
|
||||
{
|
||||
dial_check_dev = dial_scan_dev;
|
||||
dial_check_sys = dial_scan_sys;
|
||||
debounce = 0;
|
||||
}
|
||||
wait_ms(1);
|
||||
}
|
||||
|
||||
// RF link mode
|
||||
if (dial_scan_dev) {
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
switch_dev_link(LINK_USB);
|
||||
}
|
||||
} else {
|
||||
if (dev_info.link_mode != dev_info.rf_channel) {
|
||||
switch_dev_link(dev_info.rf_channel);
|
||||
}
|
||||
}
|
||||
|
||||
// Win or Mac
|
||||
if (dial_scan_sys) {
|
||||
if (dev_info.sys_sw_state != SYS_SW_MAC) {
|
||||
default_layer_set(1 << 0);
|
||||
dev_info.sys_sw_state = SYS_SW_MAC;
|
||||
keymap_config.nkro = 0;
|
||||
break_all_key();
|
||||
}
|
||||
} else {
|
||||
if (dev_info.sys_sw_state != SYS_SW_WIN) {
|
||||
//f_sys_show = 1;
|
||||
default_layer_set(1 << 2);
|
||||
dev_info.sys_sw_state = SYS_SW_WIN;
|
||||
keymap_config.nkro = 1;
|
||||
break_all_key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief timer process.
|
||||
*/
|
||||
void timer_pro(void) {
|
||||
static uint32_t interval_timer = 0;
|
||||
static bool f_first = true;
|
||||
|
||||
if (f_first) {
|
||||
f_first = false;
|
||||
interval_timer = timer_read32();
|
||||
m_host_driver = host_get_driver();
|
||||
}
|
||||
|
||||
if (timer_elapsed32(interval_timer) < 10)
|
||||
return;
|
||||
else
|
||||
interval_timer = timer_read32();
|
||||
|
||||
if (rf_link_show_time < RF_LINK_SHOW_TIME) rf_link_show_time++;
|
||||
|
||||
if (no_act_time < 0xffff) no_act_time++;
|
||||
|
||||
if (rf_linking_time < 0xffff) rf_linking_time++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief londing eeprom data.
|
||||
*/
|
||||
void londing_eeprom_data(void) {
|
||||
eeconfig_read_user_datablock(&user_config);
|
||||
if (user_config.default_brightness_flag != 0xA5) {
|
||||
/* first power on, set rgb matrix brightness at middle level*/
|
||||
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);
|
||||
user_config.default_brightness_flag = 0xA5;
|
||||
user_config.ee_side_mode = side_mode;
|
||||
user_config.ee_side_light = side_light;
|
||||
user_config.ee_side_speed = side_speed;
|
||||
user_config.ee_side_rgb = side_rgb;
|
||||
user_config.ee_side_colour = side_colour;
|
||||
user_config.sleep_enable = true;
|
||||
eeconfig_update_user_datablock(&user_config);
|
||||
} else {
|
||||
side_mode = user_config.ee_side_mode;
|
||||
side_light = user_config.ee_side_light;
|
||||
side_speed = user_config.ee_side_speed;
|
||||
side_rgb = user_config.ee_side_rgb;
|
||||
side_colour = user_config.ee_side_colour;
|
||||
}
|
||||
}
|
||||
|
||||
/* qmk process record */
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
@ -528,24 +128,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_TASK:
|
||||
if (record->event.pressed) {
|
||||
host_consumer_send(0x029F);
|
||||
} else {
|
||||
host_consumer_send(0);
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_SEARCH:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_LGUI);
|
||||
register_code(KC_SPACE);
|
||||
wait_ms(50);
|
||||
unregister_code(KC_LGUI);
|
||||
unregister_code(KC_SPACE);
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_VOICE:
|
||||
if (record->event.pressed) {
|
||||
host_consumer_send(0xcf);
|
||||
@ -554,14 +136,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_CONSOLE:
|
||||
if (record->event.pressed) {
|
||||
host_consumer_send(0x02A0);
|
||||
} else {
|
||||
host_consumer_send(0);
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_DND:
|
||||
if (record->event.pressed) {
|
||||
host_system_send(0x9b);
|
||||
@ -570,42 +144,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_PRT:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_LGUI);
|
||||
register_code(KC_LSFT);
|
||||
register_code(KC_3);
|
||||
wait_ms(50);
|
||||
unregister_code(KC_3);
|
||||
unregister_code(KC_LSFT);
|
||||
unregister_code(KC_LGUI);
|
||||
}
|
||||
return false;
|
||||
|
||||
case MAC_PRTA:
|
||||
if (record->event.pressed) {
|
||||
if (dev_info.sys_sw_state == SYS_SW_WIN) {
|
||||
register_code(KC_LGUI);
|
||||
register_code(KC_LSFT);
|
||||
register_code(KC_S);
|
||||
wait_ms(50);
|
||||
unregister_code(KC_S);
|
||||
unregister_code(KC_LSFT);
|
||||
unregister_code(KC_LGUI);
|
||||
}
|
||||
|
||||
else {
|
||||
register_code(KC_LGUI);
|
||||
register_code(KC_LSFT);
|
||||
register_code(KC_4);
|
||||
wait_ms(50);
|
||||
unregister_code(KC_4);
|
||||
unregister_code(KC_LSFT);
|
||||
unregister_code(KC_LGUI);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case SIDE_VAI:
|
||||
if (record->event.pressed) {
|
||||
side_light_contol(1);
|
||||
|
@ -27,12 +27,8 @@ enum custom_keycodes {
|
||||
LNK_BLE2,
|
||||
LNK_BLE3,
|
||||
|
||||
MAC_TASK,
|
||||
MAC_SEARCH,
|
||||
MAC_VOICE,
|
||||
MAC_CONSOLE,
|
||||
MAC_PRT,
|
||||
MAC_PRTA,
|
||||
MAC_DND,
|
||||
|
||||
SIDE_VAI,
|
||||
SIDE_VAD,
|
||||
@ -44,129 +40,11 @@ enum custom_keycodes {
|
||||
DEV_RESET,
|
||||
SLEEP_MODE,
|
||||
BAT_SHOW,
|
||||
MAC_DND,
|
||||
BAT_NUM,
|
||||
RGB_TEST
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
RX_Idle,
|
||||
RX_Receiving,
|
||||
RX_Done,
|
||||
RX_Fail,
|
||||
RX_OV_ERR,
|
||||
RX_SUM_ERR,
|
||||
RX_CMD_ERR,
|
||||
RX_DATA_ERR,
|
||||
RX_DATA_OV,
|
||||
RX_FORMAT_ERR,
|
||||
|
||||
TX_OK = 0XE0,
|
||||
TX_DONE,
|
||||
TX_BUSY,
|
||||
TX_TIMEOUT,
|
||||
TX_DATA_ERR,
|
||||
|
||||
} TYPE_RX_STATE;
|
||||
|
||||
|
||||
#define RF_IDLE 0
|
||||
#define RF_PAIRING 1
|
||||
#define RF_LINKING 2
|
||||
#define RF_CONNECT 3
|
||||
#define RF_DISCONNECT 4
|
||||
#define RF_SLEEP 5
|
||||
#define RF_SNIF 6
|
||||
#define RF_INVAILD 0XFE
|
||||
#define RF_ERR_STATE 0XFF
|
||||
|
||||
#define CMD_POWER_UP 0XF0
|
||||
#define CMD_SLEEP 0XF1
|
||||
#define CMD_HAND 0XF2
|
||||
#define CMD_SNIF 0XF3
|
||||
#define CMD_24G_SUSPEND 0XF4
|
||||
#define CMD_IDLE_EXIT 0XFE
|
||||
|
||||
#define CMD_RPT_MS 0XE0
|
||||
#define CMD_RPT_BYTE_KB 0XE1
|
||||
#define CMD_RPT_BIT_KB 0XE2
|
||||
#define CMD_RPT_CONSUME 0XE3
|
||||
#define CMD_RPT_SYS 0XE4
|
||||
|
||||
#define CMD_SET_LINK 0XC0
|
||||
#define CMD_SET_CONFIG 0XC1
|
||||
#define CMD_GET_CONFIG 0XC2
|
||||
#define CMD_SET_NAME 0XC3
|
||||
#define CMD_GET_NAME 0XC4
|
||||
#define CMD_CLR_DEVICE 0XC5
|
||||
#define CMD_NEW_ADV 0XC7
|
||||
#define CMD_RF_STS_SYSC 0XC9
|
||||
#define CMD_SET_24G_NAME 0XCA
|
||||
#define CMD_GO_TEST 0XCF
|
||||
#define CMD_RF_DFU 0XB1
|
||||
|
||||
#define CMD_WRITE_DATA 0X80
|
||||
#define CMD_READ_DATA 0X81
|
||||
|
||||
#define LINK_RF_24 0
|
||||
#define LINK_BT_1 1
|
||||
#define LINK_BT_2 2
|
||||
#define LINK_BT_3 3
|
||||
#define LINK_USB 4
|
||||
|
||||
#define UART_HEAD 0x5A
|
||||
#define FUNC_VALID_LEN 32
|
||||
#define UART_MAX_LEN 64
|
||||
|
||||
#define SYS_SW_WIN 0xa1
|
||||
#define SYS_SW_MAC 0xa2
|
||||
|
||||
#define RF_LINK_SHOW_TIME 300
|
||||
|
||||
#define HOST_USB_TYPE 0
|
||||
#define HOST_BLE_TYPE 1
|
||||
#define HOST_RF_TYPE 2
|
||||
|
||||
#define LINK_TIMEOUT (100 * 120)
|
||||
#define SLEEP_TIME_DELAY (100 * 360)
|
||||
#define POWER_DOWN_DELAY (24)
|
||||
|
||||
#define RF_LONG_PRESS_DELAY 30
|
||||
#define DEV_RESET_PRESS_DELAY 30
|
||||
#define RGB_TEST_PRESS_DELAY 30
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RXDState;
|
||||
uint8_t RXDLen;
|
||||
uint8_t RXDOverTime;
|
||||
uint8_t TXDLenBack;
|
||||
uint8_t TXDOffset;
|
||||
uint8_t TXDBuf[UART_MAX_LEN];
|
||||
uint8_t RXDBuf[UART_MAX_LEN];
|
||||
} USART_MGR_STRUCT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t link_mode;
|
||||
uint8_t rf_channel;
|
||||
uint8_t ble_channel;
|
||||
uint8_t rf_state;
|
||||
uint8_t rf_charge;
|
||||
uint8_t rf_led;
|
||||
uint8_t rf_baterry;
|
||||
uint8_t sys_sw_state;
|
||||
} DEV_INFO_STRUCT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t default_brightness_flag;
|
||||
uint8_t ee_side_mode;
|
||||
uint8_t ee_side_light;
|
||||
uint8_t ee_side_speed;
|
||||
uint8_t ee_side_rgb;
|
||||
uint8_t ee_side_colour;
|
||||
uint8_t sleep_enable;
|
||||
uint8_t retain1;
|
||||
uint8_t retain2;
|
||||
} user_config_t;
|
||||
#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)
|
||||
|
@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#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
|
||||
|
||||
@ -40,5 +39,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EECONFIG_USER_DATA_SIZE 8
|
||||
|
||||
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
"max_brightness": 128,
|
||||
"val_steps": 26,
|
||||
"speed_steps": 52,
|
||||
"sleep": true,
|
||||
"animations": {
|
||||
"gradient_up_down": true,
|
||||
"gradient_left_right": true,
|
||||
@ -169,8 +170,9 @@
|
||||
"ws2812": {
|
||||
"pin": "A7"
|
||||
},
|
||||
"community_layouts": ["75_ansi"],
|
||||
"layouts": {
|
||||
"LAYOUT_ansi_84": {
|
||||
"LAYOUT_75_ansi": {
|
||||
"layout": [
|
||||
{"label": "Esc", "matrix": [0, 0], "x": 0, "y": 0},
|
||||
{"label": "F1", "matrix": [0, 1], "x": 1, "y": 0},
|
||||
@ -266,3 +268,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,47 +20,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
// layer Mac
|
||||
[0] = LAYOUT_ansi_84(
|
||||
KC_ESC, KC_BRID, KC_BRIU, MAC_TASK, MAC_SEARCH, MAC_VOICE, MAC_DND, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, MAC_PRTA, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
[0] = LAYOUT_75_ansi(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, MAC_SEARCH, MAC_VOICE, MAC_DND, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, MAC_PRTA, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
// layer Mac Fn
|
||||
[1] = LAYOUT_ansi_84(
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, MAC_PRT, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, RGB_TEST, _______, BAT_NUM, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(1), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
[1] = LAYOUT_75_ansi(
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, SYS_PRT, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, RGB_TEST, _______, BAT_NUM, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(1), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
|
||||
// layer win
|
||||
[2] = LAYOUT_ansi_84(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(3), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
[2] = LAYOUT_75_ansi(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(3), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
// layer win Fn
|
||||
[3] = LAYOUT_ansi_84(
|
||||
_______, KC_BRID, KC_BRIU, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, RGB_TEST, _______, BAT_NUM, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(3), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
[3] = LAYOUT_75_ansi(
|
||||
_______, KC_BRID, KC_BRIU, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, RGB_TEST, _______, BAT_NUM, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(3), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
|
||||
// layer 4
|
||||
[4] = LAYOUT_ansi_84(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, SIDE_SPD, SIDE_SPI, _______, _______, SIDE_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(4), _______, SIDE_MOD, SIDE_VAD, SIDE_HUI)
|
||||
[4] = LAYOUT_75_ansi(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, SIDE_SPD, SIDE_SPI, _______, _______, SIDE_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(4), _______, SIDE_MOD, SIDE_VAD, SIDE_HUI)
|
||||
};
|
||||
|
@ -20,47 +20,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
// layer Mac
|
||||
[0] = LAYOUT_ansi_84(
|
||||
KC_ESC, KC_BRID, KC_BRIU, MAC_TASK, MAC_SEARCH, MAC_VOICE, MAC_CONSOLE,KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, MAC_PRTA, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
[0] = LAYOUT_75_ansi(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, MAC_SEARCH, MAC_VOICE, MAC_DND, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, MAC_PRTA, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
// layer Mac Fn
|
||||
[1] = LAYOUT_ansi_84(
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, MAC_PRT, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(1), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
[1] = LAYOUT_75_ansi(
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, SYS_PRT, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(1), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
|
||||
// layer win
|
||||
[2] = LAYOUT_ansi_84(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(3), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
[2] = LAYOUT_75_ansi(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(3), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
// layer win Fn
|
||||
[3] = LAYOUT_ansi_84(
|
||||
_______, KC_BRID, KC_BRIU, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(3), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
[3] = LAYOUT_75_ansi(
|
||||
_______, KC_BRID, KC_BRIU, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______,
|
||||
_______, LNK_BLE1, LNK_BLE2, LNK_BLE3, LNK_RF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DEV_RESET, SLEEP_MODE, BAT_SHOW, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, MO(4), RGB_SPD, RGB_SPI, _______, _______, RGB_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(3), _______, RGB_MOD, RGB_VAD, RGB_HUI),
|
||||
|
||||
// layer 4
|
||||
[4] = LAYOUT_ansi_84(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, SIDE_SPD, SIDE_SPI, _______, _______, SIDE_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(4), _______, SIDE_MOD, SIDE_VAD, SIDE_HUI)
|
||||
[4] = LAYOUT_75_ansi(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, SIDE_SPD, SIDE_SPI, _______, _______, SIDE_VAI, _______,
|
||||
_______, _______, _______, _______, _______, MO(4), _______, SIDE_MOD, SIDE_VAD, SIDE_HUI)
|
||||
};
|
||||
|
@ -15,8 +15,9 @@ 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 "ansi.h"
|
||||
#include "user_kb.h"
|
||||
#include "uart.h" // qmk uart.h
|
||||
#include "ansi.h"
|
||||
|
||||
USART_MGR_STRUCT Usart_Mgr;
|
||||
#define RX_SBYTE Usart_Mgr.RXDBuf[0]
|
||||
|
@ -1,5 +1,6 @@
|
||||
SRC += side.c
|
||||
SRC += rf.c
|
||||
SRC += sleep.c
|
||||
SRC += user_kb.c
|
||||
SRC += side_driver.c
|
||||
QUANTUM_LIB_SRC += uart.c
|
||||
|
@ -15,8 +15,10 @@ 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 "user_kb.h"
|
||||
#include "ansi.h"
|
||||
#include "side_table.h"
|
||||
#include "ws2812.h"
|
||||
|
||||
#define SIDE_BRIGHT_MAX 4
|
||||
#define SIDE_SPEED_MAX 4
|
||||
@ -756,7 +758,7 @@ void device_reset_init(void) {
|
||||
f_bat_hold = false;
|
||||
|
||||
rgb_matrix_enable();
|
||||
rgb_matrix_mode(RGB_MATRIX_DEFAULT_MODE);
|
||||
rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT);
|
||||
rgb_matrix_set_speed(255 - RGB_MATRIX_SPD_STEP * 2);
|
||||
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);
|
||||
|
||||
|
@ -15,6 +15,7 @@ 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 "user_kb.h"
|
||||
#include "ansi.h"
|
||||
#include "hal_usb.h"
|
||||
#include "usb_main.h"
|
||||
|
416
keyboards/nuphy/air75_v2/ansi/user_kb.c
Normal file
416
keyboards/nuphy/air75_v2/ansi/user_kb.c
Normal file
@ -0,0 +1,416 @@
|
||||
/*
|
||||
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 "user_kb.h"
|
||||
#include "ansi.h"
|
||||
#include "usb_main.h"
|
||||
|
||||
user_config_t user_config;
|
||||
DEV_INFO_STRUCT dev_info = {
|
||||
.rf_baterry = 100,
|
||||
.link_mode = LINK_USB,
|
||||
.rf_state = RF_IDLE,
|
||||
};
|
||||
bool f_bat_hold = 0;
|
||||
bool f_sys_show = 0;
|
||||
bool f_sleep_show = 0;
|
||||
bool f_send_channel = 0;
|
||||
bool f_dial_sw_init_ok = 0;
|
||||
bool f_rf_sw_press = 0;
|
||||
bool f_dev_reset_press = 0;
|
||||
bool f_rgb_test_press = 0;
|
||||
bool f_bat_num_show = 0;
|
||||
|
||||
uint8_t rf_blink_cnt = 0;
|
||||
uint8_t rf_sw_temp = 0;
|
||||
uint8_t host_mode = 0;
|
||||
uint16_t rf_linking_time = 0;
|
||||
uint16_t rf_link_show_time = 0;
|
||||
uint16_t no_act_time = 0;
|
||||
uint16_t dev_reset_press_delay = 0;
|
||||
uint16_t rf_sw_press_delay = 0;
|
||||
uint16_t rgb_test_press_delay = 0;
|
||||
host_driver_t *m_host_driver = 0;
|
||||
|
||||
extern bool f_rf_new_adv_ok;
|
||||
extern report_keyboard_t *keyboard_report;
|
||||
extern report_nkro_t *nkro_report;
|
||||
extern uint8_t bitkb_report_buf[32];
|
||||
extern uint8_t bytekb_report_buf[8];
|
||||
extern uint8_t side_mode;
|
||||
extern uint8_t side_light;
|
||||
extern uint8_t side_speed;
|
||||
extern uint8_t side_rgb;
|
||||
extern uint8_t side_colour;
|
||||
|
||||
/**
|
||||
* @brief gpio initial.
|
||||
*/
|
||||
void gpio_init(void) {
|
||||
/* enable led power driver */
|
||||
setPinOutput(DRIVER_LED_CS_PIN);
|
||||
setPinOutput(DRIVER_SIDE_CS_PIN);
|
||||
writePinLow(DRIVER_LED_CS_PIN);
|
||||
writePinLow(DRIVER_SIDE_CS_PIN);
|
||||
/* set side led pin output low */
|
||||
setPinOutput(DRIVER_SIDE_PIN);
|
||||
writePinLow(DRIVER_SIDE_PIN);
|
||||
/* config RF module pin */
|
||||
setPinOutput(NRF_WAKEUP_PIN);
|
||||
writePinHigh(NRF_WAKEUP_PIN);
|
||||
setPinInputHigh(NRF_TEST_PIN);
|
||||
/* reset RF module */
|
||||
setPinOutput(NRF_RESET_PIN);
|
||||
writePinLow(NRF_RESET_PIN);
|
||||
wait_ms(50);
|
||||
writePinHigh(NRF_RESET_PIN);
|
||||
/* config dial switch pin */
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
/* open led DC driver */
|
||||
setPinOutput(DC_BOOST_PIN);
|
||||
writePinHigh(DC_BOOST_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief long press key process.
|
||||
*/
|
||||
void long_press_key(void) {
|
||||
static uint32_t long_press_timer = 0;
|
||||
|
||||
if (timer_elapsed32(long_press_timer) < 100) return;
|
||||
long_press_timer = timer_read32();
|
||||
|
||||
// Open a new RF device
|
||||
if (f_rf_sw_press) {
|
||||
rf_sw_press_delay++;
|
||||
if (rf_sw_press_delay >= RF_LONG_PRESS_DELAY) {
|
||||
f_rf_sw_press = 0;
|
||||
|
||||
dev_info.link_mode = rf_sw_temp;
|
||||
dev_info.rf_channel = rf_sw_temp;
|
||||
dev_info.ble_channel = rf_sw_temp;
|
||||
|
||||
uint8_t timeout = 5;
|
||||
while (timeout--) {
|
||||
uart_send_cmd(CMD_NEW_ADV, 0, 1);
|
||||
wait_ms(20);
|
||||
uart_receive_pro();
|
||||
if (f_rf_new_adv_ok) break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rf_sw_press_delay = 0;
|
||||
}
|
||||
|
||||
// The device is restored to factory Settings
|
||||
if (f_dev_reset_press) {
|
||||
dev_reset_press_delay++;
|
||||
if (dev_reset_press_delay >= DEV_RESET_PRESS_DELAY) {
|
||||
f_dev_reset_press = 0;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
if (dev_info.link_mode != LINK_RF_24) {
|
||||
dev_info.link_mode = LINK_BT_1;
|
||||
dev_info.ble_channel = LINK_BT_1;
|
||||
dev_info.rf_channel = LINK_BT_1;
|
||||
}
|
||||
} else {
|
||||
dev_info.ble_channel = LINK_BT_1;
|
||||
dev_info.rf_channel = LINK_BT_1;
|
||||
}
|
||||
|
||||
uart_send_cmd(CMD_SET_LINK, 10, 10);
|
||||
wait_ms(500);
|
||||
uart_send_cmd(CMD_CLR_DEVICE, 10, 10);
|
||||
|
||||
void device_reset_show(void);
|
||||
void device_reset_init(void);
|
||||
|
||||
eeconfig_init();
|
||||
device_reset_show();
|
||||
device_reset_init();
|
||||
|
||||
if (dev_info.sys_sw_state == SYS_SW_MAC) {
|
||||
default_layer_set(1 << 0);
|
||||
keymap_config.nkro = 0;
|
||||
} else {
|
||||
default_layer_set(1 << 2);
|
||||
keymap_config.nkro = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev_reset_press_delay = 0;
|
||||
}
|
||||
|
||||
// Enter the RGB test mode
|
||||
if (f_rgb_test_press) {
|
||||
rgb_test_press_delay++;
|
||||
if (rgb_test_press_delay >= RGB_TEST_PRESS_DELAY) {
|
||||
f_rgb_test_press = 0;
|
||||
rgb_test_show();
|
||||
}
|
||||
} else {
|
||||
rgb_test_press_delay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release all keys, clear keyboard report.
|
||||
*/
|
||||
void break_all_key(void) {
|
||||
uint8_t report_buf[16];
|
||||
bool nkro_temp = keymap_config.nkro;
|
||||
|
||||
clear_weak_mods();
|
||||
clear_mods();
|
||||
clear_keyboard();
|
||||
|
||||
keymap_config.nkro = 1;
|
||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
||||
host_keyboard_send(keyboard_report);
|
||||
wait_ms(10);
|
||||
|
||||
keymap_config.nkro = 0;
|
||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
||||
host_keyboard_send(keyboard_report);
|
||||
wait_ms(10);
|
||||
|
||||
keymap_config.nkro = nkro_temp;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
memset(report_buf, 0, 16);
|
||||
uart_send_report(CMD_RPT_BIT_KB, report_buf, 16);
|
||||
wait_ms(10);
|
||||
uart_send_report(CMD_RPT_BYTE_KB, report_buf, 8);
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
memset(bitkb_report_buf, 0, sizeof(bitkb_report_buf));
|
||||
memset(bytekb_report_buf, 0, sizeof(bytekb_report_buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief switch device link mode.
|
||||
* @param mode : link mode
|
||||
*/
|
||||
void switch_dev_link(uint8_t mode) {
|
||||
if (mode > LINK_USB) return;
|
||||
|
||||
break_all_key();
|
||||
|
||||
dev_info.link_mode = mode;
|
||||
|
||||
dev_info.rf_state = RF_IDLE;
|
||||
f_send_channel = 1;
|
||||
|
||||
if (mode == LINK_USB) {
|
||||
host_mode = HOST_USB_TYPE;
|
||||
host_set_driver(m_host_driver);
|
||||
rf_link_show_time = 0;
|
||||
} else {
|
||||
host_mode = HOST_RF_TYPE;
|
||||
|
||||
host_set_driver(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief scan dial switch.
|
||||
*/
|
||||
void dial_sw_scan(void) {
|
||||
uint8_t dial_scan = 0;
|
||||
static uint8_t dial_save = 0xf0;
|
||||
static uint8_t debounce = 0;
|
||||
static uint32_t dial_scan_timer = 0;
|
||||
static bool f_first = true;
|
||||
|
||||
if (!f_first) {
|
||||
if (timer_elapsed32(dial_scan_timer) < 20) return;
|
||||
}
|
||||
dial_scan_timer = timer_read32();
|
||||
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
|
||||
if (readPin(DEV_MODE_PIN)) dial_scan |= 0X01;
|
||||
if (readPin(SYS_MODE_PIN)) dial_scan |= 0X02;
|
||||
|
||||
if (dial_save != dial_scan) {
|
||||
break_all_key();
|
||||
|
||||
no_act_time = 0;
|
||||
rf_linking_time = 0;
|
||||
|
||||
dial_save = dial_scan;
|
||||
debounce = 25;
|
||||
f_dial_sw_init_ok = 0;
|
||||
return;
|
||||
} else if (debounce) {
|
||||
debounce--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dial_scan & 0x01) {
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
switch_dev_link(LINK_USB);
|
||||
}
|
||||
} else {
|
||||
if (dev_info.link_mode != dev_info.rf_channel) {
|
||||
switch_dev_link(dev_info.rf_channel);
|
||||
}
|
||||
}
|
||||
|
||||
if (dial_scan & 0x02) {
|
||||
if (dev_info.sys_sw_state != SYS_SW_MAC) {
|
||||
f_sys_show = 1;
|
||||
default_layer_set(1 << 0);
|
||||
dev_info.sys_sw_state = SYS_SW_MAC;
|
||||
keymap_config.nkro = 0;
|
||||
break_all_key();
|
||||
}
|
||||
} else {
|
||||
if (dev_info.sys_sw_state != SYS_SW_WIN) {
|
||||
f_sys_show = 1;
|
||||
default_layer_set(1 << 2);
|
||||
dev_info.sys_sw_state = SYS_SW_WIN;
|
||||
keymap_config.nkro = 1;
|
||||
break_all_key();
|
||||
}
|
||||
}
|
||||
|
||||
if (f_dial_sw_init_ok == 0) {
|
||||
f_dial_sw_init_ok = 1;
|
||||
f_first = false;
|
||||
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
host_set_driver(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief power on scan dial switch.
|
||||
*/
|
||||
void dial_sw_fast_scan(void) {
|
||||
{
|
||||
uint8_t dial_scan_dev = 0;
|
||||
uint8_t dial_scan_sys = 0;
|
||||
uint8_t dial_check_dev = 0;
|
||||
uint8_t dial_check_sys = 0;
|
||||
uint8_t debounce = 0;
|
||||
|
||||
setPinInputHigh(DEV_MODE_PIN);
|
||||
setPinInputHigh(SYS_MODE_PIN);
|
||||
|
||||
// Debounce to get a stable state
|
||||
for(debounce=0; debounce<10; debounce++) {
|
||||
dial_scan_dev = 0;
|
||||
dial_scan_sys = 0;
|
||||
if (readPin(DEV_MODE_PIN)) dial_scan_dev = 0x01;
|
||||
else dial_scan_dev = 0;
|
||||
if (readPin(SYS_MODE_PIN)) dial_scan_sys = 0x01;
|
||||
else dial_scan_sys = 0;
|
||||
if((dial_scan_dev != dial_check_dev)||(dial_scan_sys != dial_check_sys))
|
||||
{
|
||||
dial_check_dev = dial_scan_dev;
|
||||
dial_check_sys = dial_scan_sys;
|
||||
debounce = 0;
|
||||
}
|
||||
wait_ms(1);
|
||||
}
|
||||
|
||||
// RF link mode
|
||||
if (dial_scan_dev) {
|
||||
if (dev_info.link_mode != LINK_USB) {
|
||||
switch_dev_link(LINK_USB);
|
||||
}
|
||||
} else {
|
||||
if (dev_info.link_mode != dev_info.rf_channel) {
|
||||
switch_dev_link(dev_info.rf_channel);
|
||||
}
|
||||
}
|
||||
|
||||
// Win or Mac
|
||||
if (dial_scan_sys) {
|
||||
if (dev_info.sys_sw_state != SYS_SW_MAC) {
|
||||
default_layer_set(1 << 0);
|
||||
dev_info.sys_sw_state = SYS_SW_MAC;
|
||||
keymap_config.nkro = 0;
|
||||
break_all_key();
|
||||
}
|
||||
} else {
|
||||
if (dev_info.sys_sw_state != SYS_SW_WIN) {
|
||||
//f_sys_show = 1;
|
||||
default_layer_set(1 << 2);
|
||||
dev_info.sys_sw_state = SYS_SW_WIN;
|
||||
keymap_config.nkro = 1;
|
||||
break_all_key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief timer process.
|
||||
*/
|
||||
void timer_pro(void) {
|
||||
static uint32_t interval_timer = 0;
|
||||
static bool f_first = true;
|
||||
|
||||
if (f_first) {
|
||||
f_first = false;
|
||||
interval_timer = timer_read32();
|
||||
m_host_driver = host_get_driver();
|
||||
}
|
||||
|
||||
if (timer_elapsed32(interval_timer) < 10)
|
||||
return;
|
||||
else
|
||||
interval_timer = timer_read32();
|
||||
|
||||
if (rf_link_show_time < RF_LINK_SHOW_TIME) rf_link_show_time++;
|
||||
|
||||
if (no_act_time < 0xffff) no_act_time++;
|
||||
|
||||
if (rf_linking_time < 0xffff) rf_linking_time++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief londing eeprom data.
|
||||
*/
|
||||
void londing_eeprom_data(void) {
|
||||
eeconfig_read_user_datablock(&user_config);
|
||||
if (user_config.default_brightness_flag != 0xA5) {
|
||||
/* first power on, set rgb matrix brightness at middle level*/
|
||||
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);
|
||||
user_config.default_brightness_flag = 0xA5;
|
||||
user_config.ee_side_mode = side_mode;
|
||||
user_config.ee_side_light = side_light;
|
||||
user_config.ee_side_speed = side_speed;
|
||||
user_config.ee_side_rgb = side_rgb;
|
||||
user_config.ee_side_colour = side_colour;
|
||||
user_config.sleep_enable = true;
|
||||
eeconfig_update_user_datablock(&user_config);
|
||||
} else {
|
||||
side_mode = user_config.ee_side_mode;
|
||||
side_light = user_config.ee_side_light;
|
||||
side_speed = user_config.ee_side_speed;
|
||||
side_rgb = user_config.ee_side_rgb;
|
||||
side_colour = user_config.ee_side_colour;
|
||||
}
|
||||
}
|
167
keyboards/nuphy/air75_v2/ansi/user_kb.h
Normal file
167
keyboards/nuphy/air75_v2/ansi/user_kb.h
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
typedef enum {
|
||||
RX_Idle,
|
||||
RX_Receiving,
|
||||
RX_Done,
|
||||
RX_Fail,
|
||||
RX_OV_ERR,
|
||||
RX_SUM_ERR,
|
||||
RX_CMD_ERR,
|
||||
RX_DATA_ERR,
|
||||
RX_DATA_OV,
|
||||
RX_FORMAT_ERR,
|
||||
|
||||
TX_OK = 0XE0,
|
||||
TX_DONE,
|
||||
TX_BUSY,
|
||||
TX_TIMEOUT,
|
||||
TX_DATA_ERR,
|
||||
|
||||
} TYPE_RX_STATE;
|
||||
|
||||
|
||||
#define RF_IDLE 0
|
||||
#define RF_PAIRING 1
|
||||
#define RF_LINKING 2
|
||||
#define RF_CONNECT 3
|
||||
#define RF_DISCONNECT 4
|
||||
#define RF_SLEEP 5
|
||||
#define RF_SNIF 6
|
||||
#define RF_INVAILD 0XFE
|
||||
#define RF_ERR_STATE 0XFF
|
||||
|
||||
#define CMD_POWER_UP 0XF0
|
||||
#define CMD_SLEEP 0XF1
|
||||
#define CMD_HAND 0XF2
|
||||
#define CMD_SNIF 0XF3
|
||||
#define CMD_24G_SUSPEND 0XF4
|
||||
#define CMD_IDLE_EXIT 0XFE
|
||||
|
||||
#define CMD_RPT_MS 0XE0
|
||||
#define CMD_RPT_BYTE_KB 0XE1
|
||||
#define CMD_RPT_BIT_KB 0XE2
|
||||
#define CMD_RPT_CONSUME 0XE3
|
||||
#define CMD_RPT_SYS 0XE4
|
||||
|
||||
#define CMD_SET_LINK 0XC0
|
||||
#define CMD_SET_CONFIG 0XC1
|
||||
#define CMD_GET_CONFIG 0XC2
|
||||
#define CMD_SET_NAME 0XC3
|
||||
#define CMD_GET_NAME 0XC4
|
||||
#define CMD_CLR_DEVICE 0XC5
|
||||
#define CMD_NEW_ADV 0XC7
|
||||
#define CMD_RF_STS_SYSC 0XC9
|
||||
#define CMD_SET_24G_NAME 0XCA
|
||||
#define CMD_GO_TEST 0XCF
|
||||
#define CMD_RF_DFU 0XB1
|
||||
|
||||
#define CMD_WRITE_DATA 0X80
|
||||
#define CMD_READ_DATA 0X81
|
||||
|
||||
#define LINK_RF_24 0
|
||||
#define LINK_BT_1 1
|
||||
#define LINK_BT_2 2
|
||||
#define LINK_BT_3 3
|
||||
#define LINK_USB 4
|
||||
|
||||
#define UART_HEAD 0x5A
|
||||
#define FUNC_VALID_LEN 32
|
||||
#define UART_MAX_LEN 64
|
||||
|
||||
#define SYS_SW_WIN 0xa1
|
||||
#define SYS_SW_MAC 0xa2
|
||||
|
||||
#define RF_LINK_SHOW_TIME 300
|
||||
|
||||
#define HOST_USB_TYPE 0
|
||||
#define HOST_BLE_TYPE 1
|
||||
#define HOST_RF_TYPE 2
|
||||
|
||||
#define LINK_TIMEOUT (100 * 120)
|
||||
#define SLEEP_TIME_DELAY (100 * 360)
|
||||
#define POWER_DOWN_DELAY (24)
|
||||
|
||||
#define RF_LONG_PRESS_DELAY 30
|
||||
#define DEV_RESET_PRESS_DELAY 30
|
||||
#define RGB_TEST_PRESS_DELAY 30
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RXDState;
|
||||
uint8_t RXDLen;
|
||||
uint8_t RXDOverTime;
|
||||
uint8_t TXDLenBack;
|
||||
uint8_t TXDOffset;
|
||||
uint8_t TXDBuf[UART_MAX_LEN];
|
||||
uint8_t RXDBuf[UART_MAX_LEN];
|
||||
} USART_MGR_STRUCT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t link_mode;
|
||||
uint8_t rf_channel;
|
||||
uint8_t ble_channel;
|
||||
uint8_t rf_state;
|
||||
uint8_t rf_charge;
|
||||
uint8_t rf_led;
|
||||
uint8_t rf_baterry;
|
||||
uint8_t sys_sw_state;
|
||||
} DEV_INFO_STRUCT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t default_brightness_flag;
|
||||
uint8_t ee_side_mode;
|
||||
uint8_t ee_side_light;
|
||||
uint8_t ee_side_speed;
|
||||
uint8_t ee_side_rgb;
|
||||
uint8_t ee_side_colour;
|
||||
uint8_t sleep_enable;
|
||||
uint8_t retain1;
|
||||
uint8_t retain2;
|
||||
} user_config_t;
|
||||
|
||||
void dev_sts_sync(void);
|
||||
void rf_uart_init(void);
|
||||
void rf_device_init(void);
|
||||
void uart_send_report_func(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);
|
||||
void side_light_contol(uint8_t dir);
|
||||
void side_colour_control(uint8_t dir);
|
||||
void side_mode_control(uint8_t dir);
|
||||
void side_led_show(void);
|
||||
void sleep_handle(void);
|
||||
void bat_led_close(void);
|
||||
void num_led_show(void);
|
||||
void rgb_test_show(void);
|
||||
void gpio_init(void);
|
||||
void long_press_key(void);
|
||||
void break_all_key(void);
|
||||
void switch_dev_link(uint8_t mode);
|
||||
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);
|
Loading…
Reference in New Issue
Block a user