Skip to content

Commit

Permalink
update firmware to V2.1.6
Browse files Browse the repository at this point in the history
1. Add new mode: USB with BLE Coexistence Mode.
2. Modify the VIA layout file. The original keyboard layout file is 15 columns, but there are only 14 columns in reality. So we modify the firmware VIA related codes.
  • Loading branch information
ChnMasterOG committed Oct 23, 2024
1 parent 2f6d66e commit 6424bf7
Show file tree
Hide file tree
Showing 23 changed files with 312,339 additions and 309,368 deletions.
16 changes: 14 additions & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@ bilibili:@i丶m皮皮 @阿炜阿阿炜阿

Tik Tok:@i丶m皮皮

### Purchase link
### Purchase link(Global purchasable)

[淘宝(taobao.com)](https://item.taobao.com/item.htm?id=765881659540)

### List of Extension Modules Supported by TP78
### List of Extension Modules Supported by TP78(Global purchasable)

Video shown in bilibili:[https://www.bilibili.com/video/BV1jVpneNEpq/](https://www.bilibili.com/video/BV1jVpneNEpq/)

1. TP78foc —— A FOC controlled motor knob, small keyboard expansion module

purchase link: [淘宝(taobao.com)](https://item.taobao.com/item.htm?ft=t&id=828180761483)

2. TP78mini —— A three mode examination digital keypad module

purchase link: [淘宝(taobao.com)](https://item.taobao.com/item.htm?ft=t&id=832953135960)

intrudoction video:[【开源】历时3年,打造一个模块化力反馈旋钮小键盘](https://www.bilibili.com/video/BV1jVpneNEpq/)

Expand Down Expand Up @@ -256,3 +262,9 @@ You can submit you code [here](https://github.com/ChnMasterOG/tp78_v2/issues). T
- V2.1.5

        1. Add motor_en configuration: The motor vibration is controlled by this configuration.

- V2.1.6

        1. Add new mode: USB with BLE Coexistence Mode.

  2. Modify the VIA layout file. The original keyboard layout file is 15 columns, but there are only 14 columns in reality. So we modify the firmware VIA related codes.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@ bilibili:@i丶m皮皮 @阿炜阿阿炜阿

抖音:@i丶m皮皮

### 拼车链接
### 购买链接(支持全球可售)

[淘宝(taobao.com)](https://item.taobao.com/item.htm?id=765881659540)

### TP78支持的扩展模块列表
### TP78支持的扩展模块列表(支持全球可售)

视频介绍:[https://www.bilibili.com/video/BV1jVpneNEpq/](https://www.bilibili.com/video/BV1jVpneNEpq/)

1. TP78foc —— 一个FOC控制无刷电机旋钮小键盘扩展模块

购买链接:[淘宝(taobao.com)](https://item.taobao.com/item.htm?ft=t&id=828180761483)

2. TP78mini —— 一个三模数字小键盘模块

购买链接:[淘宝(taobao.com)](https://item.taobao.com/item.htm?ft=t&id=832953135960)

扩展模块介绍视频:[【开源】历时3年,打造一个模块化力反馈旋钮小键盘](https://www.bilibili.com/video/BV1jVpneNEpq/)

Expand Down Expand Up @@ -262,3 +268,9 @@ BUG
- V2.1.5

        1. 修改触摸条按键/滑动触发振动的功能为可配置(配置项:motor_en)

- V2.1.6

        1. 增加 USB 和蓝牙共存模式

        2. 修改 VIA 的 layout 布局文件,原先键盘布局为 15 列,实际只有 14 列,对应固件 VIA相关内容进行修改
Binary file modified documents/TP78v2指导文档.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions mounriver_project/KEYBOARD_CH582M/APP/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ int main( void )
CH58X_BLEInit( ); //蓝牙初始化
HAL_Init( ); //硬件初始化
#if (defined HAL_USB) && (HAL_USB == TRUE)
if (g_Enable_Status.usb == TRUE) {
if (g_Enable_Status.usb == TRUE || g_Enable_Status.usb_ble == TRUE) {
HAL_USBInit( );
}
#endif
if (g_Enable_Status.ble == TRUE) {
if (g_Enable_Status.ble == TRUE || g_Enable_Status.usb_ble == TRUE) {
GAPRole_PeripheralInit( ); // 蓝牙层级决策功能初始化,闭源
HidDev_Init( ); // 蓝牙广播服务初始化(注册和启动),闭源
HidEmu_Init( ); // 蓝牙广播服务初始化(参数设置),闭源
Expand Down
30 changes: 13 additions & 17 deletions mounriver_project/KEYBOARD_CH582M/APP/tp78_via.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,28 +480,24 @@ void via_data_processing(uint8_t *data, uint8_t len)
uint16_t i, j = 3, k = 0;
offset >>= 1; // uint16 to uint8
size >>= 1; // uint16 to uint8
if (offset < (COL_SIZE + 1) * ROW_SIZE) { // layer 0
if (offset < COL_SIZE * ROW_SIZE) { // layer 0
keyarr_ptr = (uint8_t*)CustomKey;
} else { // layer 1
keyarr_ptr = (uint8_t*)Extra_CustomKey;
offset -= (COL_SIZE + 1) * ROW_SIZE;
offset -= COL_SIZE * ROW_SIZE;
}
keyarr_ptr += offset - offset / (COL_SIZE + 1); // 一行结束减去末尾空白键
keyarr_ptr += offset;
for (i = offset; i < offset + size; i++, j+=2) {
if (i >= (COL_SIZE + 1) * ROW_SIZE) {
if (i >= COL_SIZE * ROW_SIZE) {
command_data[j] = 0;
command_data[j + 1] = 0;
} else {
command_data[j] = 0; // MSB set to zero(USB为大端传输)
if (i % (COL_SIZE + 1) == COL_SIZE) {
command_data[j + 1] = 0; // 一行末尾保留空白
if (keyarr_ptr[k] >= KEY_SP_1 && keyarr_ptr[k] <= KEY_SP_7) {
command_data[j] = 0x77;
command_data[j + 1] = keyarr_ptr[k++] - KEY_SP_1;
} else {
if (keyarr_ptr[k] >= KEY_SP_1 && keyarr_ptr[k] <= KEY_SP_7) {
command_data[j] = 0x77;
command_data[j + 1] = keyarr_ptr[k++] - KEY_SP_1;
} else {
command_data[j + 1] = keyarr_ptr[k++];
}
command_data[j + 1] = keyarr_ptr[k++];
}
}
}
Expand All @@ -515,16 +511,16 @@ void via_data_processing(uint8_t *data, uint8_t len)
uint16_t i, j = 3, k = 0;
offset >>= 1; // uint16 to uint8
size >>= 1; // uint16 to uint8
if (offset < (COL_SIZE + 1) * ROW_SIZE) { // layer 0
if (offset < COL_SIZE * ROW_SIZE) { // layer 0
keyarr_ptr = (uint8_t*)CustomKey;
} else { // layer 1
keyarr_ptr = (uint8_t*)Extra_CustomKey;
offset -= (COL_SIZE + 1) * ROW_SIZE;
offset -= COL_SIZE * ROW_SIZE;
}
keyarr_ptr += offset - offset / (COL_SIZE + 1); // 一行结束减去末尾空白键
keyarr_ptr += offset;
for (i = offset; i < offset + size; i++, j+=2) {
if (i >= (COL_SIZE + 1) * ROW_SIZE) break;
else if (i % (COL_SIZE + 1) != COL_SIZE) {
if (i >= COL_SIZE * ROW_SIZE) break;
else {
if (command_data[j] == 0x77) // SP_KEY
keyarr_ptr[k++] = KEY_SP_1 + command_data[j + 1];
else
Expand Down
4 changes: 3 additions & 1 deletion mounriver_project/KEYBOARD_CH582M/HAL/CORE.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ void TP78Reinit(uint8_t mode, enum LP_Type lp_type)
{
uint32_t irq_status;

if (lp_type == lp_mode_none) return;

if (mode == 0) { // 进入睡眠
SYS_DisableAllIrq( &irq_status );
#if (defined HAL_WDG) && (HAL_WDG == TRUE)
Expand Down Expand Up @@ -261,7 +263,7 @@ void GotoLowpower(enum LP_Type type)
LowPower_Shutdown(0);
break;
#endif
default: // do not run here
default: // 不睡眠
return;
}
#else
Expand Down
2 changes: 1 addition & 1 deletion mounriver_project/KEYBOARD_CH582M/HAL/FATFS.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BYTE WriteBuffer[] = {
"keyboard_cfg.txt---存放键盘配置(每行一个配置)\n"
"LINE1:默认蓝牙设备(0~3)\n"
"LINE2:默认LED模式(0~5)\n"
"LINE3:工作模式(0-USB,1-BLE,2-RF)\n"
"LINE3:工作模式(0-USB,1-BLE,2-RF,3-USB&BLE)\n"
"LINE4:是否启动U盘(仅下次生效)\n"
"LINE5:MPR_alg_magic\n"
"LINE6:MPR_capmouse_tou_thr\n"
Expand Down
37 changes: 36 additions & 1 deletion mounriver_project/KEYBOARD_CH582M/HAL/KEYBOARD.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ UINT8 KEYBOARD_Custom_Function( void )
} else if ( KeyboardDat->Key1 == KEY_C && Fn_Mode != Fn_Mode_ChangeKey ) { // 设置改键 - 先按Fn+C
Fn_Mode = Fn_Mode_ChangeKey;
Fn_cnt &= 0x0C;
} else if ( KeyboardDat->Key1 == KEY_O && Fn_Mode != Fn_Mode_ChangeKey ) { // 配置参数模式
} else if ( KeyboardDat->Key1 == KEY_O && Fn_Mode != Fn_Mode_Enter_Cfg ) { // 配置参数模式
Fn_Mode = Fn_Mode_Enter_Cfg;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_R && Fn_Mode != Fn_Mode_SoftReset ) { // 软件复位模式
Expand Down Expand Up @@ -193,12 +193,21 @@ UINT8 KEYBOARD_Custom_Function( void )
} else if ( KeyboardDat->Key1 == KEY_F12 && Fn_Mode != Fn_Mode_RFMode ) { // 切换RF模式
Fn_Mode = Fn_Mode_RFMode;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_F9 && Fn_Mode != Fn_Mode_USBBLEMode ) { // 切换USB和BLE共存模式
Fn_Mode = Fn_Mode_USBBLEMode;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_U && Fn_Mode != Fn_Mode_UDiskMode ) { // 开启U盘模式
Fn_Mode = Fn_Mode_UDiskMode;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_G && Fn_Mode != Fn_Mode_GameMode ) { // 开启性能模式
Fn_Mode = Fn_Mode_GameMode;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_PageUp && Fn_Mode != Fn_Mode_Select_USB_Send ) { // 共存模式下选择USB发送
Fn_Mode = Fn_Mode_Select_USB_Send;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_PageDown && Fn_Mode != Fn_Mode_Select_BLE_Send ) { // 共存模式下选择BLE发送
Fn_Mode = Fn_Mode_Select_BLE_Send;
Fn_cnt = 0;
} else if ( KeyboardDat->Key1 == KEY_0 && Fn_Mode != Fn_Mode_BLE_ClearSNV ) { // 清除蓝牙SNV信息
Fn_Mode = Fn_Mode_BLE_ClearSNV;
Fn_cnt = 0;
Expand Down Expand Up @@ -387,6 +396,18 @@ UINT8 KEYBOARD_Custom_Function( void )
SoftReset();
break;
}
case Fn_Mode_USBBLEMode: { // Fn+F9切换USB和BLE共存模式
Fn_Mode = Fn_Mode_None;
if (g_Enable_Status.usb_ble == TRUE) {
OLED_UI_add_SHOWINFO_task("USB + BLE");
OLED_UI_add_CANCELINFO_delay_task(2000);
break;
}
uint16_t USB_with_BLE_mode = 3;
HAL_Fs_Write_keyboard_cfg(FS_LINE_WORK_MODE, 1, &USB_with_BLE_mode);
SoftReset();
break;
}
case Fn_Mode_UDiskMode: { // Fn+U开启U盘模式
Fn_Mode = Fn_Mode_None;
uint16_t Usb_mode = 0;
Expand Down Expand Up @@ -420,6 +441,20 @@ UINT8 KEYBOARD_Custom_Function( void )
}
break;
}
case Fn_Mode_Select_USB_Send: { // Fn+PgUp选择发送USB报文
Fn_Mode = Fn_Mode_None;
if (g_Enable_Status.usb_ble == TRUE) {
g_Ready_Status.usb_ble_l = TRUE;
}
break;
}
case Fn_Mode_Select_BLE_Send: { // Fn+PgDn选择发送BLE报文
Fn_Mode = Fn_Mode_None;
if (g_Enable_Status.usb_ble == TRUE) {
g_Ready_Status.usb_ble_l = FALSE;
}
break;
}
case Fn_Mode_BLE_ClearSNV: { // Fn+0清除蓝牙SNV信息
Fn_Mode = Fn_Mode_None;
uint32_t SNV_size, p_addr = BLE_SNV_ADDR;
Expand Down
Loading

0 comments on commit 6424bf7

Please sign in to comment.