Skip to content

Commit d4f0c73

Browse files
committed
Merge branch 'feat/add_keyboard_v1.1' into 'master'
feat(keyboard): add keyboard v1.1 support See merge request ae_group/esp-iot-solution!1035
2 parents e7061be + 3f7d9ee commit d4f0c73

File tree

10 files changed

+118
-90
lines changed

10 files changed

+118
-90
lines changed

examples/keyboard/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ cmake_minimum_required(VERSION 3.16)
66

77
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
88
project(keyboard)
9+
10+
# Make MAX brightness configurable
11+
idf_component_get_property(keyboard_rgb_matrix lijunru-hub__keyboard_rgb_matrix COMPONENT_LIB)
12+
target_compile_definitions(${keyboard_rgb_matrix} PUBLIC "-DRGB_MATRIX_MAXIMUM_BRIGHTNESS=100")

examples/keyboard/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ The ESP-KeyBoard project is a keyboard project using the ESP32-S3, supporting N-
2121

2222
* Demo video [video](https://www.bilibili.com/video/BV1yi421C7qV/?share_source=copy_web&vd_source=7e24f4cefdafbd8477369f33616312a9)
2323

24+
* Board support package introduction documentation [BSP](./components/esp32_s3_kbd_kit/README.md)
25+
2426
![keyboard_hardware](https://dl.espressif.com/esp-iot-solution/static/keyboard_1.gif)
2527

2628
### Software Design
@@ -30,7 +32,7 @@ The ESP-KeyBoard project is a keyboard project using the ESP32-S3, supporting N-
3032
| Connection Mode | Local Lighting | WIN11 Lighting | N-key Rollover | Report Rate |
3133
| :------------------: | :-----------------: | :------------: | :------------: | :---------: |
3234
| USB |||| 1k |
33-
| BLE | √(Default disabled) | × || 125k |
35+
| BLE | √(Default disabled) | × || 125Hz |
3436
| 2.4G (Not Supported) || × || 1k |
3537

3638
本地灯效

examples/keyboard/README_cn.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ ESP-KeyBoard 项目是使用 ESP32-S3 的键盘项目,支持全键无冲,USB
2121

2222
* Demo 视频 [video](https://www.bilibili.com/video/BV1yi421C7qV/?share_source=copy_web&vd_source=7e24f4cefdafbd8477369f33616312a9)
2323

24+
* BSP 介绍文档 [BSP](./components/esp32_s3_kbd_kit/README.md)
25+
2426
![keyboard_hardware](https://dl.espressif.com/esp-iot-solution/static/keyboard_1.gif)
2527

2628
### 软件设计
@@ -30,7 +32,7 @@ ESP-KeyBoard 项目是使用 ESP32-S3 的键盘项目,支持全键无冲,USB
3032
| 连接模式 | 本地灯效 | WIN11 灯效 | 全键无冲 | 回报率 |
3133
| :--------------: | :-------------: | :--------: | :------: | :----: |
3234
| USB |||| 1k |
33-
| BLE | √(默认不开启) | × || 125k |
35+
| BLE | √(默认不开启) | × || 125Hz |
3436
| 2.4G(暂不支持) || × || 1k |
3537

3638
本地灯效

examples/keyboard/components/esp32_s3_kbd_kit/Kconfig

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,82 @@
1-
# BSP: ESP-WROVER-KIT
1+
# BSP: ESP32-S3-KBD-KIT
22

3-
[![Component Registry](https://components.espressif.com/components/espressif/esp_wrover_kit/badge.svg)](https://components.espressif.com/components/espressif/esp_wrover_kit)
3+
ESP32-S3-KBD-KIT is an ESP32S3-based development board produced by Espressif.
4+
* [Hardware Reference](https://oshwhub.com/esp-college/esp-keyboard)
45

5-
ESP-WROVER-KIT is an ESP32-based development board produced by Espressif.
6-
* [Hardware Reference](https://www.espressif.com/en/products/hardware/esp-wrover-kit/overview)
6+
![ESP-KeyBoard](https://dl.espressif.com/esp-iot-solution/static/keyboard.jpg)
77

8-
![](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/_images/esp-wrover-kit-v4.1-layout-front.png)
8+
ESP32-S3-KBD-KIT features the following integrated components:
99

10-
ESP-WROVER-KIT features the following integrated components:
10+
* ESP32-S3-WROOM-1-N4 module
11+
* WS2812 RGB LED
12+
* 6x15 Key Scan Circuit
13+
* Battery Charge and Discharge Management
1114

12-
* ESP32-WROVER-E module
13-
* LCD screen
14-
* microSD card slot
15-
* RGB LED
15+
ESP32-S3-KBD-KIT only supports hardware version V1.1. If you need to use the V1.0 hardware version, please modify it according to the hardware GPIO.
1616

17-
Its another distinguishing feature is the embedded FTDI FT2232HL chip - an advanced multi-interface USB bridge. This chip enables to use JTAG for direct debugging of ESP32 through the USB interface without a separate JTAG debugger. ESP-WROVER-KIT makes development convenient, easy, and cost-effective.
17+
## Hardware Version
1818

19-
Most of the ESP32 I/O pins are broken out to the board’s pin headers for easy access.
19+
### v1.1
20+
21+
Make the following hardware modifications:
22+
1. Added a 32.768K crystal oscillator to reduce power consumption when the BLE connection enters light sleep mode (reduces standby current by about 2mA).
23+
2. Added total power control for the WS2812 LED group, allowing complete disconnection of WS2812 power supply when using battery power (reduces standby current by about 40mA).
24+
3. Added battery voltage detection.
25+
26+
| Name | Status | GPIO | Descriptor |
27+
| :-------------: | :------: | :----: | :-----------------: |
28+
| ROW_IO_0 | Maintain | GPIO40 | Row Scan GPIO |
29+
| ROW_IO_1 | Maintain | GPIO39 | Row Scan GPIO |
30+
| ROW_IO_2 | Maintain | GPIO38 | Row Scan GPIO |
31+
| ROW_IO_3 | Maintain | GPIO45 | Row Scan GPIO |
32+
| ROW_IO_4 | Maintain | GPIO48 | Row Scan GPIO |
33+
| ROW_IO_5 | Maintain | GPIO47 | Row Scan GPIO |
34+
| COL_IO_0 | Maintain | GPIO21 | COL Scan GPIO |
35+
| COL_IO_1 | Maintain | GPIO14 | COL Scan GPIO |
36+
| COL_IO_2 | Maintain | GPIO13 | COL Scan GPIO |
37+
| COL_IO_3 | Maintain | GPIO12 | COL Scan GPIO |
38+
| COL_IO_4 | Maintain | GPIO11 | COL Scan GPIO |
39+
| COL_IO_5 | Maintain | GPIO10 | COL Scan GPIO |
40+
| COL_IO_6 | Maintain | GPIO9 | COL Scan GPIO |
41+
| COL_IO_7 | Maintain | GPIO4 | COL Scan GPIO |
42+
| COL_IO_8 | Maintain | GPIO5 | COL Scan GPIO |
43+
| COL_IO_9 | Maintain | GPIO6 | COL Scan GPIO |
44+
| COL_IO_10 | Maintain | GPIO7 | COL Scan GPIO |
45+
| COL_IO_11 | Modify | GPIO17 | COL Scan GPIO |
46+
| COL_IO_12 | Modify | GPIO3 | COL Scan GPIO |
47+
| COL_IO_13 | Modify | GPIO18 | COL Scan GPIO |
48+
| COL_IO_14 | Modify | GPIO8 | COL Scan GPIO |
49+
| WS2812_EN | Add | GPIO1 | WS2812 Control GPIO |
50+
| WS2812_GPIO | Modify | GPIO0 | WS2812 GPIO |
51+
| Battery_Monitor | Add | GPIO2 | Battery ADC Monitor |
52+
53+
### v1.0
54+
55+
Features include:
56+
1. 6*15 row-column scanning method
57+
2. WS2812 LED strip
58+
59+
| Name | Status | GPIO | Descriptor |
60+
| :---------: | :------: | :----: | :-----------: |
61+
| ROW_IO_0 | Maintain | GPIO40 | Row Scan GPIO |
62+
| ROW_IO_1 | Maintain | GPIO39 | Row Scan GPIO |
63+
| ROW_IO_2 | Maintain | GPIO38 | Row Scan GPIO |
64+
| ROW_IO_3 | Maintain | GPIO45 | Row Scan GPIO |
65+
| ROW_IO_4 | Maintain | GPIO48 | Row Scan GPIO |
66+
| ROW_IO_5 | Maintain | GPIO47 | Row Scan GPIO |
67+
| COL_IO_0 | Maintain | GPIO21 | COL Scan GPIO |
68+
| COL_IO_1 | Maintain | GPIO14 | COL Scan GPIO |
69+
| COL_IO_2 | Maintain | GPIO13 | COL Scan GPIO |
70+
| COL_IO_3 | Maintain | GPIO12 | COL Scan GPIO |
71+
| COL_IO_4 | Maintain | GPIO11 | COL Scan GPIO |
72+
| COL_IO_5 | Maintain | GPIO10 | COL Scan GPIO |
73+
| COL_IO_6 | Maintain | GPIO9 | COL Scan GPIO |
74+
| COL_IO_7 | Maintain | GPIO4 | COL Scan GPIO |
75+
| COL_IO_8 | Maintain | GPIO5 | COL Scan GPIO |
76+
| COL_IO_9 | Maintain | GPIO6 | COL Scan GPIO |
77+
| COL_IO_10 | Maintain | GPIO7 | COL Scan GPIO |
78+
| COL_IO_11 | Maintain | GPIO15 | COL Scan GPIO |
79+
| COL_IO_12 | Maintain | GPIO16 | COL Scan GPIO |
80+
| COL_IO_13 | Maintain | GPIO17 | COL Scan GPIO |
81+
| COL_IO_14 | Maintain | GPIO18 | COL Scan GPIO |
82+
| WS2812_GPIO | Maintain | GPIO8 | WS2812 GPIO |

examples/keyboard/components/esp32_s3_kbd_kit/esp32_s3_kbd_kit.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ esp_err_t bsp_keyboard_init(keyboard_btn_handle_t *kbd_handle, keyboard_btn_conf
2929
.input_gpios = (int[])KBD_INPUT_IOS,
3030
.input_gpio_num = KBD_COL_NUM,
3131
.active_level = KBD_ATTIVE_LEVEL,
32-
.debounce_ticks = 2,
32+
.debounce_ticks = 3,
3333
.ticks_interval = KBD_TICKS_INTERVAL_US,
3434
.enable_power_save = true,
3535
};
@@ -49,6 +49,15 @@ esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip)
4949
}
5050
return ESP_OK;
5151
}
52+
53+
gpio_config_t io_conf = {
54+
.pin_bit_mask = 1ULL << KBD_WS2812_POWER_IO,
55+
.mode = GPIO_MODE_OUTPUT_OD,
56+
.pull_down_en = 0,
57+
.pull_up_en = 0,
58+
};
59+
gpio_config(&io_conf);
60+
5261
/* LED strip initialization with the GPIO and pixels number*/
5362
led_strip_config_t strip_config = {
5463
.strip_gpio_num = LIGHTMAP_GPIO, // The GPIO that connected to the LED strip's data line
@@ -70,6 +79,12 @@ esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip)
7079
return ESP_OK;
7180
}
7281

82+
esp_err_t bsp_ws2812_enable(bool enable)
83+
{
84+
gpio_set_level(KBD_WS2812_POWER_IO, !enable);
85+
return ESP_OK;
86+
}
87+
7388
esp_err_t bsp_lamp_array_init(uint32_t bind)
7489
{
7590
if (!s_led_strip) {

examples/keyboard/components/esp32_s3_kbd_kit/include/bsp/esp32_s3_kbd_kit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ esp_err_t bsp_keyboard_init(keyboard_btn_handle_t *kbd_handle, keyboard_btn_conf
1717

1818
esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip);
1919

20+
esp_err_t bsp_ws2812_enable(bool enable);
21+
2022
esp_err_t bsp_lamp_array_init(uint32_t bind);
2123

2224
esp_err_t bsp_rgb_matrix_init(void);

examples/keyboard/components/esp32_s3_kbd_kit/include/bsp/keyboard.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
extern "C" {
1010
#endif
1111

12+
/*!< Keyboard active level */
1213
#define KBD_ATTIVE_LEVEL 1
1314
#define KBD_TICKS_INTERVAL_US 500
1415

16+
/*!< Keyboard matrix GPIO */
1517
#define KBD_ROW_NUM 6
1618
#define KBD_COL_NUM 15
1719

@@ -33,16 +35,22 @@ extern "C" {
3335
#define KBD_COL_IO_8 5
3436
#define KBD_COL_IO_9 6
3537
#define KBD_COL_IO_10 7
36-
#define KBD_COL_IO_11 15
37-
#define KBD_COL_IO_12 16
38-
#define KBD_COL_IO_13 17
39-
#define KBD_COL_IO_14 18
38+
#define KBD_COL_IO_11 17
39+
#define KBD_COL_IO_12 3
40+
#define KBD_COL_IO_13 18
41+
#define KBD_COL_IO_14 8
4042

4143
#define KBD_OUTPUT_IOS {KBD_ROW_IO_0, KBD_ROW_IO_1, KBD_ROW_IO_2, KBD_ROW_IO_3, KBD_ROW_IO_4, KBD_ROW_IO_5}
4244
#define KBD_INPUT_IOS {KBD_COL_IO_0, KBD_COL_IO_1, KBD_COL_IO_2, KBD_COL_IO_3, KBD_COL_IO_4, KBD_COL_IO_5, \
4345
KBD_COL_IO_6, KBD_COL_IO_7, KBD_COL_IO_8, KBD_COL_IO_9, KBD_COL_IO_10, KBD_COL_IO_11,\
4446
KBD_COL_IO_12, KBD_COL_IO_13, KBD_COL_IO_14}
4547

48+
/*!< WS2812 power control GPIO */
49+
#define KBD_WS2812_POWER_IO 1
50+
51+
/*!< Battery monitor GPIO */
52+
#define KBD_BATTERY_MONITOR_IO 2
53+
4654
#ifdef __cplusplus
4755
}
4856
#endif

examples/keyboard/components/esp32_s3_kbd_kit/include/bsp/lightmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extern "C" {
1414
#endif
1515

16-
#define LIGHTMAP_GPIO 8
16+
#define LIGHTMAP_GPIO 0
1717
#define LIGHTMAP_NUM 82
1818
#define LIGHTMAP_WIDTH 310000 /*!< 31 cm */
1919
#define LIGHTMAP_HEIGHT 120000 /*!< 12 cm */

examples/keyboard/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ void app_main(void)
6060
btn_progress_set_light_type(sys_param->light_type);
6161
if (sys_param->report_type == TINYUSB_HID_REPORT) {
6262
tinyusb_hid_init();
63+
bsp_ws2812_enable(1);
6364
} else if (sys_param->report_type == BLE_HID_REPORT) {
6465
ble_hid_init();
66+
bsp_ws2812_enable(0);
6567
esp_pm_config_t pm_config = {
6668
.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ,
6769
.min_freq_mhz = 160,

0 commit comments

Comments
 (0)